From 75d094868e1ea00081a9009f8478a6d891b3ef78 Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Tue, 11 Apr 2023 13:48:55 +0100 Subject: [PATCH 1/5] Implement reminder notification: If user clicks same ad 3 times --- app/brave_generated_resources.grd | 6 + components/brave_ads/browser/BUILD.gn | 2 + .../brave_ads/browser/ads_service_impl.cc | 34 +-- .../brave_ads/browser/ads_service_impl.h | 2 + components/brave_ads/browser/reminder_util.cc | 71 ++++++ components/brave_ads/browser/reminder_util.h | 20 ++ .../brave_ads/common/interfaces/ads.mojom | 5 + components/brave_ads/core/ads_client.h | 3 + components/brave_ads/core/internal/BUILD.gn | 6 + .../brave_ads/core/internal/ads_client_mock.h | 2 + .../brave_ads/core/internal/ads_impl.cc | 3 + components/brave_ads/core/internal/ads_impl.h | 3 + .../common/unittest/unittest_mock_util.cc | 11 +- .../core/internal/reminder/README.md | 5 + .../core/internal/reminder/reminder.cc | 41 ++++ .../core/internal/reminder/reminder.h | 34 +++ .../internal/reminder/reminder_features.cc | 32 +++ .../internal/reminder/reminder_features.h | 21 ++ .../reminder/reminder_features_unittest.cc | 88 +++++++ .../internal/reminder/reminder_unittest.cc | 92 +++++++ ...ed_same_ad_multiple_times_reminder_util.cc | 61 +++++ ...ked_same_ad_multiple_times_reminder_util.h | 19 ++ ...d_multiple_times_reminder_util_unittest.cc | 230 ++++++++++++++++++ components/brave_ads/core/test/BUILD.gn | 3 + .../bat_ads/bat_ads_client_mojo_bridge.cc | 7 + .../bat_ads/bat_ads_client_mojo_bridge.h | 2 + .../bat_ads/public/interfaces/bat_ads.mojom | 2 + ios/browser/api/ads/ads_client_bridge.h | 1 + ios/browser/api/ads/ads_client_ios.h | 1 + ios/browser/api/ads/ads_client_ios.mm | 4 + ios/browser/api/ads/brave_ads.mm | 4 + 31 files changed, 797 insertions(+), 18 deletions(-) create mode 100644 components/brave_ads/browser/reminder_util.cc create mode 100644 components/brave_ads/browser/reminder_util.h create mode 100644 components/brave_ads/core/internal/reminder/README.md create mode 100644 components/brave_ads/core/internal/reminder/reminder.cc create mode 100644 components/brave_ads/core/internal/reminder/reminder.h create mode 100644 components/brave_ads/core/internal/reminder/reminder_features.cc create mode 100644 components/brave_ads/core/internal/reminder/reminder_features.h create mode 100644 components/brave_ads/core/internal/reminder/reminder_features_unittest.cc create mode 100644 components/brave_ads/core/internal/reminder/reminder_unittest.cc create mode 100644 components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.cc create mode 100644 components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h create mode 100644 components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc diff --git a/app/brave_generated_resources.grd b/app/brave_generated_resources.grd index af0f0601d297..0a5863232caf 100644 --- a/app/brave_generated_resources.grd +++ b/app/brave_generated_resources.grd @@ -654,6 +654,12 @@ Or change later at $2brave://settings/ext For example, you earn whenever a notification like this appears on your screen. You don't need to click to earn. + + You earn when a Brave Ads notification appears + + + You don't need to click to earn, but do click if you're interested! + diff --git a/components/brave_ads/browser/BUILD.gn b/components/brave_ads/browser/BUILD.gn index 32219c51a153..abab7dcb9a14 100644 --- a/components/brave_ads/browser/BUILD.gn +++ b/components/brave_ads/browser/BUILD.gn @@ -23,6 +23,8 @@ source_set("browser") { "component_updater/resource_info.h", "frequency_capping_helper.cc", "frequency_capping_helper.h", + "reminder_util.cc", + "reminder_util.h", ] configs += [ "//build/config/compiler:wexit_time_destructors" ] diff --git a/components/brave_ads/browser/ads_service_impl.cc b/components/brave_ads/browser/ads_service_impl.cc index a44eb710053a..5b1ed70fe952 100644 --- a/components/brave_ads/browser/ads_service_impl.cc +++ b/components/brave_ads/browser/ads_service_impl.cc @@ -22,6 +22,7 @@ #include "base/logging.h" #include "base/metrics/field_trial_params.h" #include "base/no_destructor.h" +#include "base/notreached.h" #include "base/ranges/algorithm.h" #include "base/strings/strcat.h" #include "base/strings/string_util.h" @@ -39,6 +40,7 @@ #include "brave/components/brave_ads/browser/component_updater/resource_component.h" #include "brave/components/brave_ads/browser/device_id.h" #include "brave/components/brave_ads/browser/frequency_capping_helper.h" +#include "brave/components/brave_ads/browser/reminder_util.h" #include "brave/components/brave_ads/browser/service_sandbox_type.h" // IWYU pragma: keep #include "brave/components/brave_ads/common/constants.h" #include "brave/components/brave_ads/common/features.h" @@ -60,7 +62,6 @@ #include "brave/components/brave_rewards/common/pref_names.h" #include "brave/components/brave_rewards/common/rewards_flags.h" #include "brave/components/l10n/common/locale_util.h" -#include "brave/components/l10n/common/localization_util.h" #include "brave/grit/brave_generated_resources.h" #include "build/build_config.h" #include "chrome/browser/browser_process.h" @@ -1731,6 +1732,21 @@ void AdsServiceImpl::CloseNotificationAd(const std::string& placement_id) { } } +void AdsServiceImpl::ShowReminder(const mojom::ReminderType type) { +#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) + if (IsEnabled() && CheckIfCanShowNotificationAds()) { + absl::optional reminder = GetReminder(type); + if (!reminder) { + NOTREACHED_NORETURN(); + } + + // TODO(https://github.com/brave/brave-browser/issues/29587): Decouple Brave + // Ads reminders from notification ads. + ShowNotificationAd(std::move(*reminder)); + } +#endif +} + void AdsServiceImpl::UpdateAdRewards() { for (AdsServiceObserver& observer : observers_) { observer.OnAdRewardsDidChange(); @@ -2106,21 +2122,7 @@ void AdsServiceImpl::OnRewardsWalletUpdated() { void AdsServiceImpl::OnExternalWalletConnected() { SetBooleanPref(prefs::kShouldMigrateVerifiedRewardsUser, true); -#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_IOS) - if (!IsEnabled() || !CheckIfCanShowNotificationAds()) { - return; - } - - base::Value::Dict dict; - dict.Set("title", - brave_l10n::GetLocalizedResourceUTF16String( - IDS_BRAVE_ADS_NOTIFICATION_EXTERNAL_WALLET_CONNECTED_TITLE)); - dict.Set("body", - brave_l10n::GetLocalizedResourceUTF16String( - IDS_BRAVE_ADS_NOTIFICATION_EXTERNAL_WALLET_CONNECTED_BODY)); - dict.Set("uuid", base::GUID::GenerateRandomV4().AsLowercaseString()); - ShowNotificationAd(std::move(dict)); -#endif + ShowReminder(mojom::ReminderType::kExternalWalletConnected); } void AdsServiceImpl::OnCompleteReset(const bool success) { diff --git a/components/brave_ads/browser/ads_service_impl.h b/components/brave_ads/browser/ads_service_impl.h index 6f3251692e0f..62c41bbbdd44 100644 --- a/components/brave_ads/browser/ads_service_impl.h +++ b/components/brave_ads/browser/ads_service_impl.h @@ -320,6 +320,8 @@ class AdsServiceImpl : public AdsService, void ShowNotificationAd(base::Value::Dict dict) override; void CloseNotificationAd(const std::string& placement_id) override; + void ShowReminder(mojom::ReminderType type) override; + void UpdateAdRewards() override; void RecordAdEventForId(const std::string& id, diff --git a/components/brave_ads/browser/reminder_util.cc b/components/brave_ads/browser/reminder_util.cc new file mode 100644 index 000000000000..74336db36408 --- /dev/null +++ b/components/brave_ads/browser/reminder_util.cc @@ -0,0 +1,71 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/browser/reminder_util.h" + +#include "base/guid.h" +#include "base/notreached.h" +#include "brave/components/brave_ads/common/interfaces/ads.mojom-shared.h" +#include "brave/components/brave_ads/core/notification_ad_constants.h" +#include "brave/components/l10n/common/localization_util.h" +#include "brave/grit/brave_generated_resources.h" + +namespace brave_ads { + +namespace { + +base::Value::Dict GetClickedSameAdMultipleTimesReminder() { + base::Value::Dict dict; + + dict.Set(kNotificationAdPlacementIdKey, + base::GUID::GenerateRandomV4().AsLowercaseString()); + dict.Set( + kNotificationAdTitleKey, + brave_l10n::GetLocalizedResourceUTF16String( + IDS_BRAVE_ADS_NOTIFICATION_CLICKED_SAME_AD_MULTIPLE_TIMES_TITLE)); + dict.Set(kNotificationAdBodyKey, + brave_l10n::GetLocalizedResourceUTF16String( + IDS_BRAVE_ADS_NOTIFICATION_CLICKED_SAME_AD_MULTIPLE_TIMES_BODY)); + dict.Set(kNotificationAdTargetUrlKey, + "https://support.brave.com/hc/en-us/articles/14648356808845"); + + return dict; +} + +base::Value::Dict GetExternalWalletConnectedReminder() { + base::Value::Dict dict; + + dict.Set(kNotificationAdPlacementIdKey, + base::GUID::GenerateRandomV4().AsLowercaseString()); + dict.Set(kNotificationAdTitleKey, + brave_l10n::GetLocalizedResourceUTF16String( + IDS_BRAVE_ADS_NOTIFICATION_EXTERNAL_WALLET_CONNECTED_TITLE)); + dict.Set(kNotificationAdBodyKey, + brave_l10n::GetLocalizedResourceUTF16String( + IDS_BRAVE_ADS_NOTIFICATION_EXTERNAL_WALLET_CONNECTED_BODY)); + dict.Set(kNotificationAdTargetUrlKey, + "https://support.brave.com/hc/en-us/articles/14648356808845"); + + return dict; +} + +} // namespace + +absl::optional GetReminder(const mojom::ReminderType type) { + switch (type) { + case mojom::ReminderType::kClickedSameAdMultipleTimes: { + return GetClickedSameAdMultipleTimesReminder(); + } + + case mojom::ReminderType::kExternalWalletConnected: { + return GetExternalWalletConnectedReminder(); + } + } + + NOTREACHED() << "Unexpected value for mojom::ReminderType: " << type; + return absl::nullopt; +} + +} // namespace brave_ads diff --git a/components/brave_ads/browser/reminder_util.h b/components/brave_ads/browser/reminder_util.h new file mode 100644 index 000000000000..a627e6e990b6 --- /dev/null +++ b/components/brave_ads/browser/reminder_util.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_BROWSER_REMINDER_UTIL_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_BROWSER_REMINDER_UTIL_H_ + +#include "brave/components/brave_ads/common/interfaces/ads.mojom-forward.h" + +#include "base/values.h" +#include "third_party/abseil-cpp/absl/types/optional.h" + +namespace brave_ads { + +absl::optional GetReminder(mojom::ReminderType type); + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_BROWSER_REMINDER_UTIL_H_ diff --git a/components/brave_ads/common/interfaces/ads.mojom b/components/brave_ads/common/interfaces/ads.mojom index a56f0b77d401..efbb1fd2fa79 100644 --- a/components/brave_ads/common/interfaces/ads.mojom +++ b/components/brave_ads/common/interfaces/ads.mojom @@ -23,6 +23,11 @@ struct StatementInfo { int32 ads_received_this_month; }; +enum ReminderType { + kClickedSameAdMultipleTimes = 0, + kExternalWalletConnected +}; + enum AdType { kUndefined = 0, kNotificationAd, diff --git a/components/brave_ads/core/ads_client.h b/components/brave_ads/core/ads_client.h index eaed8a66ad5e..a4a4a0252e13 100644 --- a/components/brave_ads/core/ads_client.h +++ b/components/brave_ads/core/ads_client.h @@ -59,6 +59,9 @@ class ADS_EXPORT AdsClient { // Close the notification ad for the specified |placement_id|. virtual void CloseNotificationAd(const std::string& placement_id) = 0; + // Show reminder for the specified |type|. + virtual void ShowReminder(mojom::ReminderType type) = 0; + // Record an ad event for the specified |id|, |ad_type|, |confirmation_type| // and |time|. virtual void RecordAdEventForId(const std::string& id, diff --git a/components/brave_ads/core/internal/BUILD.gn b/components/brave_ads/core/internal/BUILD.gn index 6fdb0f6cef42..95cf10e0fcbc 100644 --- a/components/brave_ads/core/internal/BUILD.gn +++ b/components/brave_ads/core/internal/BUILD.gn @@ -1028,6 +1028,12 @@ source_set("internal") { "processors/contextual/text_embedding/text_embedding_processor_util.h", "promoted_content_ad_info.cc", "promoted_content_ad_value_util.cc", + "reminder/reminder.cc", + "reminder/reminder.h", + "reminder/reminder_features.cc", + "reminder/reminder_features.h", + "reminder/reminders/clicked_same_ad_multiple_times_reminder_util.cc", + "reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h", "resources/behavioral/anti_targeting/anti_targeting_features.cc", "resources/behavioral/anti_targeting/anti_targeting_features.h", "resources/behavioral/anti_targeting/anti_targeting_info.cc", diff --git a/components/brave_ads/core/internal/ads_client_mock.h b/components/brave_ads/core/internal/ads_client_mock.h index c30ac0f7d6ac..9e216a4e44ac 100644 --- a/components/brave_ads/core/internal/ads_client_mock.h +++ b/components/brave_ads/core/internal/ads_client_mock.h @@ -42,6 +42,8 @@ class AdsClientMock : public AdsClient { MOCK_METHOD1(ShowNotificationAd, void(const NotificationAdInfo& ad)); MOCK_METHOD1(CloseNotificationAd, void(const std::string& placement_id)); + MOCK_METHOD1(ShowReminder, void(const mojom::ReminderType type)); + MOCK_METHOD0(UpdateAdRewards, void()); MOCK_CONST_METHOD4(RecordAdEventForId, diff --git a/components/brave_ads/core/internal/ads_impl.cc b/components/brave_ads/core/internal/ads_impl.cc index 55602862119a..18664abc63f2 100644 --- a/components/brave_ads/core/internal/ads_impl.cc +++ b/components/brave_ads/core/internal/ads_impl.cc @@ -47,6 +47,7 @@ #include "brave/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_processor.h" #include "brave/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor.h" #include "brave/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor.h" +#include "brave/components/brave_ads/core/internal/reminder/reminder.h" #include "brave/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_resource.h" #include "brave/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource.h" #include "brave/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_resource.h" @@ -130,6 +131,8 @@ AdsImpl::AdsImpl(AdsClient* ads_client) search_result_ad_handler_ = std::make_unique(account_.get(), transfer_.get()); + reminder_ = std::make_unique(); + user_reactions_ = std::make_unique(account_.get()); account_->AddObserver(this); diff --git a/components/brave_ads/core/internal/ads_impl.h b/components/brave_ads/core/internal/ads_impl.h index 2ce58b90c8b4..037edade4d29 100644 --- a/components/brave_ads/core/internal/ads_impl.h +++ b/components/brave_ads/core/internal/ads_impl.h @@ -70,6 +70,7 @@ class NotificationAdHandler; class NotificationAdManager; class PredictorsManager; class PromotedContentAd; +class Reminder; class SearchResultAd; class TabManager; class Transfer; @@ -229,6 +230,8 @@ class AdsImpl final : public Ads, std::unique_ptr promoted_content_ad_handler_; std::unique_ptr search_result_ad_handler_; + std::unique_ptr reminder_; + std::unique_ptr user_reactions_; base::WeakPtrFactory weak_factory_{this}; diff --git a/components/brave_ads/core/internal/common/unittest/unittest_mock_util.cc b/components/brave_ads/core/internal/common/unittest/unittest_mock_util.cc index 75f006cf3a5e..ac29bce3f5b9 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_mock_util.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_mock_util.cc @@ -166,8 +166,15 @@ void MockCanShowNotificationAdsWhileBrowserIsBackgrounded( void MockShowNotificationAd(const std::unique_ptr& mock) { ON_CALL(*mock, ShowNotificationAd(_)) - .WillByDefault( - Invoke([](const NotificationAdInfo& ad) { CHECK(ad.IsValid()); })); + .WillByDefault(Invoke([](const NotificationAdInfo& ad) { + // TODO(https://github.com/brave/brave-browser/issues/29587): Decouple + // reminders from push notification ads. + const bool is_reminder_valid = !ad.placement_id.empty() && + !ad.title.empty() && !ad.body.empty() && + ad.target_url.is_valid(); + + CHECK(ad.IsValid() || is_reminder_valid); + })); } void MockCloseNotificationAd(const std::unique_ptr& mock) { diff --git a/components/brave_ads/core/internal/reminder/README.md b/components/brave_ads/core/internal/reminder/README.md new file mode 100644 index 000000000000..55feb583e775 --- /dev/null +++ b/components/brave_ads/core/internal/reminder/README.md @@ -0,0 +1,5 @@ +# Reminder + +Deliver helpful reminders to users on how to interact with Brave Ads. + +Please add to it! diff --git a/components/brave_ads/core/internal/reminder/reminder.cc b/components/brave_ads/core/internal/reminder/reminder.cc new file mode 100644 index 000000000000..f3672a721627 --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminder.cc @@ -0,0 +1,41 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/core/internal/reminder/reminder.h" + +#include "brave/components/brave_ads/core/internal/history/history_manager.h" +#include "brave/components/brave_ads/core/internal/reminder/reminder_features.h" +#include "brave/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h" + +namespace brave_ads { + +namespace { + +void MaybeShowReminder(const HistoryItemInfo& history_item) { + if (!features::IsEnabled()) { + return; + } + + if (DidUserClickTheSameAdMultipleTimes(history_item)) { + RemindUserTheyDoNotNeedToClickToEarnRewards(); + } +} +} // namespace + +Reminder::Reminder() { + HistoryManager::GetInstance()->AddObserver(this); +} + +Reminder::~Reminder() { + HistoryManager::GetInstance()->RemoveObserver(this); +} + +/////////////////////////////////////////////////////////////////////////////// + +void Reminder::OnHistoryDidChange(const HistoryItemInfo& history_item) { + MaybeShowReminder(history_item); +} + +} // namespace brave_ads diff --git a/components/brave_ads/core/internal/reminder/reminder.h b/components/brave_ads/core/internal/reminder/reminder.h new file mode 100644 index 000000000000..fce9cc71d85d --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminder.h @@ -0,0 +1,34 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDER_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDER_H_ + +#include "brave/components/brave_ads/core/internal/history/history_manager_observer.h" + +namespace brave_ads { + +struct HistoryItemInfo; + +class Reminder : public HistoryManagerObserver { + public: + Reminder(); + + Reminder(const Reminder& other) = delete; + Reminder& operator=(const Reminder& other) = delete; + + Reminder(Reminder&& other) noexcept = delete; + Reminder& operator=(Reminder&& other) noexcept = delete; + + ~Reminder() override; + + private: + // HistoryManagerObserver: + void OnHistoryDidChange(const HistoryItemInfo& history_item) override; +}; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDER_H_ diff --git a/components/brave_ads/core/internal/reminder/reminder_features.cc b/components/brave_ads/core/internal/reminder/reminder_features.cc new file mode 100644 index 000000000000..63f05508ce2b --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminder_features.cc @@ -0,0 +1,32 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/core/internal/reminder/reminder_features.h" + +#include "base/metrics/field_trial_params.h" + +namespace brave_ads::features { + +namespace { + +constexpr char kRemindUserIfClickingTheSameAdAfterTrialParamName[] = + "remind_user_if_clicking_the_same_ad_after"; +constexpr int kRemindUserIfClickingTheSameAdAfterDefaultValue = 3; + +} // namespace + +BASE_FEATURE(kReminder, "Reminder", base::FEATURE_ENABLED_BY_DEFAULT); + +bool IsEnabled() { + return base::FeatureList::IsEnabled(kReminder); +} + +size_t GetRemindUserIfClickingTheSameAdAfter() { + return static_cast(GetFieldTrialParamByFeatureAsInt( + kReminder, kRemindUserIfClickingTheSameAdAfterTrialParamName, + kRemindUserIfClickingTheSameAdAfterDefaultValue)); +} + +} // namespace brave_ads::features diff --git a/components/brave_ads/core/internal/reminder/reminder_features.h b/components/brave_ads/core/internal/reminder/reminder_features.h new file mode 100644 index 000000000000..d5dcea39acf0 --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminder_features.h @@ -0,0 +1,21 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDER_FEATURES_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDER_FEATURES_H_ + +#include "base/feature_list.h" + +namespace brave_ads::features { + +BASE_DECLARE_FEATURE(kReminder); + +bool IsEnabled(); + +size_t GetRemindUserIfClickingTheSameAdAfter(); + +} // namespace brave_ads::features + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDER_FEATURES_H_ diff --git a/components/brave_ads/core/internal/reminder/reminder_features_unittest.cc b/components/brave_ads/core/internal/reminder/reminder_features_unittest.cc new file mode 100644 index 000000000000..d5b39e3d11c8 --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminder_features_unittest.cc @@ -0,0 +1,88 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/core/internal/reminder/reminder_features.h" + +#include + +#include "base/test/scoped_feature_list.h" +#include "testing/gtest/include/gtest/gtest.h" + +// npm run test -- brave_unit_tests --filter=BatAds* + +namespace brave_ads::features { + +TEST(BatAdsReminderFeaturesTest, IsEnabled) { + // Arrange + + // Act + + // Assert + EXPECT_TRUE(IsEnabled()); +} +TEST(BatAdsReminderFeaturesTest, IsDisabled) { + // Arrange + const std::vector enabled_features; + + std::vector disabled_features; + disabled_features.emplace_back(kReminder); + + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitWithFeaturesAndParameters(enabled_features, + disabled_features); + + // Act + + // Assert + EXPECT_FALSE(IsEnabled()); +} + +TEST(BatAdsReminderFeaturesTest, RemindUserIfClickingTheSameAdAfter) { + // Arrange + base::FieldTrialParams params; + params["remind_user_if_clicking_the_same_ad_after"] = "1"; + std::vector enabled_features; + enabled_features.emplace_back(kReminder, params); + + const std::vector disabled_features; + + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitWithFeaturesAndParameters(enabled_features, + disabled_features); + + // Act + + // Assert + EXPECT_EQ(1U, GetRemindUserIfClickingTheSameAdAfter()); +} + +TEST(BatAdsReminderFeaturesTest, DefaultRemindUserIfClickingTheSameAdAfter) { + // Arrange + + // Act + + // Assert + EXPECT_EQ(3U, GetRemindUserIfClickingTheSameAdAfter()); +} + +TEST(BatAdsReminderFeaturesTest, + DefaultRemindUserIfClickingTheSameAdAfterWhenDisabled) { + // Arrange + const std::vector enabled_features; + + std::vector disabled_features; + disabled_features.emplace_back(kReminder); + + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitWithFeaturesAndParameters(enabled_features, + disabled_features); + + // Act + + // Assert + EXPECT_EQ(3U, GetRemindUserIfClickingTheSameAdAfter()); +} + +} // namespace brave_ads::features diff --git a/components/brave_ads/core/internal/reminder/reminder_unittest.cc b/components/brave_ads/core/internal/reminder/reminder_unittest.cc new file mode 100644 index 000000000000..78809dd53501 --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminder_unittest.cc @@ -0,0 +1,92 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/core/internal/reminder/reminder.h" + +#include +#include + +#include "base/test/scoped_feature_list.h" +#include "brave/components/brave_ads/common/interfaces/ads.mojom-shared.h" +#include "brave/components/brave_ads/core/history_item_info.h" +#include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" +#include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" +#include "brave/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_builder.h" +#include "brave/components/brave_ads/core/internal/history/history_manager.h" +#include "brave/components/brave_ads/core/internal/reminder/reminder_features.h" + +// npm run test -- brave_unit_tests --filter=BatAds* + +namespace brave_ads { + +using ::testing::_; + +namespace { + +void AddHistory(const size_t count) { + const NotificationAdInfo ad = BuildNotificationAd( + BuildCreativeNotificationAd(/*should_use_random_guids*/ false)); + + for (size_t i = 0; i < count; i++) { + HistoryManager::GetInstance()->Add(ad, ConfirmationType::kClicked); + } +} + +} // namespace + +class BatAdsReminderTest : public UnitTestBase { + void SetUp() override { + UnitTestBase::SetUp(); + + reminder_ = std::make_unique(); + } + + protected: + std::unique_ptr reminder_; +}; + +TEST_F(BatAdsReminderTest, ShowReminderWhenUserClicksTheSameAdMultipleTimes) { + // Arrange + EXPECT_CALL(*ads_client_mock_, + ShowReminder(mojom::ReminderType::kClickedSameAdMultipleTimes)); + + // Act + AddHistory(/*count*/ features::GetRemindUserIfClickingTheSameAdAfter()); + + // Assert +} + +TEST_F(BatAdsReminderTest, + DoNotShowReminderIfUserDoesNotClickTheSameAdMultipleTimes) { + // Arrange + EXPECT_CALL(*ads_client_mock_, ShowReminder(_)).Times(0); + + // Act + AddHistory(/*count*/ features::GetRemindUserIfClickingTheSameAdAfter() - 1); + + // Assert +} + +TEST_F(BatAdsReminderTest, + DoNotShowReminderIfUserDoesNotClickTheSameAdMultipleTimesWhenDisabled) { + // Arrange + const std::vector enabled_features; + + std::vector disabled_features; + disabled_features.emplace_back(features::kReminder); + + base::test::ScopedFeatureList scoped_feature_list; + scoped_feature_list.InitWithFeaturesAndParameters(enabled_features, + disabled_features); + + EXPECT_CALL(*ads_client_mock_, ShowReminder(_)).Times(0); + + // Act + AddHistory(/*count*/ features::GetRemindUserIfClickingTheSameAdAfter()); + + // Assert +} + +} // namespace brave_ads diff --git a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.cc b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.cc new file mode 100644 index 000000000000..48cb23e025ee --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.cc @@ -0,0 +1,61 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h" + +#include "base/check_op.h" +#include "base/ranges/algorithm.h" +#include "brave/components/brave_ads/common/interfaces/ads.mojom-shared.h" +#include "brave/components/brave_ads/core/history_item_info.h" +#include "brave/components/brave_ads/core/internal/ads_client_helper.h" +#include "brave/components/brave_ads/core/internal/common/platform/platform_helper.h" +#include "brave/components/brave_ads/core/internal/history/history_manager.h" +#include "brave/components/brave_ads/core/internal/reminder/reminder_features.h" + +namespace brave_ads { + +namespace { + +bool CanRemind(const HistoryItemInfo& history_item) { + return !PlatformHelper::GetInstance()->IsMobile() && + features::GetRemindUserIfClickingTheSameAdAfter() > 0 && + history_item.ad_content.type == AdType::kNotificationAd && + history_item.ad_content.confirmation_type == + ConfirmationType::kClicked; +} + +} // namespace + +bool DidUserClickTheSameAdMultipleTimes(const HistoryItemInfo& history_item) { + if (!CanRemind(history_item)) { + return false; + } + + const size_t count = base::ranges::count_if( + HistoryManager::Get(), [&history_item](const HistoryItemInfo& other) { + return other.ad_content.confirmation_type == + ConfirmationType::kClicked && + other.ad_content.creative_instance_id == + history_item.ad_content.creative_instance_id; + }); + + if (count == 0) { + return false; + } + + const size_t remind_user_if_clicking_the_same_ad_after = + features::GetRemindUserIfClickingTheSameAdAfter(); + DCHECK_GT(remind_user_if_clicking_the_same_ad_after, 0U); + + return (count - 1) % remind_user_if_clicking_the_same_ad_after == + remind_user_if_clicking_the_same_ad_after - 1; +} + +void RemindUserTheyDoNotNeedToClickToEarnRewards() { + AdsClientHelper::GetInstance()->ShowReminder( + mojom::ReminderType::kClickedSameAdMultipleTimes); +} + +} // namespace brave_ads diff --git a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h new file mode 100644 index 000000000000..c4797ba86e9d --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDERS_CLICKED_SAME_AD_MULTIPLE_TIMES_REMINDER_UTIL_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDERS_CLICKED_SAME_AD_MULTIPLE_TIMES_REMINDER_UTIL_H_ + +namespace brave_ads { + +struct HistoryItemInfo; + +bool DidUserClickTheSameAdMultipleTimes(const HistoryItemInfo& history_item); + +void RemindUserTheyDoNotNeedToClickToEarnRewards(); + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_REMINDER_REMINDERS_CLICKED_SAME_AD_MULTIPLE_TIMES_REMINDER_UTIL_H_ diff --git a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc new file mode 100644 index 000000000000..f94e203d75f6 --- /dev/null +++ b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc @@ -0,0 +1,230 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#include "brave/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util.h" + +#include "base/time/time.h" +#include "brave/components/brave_ads/core/history_item_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_util.h" +#include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" +#include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" +#include "brave/components/brave_ads/core/internal/history/history_constants.h" +#include "brave/components/brave_ads/core/internal/history/history_util.h" +#include "brave/components/brave_ads/core/internal/reminder/reminder_features.h" + +// npm run test -- brave_unit_tests --filter=BatAds* + +namespace brave_ads { + +using ::testing::_; + +namespace { + +constexpr char kHistoryTitle[] = "title"; +constexpr char kHistoryDescription[] = "description"; + +HistoryItemInfo AddHistory(const AdInfo& ad, + const ConfirmationType confirmation_type) { + return AddHistory(ad, confirmation_type, kHistoryTitle, kHistoryDescription); +} + +HistoryItemInfo AddHistory( + const size_t count, + const bool should_use_random_creative_instance_guid) { + CHECK_GT(count, 0U); + + HistoryItemInfo history_item; + + AdInfo ad; + for (size_t i = 0; i < count; i++) { + if (i == 0 || should_use_random_creative_instance_guid) { + ad = BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ true); + CHECK(ad.IsValid()); + } + + history_item = AddHistory(ad, ConfirmationType::kClicked); + } + + return history_item; +} + +} // namespace + +class BatAdsClickedSameAdMultipleTimesReminderUtilTest : public UnitTestBase {}; + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + RemindUserOnDesktopOperatingSystems) { + // Arrange + const HistoryItemInfo history_item = + AddHistory(/*count*/ features::GetRemindUserIfClickingTheSameAdAfter(), + /*should_use_random_creative_instance_guid*/ false); + + // Assert + EXPECT_TRUE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + DoNotRemindUserOnMobileOperatingSystems) { + // Arrange + MockPlatformHelper(platform_helper_mock_, PlatformType::kAndroid); + + const HistoryItemInfo history_item = + AddHistory(/*count*/ 3, + /*should_use_random_creative_instance_guid*/ false); + + // Act + + // Assert + EXPECT_FALSE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + RemindUserAfterClickingTheSameAdMultipleTimes) { + // Arrange + const HistoryItemInfo history_item = + AddHistory(/*count*/ features::GetRemindUserIfClickingTheSameAdAfter(), + /*should_use_random_creative_instance_guid*/ false); + + // Act + + // Assert + EXPECT_TRUE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + DoNotRemindUserIfTheyDidNotClickTheSameAdMultipleTimes) { + // Arrange + const HistoryItemInfo history_item = AddHistory( + /*count*/ features::GetRemindUserIfClickingTheSameAdAfter() - 1, + /*should_use_random_creative_instance_guid*/ false); + + // Act + + // Assert + EXPECT_FALSE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + RemindUserAfterOnceAgainClickingTheSameAdMultipleTimes) { + // Arrange + const HistoryItemInfo history_item = AddHistory( + /*count*/ features::GetRemindUserIfClickingTheSameAdAfter() * 2, + /*should_use_random_creative_instance_guid*/ false); + + // Act + + // Assert + EXPECT_TRUE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + DoNotRemindUserIfTheyDidNotOnceAgainClickTheSameAdMultipleTimes) { + // Arrange + const HistoryItemInfo history_item = AddHistory( + /*count*/ (features::GetRemindUserIfClickingTheSameAdAfter() * 2) - 1, + /*should_use_random_creative_instance_guid*/ false); + + // Act + + // Assert + EXPECT_FALSE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F( + BatAdsClickedSameAdMultipleTimesReminderUtilTest, + RemindUserAfterClickingTheSameAdMultipleTimesOnTheCuspOfExpiringHistory) { + // Arrange + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); + + AddHistory(ad, ConfirmationType::kClicked); + AddHistory(ad, ConfirmationType::kClicked); + + AdvanceClockBy(kHistoryTimeWindow - base::Nanoseconds(1)); + + // Act + const HistoryItemInfo history_item = + AddHistory(ad, ConfirmationType::kClicked); + + // Assert + EXPECT_TRUE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F( + BatAdsClickedSameAdMultipleTimesReminderUtilTest, + DoNotRemindUserIfTheyDidNotClickTheSameAdMultipleTimesAfterTheHistoryHasExpired) { + // Arrange + AddHistory( + /*count*/ features::GetRemindUserIfClickingTheSameAdAfter() - 1, + /*should_use_random_creative_instance_guid*/ false); + + AdvanceClockBy(kHistoryTimeWindow); + + // Act + const HistoryItemInfo history_item = AddHistory( + /*count*/ 1, /*should_use_random_creative_instance_guid*/ false); + + // Assert + EXPECT_FALSE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + DoNotRemindTheUserAfterClickingDifferentAds) { + // Arrange + const HistoryItemInfo history_item = AddHistory( + /*count*/ features::GetRemindUserIfClickingTheSameAdAfter(), + /*should_use_random_creative_instance_guid*/ true); + + // Act + + // Assert + EXPECT_FALSE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + DoNotRemindTheUserForTheSameAdWithDifferentConfirmationTypes) { + // Arrange + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); + + AddHistory(ad, ConfirmationType::kServed); + AddHistory(ad, ConfirmationType::kViewed); + const HistoryItemInfo history_item = + AddHistory(ad, ConfirmationType::kClicked); + + // Act + + // Assert + EXPECT_FALSE(DidUserClickTheSameAdMultipleTimes(history_item)); +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + RemindUserTheyDoNotNeedToClickToEarnRewards) { + // Arrange + EXPECT_CALL(*ads_client_mock_, + ShowReminder(mojom::ReminderType::kClickedSameAdMultipleTimes)); + + // Act + RemindUserTheyDoNotNeedToClickToEarnRewards(); + + // Assert +} + +TEST_F(BatAdsClickedSameAdMultipleTimesReminderUtilTest, + RemindUserMultipleTimesTheyDoNotNeedToClickToEarnRewards) { + // Arrange + EXPECT_CALL(*ads_client_mock_, + ShowReminder(mojom::ReminderType::kClickedSameAdMultipleTimes)) + .Times(2); + + RemindUserTheyDoNotNeedToClickToEarnRewards(); + + // Act + RemindUserTheyDoNotNeedToClickToEarnRewards(); + + // Assert +} + +} // namespace brave_ads diff --git a/components/brave_ads/core/test/BUILD.gn b/components/brave_ads/core/test/BUILD.gn index 91aa29dfea78..7aeb5b819dc4 100644 --- a/components/brave_ads/core/test/BUILD.gn +++ b/components/brave_ads/core/test/BUILD.gn @@ -435,6 +435,9 @@ source_set("brave_ads_unit_tests") { "//brave/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor_util_unittest.cc", "//brave/components/brave_ads/core/internal/promoted_content_ad_info_unittest.cc", "//brave/components/brave_ads/core/internal/promoted_content_ad_value_util_unittest.cc", + "//brave/components/brave_ads/core/internal/reminder/reminder_features_unittest.cc", + "//brave/components/brave_ads/core/internal/reminder/reminder_unittest.cc", + "//brave/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc", "//brave/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_features_unittest.cc", "//brave/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_resource_unittest.cc", "//brave/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_resource_unittest.cc", diff --git a/components/services/bat_ads/bat_ads_client_mojo_bridge.cc b/components/services/bat_ads/bat_ads_client_mojo_bridge.cc index 4f997815f309..499b094f3513 100644 --- a/components/services/bat_ads/bat_ads_client_mojo_bridge.cc +++ b/components/services/bat_ads/bat_ads_client_mojo_bridge.cc @@ -88,6 +88,13 @@ void BatAdsClientMojoBridge::ShowNotificationAd( } } +void BatAdsClientMojoBridge::ShowReminder( + const brave_ads::mojom::ReminderType type) { + if (bat_ads_client_.is_bound()) { + bat_ads_client_->ShowReminder(type); + } +} + bool BatAdsClientMojoBridge::CanShowNotificationAds() { if (!bat_ads_client_.is_bound()) { return false; diff --git a/components/services/bat_ads/bat_ads_client_mojo_bridge.h b/components/services/bat_ads/bat_ads_client_mojo_bridge.h index 8d30954b9ed1..a85211a6ea48 100644 --- a/components/services/bat_ads/bat_ads_client_mojo_bridge.h +++ b/components/services/bat_ads/bat_ads_client_mojo_bridge.h @@ -60,6 +60,8 @@ class BatAdsClientMojoBridge : public brave_ads::AdsClient { void ShowNotificationAd(const brave_ads::NotificationAdInfo& ad) override; void CloseNotificationAd(const std::string& placement_id) override; + void ShowReminder(brave_ads::mojom::ReminderType type) override; + void UpdateAdRewards() override; void RecordAdEventForId(const std::string& id, diff --git a/components/services/bat_ads/public/interfaces/bat_ads.mojom b/components/services/bat_ads/public/interfaces/bat_ads.mojom index a4e3184ca6f3..42b5e1e0c0d7 100644 --- a/components/services/bat_ads/public/interfaces/bat_ads.mojom +++ b/components/services/bat_ads/public/interfaces/bat_ads.mojom @@ -76,6 +76,8 @@ interface BatAdsClient { ShowNotificationAd(mojo_base.mojom.DictionaryValue value); CloseNotificationAd(string placement_id); + ShowReminder(brave_ads.mojom.ReminderType type); + UpdateAdRewards(); RecordAdEventForId(string id, diff --git a/ios/browser/api/ads/ads_client_bridge.h b/ios/browser/api/ads/ads_client_bridge.h index 3e4eed7251a7..bb6d2ebe7f39 100644 --- a/ios/browser/api/ads/ads_client_bridge.h +++ b/ios/browser/api/ads/ads_client_bridge.h @@ -46,6 +46,7 @@ callback:(brave_ads::SaveCallback)callback; - (void)showNotificationAd:(const brave_ads::NotificationAdInfo&)info; - (void)closeNotificationAd:(const std::string&)placement_id; +- (void)showReminder:(const brave_ads::mojom::ReminderType)type; - (void)recordAdEventForId:(const std::string&)id adType:(const std::string&)ad_type confirmationType:(const std::string&)confirmation_type diff --git a/ios/browser/api/ads/ads_client_ios.h b/ios/browser/api/ads/ads_client_ios.h index 911310b21052..aa3534a691bb 100644 --- a/ios/browser/api/ads/ads_client_ios.h +++ b/ios/browser/api/ads/ads_client_ios.h @@ -31,6 +31,7 @@ class AdsClientIOS : public brave_ads::AdsClient { void ShowNotificationAd(const brave_ads::NotificationAdInfo& ad) override; bool CanShowNotificationAds() override; void CloseNotificationAd(const std::string& placement_id) override; + void ShowReminder(const brave_ads::mojom::ReminderType type) override; void RecordAdEventForId(const std::string& id, const std::string& ad_type, const std::string& confirmation_type, diff --git a/ios/browser/api/ads/ads_client_ios.mm b/ios/browser/api/ads/ads_client_ios.mm index 1a749c5f7e45..790f7851353e 100644 --- a/ios/browser/api/ads/ads_client_ios.mm +++ b/ios/browser/api/ads/ads_client_ios.mm @@ -60,6 +60,10 @@ [bridge_ closeNotificationAd:placement_id]; } +void AdsClientIOS::ShowReminder(const brave_ads::mojom::ReminderType type) { + [bridge_ showReminder:type]; +} + void AdsClientIOS::RecordAdEventForId(const std::string& id, const std::string& ad_type, const std::string& confirmation_type, diff --git a/ios/browser/api/ads/brave_ads.mm b/ios/browser/api/ads/brave_ads.mm index dd15c27fe1c6..e82f5129567d 100644 --- a/ios/browser/api/ads/brave_ads.mm +++ b/ios/browser/api/ads/brave_ads.mm @@ -1289,6 +1289,10 @@ - (void)closeNotificationAd:(const std::string&)placement_id { clearNotificationWithIdentifier:bridgedPlacementId]; } +- (void)showReminder:(const brave_ads::mojom::ReminderType)type { + // Not needed on iOS +} + - (void)recordAdEventForId:(const std::string&)id adType:(const std::string&)ad_type confirmationType:(const std::string&)confirmation_type From 452ea411d67cd8a45f1d92fab4f3d7e6afc48a4e Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Tue, 11 Apr 2023 13:50:11 +0100 Subject: [PATCH 2/5] Cleanup Brave Ads unit tests --- components/brave_ads/core/BUILD.gn | 4 + .../core/inline_content_ad_constants.h | 26 + components/brave_ads/core/internal/BUILD.gn | 2 + .../core/internal/account/account.cc | 1 + .../core/internal/account/account_unittest.cc | 121 +-- .../internal/account/account_util_unittest.cc | 1 + ...nfirmation_payload_json_writer_unittest.cc | 1 + ...confirmation_user_data_builder_unittest.cc | 30 +- .../account/deposits/cash_deposit_test.cc | 9 +- .../deposits_database_table_unittest.cc | 4 +- .../deposits/non_cash_deposit_unittest.cc | 5 +- .../statement/ads_received_util_unittest.cc | 15 +- .../statement/statement_util_unittest.cc | 4 +- .../transactions_database_table_unittest.cc | 72 +- .../transactions_util_unittest.cc | 8 +- .../user_data/catalog_user_data_unittest.cc | 7 +- .../user_data/conversion_user_data_builder.cc | 44 +- .../conversion_user_data_builder_unittest.cc | 52 +- .../conversion_user_data_unittest.cc | 29 +- .../conversion_user_data_util_unittest.cc | 29 +- .../rotating_hash_user_data_unittest.cc | 7 +- .../user_data/segment_user_data_unittest.cc | 3 +- .../totals_user_data_util_unittest.cc | 8 +- .../redeem_opted_in_confirmation_unittest.cc | 19 + ...ment_token_url_request_builder_unittest.cc | 1 + ...edeem_unblinded_payment_tokens_unittest.cc | 5 +- .../refill_unblinded_tokens_unittest.cc | 3 +- .../account/wallet/wallet_unittest.cc | 15 +- .../wallet/wallet_unittest_constants.h | 27 + .../account/wallet/wallet_unittest_util.cc | 27 +- .../account/wallet/wallet_unittest_util.h | 6 - .../ad_content_value_util_unittest.cc | 4 +- .../internal/ad_event_history_unittest.cc | 1 + .../core/internal/ad_info_unittest.cc | 3 +- .../ads/ad_events/ad_event_unittest_util.cc | 7 +- .../ads/ad_events/ad_event_util_unittest.cc | 27 +- .../ad_events_database_table_unittest.cc | 6 +- ...nline_content_ad_event_handler_unittest.cc | 14 +- ..._event_handler_if_ads_disabled_unittest.cc | 14 +- .../new_tab_page_ad_event_handler_unittest.cc | 14 +- .../notification_ad_event_handler_unittest.cc | 6 +- ...moted_content_ad_event_handler_unittest.cc | 14 +- ...search_result_ad_event_handler_unittest.cc | 100 +- .../core/internal/ads/ad_unittest_constants.h | 32 + .../core/internal/ads/ad_unittest_util.cc | 47 +- .../core/internal/ads/ad_unittest_util.h | 3 +- .../internal/ads/inline_content_ad_test.cc | 17 +- .../core/internal/ads/new_tab_page_ad_test.cc | 20 +- .../notification_ad_handler_util_unittest.cc | 3 +- .../internal/ads/promoted_content_ad_test.cc | 21 +- .../internal/ads/search_result_ad_test.cc | 16 +- .../eligible_ads_predictor_util_unittest.cc | 59 +- .../ads/serving/choose/sample_ads_unittest.cc | 15 +- .../eligible_ads_features_util_unittest.cc | 12 +- .../conversion_exclusion_rule_unittest.cc | 3 +- ...eative_instance_exclusion_rule_unittest.cc | 5 +- .../daypart_exclusion_rule_unittest.cc | 103 +-- .../dislike_exclusion_rule_unittest.cc | 5 +- ...s_inappropriate_exclusion_rule_unittest.cc | 8 +- ..._longer_receive_exclusion_rule_unittest.cc | 5 +- ...on_ad_dismissed_exclusion_rule_unittest.cc | 3 +- .../per_day_exclusion_rule_unittest.cc | 5 +- .../per_month_exclusion_rule_unittest.cc | 5 +- .../per_week_exclusion_rule_unittest.cc | 5 +- .../split_test_exclusion_rule_unittest.cc | 3 +- ...ision_targeting_exclusion_rule_unittest.cc | 3 +- .../transferred_exclusion_rule_unittest.cc | 3 +- .../eligible_ads/pacing/pacing_unittest.cc | 18 +- ...eligible_inline_content_ads_v1_unittest.cc | 159 ++-- ...eligible_inline_content_ads_v2_unittest.cc | 39 +- .../eligible_new_tab_page_ads_v1_unittest.cc | 151 +-- .../eligible_new_tab_page_ads_v2_unittest.cc | 23 +- ...otification_ads_v1_issue_17199_unittest.cc | 9 +- .../eligible_notification_ads_v1_unittest.cc | 151 +-- .../eligible_notification_ads_v2_unittest.cc | 23 +- .../eligible_notification_ads_v3_unittest.cc | 24 +- .../priority/priority_unittest.cc | 19 +- .../inline_content_ad_serving_unittest.cc | 18 +- .../new_tab_page_ad_serving_unittest.cc | 21 +- .../notification_ad_serving_unittest.cc | 14 +- .../epsilon_greedy_bandit_model_unittest.cc | 7 +- .../purchase_intent_model_unittest.cc | 40 +- .../text_classification_model_unittest.cc | 31 +- .../targeting/top_segments_unittest.cc | 10 +- .../catalog/catalog_json_reader_unittest.cc | 9 +- .../catalog/catalog_unittest_constants.h | 15 + .../internal/catalog/catalog_util_unittest.cc | 8 +- .../common/calendar/calendar_util_unittest.cc | 6 +- .../common/crypto/crypto_util_unittest.cc | 1 - .../common/database/database_bind_util.cc | 4 +- .../common/locale/subdivision_code_util.cc | 4 +- .../string_html_parser_util_unittest.cc | 1 + .../internal/common/unittest/unittest_base.cc | 4 +- .../internal/common/unittest/unittest_base.h | 4 +- .../anonymous_search_url_host_unittest.cc | 12 +- .../host/hosts/anonymous_url_host_unittest.cc | 9 +- .../host/hosts/geo_url_host_unittest.cc | 8 +- .../hosts/non_anonymous_url_host_unittest.cc | 9 +- .../host/hosts/static_url_host_unittest.cc | 8 +- .../host/url_host_util_unittest.cc | 22 +- ...onversion_queue_database_table_unittest.cc | 410 +++------ .../conversion_queue_item_unittest_util.cc | 67 +- .../conversion_queue_item_unittest_util.h | 14 +- .../conversions_database_table_test.cc | 2 +- .../conversions_database_table_unittest.cc | 177 ++-- .../conversions/conversions_unittest.cc | 149 +-- .../conversions_unittest_constants.h | 25 + .../internal/conversions/conversions_util.cc | 27 +- .../internal/conversions/conversions_util.h | 4 + .../conversions/conversions_util_constants.h | 18 + .../conversions/conversions_util_unittest.cc | 43 +- .../sorts/conversions_sort_unittest.cc | 4 +- ...verifiable_conversion_envelope_constants.h | 19 + ...iable_conversion_envelope_unittest_util.cc | 21 +- .../campaigns_database_table_unittest.cc | 4 +- .../creatives/creative_ad_unittest_util.cc | 37 +- .../creatives/creative_ad_unittest_util.h | 2 +- .../creative_ads_database_table_unittest.cc | 4 +- .../dayparts_database_table_unittest.cc | 4 +- .../embeddings_database_table_unittest.cc | 4 +- .../geo_targets_database_table_unittest.cc | 4 +- ...creative_inline_content_ad_unittest_util.h | 2 +- ..._inline_content_ads_database_table_test.cc | 8 +- ...ine_content_ads_database_table_unittest.cc | 748 +++------------ .../creative_new_tab_page_ad_unittest_util.h | 2 +- ...e_ad_wallpapers_database_table_unittest.cc | 5 +- ...ve_new_tab_page_ads_database_table_test.cc | 6 +- ...ew_tab_page_ads_database_table_unittest.cc | 127 ++- .../creative_notification_ad_unittest_util.h | 2 +- ...ve_notification_ads_database_table_test.cc | 6 +- ...otification_ads_database_table_unittest.cc | 688 +++----------- ...eative_promoted_content_ad_unittest_util.h | 2 +- ...ive_promoted_content_ads_database_table.cc | 1 + ...romoted_content_ads_database_table_test.cc | 6 +- ...ted_content_ads_database_table_unittest.cc | 870 ++++-------------- .../search_result_ad_unittest_util.cc | 77 +- .../search_result_ad_unittest_util.h | 4 +- .../segments_database_table_unittest.cc | 4 +- .../ad_preferences_info_unittest.cc | 65 +- .../diagnostic_manager_unittest.cc | 1 - ...hrough_rate_predictor_variable_unittest.cc | 27 +- .../history/ad_content_util_unittest.cc | 3 +- .../history/category_content_util_unittest.cc | 5 +- .../category_content_value_util_unittest.cc | 7 +- .../date_range_history_filter_unittest.cc | 16 +- .../history/history_item_util_unittest.cc | 3 +- .../core/internal/history/history_manager.cc | 23 +- .../core/internal/history/history_manager.h | 3 +- .../history/history_manager_observer.h | 3 +- .../history/history_manager_unittest.cc | 56 +- .../core/internal/history/history_util.cc | 2 + .../internal/history/history_util_unittest.cc | 11 +- .../history_item_value_util_unittest.cc | 5 +- .../inline_content_ad_info_unittest.cc | 2 +- .../internal/inline_content_ad_value_util.cc | 65 +- .../inline_content_ad_value_util_unittest.cc | 5 +- ...database_migration_issue_17231_unittest.cc | 2 +- .../database/database_migration_unittest.cc | 7 +- .../internal/ml/data/text_data_unittest.cc | 3 +- .../internal/ml/data/vector_data_unittest.cc | 17 +- .../ml/model/linear/linear_unittest.cc | 13 +- .../text_processing_unittest.cc | 6 +- .../hashed_ngrams_transformation_unittest.cc | 3 +- .../normalization_transformation_unittest.cc | 3 +- .../internal/new_tab_page_ad_info_unittest.cc | 3 +- .../internal/new_tab_page_ad_value_util.cc | 80 +- .../new_tab_page_ad_value_util_unittest.cc | 5 +- .../internal/notification_ad_info_unittest.cc | 3 +- .../internal/notification_ad_value_util.cc | 49 +- .../notification_ad_value_util_unittest.cc | 7 +- .../tokens/token_generator_unittest.cc | 2 +- ...inded_payment_token_value_util_unittest.cc | 3 +- .../unblinded_payment_tokens_unittest_util.cc | 1 + .../unblinded_payment_tokens_unittest_util.h | 9 +- .../unblinded_token_value_util_unittest.cc | 3 +- .../text_classification_processor_unittest.cc | 4 +- ...ing_html_events_database_table_unittest.cc | 4 +- .../text_embedding_processor_util_unittest.cc | 6 +- .../promoted_content_ad_info_unittest.cc | 2 +- .../promoted_content_ad_value_util.cc | 51 +- ...promoted_content_ad_value_util_unittest.cc | 5 +- ...d_multiple_times_reminder_util_unittest.cc | 2 - ...epsilon_greedy_bandit_resource_unittest.cc | 3 +- .../segments/segment_util_unittest.cc | 35 +- .../internal/transfer/transfer_unittest.cc | 21 +- .../idle_detection_util_unittest.cc | 6 +- .../user_activity_util_unittest.cc | 3 +- .../user_reactions/user_reactions_unittest.cc | 3 +- .../core/new_tab_page_ad_constants.h | 28 + .../core/notification_ad_constants.h | 23 + .../core/promoted_content_ad_constants.h | 24 + components/brave_ads/core/test/BUILD.gn | 4 + .../brave_ads/core/test/data/catalog.json | 4 +- .../data/catalog_with_inline_content_ad.json | 2 +- .../data/catalog_with_multiple_campaigns.json | 2 +- .../data/catalog_with_new_tab_page_ad.json | 2 +- .../data/catalog_with_notification_ad.json | 2 +- .../catalog_with_promoted_content_ad.json | 2 +- .../data/catalog_with_single_campaign.json | 2 +- 199 files changed, 2552 insertions(+), 3883 deletions(-) create mode 100644 components/brave_ads/core/inline_content_ad_constants.h create mode 100644 components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h create mode 100644 components/brave_ads/core/internal/ads/ad_unittest_constants.h create mode 100644 components/brave_ads/core/internal/catalog/catalog_unittest_constants.h create mode 100644 components/brave_ads/core/internal/conversions/conversions_unittest_constants.h create mode 100644 components/brave_ads/core/internal/conversions/conversions_util_constants.h create mode 100644 components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_constants.h create mode 100644 components/brave_ads/core/new_tab_page_ad_constants.h create mode 100644 components/brave_ads/core/notification_ad_constants.h create mode 100644 components/brave_ads/core/promoted_content_ad_constants.h diff --git a/components/brave_ads/core/BUILD.gn b/components/brave_ads/core/BUILD.gn index 3a83c3757c99..fd1e0cf36ae8 100644 --- a/components/brave_ads/core/BUILD.gn +++ b/components/brave_ads/core/BUILD.gn @@ -51,15 +51,19 @@ source_set("headers") { "history_item_info.h", "history_item_value_util.h", "history_sort_types.h", + "inline_content_ad_constants.h", "inline_content_ad_info.h", "inline_content_ad_value_util.h", + "new_tab_page_ad_constants.h", "new_tab_page_ad_info.h", "new_tab_page_ad_value_util.h", "new_tab_page_ad_wallpaper_focal_point_info.h", "new_tab_page_ad_wallpaper_info.h", + "notification_ad_constants.h", "notification_ad_info.h", "notification_ad_value_util.h", "page_transition_types.h", + "promoted_content_ad_constants.h", "promoted_content_ad_info.h", "promoted_content_ad_value_util.h", "supported_subdivisions.h", diff --git a/components/brave_ads/core/inline_content_ad_constants.h b/components/brave_ads/core/inline_content_ad_constants.h new file mode 100644 index 000000000000..c3bdac7967bd --- /dev/null +++ b/components/brave_ads/core/inline_content_ad_constants.h @@ -0,0 +1,26 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INLINE_CONTENT_AD_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INLINE_CONTENT_AD_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kInlineContentAdPlacementIdKey[] = "uuid"; +constexpr char kInlineContentAdCreativeInstanceIdKey[] = "creativeInstanceId"; +constexpr char kInlineContentAdCreativeSetIdKey[] = "creativeSetId"; +constexpr char kInlineContentAdCampaignIdKey[] = "campaignId"; +constexpr char kInlineContentAdAdvertiserIdKey[] = "advertiserId"; +constexpr char kInlineContentAdSegmentKey[] = "segment"; +constexpr char kInlineContentAdTitleKey[] = "title"; +constexpr char kInlineContentAdDescriptionKey[] = "description"; +constexpr char kInlineContentAdImageUrlKey[] = "imageUrl"; +constexpr char kInlineContentAdDimensionsKey[] = "dimensions"; +constexpr char kInlineContentAdCtaTextKey[] = "ctaText"; +constexpr char kInlineContentAdTargetUrlKey[] = "targetUrl"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INLINE_CONTENT_AD_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/BUILD.gn b/components/brave_ads/core/internal/BUILD.gn index 95cf10e0fcbc..31e52ea57ec3 100644 --- a/components/brave_ads/core/internal/BUILD.gn +++ b/components/brave_ads/core/internal/BUILD.gn @@ -644,6 +644,7 @@ source_set("internal") { "conversions/conversions_observer.h", "conversions/conversions_util.cc", "conversions/conversions_util.h", + "conversions/conversions_util_constants.h", "conversions/sorts/conversion_sort_types.h", "conversions/sorts/conversions_ascending_sort.cc", "conversions/sorts/conversions_ascending_sort.h", @@ -652,6 +653,7 @@ source_set("internal") { "conversions/sorts/conversions_sort_factory.cc", "conversions/sorts/conversions_sort_factory.h", "conversions/sorts/conversions_sort_interface.h", + "conversions/verifiable_conversion_envelope_constants.h", "conversions/verifiable_conversion_envelope_info.cc", "conversions/verifiable_conversion_envelope_info.h", "conversions/verifiable_conversion_info.cc", diff --git a/components/brave_ads/core/internal/account/account.cc b/components/brave_ads/core/internal/account/account.cc index 7369dbc724f0..c3f0561217a5 100644 --- a/components/brave_ads/core/internal/account/account.cc +++ b/components/brave_ads/core/internal/account/account.cc @@ -13,6 +13,7 @@ #include "base/functional/bind.h" #include "brave/components/brave_ads/common/interfaces/ads.mojom.h" // IWYU pragma: keep #include "brave/components/brave_ads/common/pref_names.h" +#include "brave/components/brave_ads/core/ad_type.h" #include "brave/components/brave_ads/core/internal/account/account_util.h" #include "brave/components/brave_ads/core/internal/account/confirmations/confirmation_info.h" #include "brave/components/brave_ads/core/internal/account/confirmations/confirmation_util.h" diff --git a/components/brave_ads/core/internal/account/account_unittest.cc b/components/brave_ads/core/internal/account/account_unittest.cc index 7f0c8d31c20b..612aa3a54c3c 100644 --- a/components/brave_ads/core/internal/account/account_unittest.cc +++ b/components/brave_ads/core/internal/account/account_unittest.cc @@ -18,7 +18,8 @@ #include "brave/components/brave_ads/core/internal/account/transactions/transactions.h" #include "brave/components/brave_ads/core/internal/account/transactions/transactions_unittest_util.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet_info.h" -#include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h" +#include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -29,7 +30,6 @@ #include "brave/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_tokens_unittest_util.h" #include "net/http/http_status_code.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#include "url/gurl.h" // npm run test -- brave_unit_tests --filter=BatAds @@ -105,8 +105,7 @@ TEST_F(BatAdsAccountTest, SetWallet) { // Arrange // Act - account_->SetWallet(GetWalletPaymentIdForTesting(), - GetWalletRecoverySeedForTesting()); + account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); // Assert EXPECT_TRUE(wallet_was_created_); @@ -120,7 +119,7 @@ TEST_F(BatAdsAccountTest, SetWalletWithEmptyPaymentId) { MockUrlResponses(ads_client_mock_, GetValidIssuersUrlResponses()); // Act - account_->SetWallet(/*payment_id*/ {}, GetWalletRecoverySeedForTesting()); + account_->SetWallet(/*payment_id*/ {}, kWalletRecoverySeed); // Assert EXPECT_FALSE(wallet_was_created_); @@ -134,8 +133,7 @@ TEST_F(BatAdsAccountTest, SetWalletWithInvalidRecoverySeed) { MockUrlResponses(ads_client_mock_, GetValidIssuersUrlResponses()); // Act - account_->SetWallet(GetWalletPaymentIdForTesting(), - GetInvalidWalletRecoverySeedForTesting()); + account_->SetWallet(kWalletPaymentId, kInvalidWalletRecoverySeed); // Assert EXPECT_FALSE(wallet_was_created_); @@ -149,7 +147,7 @@ TEST_F(BatAdsAccountTest, SetWalletWithEmptyRecoverySeed) { MockUrlResponses(ads_client_mock_, GetValidIssuersUrlResponses()); // Act - account_->SetWallet(GetWalletPaymentIdForTesting(), /*recovery_seed*/ ""); + account_->SetWallet(kWalletPaymentId, /*recovery_seed*/ ""); // Assert EXPECT_FALSE(wallet_was_created_); @@ -160,12 +158,11 @@ TEST_F(BatAdsAccountTest, SetWalletWithEmptyRecoverySeed) { TEST_F(BatAdsAccountTest, ChangeWallet) { // Arrange - account_->SetWallet(GetWalletPaymentIdForTesting(), - GetWalletRecoverySeedForTesting()); + account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); // Act account_->SetWallet(/*payment_id*/ "c1bf0a09-cac8-48eb-8c21-7ca6d995b0a3", - GetWalletRecoverySeedForTesting()); + kWalletRecoverySeed); // Assert EXPECT_TRUE(wallet_was_created_); @@ -176,19 +173,16 @@ TEST_F(BatAdsAccountTest, ChangeWallet) { TEST_F(BatAdsAccountTest, GetWallet) { // Arrange - account_->SetWallet(GetWalletPaymentIdForTesting(), - GetWalletRecoverySeedForTesting()); + account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); // Act const WalletInfo& wallet = account_->GetWallet(); // Assert WalletInfo expected_wallet; - expected_wallet.payment_id = "27a39b2f-9b2e-4eb0-bbb2-2f84447496e7"; - expected_wallet.public_key = "BiG/i3tfNLSeOA9ZF5rkPCGyhkc7KCRbQS3bVGMvFQ0="; - expected_wallet.secret_key = - "kwUjEEdzI6rkI6hLoyxosa47ZrcZUvbYppAm4zvYF5gGIb+" - "Le180tJ44D1kXmuQ8IbKGRzsoJFtBLdtUYy8VDQ=="; + expected_wallet.payment_id = kWalletPaymentId; + expected_wallet.public_key = kWalletPublicKey; + expected_wallet.secret_key = kWalletSecretKey; EXPECT_EQ(expected_wallet, wallet); } @@ -196,11 +190,11 @@ TEST_F(BatAdsAccountTest, GetWallet) { TEST_F(BatAdsAccountTest, GetIssuersWhenWalletIsCreated) { // Arrange privacy::SetUnblindedTokens(50); + MockUrlResponses(ads_client_mock_, GetValidIssuersUrlResponses()); // Act - account_->SetWallet(GetWalletPaymentIdForTesting(), - GetWalletRecoverySeedForTesting()); + account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); // Assert EXPECT_TRUE(wallet_was_created_); @@ -218,13 +212,13 @@ TEST_F(BatAdsAccountTest, DoNotGetIssuersWhenWalletIsCreatedIfIssuersAlreadyExist) { // Arrange privacy::SetUnblindedTokens(50); + MockUrlResponses(ads_client_mock_, GetValidIssuersUrlResponses()); BuildAndSetIssuers(); // Act - account_->SetWallet(GetWalletPaymentIdForTesting(), - GetWalletRecoverySeedForTesting()); + account_->SetWallet(kWalletPaymentId, kWalletRecoverySeed); // Assert EXPECT_TRUE(wallet_was_created_); @@ -269,7 +263,6 @@ TEST_F(BatAdsAccountTest, DoNotGetIssuersIfAdsAreDisabled) { // Assert const IssuersInfo expected_issuers; - EXPECT_EQ(expected_issuers, *issuers); } @@ -285,7 +278,6 @@ TEST_F(BatAdsAccountTest, DoNotGetInvalidIssuers) { // Assert const IssuersInfo expected_issuers; - EXPECT_EQ(expected_issuers, *issuers); } @@ -309,7 +301,6 @@ TEST_F(BatAdsAccountTest, DoNotGetMissingIssuers) { // Assert const IssuersInfo expected_issuers; - EXPECT_EQ(expected_issuers, *issuers); } @@ -328,7 +319,6 @@ TEST_F(BatAdsAccountTest, DoNotGetIssuersFromInvalidResponse) { // Assert const IssuersInfo expected_issuers; - EXPECT_EQ(expected_issuers, *issuers); } @@ -382,36 +372,13 @@ TEST_F(BatAdsAccountTest, DepositForCash) { privacy::SetUnblindedTokens(1); - CreativeNotificationAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.body = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeAds(creative_ads); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + SaveCreativeAds({creative_ad}); // Act - account_->Deposit(info.creative_instance_id, AdType::kNotificationAd, - "segment", ConfirmationType::kViewed); + account_->Deposit(creative_ad.creative_instance_id, AdType::kNotificationAd, + kSegment, ConfirmationType::kViewed); // Assert EXPECT_TRUE(did_process_deposit_); @@ -422,8 +389,8 @@ TEST_F(BatAdsAccountTest, DepositForCash) { TransactionInfo expected_transaction; expected_transaction.id = transaction_.id; expected_transaction.created_at = Now(); - expected_transaction.creative_instance_id = info.creative_instance_id; - expected_transaction.segment = "segment"; + expected_transaction.creative_instance_id = creative_ad.creative_instance_id; + expected_transaction.segment = kSegment; expected_transaction.value = 1.0; expected_transaction.ad_type = AdType::kNotificationAd; expected_transaction.confirmation_type = ConfirmationType::kViewed; @@ -448,8 +415,7 @@ TEST_F(BatAdsAccountTest, DepositForNonCash) { privacy::SetUnblindedTokens(1); // Act - account_->Deposit("3519f52c-46a4-4c48-9c2b-c264c0067f04", - AdType::kNotificationAd, "segment", + account_->Deposit(kCreativeInstanceId, AdType::kNotificationAd, kSegment, ConfirmationType::kClicked); // Assert @@ -461,9 +427,8 @@ TEST_F(BatAdsAccountTest, DepositForNonCash) { TransactionInfo expected_transaction; expected_transaction.id = transaction_.id; expected_transaction.created_at = Now(); - expected_transaction.creative_instance_id = - "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - expected_transaction.segment = "segment"; + expected_transaction.creative_instance_id = kCreativeInstanceId; + expected_transaction.segment = kSegment; expected_transaction.value = 0.0; expected_transaction.ad_type = AdType::kNotificationAd; expected_transaction.confirmation_type = ConfirmationType::kClicked; @@ -485,37 +450,13 @@ TEST_F(BatAdsAccountTest, DoNotDepositCashIfCreativeInstanceIdDoesNotExist) { ON_CALL(*token_generator_mock_, Generate(_)) .WillByDefault(Return(privacy::GetTokens(1))); - CreativeNotificationAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.body = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeAds(creative_ads); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + SaveCreativeAds({creative_ad}); // Act - account_->Deposit("eaa6224a-876d-4ef8-a384-9ac34f238631", - AdType::kNotificationAd, "segment", - ConfirmationType::kViewed); + account_->Deposit(kMissingCreativeInstanceId, AdType::kNotificationAd, + kSegment, ConfirmationType::kViewed); // Assert EXPECT_FALSE(did_process_deposit_); diff --git a/components/brave_ads/core/internal/account/account_util_unittest.cc b/components/brave_ads/core/internal/account/account_util_unittest.cc index ce2729cdb813..17d5bff8ec4c 100644 --- a/components/brave_ads/core/internal/account/account_util_unittest.cc +++ b/components/brave_ads/core/internal/account/account_util_unittest.cc @@ -53,6 +53,7 @@ TEST_F(BatAdsAccountUtilTest, ResetRewards) { SaveTransactions(transactions); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); ConfirmationStateManager::GetInstance()->AppendFailedConfirmation( diff --git a/components/brave_ads/core/internal/account/confirmations/confirmation_payload_json_writer_unittest.cc b/components/brave_ads/core/internal/account/confirmations/confirmation_payload_json_writer_unittest.cc index 61e0757df23d..126c13b2bb62 100644 --- a/components/brave_ads/core/internal/account/confirmations/confirmation_payload_json_writer_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/confirmation_payload_json_writer_unittest.cc @@ -25,6 +25,7 @@ class BatAdsConfirmationPayloadJsonWriterTest : public UnitTestBase {}; TEST_F(BatAdsConfirmationPayloadJsonWriterTest, WriteJson) { // Arrange privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); diff --git a/components/brave_ads/core/internal/account/confirmations/confirmation_user_data_builder_unittest.cc b/components/brave_ads/core/internal/account/confirmations/confirmation_user_data_builder_unittest.cc index c1a11f548b79..97eac2828fc2 100644 --- a/components/brave_ads/core/internal/account/confirmations/confirmation_user_data_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/confirmations/confirmation_user_data_builder_unittest.cc @@ -12,11 +12,14 @@ #include "brave/components/brave_ads/core/internal/account/confirmations/confirmation_user_data_builder.h" #include "brave/components/brave_ads/core/internal/account/transactions/transaction_info.h" #include "brave/components/brave_ads/core/internal/account/transactions/transactions_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" +#include "brave/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h" #include "brave/components/brave_ads/core/internal/catalog/catalog_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" #include "brave/components/brave_ads/core/sys_info.h" #include "third_party/re2/src/re2/re2.h" @@ -24,17 +27,6 @@ namespace brave_ads { -namespace { - -constexpr char kCatalogId[] = "29e5c8bc0ba319069980bb390d8e8f9b58c05a20"; - -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -constexpr char kConversionId[] = "smartbrownfoxes42"; -constexpr char kAdvertiserPublicKey[] = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - -} // namespace - class BatAdsConfirmationUserDataBuilderTest : public UnitTestBase {}; TEST_F(BatAdsConfirmationUserDataBuilderTest, @@ -56,8 +48,12 @@ TEST_F(BatAdsConfirmationUserDataBuilderTest, BuildTransaction(/*value*/ 0.0, ConfirmationType::kViewed); transaction.creative_instance_id = kCreativeInstanceId; + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); + // Act - BuildAndSaveConversionQueueItem(kConversionId, kAdvertiserPublicKey); // Assert const ConfirmationUserDataBuilder user_data_builder(transaction); @@ -66,7 +62,7 @@ TEST_F(BatAdsConfirmationUserDataBuilderTest, ASSERT_TRUE(base::JSONWriter::Write(user_data, &json)); const std::string pattern = - R"~({"buildChannel":"release","catalog":\[{"id":"29e5c8bc0ba319069980bb390d8e8f9b58c05a20"}],"countryCode":"US","createdAtTimestamp":"2020-11-18T12:00:00.000Z","mutated":true,"platform":"windows","rotating_hash":"p3QDOuQ3HakWNXLBZCP8dktH\+zyu7FsHpKONKhWliJE=","segment":"untargeted","studies":\[],"versionNumber":"\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}"})~"; + R"~({"buildChannel":"release","catalog":\[{"id":"29e5c8bc0ba319069980bb390d8e8f9b58c05a20"}],"countryCode":"US","createdAtTimestamp":"2020-11-18T12:00:00.000Z","mutated":true,"platform":"windows","rotating_hash":"(.{44})","segment":"untargeted","studies":\[],"versionNumber":"\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}"})~"; EXPECT_TRUE(RE2::FullMatch(json, pattern)); })); } @@ -90,8 +86,12 @@ TEST_F(BatAdsConfirmationUserDataBuilderTest, BuildTransaction(/*value*/ 0.0, ConfirmationType::kConversion); transaction.creative_instance_id = kCreativeInstanceId; + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); + // Act - BuildAndSaveConversionQueueItem(kConversionId, kAdvertiserPublicKey); // Assert const ConfirmationUserDataBuilder user_data_builder(transaction); @@ -100,7 +100,7 @@ TEST_F(BatAdsConfirmationUserDataBuilderTest, ASSERT_TRUE(base::JSONWriter::Write(user_data, &json)); const std::string pattern = - R"~({"buildChannel":"release","catalog":\[{"id":"29e5c8bc0ba319069980bb390d8e8f9b58c05a20"}],"conversionEnvelope":{"alg":"crypto_box_curve25519xsalsa20poly1305","ciphertext":"(.{64})","epk":"(.{44})","nonce":"(.{32})"},"countryCode":"US","createdAtTimestamp":"2020-11-18T12:00:00.000Z","mutated":true,"platform":"windows","rotating_hash":"p3QDOuQ3HakWNXLBZCP8dktH\+zyu7FsHpKONKhWliJE=","segment":"untargeted","studies":\[],"versionNumber":"\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}"})~"; + R"~({"buildChannel":"release","catalog":\[{"id":"29e5c8bc0ba319069980bb390d8e8f9b58c05a20"}],"conversionEnvelope":{"alg":"crypto_box_curve25519xsalsa20poly1305","ciphertext":"(.{64})","epk":"(.{44})","nonce":"(.{32})"},"countryCode":"US","createdAtTimestamp":"2020-11-18T12:00:00.000Z","mutated":true,"platform":"windows","rotating_hash":"(.{44})","segment":"untargeted","studies":\[],"versionNumber":"\d{1,}\.\d{1,}\.\d{1,}\.\d{1,}"})~"; EXPECT_TRUE(RE2::FullMatch(json, pattern)); })); } diff --git a/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc b/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc index 2bbf8ea9d83b..89ad385724dc 100644 --- a/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc +++ b/components/brave_ads/core/internal/account/deposits/cash_deposit_test.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/account/deposits/cash_deposit.h" #include "base/functional/bind.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" #include "net/http/http_status_code.h" @@ -14,14 +15,6 @@ namespace brave_ads { -namespace { - -constexpr char kCreativeInstanceId[] = "18d8df02-68b1-4a6d-81a1-67357b157e2a"; -constexpr char kMissingCreativeInstanceId[] = - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - -} // namespace - class BatAdsCashDepositIntegrationTest : public UnitTestBase { protected: void SetUp() override { diff --git a/components/brave_ads/core/internal/account/deposits/deposits_database_table_unittest.cc b/components/brave_ads/core/internal/account/deposits/deposits_database_table_unittest.cc index 924c79d60a99..543456273f80 100644 --- a/components/brave_ads/core/internal/account/deposits/deposits_database_table_unittest.cc +++ b/components/brave_ads/core/internal/account/deposits/deposits_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsDepositsDatabaseTableTest, TableName) { const Deposits database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "deposits"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("deposits", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc b/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc index 74ca62224ff7..770cfa004a64 100644 --- a/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc +++ b/components/brave_ads/core/internal/account/deposits/non_cash_deposit_unittest.cc @@ -6,16 +6,13 @@ #include "brave/components/brave_ads/core/internal/account/deposits/non_cash_deposit.h" #include "base/functional/bind.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" // npm run test -- brave_unit_tests --filter=BatAds* namespace brave_ads { -namespace { -constexpr char kCreativeInstanceId[] = "b77e16fd-e4bf-4bfb-b033-b8772ec6113b"; -} // namespace - class BatAdsNonCashDepositTest : public UnitTestBase {}; TEST_F(BatAdsNonCashDepositTest, GetValue) { diff --git a/components/brave_ads/core/internal/account/statement/ads_received_util_unittest.cc b/components/brave_ads/core/internal/account/statement/ads_received_util_unittest.cc index 03642f2278a0..94902fa7f099 100644 --- a/components/brave_ads/core/internal/account/statement/ads_received_util_unittest.cc +++ b/components/brave_ads/core/internal/account/statement/ads_received_util_unittest.cc @@ -46,12 +46,9 @@ TEST_F(BatAdsAdsReceivedUtilTest, GetAdsReceivedForDateRange) { const base::Time to_time = DistantFuture(); // Act - const int ads_received = - GetAdsReceivedForDateRange(transactions, from_time, to_time); // Assert - constexpr int kExpectedAdsReceived = 2; - EXPECT_EQ(kExpectedAdsReceived, ads_received); + EXPECT_EQ(2, GetAdsReceivedForDateRange(transactions, from_time, to_time)); } TEST_F(BatAdsAdsReceivedUtilTest, DoNotGetAdsReceivedForDateRange) { @@ -74,12 +71,9 @@ TEST_F(BatAdsAdsReceivedUtilTest, DoNotGetAdsReceivedForDateRange) { const base::Time to_time = DistantFuture(); // Act - const int ads_received = - GetAdsReceivedForDateRange(transactions, from_time, to_time); // Assert - constexpr int kExpectedAdsReceived = 0; - EXPECT_EQ(kExpectedAdsReceived, ads_received); + EXPECT_EQ(0, GetAdsReceivedForDateRange(transactions, from_time, to_time)); } TEST_F(BatAdsAdsReceivedUtilTest, GetAdsReceivedForNoTransactions) { @@ -90,12 +84,9 @@ TEST_F(BatAdsAdsReceivedUtilTest, GetAdsReceivedForNoTransactions) { const base::Time to_time = DistantFuture(); // Act - const int ads_received = - GetAdsReceivedForDateRange(transactions, from_time, to_time); // Assert - constexpr int kExpectedAdsReceived = 0; - EXPECT_EQ(kExpectedAdsReceived, ads_received); + EXPECT_EQ(0, GetAdsReceivedForDateRange(transactions, from_time, to_time)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc b/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc index a0f86a1a48c9..bf5fd21e175d 100644 --- a/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc +++ b/components/brave_ads/core/internal/account/statement/statement_util_unittest.cc @@ -139,11 +139,9 @@ TEST_F(BatAdsStatementUtilTest, GetAdsReceivedThisMonth) { transactions.push_back(transaction_4); // Act - const int ads_received = GetAdsReceivedThisMonth(transactions); // Assert - constexpr int kExpectedAdsReceived = 2; - EXPECT_EQ(kExpectedAdsReceived, ads_received); + EXPECT_EQ(2, GetAdsReceivedThisMonth(transactions)); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/transactions/transactions_database_table_unittest.cc b/components/brave_ads/core/internal/account/transactions/transactions_database_table_unittest.cc index eab507399253..355f0c32ff95 100644 --- a/components/brave_ads/core/internal/account/transactions/transactions_database_table_unittest.cc +++ b/components/brave_ads/core/internal/account/transactions/transactions_database_table_unittest.cc @@ -21,44 +21,37 @@ class BatAdsTransactionsDatabaseTableTest : public UnitTestBase {}; TEST_F(BatAdsTransactionsDatabaseTableTest, SaveEmptyTransactions) { // Arrange - const TransactionList transactions; // Act - SaveTransactions(transactions); + SaveTransactions({}); // Assert - TransactionList expected_transactions = transactions; - const Transactions database_table; database_table.GetAll(base::BindOnce( - [](const TransactionList& expected_transactions, const bool success, - const TransactionList& transactions) { + [](const bool success, const TransactionList& transactions) { ASSERT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_transactions, transactions)); - }, - std::move(expected_transactions))); + EXPECT_TRUE(transactions.empty()); + })); } TEST_F(BatAdsTransactionsDatabaseTableTest, SaveTransactions) { // Arrange TransactionList transactions; - const TransactionInfo info_1 = BuildTransaction( + const TransactionInfo transaction_1 = BuildTransaction( /*value*/ 0.01, ConfirmationType::kViewed, DistantFuture()); - transactions.push_back(info_1); + transactions.push_back(transaction_1); AdvanceClockBy(base::Days(5)); - const TransactionInfo info_2 = + const TransactionInfo transaction_2 = BuildTransaction(/*value*/ 0.03, ConfirmationType::kClicked); - transactions.push_back(info_2); + transactions.push_back(transaction_2); // Act SaveTransactions(transactions); // Assert - TransactionList expected_transactions = transactions; - const Transactions database_table; database_table.GetAll(base::BindOnce( [](const TransactionList& expected_transactions, const bool success, @@ -66,16 +59,16 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, SaveTransactions) { ASSERT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_transactions, transactions)); }, - std::move(expected_transactions))); + std::move(transactions))); } TEST_F(BatAdsTransactionsDatabaseTableTest, DoNotSaveDuplicateTransactions) { // Arrange TransactionList transactions; - const TransactionInfo info = + const TransactionInfo transaction = BuildTransaction(/*value*/ 0.01, ConfirmationType::kViewed, Now()); - transactions.push_back(info); + transactions.push_back(transaction); SaveTransactions(transactions); @@ -83,8 +76,6 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, DoNotSaveDuplicateTransactions) { SaveTransactions(transactions); // Assert - TransactionList expected_transactions = transactions; - const Transactions database_table; database_table.GetAll(base::BindOnce( [](const TransactionList& expected_transactions, const bool success, @@ -92,27 +83,27 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, DoNotSaveDuplicateTransactions) { ASSERT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_transactions, transactions)); }, - std::move(expected_transactions))); + std::move(transactions))); } TEST_F(BatAdsTransactionsDatabaseTableTest, GetTransactionsForDateRange) { // Arrange TransactionList transactions; - const TransactionInfo info_1 = BuildTransaction( + const TransactionInfo transaction_1 = BuildTransaction( /*value*/ 0.01, ConfirmationType::kViewed, DistantFuture()); - transactions.push_back(info_1); + transactions.push_back(transaction_1); AdvanceClockBy(base::Days(5)); - const TransactionInfo info_2 = + const TransactionInfo transaction_2 = BuildTransaction(/*value*/ 0.03, ConfirmationType::kClicked); - transactions.push_back(info_2); + transactions.push_back(transaction_2); SaveTransactions(transactions); // Act - TransactionList expected_transactions = {info_2}; + TransactionList expected_transactions = {transaction_2}; const Transactions database_table; database_table.GetForDateRange( @@ -121,7 +112,7 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, GetTransactionsForDateRange) { [](const TransactionList& expected_transactions, const bool success, const TransactionList& transactions) { ASSERT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_transactions, transactions)); + EXPECT_EQ(expected_transactions, transactions); }, std::move(expected_transactions))); @@ -132,19 +123,19 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, UpdateTransactions) { // Arrange TransactionList transactions; - const TransactionInfo info_1 = BuildTransaction( + const TransactionInfo transaction_1 = BuildTransaction( /*value*/ 0.01, ConfirmationType::kViewed, DistantFuture()); - transactions.push_back(info_1); + transactions.push_back(transaction_1); - TransactionInfo info_2 = + TransactionInfo transaction_2 = BuildTransaction(/*value*/ 0.03, ConfirmationType::kClicked); - transactions.push_back(info_2); + transactions.push_back(transaction_2); SaveTransactions(transactions); privacy::UnblindedPaymentTokenList unblinded_payment_tokens; privacy::UnblindedPaymentTokenInfo unblinded_payment_token; - unblinded_payment_token.transaction_id = info_2.id; + unblinded_payment_token.transaction_id = transaction_2.id; unblinded_payment_tokens.push_back(unblinded_payment_token); // Act @@ -153,9 +144,10 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, UpdateTransactions) { unblinded_payment_tokens, base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); + transaction_2.reconciled_at = Now(); + // Assert - info_2.reconciled_at = Now(); - TransactionList expected_transactions = {info_1, info_2}; + TransactionList expected_transactions = {transaction_1, transaction_2}; database_table.GetAll(base::BindOnce( [](const TransactionList& expected_transactions, const bool success, @@ -170,13 +162,13 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, DeleteTransactions) { // Arrange TransactionList transactions; - const TransactionInfo info_1 = BuildTransaction( + const TransactionInfo transaction_1 = BuildTransaction( /*value*/ 0.01, ConfirmationType::kViewed, DistantFuture()); - transactions.push_back(info_1); + transactions.push_back(transaction_1); - const TransactionInfo info_2 = + const TransactionInfo transaction_2 = BuildTransaction(/*value*/ 0.03, ConfirmationType::kClicked); - transactions.push_back(info_2); + transactions.push_back(transaction_2); SaveTransactions(transactions); @@ -199,11 +191,9 @@ TEST_F(BatAdsTransactionsDatabaseTableTest, TableName) { const Transactions database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "transactions"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("transactions", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/account/transactions/transactions_util_unittest.cc b/components/brave_ads/core/internal/account/transactions/transactions_util_unittest.cc index af3a60fe2f42..54ec362cffe0 100644 --- a/components/brave_ads/core/internal/account/transactions/transactions_util_unittest.cc +++ b/components/brave_ads/core/internal/account/transactions/transactions_util_unittest.cc @@ -39,9 +39,7 @@ TEST_F(BatAdsTransactionsUtilTest, GetTransactionsForDateRange) { GetTransactionsForDateRange(transactions, from_time, to_time); // Assert - TransactionList expected_transactions_for_date_range; - expected_transactions_for_date_range.push_back(transaction_2); - + const TransactionList expected_transactions_for_date_range = {transaction_2}; EXPECT_EQ(expected_transactions_for_date_range, transactions_for_date_range); } @@ -69,9 +67,7 @@ TEST_F(BatAdsTransactionsUtilTest, DoNotGetTransactionsForDateRange) { GetTransactionsForDateRange(transactions, from_time, to_time); // Assert - const TransactionList expected_transactions_for_date_range; - - EXPECT_EQ(expected_transactions_for_date_range, transactions_for_date_range); + EXPECT_TRUE(transactions_for_date_range.empty()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/user_data/catalog_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/catalog_user_data_unittest.cc index de3fa1e60484..e4bbe912e16b 100644 --- a/components/brave_ads/core/internal/account/user_data/catalog_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/catalog_user_data_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/account/user_data/catalog_user_data.h" #include "base/test/values_test_util.h" +#include "brave/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h" #include "brave/components/brave_ads/core/internal/catalog/catalog_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" @@ -13,10 +14,6 @@ namespace brave_ads::user_data { -namespace { -constexpr char kCatalogId[] = "04a13086-8fd8-4dce-a44f-afe86f14a662"; -} // namespace - class BatAdsCatalogUserDataTest : public UnitTestBase {}; TEST_F(BatAdsCatalogUserDataTest, GetCatalog) { @@ -28,7 +25,7 @@ TEST_F(BatAdsCatalogUserDataTest, GetCatalog) { // Assert const base::Value expected_user_data = base::test::ParseJson( - R"({"catalog":[{"id":"04a13086-8fd8-4dce-a44f-afe86f14a662"}]})"); + R"({"catalog":[{"id":"29e5c8bc0ba319069980bb390d8e8f9b58c05a20"}]})"); ASSERT_TRUE(expected_user_data.is_dict()); EXPECT_EQ(expected_user_data, user_data); diff --git a/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder.cc b/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder.cc index a1cc67a98282..02f5e5a3b39b 100644 --- a/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder.cc +++ b/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder.cc @@ -13,26 +13,13 @@ #include "brave/components/brave_ads/core/internal/account/user_data/conversion_user_data_util.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_database_table.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_info.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_util.h" +#include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace brave_ads::user_data::builder { -namespace { - -constexpr char kAlgorithmKey[] = "alg"; -constexpr char kAlgorithm[] = "crypto_box_curve25519xsalsa20poly1305"; -constexpr char kCipherTextKey[] = "ciphertext"; -constexpr char kEphemeralPublicKeyKey[] = "epk"; -constexpr char kNonceKey[] = "nonce"; -constexpr char kConversionEnvelopeKey[] = "conversionEnvelope"; - -void ReportConversionDoesNotExist(BuildConversionCallback callback) { - std::move(callback).Run(base::Value::Dict()); -} - -} // namespace - void BuildConversion(const std::string& creative_instance_id, BuildConversionCallback callback) { DCHECK(!creative_instance_id.empty()); @@ -45,11 +32,11 @@ void BuildConversion(const std::string& creative_instance_id, const std::string& /*creative_instance_id*/, const ConversionQueueItemList& conversion_queue_items) { if (!success) { - return ReportConversionDoesNotExist(std::move(callback)); + return std::move(callback).Run({}); } if (conversion_queue_items.empty()) { - return ReportConversionDoesNotExist(std::move(callback)); + return std::move(callback).Run({}); } const ConversionQueueItemInfo& conversion_queue_item = @@ -58,22 +45,21 @@ void BuildConversion(const std::string& creative_instance_id, verifiable_conversion_envelope = GetEnvelope(conversion_queue_item); if (!verifiable_conversion_envelope) { - return ReportConversionDoesNotExist(std::move(callback)); + return std::move(callback).Run({}); } - base::Value::Dict conversion_envelope; - conversion_envelope.Set(kAlgorithmKey, kAlgorithm); - conversion_envelope.Set(kCipherTextKey, - verifiable_conversion_envelope->ciphertext); - conversion_envelope.Set( - kEphemeralPublicKeyKey, - verifiable_conversion_envelope->ephemeral_public_key); - conversion_envelope.Set(kNonceKey, - verifiable_conversion_envelope->nonce); + base::Value::Dict dict; + dict.Set(kVerifiableConversionEnvelopeAlgorithmKey, + security::GetAlgorithm()); + dict.Set(kVerifiableConversionEnvelopeCipherTextKey, + verifiable_conversion_envelope->ciphertext); + dict.Set(kVerifiableConversionEnvelopeEphemeralPublicKeyKey, + verifiable_conversion_envelope->ephemeral_public_key); + dict.Set(kVerifiableConversionEnvelopeNonceKey, + verifiable_conversion_envelope->nonce); base::Value::Dict user_data; - user_data.Set(kConversionEnvelopeKey, - std::move(conversion_envelope)); + user_data.Set(kVerifiableConversionEnvelopeKey, std::move(dict)); std::move(callback).Run(std::move(user_data)); }, diff --git a/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder_unittest.cc b/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder_unittest.cc index c8a6652bf722..714bb6a667f0 100644 --- a/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/conversion_user_data_builder_unittest.cc @@ -7,8 +7,10 @@ #include "base/functional/bind.h" #include "base/test/values_test_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -16,51 +18,41 @@ namespace brave_ads::user_data::builder { -namespace { - -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -constexpr char kMissingCreativeInstanceId[] = - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - -constexpr char kConversionId[] = "smartbrownfoxes42"; -constexpr char kEmptyConversionId[] = ""; - -constexpr char kAdvertiserPublicKey[] = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; -constexpr char kEmptyAdvertiserPublicKey[] = ""; - -constexpr char kAdvertiserSecretKey[] = - "Ete7+aKfrX25gt0eN4kBV1LqeF9YmB1go8OqnGXUGG4="; - -} // namespace - class BatAdsConversionUserDataBuilderTest : public UnitTestBase {}; TEST_F(BatAdsConversionUserDataBuilderTest, BuildConversion) { // Arrange - BuildAndSaveConversionQueueItem(kConversionId, kAdvertiserPublicKey); + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); // Act + + // Assert BuildConversion(kCreativeInstanceId, base::BindOnce([](base::Value::Dict user_data) { const absl::optional message = security::OpenEnvelopeForUserDataAndAdvertiserSecretKey( - user_data, kAdvertiserSecretKey); + user_data, kConversionAdvertiserSecretKey); ASSERT_TRUE(message); const std::string expected_message = kConversionId; EXPECT_EQ(expected_message, *message); })); - - // Assert } TEST_F(BatAdsConversionUserDataBuilderTest, DoNotBuildConversionForMissingCreativeInstanceId) { // Arrange - BuildAndSaveConversionQueueItem(kConversionId, kAdvertiserPublicKey); + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); // Act + + // Assert BuildConversion(kMissingCreativeInstanceId, base::BindOnce([](base::Value::Dict user_data) { // Assert @@ -70,17 +62,19 @@ TEST_F(BatAdsConversionUserDataBuilderTest, EXPECT_EQ(expected_user_data, user_data); })); - - // Assert } TEST_F(BatAdsConversionUserDataBuilderTest, - DoNotBuildConversionIfConversionIdOrAdvertiserPublicKeyIsEmpty) { + DoNotBuildConversionIfConversionIdOrAdvertiserPublicKeyAreEmpty) { // Arrange - BuildAndSaveConversionQueueItem(kEmptyConversionId, - kEmptyAdvertiserPublicKey); + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kEmptyConversionId, + kEmptyConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); // Act + + // Assert BuildConversion( kCreativeInstanceId, base::BindOnce([](base::Value::Dict user_data) { // Assert @@ -89,8 +83,6 @@ TEST_F(BatAdsConversionUserDataBuilderTest, EXPECT_EQ(expected_user_data, user_data); })); - - // Assert } } // namespace brave_ads::user_data::builder diff --git a/components/brave_ads/core/internal/account/user_data/conversion_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/conversion_user_data_unittest.cc index a49bd9d7f5b0..a43f84f0ca15 100644 --- a/components/brave_ads/core/internal/account/user_data/conversion_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/conversion_user_data_unittest.cc @@ -7,8 +7,10 @@ #include "base/functional/bind.h" #include "brave/components/brave_ads/core/confirmation_type.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -17,22 +19,18 @@ namespace brave_ads::user_data { -namespace { - -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -constexpr char kConversionId[] = "smartbrownfoxes42"; -constexpr char kAdvertiserPublicKey[] = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - -} // namespace - class BatAdsConversionUserDataTest : public UnitTestBase {}; TEST_F(BatAdsConversionUserDataTest, GetForConversionConfirmationType) { // Arrange - BuildAndSaveConversionQueueItem(kConversionId, kAdvertiserPublicKey); + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); // Act + + // Assert GetConversion( kCreativeInstanceId, ConfirmationType::kConversion, base::BindOnce([](base::Value::Dict user_data) { @@ -41,15 +39,18 @@ TEST_F(BatAdsConversionUserDataTest, GetForConversionConfirmationType) { security::GetVerifiableConversionEnvelopeForUserData(user_data); ASSERT_TRUE(verifiable_conversion_envelope); })); - - // Assert } TEST_F(BatAdsConversionUserDataTest, DoNotGetForNonConversionConfirmationType) { // Arrange - BuildAndSaveConversionQueueItem(kConversionId, kAdvertiserPublicKey); + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 1); // Act + + // Assert GetConversion( kCreativeInstanceId, ConfirmationType::kViewed, base::BindOnce([](base::Value::Dict user_data) { @@ -58,8 +59,6 @@ TEST_F(BatAdsConversionUserDataTest, DoNotGetForNonConversionConfirmationType) { security::GetVerifiableConversionEnvelopeForUserData(user_data); ASSERT_FALSE(verifiable_conversion_envelope); })); - - // Assert } } // namespace brave_ads::user_data diff --git a/components/brave_ads/core/internal/account/user_data/conversion_user_data_util_unittest.cc b/components/brave_ads/core/internal/account/user_data/conversion_user_data_util_unittest.cc index 278a0cf345d3..2dde2b3fcb9b 100644 --- a/components/brave_ads/core/internal/account/user_data/conversion_user_data_util_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/conversion_user_data_util_unittest.cc @@ -7,6 +7,7 @@ #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_info.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h" #include "testing/gtest/include/gtest/gtest.h" @@ -14,20 +15,12 @@ namespace brave_ads::user_data { -namespace { - -constexpr char kConversionId[] = "smartbrownfoxes42"; -constexpr char kEmptyConversionId[] = ""; -constexpr char kAdvertiserPublicKey[] = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; -constexpr char kEmptyAdvertiserPublicKey[] = ""; - -} // namespace - TEST(BatAdsConversionUserDataUtilTest, GetEnvelope) { // Arrange const ConversionQueueItemInfo conversion_queue_item = - BuildConversionQueueItem(kConversionId, kAdvertiserPublicKey); + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false); // Act const absl::optional @@ -40,7 +33,9 @@ TEST(BatAdsConversionUserDataUtilTest, GetEnvelope) { TEST(BatAdsConversionUserDataUtilTest, DoNotGetEnvelopeIfConversionIdIsEmpty) { // Arrange const ConversionQueueItemInfo conversion_queue_item = - BuildConversionQueueItem(kEmptyConversionId, kAdvertiserPublicKey); + BuildConversionQueueItem(AdType::kNotificationAd, kEmptyConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false); // Act const absl::optional @@ -54,7 +49,9 @@ TEST(BatAdsConversionUserDataUtilTest, DoNotGetEnvelopeIfAdvertiserPublicKeyIsEmpty) { // Arrange const ConversionQueueItemInfo conversion_queue_item = - BuildConversionQueueItem(kConversionId, kEmptyAdvertiserPublicKey); + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kEmptyConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false); // Act const absl::optional @@ -65,10 +62,12 @@ TEST(BatAdsConversionUserDataUtilTest, } TEST(BatAdsConversionUserDataUtilTest, - DoNotGetEnvelopeIfConversionIdAndAdvertiserPublicKeyIsEmpty) { + DoNotGetEnvelopeIfConversionIdAndAdvertiserPublicKeyAreEmpty) { // Arrange const ConversionQueueItemInfo conversion_queue_item = - BuildConversionQueueItem(kEmptyConversionId, kEmptyAdvertiserPublicKey); + BuildConversionQueueItem(AdType::kNotificationAd, kEmptyConversionId, + kEmptyConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false); // Act const absl::optional diff --git a/components/brave_ads/core/internal/account/user_data/rotating_hash_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/rotating_hash_user_data_unittest.cc index bb1cb9f5d973..e5deea6c2d28 100644 --- a/components/brave_ads/core/internal/account/user_data/rotating_hash_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/rotating_hash_user_data_unittest.cc @@ -7,6 +7,7 @@ #include "base/test/values_test_util.h" #include "brave/components/brave_ads/core/internal/account/transactions/transaction_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" #include "brave/components/brave_ads/core/sys_info.h" @@ -15,10 +16,6 @@ namespace brave_ads::user_data { -namespace { -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -} // namespace - class BatAdsRotatingHashUserDataTest : public UnitTestBase {}; TEST_F(BatAdsRotatingHashUserDataTest, GetRotatingHash) { @@ -36,7 +33,7 @@ TEST_F(BatAdsRotatingHashUserDataTest, GetRotatingHash) { // Assert const base::Value expected_user_data = base::test::ParseJson( - R"({"rotating_hash":"06a6D0QCW5onYUDKqCBBXUoil02apd6pcJ47M3Li7hA="})"); + R"({"rotating_hash":"ooLbypB5vcA/kLjWz+w395SGG+s5M8O9IWbj/OlHuR8="})"); ASSERT_TRUE(expected_user_data.is_dict()); EXPECT_EQ(expected_user_data, user_data); diff --git a/components/brave_ads/core/internal/account/user_data/segment_user_data_unittest.cc b/components/brave_ads/core/internal/account/user_data/segment_user_data_unittest.cc index a2dd8cb7b0e7..eadd0206d4a5 100644 --- a/components/brave_ads/core/internal/account/user_data/segment_user_data_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/segment_user_data_unittest.cc @@ -17,10 +17,9 @@ class BatAdsSegmentUserDataTest : public UnitTestBase {}; TEST_F(BatAdsSegmentUserDataTest, GetEmptySegment) { // Arrange - const TransactionInfo transaction; // Act - const base::Value::Dict user_data = GetSegment(transaction); + const base::Value::Dict user_data = GetSegment({}); // Assert const base::Value expected_user_data = base::test::ParseJson("{}"); diff --git a/components/brave_ads/core/internal/account/user_data/totals_user_data_util_unittest.cc b/components/brave_ads/core/internal/account/user_data/totals_user_data_util_unittest.cc index 3b37c1f79ef7..c89ff5103f67 100644 --- a/components/brave_ads/core/internal/account/user_data/totals_user_data_util_unittest.cc +++ b/components/brave_ads/core/internal/account/user_data/totals_user_data_util_unittest.cc @@ -14,15 +14,12 @@ namespace brave_ads::user_data { TEST(BatAdsTotalsUserDataUtilTest, GetBucketsForNoUnblindedPaymentTokens) { // Arrange - const privacy::UnblindedPaymentTokenList unblinded_payment_tokens; // Act - const AdTypeBucketMap buckets = BuildBuckets(unblinded_payment_tokens); + const AdTypeBucketMap buckets = BuildBuckets({}); // Assert - const AdTypeBucketMap expected_buckets; - - EXPECT_EQ(expected_buckets, buckets); + EXPECT_TRUE(buckets.empty()); } TEST(BatAdsTotalsUserDataUtilTest, GetBuckets) { @@ -35,7 +32,6 @@ TEST(BatAdsTotalsUserDataUtilTest, GetBuckets) { // Assert const AdTypeBucketMap expected_buckets = {{"ad_notification", {{"view", 2}}}}; - EXPECT_EQ(expected_buckets, buckets); } diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation_unittest.cc index bfa3fb342e6c..73dbc0cc08ba 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation_unittest.cc @@ -86,6 +86,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, Redeem) { BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -113,6 +114,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, Redeem) { TEST_F(BatAdsRedeemOptedInConfirmationTest, RetryRedeemingIfNoIssuers) { // Arrange privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -163,6 +165,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -212,6 +215,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -259,6 +263,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -309,6 +314,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -359,6 +365,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -417,6 +424,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -486,6 +494,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -559,6 +568,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -625,6 +635,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -697,6 +708,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -770,6 +782,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -842,6 +855,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -914,6 +928,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -987,6 +1002,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -1057,6 +1073,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -1127,6 +1144,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); @@ -1200,6 +1218,7 @@ TEST_F(BatAdsRedeemOptedInConfirmationTest, BuildAndSetIssuers(); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/url_request_builders/fetch_payment_token_url_request_builder_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_confirmation/url_request_builders/fetch_payment_token_url_request_builder_unittest.cc index 67df1842e9c5..7abb7277ac1c 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/url_request_builders/fetch_payment_token_url_request_builder_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/url_request_builders/fetch_payment_token_url_request_builder_unittest.cc @@ -23,6 +23,7 @@ TEST_F(BatAdsFetchPaymentTokenUrlRequestBuilderTest, BuildUrl) { EnvironmentType::kStaging); privacy::SetUnblindedTokens(1); + const absl::optional confirmation = BuildConfirmation(); ASSERT_TRUE(confirmation); diff --git a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_unittest.cc b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_unittest.cc index 74555f30e4a3..994b2d9b472f 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_unittest.cc @@ -168,7 +168,7 @@ TEST_F(BatAdsRedeemUnblindedPaymentTokensTest, redeem_unblinded_payment_tokens_->MaybeRedeemAfterDelay(wallet); // Assert - EXPECT_EQ(1UL, GetPendingTaskCount()); + EXPECT_EQ(1U, GetPendingTaskCount()); } TEST_F(BatAdsRedeemUnblindedPaymentTokensTest, ScheduleNextTokenRedemption) { @@ -275,8 +275,7 @@ TEST_F(BatAdsRedeemUnblindedPaymentTokensTest, InvalidWallet) { OnDidScheduleNextUnblindedPaymentTokensRedemption(_)) .Times(0); - const WalletInfo invalid_wallet; - redeem_unblinded_payment_tokens_->MaybeRedeemAfterDelay(invalid_wallet); + redeem_unblinded_payment_tokens_->MaybeRedeemAfterDelay(/*wallet*/ {}); // Assert EXPECT_EQ(1, privacy::GetUnblindedPaymentTokens()->Count()); diff --git a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_unittest.cc b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_unittest.cc index 34e3a39fcfc7..7b929d70f7f1 100644 --- a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_unittest.cc +++ b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_unittest.cc @@ -315,8 +315,7 @@ TEST_F(BatAdsRefillUnblindedTokensTest, InvalidWallet) { OnDidRetryRefillingUnblindedTokens()) .Times(0); - const WalletInfo invalid_wallet; - refill_unblinded_tokens_->MaybeRefill(invalid_wallet); + refill_unblinded_tokens_->MaybeRefill(/*wallet*/ {}); // Assert EXPECT_EQ(0, privacy::UnblindedTokenCount()); diff --git a/components/brave_ads/core/internal/account/wallet/wallet_unittest.cc b/components/brave_ads/core/internal/account/wallet/wallet_unittest.cc index 77626a77e965..de739a2ead69 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_unittest.cc +++ b/components/brave_ads/core/internal/account/wallet/wallet_unittest.cc @@ -6,7 +6,7 @@ #include "brave/components/brave_ads/core/internal/account/wallet/wallet.h" #include "base/base64.h" -#include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h" +#include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/abseil-cpp/absl/types/optional.h" @@ -19,21 +19,18 @@ TEST(BatAdsWalletTest, SetWallet) { Wallet wallet; const absl::optional> raw_recovery_seed = - base::Base64Decode(GetWalletRecoverySeedForTesting()); + base::Base64Decode(kWalletRecoverySeed); ASSERT_TRUE(raw_recovery_seed); // Act - const bool success = - wallet.Set(GetWalletPaymentIdForTesting(), *raw_recovery_seed); + const bool success = wallet.Set(kWalletPaymentId, *raw_recovery_seed); ASSERT_TRUE(success); // Assert WalletInfo expected_wallet; - expected_wallet.payment_id = "27a39b2f-9b2e-4eb0-bbb2-2f84447496e7"; - expected_wallet.public_key = "BiG/i3tfNLSeOA9ZF5rkPCGyhkc7KCRbQS3bVGMvFQ0="; - expected_wallet.secret_key = - "kwUjEEdzI6rkI6hLoyxosa47ZrcZUvbYppAm4zvYF5gGIb+" - "Le180tJ44D1kXmuQ8IbKGRzsoJFtBLdtUYy8VDQ=="; + expected_wallet.payment_id = kWalletPaymentId; + expected_wallet.public_key = kWalletPublicKey; + expected_wallet.secret_key = kWalletSecretKey; EXPECT_EQ(expected_wallet, wallet.Get()); } diff --git a/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h b/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h new file mode 100644 index 000000000000..24a9e61967b3 --- /dev/null +++ b/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h @@ -0,0 +1,27 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_UNITTEST_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_UNITTEST_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kWalletPaymentId[] = "27a39b2f-9b2e-4eb0-bbb2-2f84447496e7"; + +constexpr char kWalletRecoverySeed[] = + "x5uBvgI5MTTVY6sjGv65e9EHr8v7i+UxkFB9qVc5fP0="; +constexpr char kInvalidWalletRecoverySeed[] = + "y6vCwhJ6NUUWZ7tkHw76f0FIs9w8j-VylGC0rWd6gQ1="; + +constexpr char kWalletPublicKey[] = + "BiG/i3tfNLSeOA9ZF5rkPCGyhkc7KCRbQS3bVGMvFQ0="; + +constexpr char kWalletSecretKey[] = + "kwUjEEdzI6rkI6hLoyxosa47ZrcZUvbYppAm4zvYF5gGIb+" + "Le180tJ44D1kXmuQ8IbKGRzsoJFtBLdtUYy8VDQ=="; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_UNITTEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.cc b/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.cc index 24913b358284..ee3b10252620 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.cc +++ b/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.cc @@ -11,39 +11,18 @@ #include "base/check.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet_info.h" +#include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace brave_ads { -namespace { - -constexpr char kPaymentId[] = "27a39b2f-9b2e-4eb0-bbb2-2f84447496e7"; -constexpr char kValidRecoverySeed[] = - "x5uBvgI5MTTVY6sjGv65e9EHr8v7i+UxkFB9qVc5fP0="; -constexpr char kInvalidRecoverySeed[] = - "y6vCwhJ6NUUWZ7tkHw76f0FIs9w8j-VylGC0rWd6gQ1="; - -} // namespace - -std::string GetWalletPaymentIdForTesting() { - return kPaymentId; -} - -std::string GetWalletRecoverySeedForTesting() { - return kValidRecoverySeed; -} - -std::string GetInvalidWalletRecoverySeedForTesting() { - return kInvalidRecoverySeed; -} - WalletInfo GetWalletForTesting() { const absl::optional> raw_recovery_seed = - base::Base64Decode(kValidRecoverySeed); + base::Base64Decode(kWalletRecoverySeed); CHECK(raw_recovery_seed); Wallet wallet; - wallet.Set(kPaymentId, *raw_recovery_seed); + wallet.Set(kWalletPaymentId, *raw_recovery_seed); return wallet.Get(); } diff --git a/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h b/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h index 9e8a273b70c7..362bb737618f 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h +++ b/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h @@ -6,16 +6,10 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_UNITTEST_UTIL_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_WALLET_WALLET_UNITTEST_UTIL_H_ -#include - namespace brave_ads { struct WalletInfo; -std::string GetWalletPaymentIdForTesting(); -std::string GetWalletRecoverySeedForTesting(); -std::string GetInvalidWalletRecoverySeedForTesting(); - WalletInfo GetWalletForTesting(); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/ad_content_value_util_unittest.cc b/components/brave_ads/core/internal/ad_content_value_util_unittest.cc index d8468b987b1b..afc3eb28c980 100644 --- a/components/brave_ads/core/internal/ad_content_value_util_unittest.cc +++ b/components/brave_ads/core/internal/ad_content_value_util_unittest.cc @@ -7,6 +7,7 @@ #include "base/test/values_test_util.h" #include "brave/components/brave_ads/core/confirmation_type.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" @@ -20,12 +21,11 @@ namespace brave_ads { namespace { -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; constexpr char kTitle[] = "title"; constexpr char kDescription[] = "description"; constexpr char kJson[] = - R"({"adAction":"view","adType":"ad_notification","advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","brand":"title","brandDisplayUrl":"brave.com","brandInfo":"description","brandUrl":"https://brave.com/","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","flaggedAd":false,"likeAction":0,"placementId":"f0948316-df6f-4e31-814d-d0b5f2a1f28c","savedAd":false,"segment":"untargeted"})"; + R"({"adAction":"view","adType":"ad_notification","advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","brand":"title","brandDisplayUrl":"brave.com","brandInfo":"description","brandUrl":"https://brave.com/","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","flaggedAd":false,"likeAction":0,"placementId":"8b742869-6e4a-490c-ac31-31b49130098a","savedAd":false,"segment":"untargeted"})"; } // namespace diff --git a/components/brave_ads/core/internal/ad_event_history_unittest.cc b/components/brave_ads/core/internal/ad_event_history_unittest.cc index c16123f7f336..5b235195c747 100644 --- a/components/brave_ads/core/internal/ad_event_history_unittest.cc +++ b/components/brave_ads/core/internal/ad_event_history_unittest.cc @@ -5,6 +5,7 @@ #include "brave/components/brave_ads/core/ad_event_history.h" +#include "brave/components/brave_ads/core/ad_type.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" diff --git a/components/brave_ads/core/internal/ad_info_unittest.cc b/components/brave_ads/core/internal/ad_info_unittest.cc index c4e687c573fc..864f89e4aee5 100644 --- a/components/brave_ads/core/internal/ad_info_unittest.cc +++ b/components/brave_ads/core/internal/ad_info_unittest.cc @@ -16,7 +16,8 @@ class BatAdsAdInfoTest : public UnitTestBase {}; TEST_F(BatAdsAdInfoTest, IsValid) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); // Act diff --git a/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.cc b/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.cc index 26fbb3ce01e4..89562e716c42 100644 --- a/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.cc +++ b/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.cc @@ -16,6 +16,7 @@ #include "brave/components/brave_ads/core/confirmation_type.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_events.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads_client_helper.h" #include "brave/components/brave_ads/core/internal/common/instance_id_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -77,10 +78,10 @@ AdEventInfo BuildAdEvent(const std::string& placement_id, ad_event.type = AdType::kNotificationAd; ad_event.confirmation_type = confirmation_type; ad_event.placement_id = placement_id; - ad_event.campaign_id = "604df73f-bc6e-4583-a56d-ce4e243c8537"; + ad_event.campaign_id = kCampaignId; ad_event.creative_set_id = creative_set_id; - ad_event.creative_instance_id = "7a3b6d9f-d0b7-4da6-8988-8d5b8938c94f"; - ad_event.advertiser_id = "f646c5f5-027a-4a35-b081-fce85e830b19"; + ad_event.creative_instance_id = kCreativeInstanceId; + ad_event.advertiser_id = kAdvertiserId; ad_event.created_at = Now(); return ad_event; diff --git a/components/brave_ads/core/internal/ads/ad_events/ad_event_util_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/ad_event_util_unittest.cc index e6be51a9007d..e90987871dbb 100644 --- a/components/brave_ads/core/internal/ads/ad_events/ad_event_util_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/ad_event_util_unittest.cc @@ -22,7 +22,8 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdTimeForEmptyAdEvents) { // Arrange const AdEventList ad_events; - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); // Act const absl::optional last_seen_ad_time = @@ -37,7 +38,7 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdTimeForUnseenAd) { AdEventList ad_events; const CreativeNotificationAdInfo creative_ad_1 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const base::Time event_time = Now() - base::Hours(12); const AdEventInfo ad_event = @@ -47,7 +48,7 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdTimeForUnseenAd) { // Act const CreativeNotificationAdInfo creative_ad_2 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const absl::optional last_seen_ad_time = GetLastSeenAdTime(ad_events, creative_ad_2); @@ -60,10 +61,10 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdTime) { AdEventList ad_events; const CreativeNotificationAdInfo creative_ad_1 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const CreativeNotificationAdInfo creative_ad_2 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const base::Time now = Now(); @@ -100,7 +101,8 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdvertiserTimeForEmptyAdEvents) { // Arrange const AdEventList ad_events; - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); // Act const absl::optional last_seen_advertiser_time = @@ -115,7 +117,7 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdvertiserTimeForUnseenAdvertiser) { AdEventList ad_events; const CreativeNotificationAdInfo creative_ad_1 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent(creative_ad_1, AdType::kNotificationAd, @@ -124,7 +126,7 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdvertiserTimeForUnseenAdvertiser) { // Act const CreativeNotificationAdInfo creative_ad_2 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const absl::optional last_seen_advertiser_time = GetLastSeenAdvertiserTime(ad_events, creative_ad_2); @@ -139,13 +141,16 @@ TEST(BatAdsAdEventUtilTest, GetLastSeenAdvertiserTime) { const std::string advertiser_2 = base::GUID::GenerateRandomV4().AsLowercaseString(); - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.advertiser_id = advertiser_1; - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.advertiser_id = advertiser_2; - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.advertiser_id = advertiser_1; AdEventList ad_events; diff --git a/components/brave_ads/core/internal/ads/ad_events/ad_events_database_table_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/ad_events_database_table_unittest.cc index 75a4e6154320..1d7840b461d4 100644 --- a/components/brave_ads/core/internal/ads/ad_events/ad_events_database_table_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/ad_events_database_table_unittest.cc @@ -13,14 +13,12 @@ namespace brave_ads::database::table { TEST(BatAdsAdEventsDatabaseTableTest, TableName) { // Arrange - AdEvents const database_table; + const AdEvents database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "ad_events"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("ad_events", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc index cd439b5477fd..4290fdf3beac 100644 --- a/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler_unittest.cc @@ -12,6 +12,7 @@ #include "brave/components/brave_ads/core/inline_content_ad_info.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler_observer.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h" @@ -23,18 +24,11 @@ namespace brave_ads::inline_content_ads { namespace { -constexpr char kPlacementId[] = "d2ef9bb0-a0dc-472c-bc49-62105bb6da68"; -constexpr char kInvalidPlacementId[] = ""; - -constexpr char kCreativeInstanceId[] = "1547f94f-9086-4db9-a441-efb2f0365269"; -constexpr char kInvalidCreativeInstanceId[] = ""; - CreativeInlineContentAdInfo BuildAndSaveCreativeAd() { - CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(); - creative_ads.push_back(creative_ad); + CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); return creative_ad; } diff --git a/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc index d879e8684862..7d9fdc7f9c67 100644 --- a/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_if_ads_disabled_unittest.cc @@ -14,6 +14,7 @@ #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_observer.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/new_tab_page_ad_features.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" @@ -29,18 +30,11 @@ namespace brave_ads::new_tab_page_ads { namespace { -constexpr char kPlacementId[] = "d2ef9bb0-a0dc-472c-bc49-62105bb6da68"; -constexpr char kInvalidPlacementId[] = ""; - -constexpr char kCreativeInstanceId[] = "1547f94f-9086-4db9-a441-efb2f0365269"; -constexpr char kInvalidCreativeInstanceId[] = ""; - CreativeNewTabPageAdInfo BuildAndSaveCreativeAd() { - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); - creative_ads.push_back(creative_ad); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); return creative_ad; } diff --git a/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc index 2bb3bc874098..da26a6f8e0ef 100644 --- a/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_unittest.cc @@ -13,6 +13,7 @@ #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler_observer.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/new_tab_page_ad_features.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" @@ -28,18 +29,11 @@ namespace brave_ads::new_tab_page_ads { namespace { -constexpr char kPlacementId[] = "d2ef9bb0-a0dc-472c-bc49-62105bb6da68"; -constexpr char kInvalidPlacementId[] = ""; - -constexpr char kCreativeInstanceId[] = "1547f94f-9086-4db9-a441-efb2f0365269"; -constexpr char kInvalidCreativeInstanceId[] = ""; - CreativeNewTabPageAdInfo BuildAndSaveCreativeAd() { - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); - creative_ads.push_back(creative_ad); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); return creative_ad; } diff --git a/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler_unittest.cc index d00244d11a28..25e92fb989f8 100644 --- a/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler_unittest.cc @@ -11,6 +11,7 @@ #include "brave/components/brave_ads/core/confirmation_type.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler_observer.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" @@ -23,10 +24,9 @@ namespace brave_ads::notification_ads { namespace { -constexpr char kPlacementId[] = "d2ef9bb0-a0dc-472c-bc49-62105bb6da68"; - NotificationAdInfo BuildAndSaveNotificationAd() { - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); NotificationAdInfo ad = BuildNotificationAd(creative_ad); NotificationAdManager::GetInstance()->Add(ad); return ad; diff --git a/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc index b6303b98aac6..45995c1f68a3 100644 --- a/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc @@ -13,6 +13,7 @@ #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler_observer.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/promoted_content_ad_features.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" @@ -28,18 +29,11 @@ namespace brave_ads::promoted_content_ads { namespace { -constexpr char kPlacementId[] = "d2ef9bb0-a0dc-472c-bc49-62105bb6da68"; -constexpr char kInvalidPlacementId[] = ""; - -constexpr char kCreativeInstanceId[] = "1547f94f-9086-4db9-a441-efb2f0365269"; -constexpr char kInvalidCreativeInstanceId[] = ""; - CreativePromotedContentAdInfo BuildAndSaveCreativeAd() { - CreativePromotedContentAdList creative_ads; - CreativePromotedContentAdInfo creative_ad = BuildCreativePromotedContentAd(); - creative_ads.push_back(creative_ad); + CreativePromotedContentAdInfo creative_ad = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); return creative_ad; } diff --git a/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc b/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc index 44013c840a9d..6dc6f8216cb4 100644 --- a/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc +++ b/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc @@ -14,6 +14,7 @@ #include "brave/components/brave_ads/core/internal/account/deposits/deposits_database_table.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/search_result_ad_features.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" @@ -22,8 +23,8 @@ #include "brave/components/brave_ads/core/internal/conversions/conversions_database_table.h" #include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_builder.h" #include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_info.h" +#include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#include "url/gurl.h" // npm run test -- brave_unit_tests --filter=BatAds* @@ -31,46 +32,6 @@ namespace brave_ads::search_result_ads { namespace { -constexpr char kPlacementId[] = "d2ef9bb0-a0dc-472c-bc49-62105bb6da68"; -constexpr char kInvalidPlacementId[] = ""; - -constexpr char kCreativeInstanceId[] = "1547f94f-9086-4db9-a441-efb2f0365269"; -constexpr char kInvalidCreativeInstanceId[] = ""; - -mojom::SearchResultAdInfoPtr BuildAd(const std::string& placement_id, - const std::string& creative_instance_id) { - mojom::SearchResultAdInfoPtr ad_mojom = mojom::SearchResultAdInfo::New(); - - ad_mojom->creative_instance_id = creative_instance_id; - ad_mojom->placement_id = placement_id; - ad_mojom->creative_set_id = "7a41297b-ff7f-4ca8-9787-b4c9c1105f01"; - ad_mojom->campaign_id = "be5d25ca-93e4-4a16-8f8b-4714abca31ed"; - ad_mojom->advertiser_id = "f82389c6-c6ca-4db5-99f9-724f038efddf"; - ad_mojom->target_url = GURL("https://brave.com"); - ad_mojom->headline_text = "headline"; - ad_mojom->description = "description"; - ad_mojom->value = 1.0; - ad_mojom->conversion = mojom::ConversionInfo::New(); - - return ad_mojom; -} - -mojom::SearchResultAdInfoPtr BuildAdWithConversion( - const std::string& placement_id, - const std::string& creative_instance_id) { - mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(placement_id, creative_instance_id); - - ad_mojom->conversion->type = "postview"; - ad_mojom->conversion->url_pattern = "https://brave.com/*"; - ad_mojom->conversion->advertiser_public_key = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - ad_mojom->conversion->observation_window = 3; - ad_mojom->conversion->expire_at = DistantFuture(); - - return ad_mojom; -} - void ExpectDepositExistsForCreativeInstanceId( const std::string& creative_instance_id) { const database::table::Deposits database_table; @@ -90,7 +51,6 @@ void ExpectConversionCountEquals(const size_t expected_count) { [](const size_t expected_count, const bool success, const ConversionList& conversions) { ASSERT_TRUE(success); - EXPECT_EQ(expected_count, conversions.size()); }, expected_count)); @@ -157,7 +117,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, FireViewedEvent) { ForcePermissionRulesForTesting(); const mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); // Act FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kServed); @@ -168,13 +128,12 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, FireViewedEvent) { EXPECT_TRUE(did_view_ad_); EXPECT_FALSE(did_click_ad_); EXPECT_FALSE(did_fail_to_fire_event_); - const SearchResultAdInfo expected_ad = BuildSearchResultAd(ad_mojom); - EXPECT_EQ(expected_ad, ad_); + EXPECT_EQ(BuildSearchResultAd(ad_mojom), ad_); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); - ExpectDepositExistsForCreativeInstanceId(kCreativeInstanceId); + ExpectDepositExistsForCreativeInstanceId(ad_mojom->creative_instance_id); ExpectConversionCountEquals(0); } @@ -183,7 +142,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, FireViewedEventWithConversion) { ForcePermissionRulesForTesting(); const mojom::SearchResultAdInfoPtr ad_mojom = - BuildAdWithConversion(kPlacementId, kCreativeInstanceId); + BuildSearchResultAdWithConversion(/*should_use_random_guids*/ false); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kServed); @@ -195,13 +154,12 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, FireViewedEventWithConversion) { EXPECT_TRUE(did_view_ad_); EXPECT_FALSE(did_click_ad_); EXPECT_FALSE(did_fail_to_fire_event_); - const SearchResultAdInfo expected_ad = BuildSearchResultAd(ad_mojom); - EXPECT_EQ(expected_ad, ad_); + EXPECT_EQ(BuildSearchResultAd(ad_mojom), ad_); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); - ExpectDepositExistsForCreativeInstanceId(kCreativeInstanceId); + ExpectDepositExistsForCreativeInstanceId(ad_mojom->creative_instance_id); ExpectConversionCountEquals(1); } @@ -211,7 +169,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, ForcePermissionRulesForTesting(); const mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kServed); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kViewed); @@ -224,7 +182,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); - ExpectDepositExistsForCreativeInstanceId(kCreativeInstanceId); + ExpectDepositExistsForCreativeInstanceId(ad_mojom->creative_instance_id); ExpectConversionCountEquals(0); } @@ -233,7 +191,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, FireClickedEvent) { ForcePermissionRulesForTesting(); const mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kServed); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kViewed); @@ -246,14 +204,14 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, FireClickedEvent) { EXPECT_TRUE(did_view_ad_); EXPECT_TRUE(did_click_ad_); EXPECT_FALSE(did_fail_to_fire_event_); - const SearchResultAdInfo expected_ad = BuildSearchResultAd(ad_mojom); - EXPECT_EQ(expected_ad, ad_); + EXPECT_EQ(BuildSearchResultAd(ad_mojom), ad_); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kClicked)); + ExpectConversionCountEquals(0); } TEST_F(BatAdsSearchResultAdEventHandlerTest, @@ -262,7 +220,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, ForcePermissionRulesForTesting(); const mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kServed); FireEvent(ad_mojom->Clone(), mojom::SearchResultAdEventType::kViewed); @@ -278,13 +236,15 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); EXPECT_EQ( 1, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kClicked)); + ExpectConversionCountEquals(0); } TEST_F(BatAdsSearchResultAdEventHandlerTest, DoNotFireEventWithInvalidPlacementId) { // Arrange mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kInvalidPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); + ad_mojom->placement_id = kInvalidPlacementId; // Act FireEvent(std::move(ad_mojom), mojom::SearchResultAdEventType::kServed); @@ -296,13 +256,15 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, EXPECT_TRUE(did_fail_to_fire_event_); EXPECT_EQ( 0, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); + ExpectConversionCountEquals(0); } TEST_F(BatAdsSearchResultAdEventHandlerTest, DoNotFireEventWithInvalidCreativeInstanceId) { // Arrange mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kInvalidCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); + ad_mojom->creative_instance_id = kInvalidCreativeInstanceId; // Act FireEvent(std::move(ad_mojom), mojom::SearchResultAdEventType::kViewed); @@ -314,12 +276,13 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, EXPECT_TRUE(did_fail_to_fire_event_); EXPECT_EQ( 0, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); + ExpectConversionCountEquals(0); } TEST_F(BatAdsSearchResultAdEventHandlerTest, DoNotFireEventWhenNotPermitted) { // Arrange mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); // Act FireEvent(std::move(ad_mojom), mojom::SearchResultAdEventType::kViewed); @@ -331,6 +294,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, DoNotFireEventWhenNotPermitted) { EXPECT_TRUE(did_fail_to_fire_event_); EXPECT_EQ( 0, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); + ExpectConversionCountEquals(0); } TEST_F(BatAdsSearchResultAdEventHandlerTest, @@ -338,8 +302,8 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, // Arrange ForcePermissionRulesForTesting(); - mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + const mojom::SearchResultAdInfoPtr ad_mojom = + BuildSearchResultAd(/*should_use_random_guids*/ false); const int ads_per_hour = features::GetMaximumAdsPerHour(); @@ -361,7 +325,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, ConfirmationType::kServed)); EXPECT_EQ(ads_per_hour, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); - ExpectDepositExistsForCreativeInstanceId(kCreativeInstanceId); + ExpectDepositExistsForCreativeInstanceId(ad.creative_instance_id); ExpectConversionCountEquals(0); } @@ -371,7 +335,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, ForcePermissionRulesForTesting(); mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); const SearchResultAdInfo ad = BuildSearchResultAd(ad_mojom); const AdEventInfo ad_event = BuildAdEvent(ad, AdType::kSearchResultAd, @@ -386,6 +350,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, // Assert EXPECT_EQ(ads_per_hour, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); + ExpectConversionCountEquals(0); } TEST_F(BatAdsSearchResultAdEventHandlerTest, @@ -393,8 +358,8 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, // Arrange ForcePermissionRulesForTesting(); - mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + const mojom::SearchResultAdInfoPtr ad_mojom = + BuildSearchResultAd(/*should_use_random_guids*/ false); const int ads_per_day = features::GetMaximumAdsPerDay(); @@ -418,7 +383,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, ConfirmationType::kServed)); EXPECT_EQ(ads_per_day, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kViewed)); - ExpectDepositExistsForCreativeInstanceId(kCreativeInstanceId); + ExpectDepositExistsForCreativeInstanceId(ad.creative_instance_id); ExpectConversionCountEquals(0); } @@ -428,7 +393,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, ForcePermissionRulesForTesting(); mojom::SearchResultAdInfoPtr ad_mojom = - BuildAd(kPlacementId, kCreativeInstanceId); + BuildSearchResultAd(/*should_use_random_guids*/ false); const SearchResultAdInfo ad = BuildSearchResultAd(ad_mojom); const AdEventInfo ad_event = BuildAdEvent(ad, AdType::kSearchResultAd, @@ -446,6 +411,7 @@ TEST_F(BatAdsSearchResultAdEventHandlerTest, // Assert EXPECT_EQ(ads_per_day, GetAdEventCount(AdType::kSearchResultAd, ConfirmationType::kServed)); + ExpectConversionCountEquals(0); } } // namespace brave_ads::search_result_ads diff --git a/components/brave_ads/core/internal/ads/ad_unittest_constants.h b/components/brave_ads/core/internal/ads/ad_unittest_constants.h new file mode 100644 index 000000000000..c0627de5f263 --- /dev/null +++ b/components/brave_ads/core/internal/ads/ad_unittest_constants.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ADS_AD_UNITTEST_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ADS_AD_UNITTEST_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kPlacementId[] = "8b742869-6e4a-490c-ac31-31b49130098a"; +constexpr char kInvalidPlacementId[] = ""; + +constexpr char kCreativeInstanceId[] = "546fe7b0-5047-4f28-a11c-81f14edcf0f6"; +constexpr char kMissingCreativeInstanceId[] = + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; +constexpr char kInvalidCreativeInstanceId[] = ""; + +constexpr char kCreativeSetId[] = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; +constexpr char kInvalidCreativeSetId[] = ""; + +constexpr char kCampaignId[] = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; +constexpr char kInvalidCampaignId[] = ""; + +constexpr char kAdvertiserId[] = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; +constexpr char kInvalidAdvertiserId[] = ""; + +constexpr char kSegment[] = "untargeted"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ADS_AD_UNITTEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/ads/ad_unittest_util.cc b/components/brave_ads/core/internal/ads/ad_unittest_util.cc index 0c956bf5961a..9e5a69cd6546 100644 --- a/components/brave_ads/core/internal/ads/ad_unittest_util.cc +++ b/components/brave_ads/core/internal/ads/ad_unittest_util.cc @@ -5,32 +5,47 @@ #include "brave/components/brave_ads/core/internal/ads/ad_unittest_util.h" +#include "base/guid.h" #include "brave/components/brave_ads/core/ad_info.h" +#include "brave/components/brave_ads/core/ad_type.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "url/gurl.h" namespace brave_ads { -namespace { +AdInfo BuildAd(const AdType& ad_type, const bool should_use_random_guids) { + AdInfo ad; -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -constexpr char kCreativeSetId[] = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; -constexpr char kCampaignId[] = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; -constexpr char kAdvertiserId[] = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; -constexpr char kSegment[] = "segment"; + ad.type = ad_type; -} // namespace + ad.placement_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kPlacementId; -AdInfo BuildAd() { - AdInfo ad; + ad.creative_instance_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeInstanceId; + + ad.creative_instance_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeInstanceId; + + ad.creative_set_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeSetId; + + ad.campaign_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCampaignId; + + ad.advertiser_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kAdvertiserId; - ad.type = AdType::kNotificationAd; - ad.placement_id = kPlacementId; - ad.creative_instance_id = kCreativeInstanceId; - ad.creative_set_id = kCreativeSetId; - ad.campaign_id = kCampaignId; - ad.advertiser_id = kAdvertiserId; ad.segment = kSegment; + ad.target_url = GURL("https://brave.com"); return ad; diff --git a/components/brave_ads/core/internal/ads/ad_unittest_util.h b/components/brave_ads/core/internal/ads/ad_unittest_util.h index 9403d8702e30..2de2f41448fc 100644 --- a/components/brave_ads/core/internal/ads/ad_unittest_util.h +++ b/components/brave_ads/core/internal/ads/ad_unittest_util.h @@ -8,9 +8,10 @@ namespace brave_ads { +class AdType; struct AdInfo; -AdInfo BuildAd(); +AdInfo BuildAd(const AdType& ad_type, bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/ads/inline_content_ad_test.cc b/components/brave_ads/core/internal/ads/inline_content_ad_test.cc index fa5088943720..b80c442fade2 100644 --- a/components/brave_ads/core/internal/ads/inline_content_ad_test.cc +++ b/components/brave_ads/core/internal/ads/inline_content_ad_test.cc @@ -9,6 +9,7 @@ #include "brave/components/brave_ads/core/inline_content_ad_info.h" #include "brave/components/brave_ads/core/internal/account/transactions/transactions_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" @@ -24,11 +25,7 @@ namespace brave_ads { using ::testing::_; namespace { - constexpr char kDimensions[] = "200x100"; -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; -constexpr char kCreativeInstanceIdId[] = "30db5f7b-dba3-48a3-b299-c9bd9c67da65"; - } // namespace class BatAdsInlineContentAdIntegrationTest : public UnitTestBase { @@ -69,7 +66,7 @@ TEST_F(BatAdsInlineContentAdIntegrationTest, TriggerServedEvent) { // Act GetAds()->TriggerInlineContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::InlineContentAdEventType::kServed); // Assert @@ -86,12 +83,12 @@ TEST_F(BatAdsInlineContentAdIntegrationTest, TriggerViewedEvent) { EXPECT_CALL(*ads_client_mock_, RecordP2AEvent(name, _)); GetAds()->TriggerInlineContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::InlineContentAdEventType::kServed); // Act GetAds()->TriggerInlineContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::InlineContentAdEventType::kViewed); // Assert @@ -104,15 +101,15 @@ TEST_F(BatAdsInlineContentAdIntegrationTest, TriggerViewedEvent) { TEST_F(BatAdsInlineContentAdIntegrationTest, TriggerClickedEvent) { // Arrange GetAds()->TriggerInlineContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::InlineContentAdEventType::kServed); GetAds()->TriggerInlineContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::InlineContentAdEventType::kViewed); // Act GetAds()->TriggerInlineContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::InlineContentAdEventType::kClicked); // Assert diff --git a/components/brave_ads/core/internal/ads/new_tab_page_ad_test.cc b/components/brave_ads/core/internal/ads/new_tab_page_ad_test.cc index 2a774c1748c9..93cf904b56b9 100644 --- a/components/brave_ads/core/internal/ads/new_tab_page_ad_test.cc +++ b/components/brave_ads/core/internal/ads/new_tab_page_ad_test.cc @@ -8,6 +8,7 @@ #include "brave/components/brave_ads/core/confirmation_type.h" #include "brave/components/brave_ads/core/internal/account/transactions/transactions_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" @@ -20,13 +21,6 @@ namespace brave_ads { -namespace { - -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; -constexpr char kCreativeInstanceIdId[] = "7ff400b9-7f8a-46a8-89f1-cb386612edcf"; - -} // namespace - class BatAdsNewTabPageAdIntegrationTest : public UnitTestBase { protected: void SetUp() override { @@ -61,7 +55,7 @@ TEST_F(BatAdsNewTabPageAdIntegrationTest, TriggerServedEvent) { // Arrange // Act - GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceIdId, + GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kServed); // Assert @@ -73,11 +67,11 @@ TEST_F(BatAdsNewTabPageAdIntegrationTest, TriggerServedEvent) { TEST_F(BatAdsNewTabPageAdIntegrationTest, TriggerViewedEvent) { // Arrange - GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceIdId, + GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kServed); // Act - GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceIdId, + GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kViewed); // Assert @@ -91,13 +85,13 @@ TEST_F(BatAdsNewTabPageAdIntegrationTest, TriggerViewedEvent) { TEST_F(BatAdsNewTabPageAdIntegrationTest, TriggerClickedEvent) { // Arrange - GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceIdId, + GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kServed); - GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceIdId, + GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kViewed); // Act - GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceIdId, + GetAds()->TriggerNewTabPageAdEvent(kPlacementId, kCreativeInstanceId, mojom::NewTabPageAdEventType::kClicked); // Assert diff --git a/components/brave_ads/core/internal/ads/notification_ad_handler_util_unittest.cc b/components/brave_ads/core/internal/ads/notification_ad_handler_util_unittest.cc index 6092a571b0f0..11240911bb8c 100644 --- a/components/brave_ads/core/internal/ads/notification_ad_handler_util_unittest.cc +++ b/components/brave_ads/core/internal/ads/notification_ad_handler_util_unittest.cc @@ -21,7 +21,8 @@ namespace brave_ads { namespace { void BuildAndShowNotificationAd() { - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); ShowNotificationAd(ad); } diff --git a/components/brave_ads/core/internal/ads/promoted_content_ad_test.cc b/components/brave_ads/core/internal/ads/promoted_content_ad_test.cc index f3217340f81d..22d80f71dd94 100644 --- a/components/brave_ads/core/internal/ads/promoted_content_ad_test.cc +++ b/components/brave_ads/core/internal/ads/promoted_content_ad_test.cc @@ -7,6 +7,7 @@ #include "brave/components/brave_ads/core/confirmation_type.h" #include "brave/components/brave_ads/core/internal/account/transactions/transactions_unittest_util.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" @@ -17,13 +18,6 @@ namespace brave_ads { -namespace { - -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; -constexpr char kCreativeInstanceIdId[] = "75d4cbac-b661-4126-9ccb-7bbb6ee56ef3"; - -} // namespace - class BatAdsPromotedContentAdIntegrationTest : public UnitTestBase { protected: void SetUp() override { @@ -34,7 +28,8 @@ class BatAdsPromotedContentAdIntegrationTest : public UnitTestBase { void SetUpMocks() override { const URLResponseMap url_responses = { - {"/v9/catalog", {{net::HTTP_OK, "/catalog.json"}}}}; + {"/v9/catalog", + {{net::HTTP_OK, "/catalog_with_promoted_content_ad.json"}}}}; MockUrlResponses(ads_client_mock_, url_responses); } }; @@ -42,12 +37,12 @@ class BatAdsPromotedContentAdIntegrationTest : public UnitTestBase { TEST_F(BatAdsPromotedContentAdIntegrationTest, TriggerViewedEvent) { // Arrange GetAds()->TriggerPromotedContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::PromotedContentAdEventType::kServed); // Act GetAds()->TriggerPromotedContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::PromotedContentAdEventType::kViewed); // Assert @@ -62,15 +57,15 @@ TEST_F(BatAdsPromotedContentAdIntegrationTest, TriggerViewedEvent) { TEST_F(BatAdsPromotedContentAdIntegrationTest, TriggerClickedEvent) { // Arrange GetAds()->TriggerPromotedContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::PromotedContentAdEventType::kServed); GetAds()->TriggerPromotedContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::PromotedContentAdEventType::kViewed); // Act GetAds()->TriggerPromotedContentAdEvent( - kPlacementId, kCreativeInstanceIdId, + kPlacementId, kCreativeInstanceId, mojom::PromotedContentAdEventType::kClicked); // Assert diff --git a/components/brave_ads/core/internal/ads/search_result_ad_test.cc b/components/brave_ads/core/internal/ads/search_result_ad_test.cc index 3acfccb9ee4d..3b77b2483e52 100644 --- a/components/brave_ads/core/internal/ads/search_result_ad_test.cc +++ b/components/brave_ads/core/internal/ads/search_result_ad_test.cc @@ -36,7 +36,8 @@ TEST_F(BatAdsSearchResultAdIntegrationTest, TriggerViewedEvents) { // Act { - const mojom::SearchResultAdInfoPtr search_result_ad = BuildSearchResultAd(); + const mojom::SearchResultAdInfoPtr search_result_ad = + BuildSearchResultAd(/*should_use_random_guids*/ true); GetAds()->TriggerSearchResultAdEvent( search_result_ad.Clone(), mojom::SearchResultAdEventType::kServed); @@ -45,7 +46,8 @@ TEST_F(BatAdsSearchResultAdIntegrationTest, TriggerViewedEvents) { } { - const mojom::SearchResultAdInfoPtr search_result_ad = BuildSearchResultAd(); + const mojom::SearchResultAdInfoPtr search_result_ad = + BuildSearchResultAd(/*should_use_random_guids*/ true); GetAds()->TriggerSearchResultAdEvent( search_result_ad.Clone(), mojom::SearchResultAdEventType::kServed); @@ -70,7 +72,8 @@ TEST_F(BatAdsSearchResultAdIntegrationTest, TriggerQueuedViewedEvents) { { // This ad viewed event triggering will be deferred. - const mojom::SearchResultAdInfoPtr search_result_ad = BuildSearchResultAd(); + const mojom::SearchResultAdInfoPtr search_result_ad = + BuildSearchResultAd(/*should_use_random_guids*/ true); GetAds()->TriggerSearchResultAdEvent( search_result_ad.Clone(), mojom::SearchResultAdEventType::kServed); @@ -81,8 +84,8 @@ TEST_F(BatAdsSearchResultAdIntegrationTest, TriggerQueuedViewedEvents) { { // This ad viewed event will be queued as the previous ad viewed event has // not completed. - const mojom::SearchResultAdInfoPtr search_result_ad = BuildSearchResultAd(); - + const mojom::SearchResultAdInfoPtr search_result_ad = + BuildSearchResultAd(/*should_use_random_guids*/ true); GetAds()->TriggerSearchResultAdEvent( search_result_ad.Clone(), mojom::SearchResultAdEventType::kServed); GetAds()->TriggerSearchResultAdEvent( @@ -110,7 +113,8 @@ TEST_F(BatAdsSearchResultAdIntegrationTest, TriggerQueuedViewedEvents) { TEST_F(BatAdsSearchResultAdIntegrationTest, TriggerClickedEvent) { // Arrange - const mojom::SearchResultAdInfoPtr search_result_ad = BuildSearchResultAd(); + const mojom::SearchResultAdInfoPtr search_result_ad = + BuildSearchResultAd(/*should_use_random_guids*/ true); GetAds()->TriggerSearchResultAdEvent(search_result_ad->Clone(), mojom::SearchResultAdEventType::kServed); diff --git a/components/brave_ads/core/internal/ads/serving/choose/eligible_ads_predictor_util_unittest.cc b/components/brave_ads/core/internal/ads/serving/choose/eligible_ads_predictor_util_unittest.cc index 23984d90ae5b..03becddf1de1 100644 --- a/components/brave_ads/core/internal/ads/serving/choose/eligible_ads_predictor_util_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/choose/eligible_ads_predictor_util_unittest.cc @@ -24,19 +24,23 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, GroupCreativeAdsByCreativeInstanceId) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo-bar1"; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar2"; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "foo-bar3"; creative_ads.push_back(creative_ad_3); - CreativeNotificationAdInfo creative_ad_4 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_4 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_4.creative_instance_id = creative_ad_2.creative_instance_id; creative_ad_4.segment = "foo-bar4"; creative_ads.push_back(creative_ad_4); @@ -78,7 +82,8 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, scoped_feature_list.InitWithFeaturesAndParameters( {{features::kEligibleAds, params}}, {}); - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.segment = "foo-bar"; AdPredictorInfo ad_predictor; @@ -101,7 +106,8 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, TEST(BatAdsEligibleAdsPredictorUtilTest, ComputePredictorScoreWithDefaultWeights) { // Arrange - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.segment = "foo-bar"; AdPredictorInfo ad_predictor; @@ -118,9 +124,8 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, ad_predictor.score = ComputePredictorScore(ad_predictor); // Assert - const double expected_score = - 0.0 + 1.0 + 1.0 * (15 / 24.0) + (1.0 / 2.0) * 1.0; - EXPECT_EQ(expected_score, ad_predictor.score); + EXPECT_EQ(0.0 + 1.0 + 1.0 * (15 / 24.0) + (1.0 / 2.0) * 1.0, + ad_predictor.score); } TEST(BatAdsEligibleAdsPredictorUtilTest, @@ -132,27 +137,30 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, ad_predictor.score = ComputePredictorScore(ad_predictor); // Assert - const double expected_score = 0.0; - EXPECT_EQ(expected_score, ad_predictor.score); + EXPECT_EQ(0.0, ad_predictor.score); } TEST(BatAdsEligibleAdsPredictorUtilTest, ComputeVoteRegistry) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.embedding = {0.0853, -0.1789, -0.4221}; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.embedding = {-0.0853, -0.1789, 0.4221}; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.embedding = {-0.0853, 0.1789, -0.4221}; creative_ads.push_back(creative_ad_3); - CreativeNotificationAdInfo creative_ad_4 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_4 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_4.creative_instance_id = creative_ad_2.creative_instance_id; creative_ad_4.embedding = {0.0853, -0.1789, 0.4221}; creative_ads.push_back(creative_ad_4); @@ -188,15 +196,18 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.embedding = {0.0853, -0.1789, -0.4221}; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.embedding = {0.0853, -0.1789, -0.4221}; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.embedding = {0.0853, -0.1789, -0.4221}; creative_ads.push_back(creative_ad_3); @@ -228,19 +239,23 @@ TEST(BatAdsEligibleAdsPredictorUtilTest, // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.embedding = {0.0853, -0.1789, -0.4221}; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.embedding = {-0.0853, -0.1789, 0.4221}; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.embedding = {-0.0853, 0.1789, -0.4221}; creative_ads.push_back(creative_ad_3); - CreativeNotificationAdInfo creative_ad_4 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_4 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_4.creative_instance_id = creative_ad_2.creative_instance_id; creative_ad_4.embedding = {0.0853, -0.1789, 0.4221}; creative_ads.push_back(creative_ad_4); diff --git a/components/brave_ads/core/internal/ads/serving/choose/sample_ads_unittest.cc b/components/brave_ads/core/internal/ads/serving/choose/sample_ads_unittest.cc index c4286d2094b9..cee88a7d0b3a 100644 --- a/components/brave_ads/core/internal/ads/serving/choose/sample_ads_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/choose/sample_ads_unittest.cc @@ -110,7 +110,8 @@ TEST(BatAdsSampleAdsTest, // Arrange CreativeAdPredictorMap creative_ad_predictors; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo-bar"; AdPredictorInfo ad_predictor_1; @@ -118,7 +119,8 @@ TEST(BatAdsSampleAdsTest, ad_predictor_1.creative_ad = creative_ad_1; creative_ad_predictors[creative_ad_1.creative_instance_id] = ad_predictor_1; - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar"; AdPredictorInfo ad_predictor_2; @@ -126,7 +128,8 @@ TEST(BatAdsSampleAdsTest, ad_predictor_2.creative_ad = creative_ad_2; creative_ad_predictors[creative_ad_2.creative_instance_id] = ad_predictor_2; - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "foo-bar"; AdPredictorInfo ad_predictor_3; @@ -150,7 +153,8 @@ TEST(BatAdsSampleAdsTest, ProbabilisticallySampleAdFromPredictors) { // Arrange CreativeAdPredictorMap creative_ad_predictors; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo-bar"; AdPredictorInfo ad_predictor_1; @@ -158,7 +162,8 @@ TEST(BatAdsSampleAdsTest, ProbabilisticallySampleAdFromPredictors) { ad_predictor_1.score = 3; creative_ad_predictors[creative_ad_1.creative_instance_id] = ad_predictor_1; - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar"; AdPredictorInfo ad_predictor_2; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/eligible_ads_features_util_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/eligible_ads_features_util_unittest.cc index 000e74fd6e1f..835a18da2df6 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/eligible_ads_features_util_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/eligible_ads_features_util_unittest.cc @@ -19,8 +19,7 @@ TEST(BatAdsEligibleAdsFeaturesUtilTest, const AdPredictorWeightList weights = ToAdPredictorWeights({}); // Assert - const AdPredictorWeightList expected_weights; - EXPECT_EQ(expected_weights, weights); + EXPECT_TRUE(weights.empty()); } TEST(BatAdsEligibleAdsFeaturesUtilTest, @@ -32,8 +31,7 @@ TEST(BatAdsEligibleAdsFeaturesUtilTest, ToAdPredictorWeights("1.0, foobar, 2.2"); // Assert - const AdPredictorWeightList expected_weights; - EXPECT_EQ(expected_weights, weights); + EXPECT_TRUE(weights.empty()); } TEST(BatAdsEligibleAdsFeaturesUtilTest, @@ -44,8 +42,7 @@ TEST(BatAdsEligibleAdsFeaturesUtilTest, const AdPredictorWeightList weights = ToAdPredictorWeights("0.0, 0.0, 0.0"); // Assert - const AdPredictorWeightList expected_weights; - EXPECT_EQ(expected_weights, weights); + EXPECT_TRUE(weights.empty()); } TEST(BatAdsEligibleAdsFeaturesUtilTest, @@ -68,8 +65,7 @@ TEST(BatAdsEligibleAdsFeaturesUtilTest, const AdPredictorWeightList weights = ToAdPredictorWeights("1.0, 3.0, -2.0"); // Assert - const AdPredictorWeightList expected_weights; - EXPECT_EQ(expected_weights, weights); + EXPECT_TRUE(weights.empty()); } TEST(BatAdsEligibleAdsFeaturesUtilTest, diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc index 360c2007d03e..655c15be3aab 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule_unittest.cc @@ -9,6 +9,7 @@ #include "base/test/scoped_feature_list.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rule_features.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -30,7 +31,7 @@ class BatAdsConversionExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsConversionExclusionRuleTest, AllowAdIfThereIsNoConversionHistory) { // Arrange CreativeAdInfo creative_ad; - creative_ad.creative_set_id = "654f10df-fbc4-4a92-8d43-2edf73734a60"; + creative_ad.creative_set_id = kCreativeSetId; const AdEventList ad_events; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc index 4d18e692c1f9..442b26cf6282 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -13,10 +14,6 @@ namespace brave_ads { -namespace { -constexpr char kCreativeInstanceId[] = "9aea9a47-c6a0-4718-a0fa-706338bb2156"; -} // namespace - class BatAdsCreativeInstanceExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsCreativeInstanceExclusionRuleTest, AllowAdIfThereIsNoAdsHistory) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc index ea95028fb00f..af1d56c8debd 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daypart_exclusion_rule_unittest.cc @@ -7,6 +7,7 @@ #include "base/strings/string_number_conversions.h" #include "base/time/time.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -14,10 +15,6 @@ namespace brave_ads { -namespace { -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; -} // namespace - class BatAdsDaypartExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsDaypartExclusionRuleTest, AllowIfDaypartsIsEmpty) { @@ -43,11 +40,11 @@ TEST_F(BatAdsDaypartExclusionRuleTest, AllowIfRightDayAndHours) { const int current_time = base::Time::kMinutesPerHour * exploded.hour + exploded.minute; - CreativeDaypartInfo daypart_info; - daypart_info.dow = base::NumberToString(exploded.day_of_week); - daypart_info.start_minute = current_time - base::Time::kMinutesPerHour; - daypart_info.end_minute = current_time + base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info); + CreativeDaypartInfo daypart_1; + daypart_1.dow = base::NumberToString(exploded.day_of_week); + daypart_1.start_minute = current_time - base::Time::kMinutesPerHour; + daypart_1.end_minute = current_time + base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_1); // Act DaypartExclusionRule exclusion_rule; @@ -67,10 +64,10 @@ TEST_F(BatAdsDaypartExclusionRuleTest, AllowForMultipleDays) { const int current_time = base::Time::kMinutesPerHour * exploded.hour + exploded.minute; - CreativeDaypartInfo daypart_info; - daypart_info.start_minute = current_time - base::Time::kMinutesPerHour; - daypart_info.end_minute = current_time + base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info); + CreativeDaypartInfo daypart_1; + daypart_1.start_minute = current_time - base::Time::kMinutesPerHour; + daypart_1.end_minute = current_time + base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_1); // Act DaypartExclusionRule exclusion_rule; @@ -93,23 +90,23 @@ TEST_F(BatAdsDaypartExclusionRuleTest, AllowIfOneMatchExists) { base::NumberToString((exploded.day_of_week + 1) % 7); const std::string current_dow = base::NumberToString(exploded.day_of_week); - CreativeDaypartInfo daypart_info; - daypart_info.dow = tomorrow_dow; - daypart_info.start_minute = current_time - 2 * base::Time::kMinutesPerHour; - daypart_info.end_minute = current_time - base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info); + CreativeDaypartInfo daypart_1; + daypart_1.dow = tomorrow_dow; + daypart_1.start_minute = current_time - 2 * base::Time::kMinutesPerHour; + daypart_1.end_minute = current_time - base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_1); - CreativeDaypartInfo daypart_info_2; - daypart_info_2.dow = tomorrow_dow; - daypart_info_2.start_minute = current_time + 2 * base::Time::kMinutesPerHour; - daypart_info_2.end_minute = current_time + 3 * base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info_2); + CreativeDaypartInfo daypart_2; + daypart_2.dow = tomorrow_dow; + daypart_2.start_minute = current_time + 2 * base::Time::kMinutesPerHour; + daypart_2.end_minute = current_time + 3 * base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_2); - CreativeDaypartInfo daypart_info_3; - daypart_info_3.dow = current_dow; - daypart_info_3.start_minute = current_time - base::Time::kMinutesPerHour; - daypart_info_3.end_minute = current_time + base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info_3); + CreativeDaypartInfo daypart_3; + daypart_3.dow = current_dow; + daypart_3.start_minute = current_time - base::Time::kMinutesPerHour; + daypart_3.end_minute = current_time + base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_3); // Act DaypartExclusionRule exclusion_rule; @@ -132,23 +129,23 @@ TEST_F(BatAdsDaypartExclusionRuleTest, DisallowIfNoMatches) { base::NumberToString((exploded.day_of_week + 1) % 7); const std::string current_dow = base::NumberToString(exploded.day_of_week); - CreativeDaypartInfo daypart_info; - daypart_info.dow = tomorrow_dow; - daypart_info.start_minute = current_time - 2 * base::Time::kMinutesPerHour; - daypart_info.end_minute = current_time - base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info); + CreativeDaypartInfo daypart_1; + daypart_1.dow = tomorrow_dow; + daypart_1.start_minute = current_time - 2 * base::Time::kMinutesPerHour; + daypart_1.end_minute = current_time - base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_1); - CreativeDaypartInfo daypart_info_2; - daypart_info_2.dow = tomorrow_dow; - daypart_info_2.start_minute = current_time + 2 * base::Time::kMinutesPerHour; - daypart_info_2.end_minute = current_time + 3 * base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info_2); + CreativeDaypartInfo daypart_2; + daypart_2.dow = tomorrow_dow; + daypart_2.start_minute = current_time + 2 * base::Time::kMinutesPerHour; + daypart_2.end_minute = current_time + 3 * base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_2); - CreativeDaypartInfo daypart_info_3; - daypart_info_3.dow = current_dow; - daypart_info_3.start_minute = current_time + base::Time::kMinutesPerHour; - daypart_info_3.end_minute = current_time + 2 * base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info_3); + CreativeDaypartInfo daypart_3; + daypart_3.dow = current_dow; + daypart_3.start_minute = current_time + base::Time::kMinutesPerHour; + daypart_3.end_minute = current_time + 2 * base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_3); // Act DaypartExclusionRule exclusion_rule; @@ -170,11 +167,11 @@ TEST_F(BatAdsDaypartExclusionRuleTest, DisallowIfWrongDay) { const std::string tomorrow_dow = base::NumberToString((exploded.day_of_week + 1) % 7); - CreativeDaypartInfo daypart_info; - daypart_info.dow = tomorrow_dow; - daypart_info.start_minute = current_time - 2 * base::Time::kMinutesPerHour; - daypart_info.end_minute = current_time - base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info); + CreativeDaypartInfo daypart_1; + daypart_1.dow = tomorrow_dow; + daypart_1.start_minute = current_time - 2 * base::Time::kMinutesPerHour; + daypart_1.end_minute = current_time - base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_1); // Act DaypartExclusionRule exclusion_rule; @@ -195,11 +192,11 @@ TEST_F(BatAdsDaypartExclusionRuleTest, DisallowIfWrongHours) { base::Time::kMinutesPerHour * exploded.hour + exploded.minute; const std::string current_dow = base::NumberToString(exploded.day_of_week); - CreativeDaypartInfo daypart_info; - daypart_info.dow = current_dow; - daypart_info.start_minute = current_time - base::Time::kMinutesPerHour; - daypart_info.end_minute = current_time - base::Time::kMinutesPerHour; - creative_ad.dayparts.push_back(daypart_info); + CreativeDaypartInfo daypart_1; + daypart_1.dow = current_dow; + daypart_1.start_minute = current_time - base::Time::kMinutesPerHour; + daypart_1.end_minute = current_time - base::Time::kMinutesPerHour; + creative_ad.dayparts.push_back(daypart_1); // Act DaypartExclusionRule exclusion_rule; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc index 5e663673f436..c29c71ea1de0 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/dislike_exclusion_rule.h" #include "brave/components/brave_ads/core/ad_content_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/deprecated/client/client_state_manager.h" @@ -13,10 +14,6 @@ namespace brave_ads { -namespace { -constexpr char kAdvertiserId[] = "1d3349f6-6713-4324-a135-b377237450a4"; -} // namespace - class BatAdsDislikeExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsDislikeExclusionRuleTest, AllowAd) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc index 4c1894ac73a0..9347012dee93 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_as_inappropriate_exclusion_rule.h" #include "brave/components/brave_ads/core/ad_content_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/deprecated/client/client_state_manager.h" @@ -13,13 +14,6 @@ namespace brave_ads { -namespace { - -constexpr char kCreativeInstanceId[] = "9cf19f6e-25b8-44f1-9050-2a7247185489"; -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; - -} // namespace - class BatAdsMarkedAsInappropriateExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsMarkedAsInappropriateExclusionRuleTest, AllowAd) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_to_no_longer_receive_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_to_no_longer_receive_exclusion_rule_unittest.cc index 57589d544ba7..9e6d59409908 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_to_no_longer_receive_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_to_no_longer_receive_exclusion_rule_unittest.cc @@ -5,6 +5,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/marked_to_no_longer_receive_exclusion_rule.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/deprecated/client/client_state_manager.h" @@ -12,10 +13,6 @@ namespace brave_ads { -namespace { -constexpr char kSegment[] = "segment"; -} // namespace - class BatAdsMarkedToNoLongerReceiveExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsMarkedToNoLongerReceiveExclusionRuleTest, AllowAd) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc index 53f8b1102e72..efc3e66db5a2 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule_unittest.cc @@ -9,6 +9,7 @@ #include "base/test/scoped_feature_list.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rule_features.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -19,8 +20,6 @@ namespace brave_ads::notification_ads { namespace { -constexpr char kCreativeInstanceId[] = "9aea9a47-c6a0-4718-a0fa-706338bb2156"; - constexpr const char* kCampaignIds[] = {"60267cee-d5bb-4a0d-baaf-91cd7f18e07e", "90762cee-d5bb-4a0d-baaf-61cd7f18e07e"}; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc index e4481b77c4ed..b8f5a31ed878 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -13,10 +14,6 @@ namespace brave_ads { -namespace { -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; -} // namespace - class BatAdsPerDayExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsPerDayExclusionRuleTest, AllowAdIfThereIsNoAdsHistory) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc index 42f0b788343f..302960f65588 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -13,10 +14,6 @@ namespace brave_ads { -namespace { -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; -} // namespace - class BatAdsPerMonthExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsPerMonthExclusionRuleTest, AllowAdIfThereIsNoAdsHistory) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc index 68087353b976..d86f2b39165b 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -13,10 +14,6 @@ namespace brave_ads { -namespace { -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; -} // namespace - class BatAdsPerWeekExclusionRuleTest : public UnitTestBase {}; TEST_F(BatAdsPerWeekExclusionRuleTest, AllowAdIfThereIsNoAdsHistory) { diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc index 729fd6a305f8..d10b10ca7902 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/split_test_exclusion_rule_unittest.cc @@ -7,6 +7,7 @@ #include "base/metrics/field_trial.h" #include "base/test/mock_entropy_provider.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" // npm run test -- brave_unit_tests --filter=BatAds* @@ -18,8 +19,6 @@ namespace { constexpr char kTrialName[] = "AdvertiserSplitTestStudy"; constexpr char kGroupName[] = "GroupA"; -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; - scoped_refptr CreateFieldTrial( const std::string& trial_name) { base::MockEntropyProvider entropy_provider(0.9); diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc index d65f55b7a0c7..5caf8e6b9b1a 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule_unittest.cc @@ -9,6 +9,7 @@ #include "base/strings/strcat.h" #include "brave/components/brave_ads/common/pref_names.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_mock_util.h" #include "brave/components/brave_ads/core/internal/geographic/subdivision/subdivision_targeting.h" @@ -21,8 +22,6 @@ namespace brave_ads { namespace { -constexpr char kCreativeSetId[] = "654f10df-fbc4-4a92-8d43-2edf73734a60"; - struct SubdivisionTargetingExclusionRuleTestParam { const char* country; const char* region; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule_unittest.cc index 6bfea874a631..8610486a424e 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule_unittest.cc @@ -9,6 +9,7 @@ #include "base/test/scoped_feature_list.h" #include "brave/components/brave_ads/core/internal/ads/ad_events/ad_event_unittest_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rule_features.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -19,8 +20,6 @@ namespace brave_ads { namespace { -constexpr char kCreativeInstanceId[] = "9aea9a47-c6a0-4718-a0fa-706338bb2156"; - constexpr const char* kCampaignIds[] = {"60267cee-d5bb-4a0d-baaf-91cd7f18e07e", "90762cee-d5bb-4a0d-baaf-61cd7f18e07e"}; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pacing/pacing_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pacing/pacing_unittest.cc index 9f1c4a1a1f9b..43781f94ba64 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pacing/pacing_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pacing/pacing_unittest.cc @@ -27,7 +27,9 @@ std::vector GetPacingRandomNumbers() { TEST(BatAdsPacingTest, PaceCreativeAdsWithMinPassThroughRate) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.ptr = 0.0; creative_ads.push_back(creative_ad); @@ -45,7 +47,9 @@ TEST(BatAdsPacingTest, PaceCreativeAdsWithMinPassThroughRate) { TEST(BatAdsPacingTest, DoNotPaceCreativeAdsWithMaxPassThroughRate) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.ptr = 1.0; creative_ads.push_back(creative_ad); @@ -66,7 +70,9 @@ TEST(BatAdsPacingTest, PaceCreativeAdIfPacingIsGreaterThanOrEqualToPassThroughRate) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.ptr = 0.5; creative_ads.push_back(creative_ad); @@ -83,11 +89,13 @@ TEST(BatAdsPacingTest, DoNotPaceCreativeAdWhenPacingIsLessThanPassThroughRate) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.ptr = 0.1; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.ptr = 0.5; creative_ads.push_back(creative_ad_2); diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v1_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v1_unittest.cc index 5acf9ceed4b5..54242f8e7ed4 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v1_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v1_unittest.cc @@ -45,11 +45,13 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForChildSegment) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "technology & computing-software"; creative_ads.push_back(creative_ad_2); @@ -59,11 +61,12 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForChildSegment) { CreativeInlineContentAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing-software"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + /*interest_segments*/ {"technology & computing-software"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -77,21 +80,21 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForChildSegment) { TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForParentSegment) { // Arrange - CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeInlineContentAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing-software"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + /*interest_segments*/ {"technology & computing-software"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -105,21 +108,20 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForParentSegment) { TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForUntargetedSegment) { // Arrange - CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad.segment = "untargeted"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeInlineContentAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"finance-banking"}, + targeting::BuildUserModel(/*interest_segments*/ {"finance-banking"}, /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), - "200x100", + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -135,15 +137,18 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForMultipleSegments) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "finance-banking"; creative_ads.push_back(creative_ad_2); - CreativeInlineContentAdInfo creative_ad_3 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_3 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ads.push_back(creative_ad_3); @@ -154,11 +159,12 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForMultipleSegments) { creative_ad_3}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + /*interest_segments*/ {"technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -172,17 +178,16 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForMultipleSegments) { TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForNoSegments) { // Arrange - CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad.segment = "untargeted"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeInlineContentAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - {}, "200x100", + /*user_model*/ {}, /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -196,18 +201,18 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetAdsForNoSegments) { TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetAdsForUnmatchedSegments) { // Arrange - CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"UNMATCHED"}, /*latent_interest_segments*/ {}, + targeting::BuildUserModel({/*interest_segments*/ "UNMATCHED"}, + /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), - "200x100", + /*dimensions*/ "200x100", base::BindOnce([](const bool had_opportunity, const CreativeInlineContentAdList& creative_ads) { // Assert @@ -219,19 +224,19 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetAdsForUnmatchedSegments) { TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetAdsForNonExistentDimensions) { // Arrange - CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "?x?", + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "?x?", base::BindOnce([](const bool had_opportunity, const CreativeInlineContentAdList& creative_ads) { // Assert @@ -244,11 +249,13 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetAdsIfAlreadySeen) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ads.push_back(creative_ad_2); @@ -261,11 +268,12 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetAdsIfAlreadySeen) { CreativeInlineContentAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -281,12 +289,14 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetPacedAds) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ad_1.ptr = 0.1; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ad_2.ptr = 0.5; creative_ads.push_back(creative_ad_2); @@ -299,11 +309,12 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, DoNotGetPacedAds) { CreativeInlineContentAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, @@ -319,17 +330,20 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetPrioritizedAds) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ad_1.priority = 1; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "finance-banking"; creative_ad_2.priority = 1; creative_ads.push_back(creative_ad_2); - CreativeInlineContentAdInfo creative_ad_3 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_3 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ad_3.priority = 2; creative_ads.push_back(creative_ad_3); @@ -340,11 +354,12 @@ TEST_F(BatAdsEligibleInlineContentAdsV1Test, GetPrioritizedAds) { CreativeInlineContentAdList expected_creative_ads = {creative_ad_1}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool had_opportunity, diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc index f7ff58df5994..0d8a69db2a9f 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_v2_unittest.cc @@ -40,11 +40,13 @@ TEST_F(BatAdsEligibleInlineContentAdsV2Test, GetAds) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo-bar1"; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar3"; creative_ads.push_back(creative_ad_2); @@ -52,10 +54,11 @@ TEST_F(BatAdsEligibleInlineContentAdsV2Test, GetAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"foo-bar3"}, /*latent_interest_segments*/ {}, + targeting::BuildUserModel({/*interest_segments*/ "foo-bar3"}, + /*latent_interest_segments*/ {}, {"foo-bar1", "foo-bar2"}, /*text_embedding_html_events*/ {}), - "200x100", + /*dimensions*/ "200x100", base::BindOnce([](const bool had_opportunity, const CreativeInlineContentAdList& creative_ads) { // Assert @@ -68,11 +71,13 @@ TEST_F(BatAdsEligibleInlineContentAdsV2Test, GetAdsForNoSegments) { // Arrange CreativeInlineContentAdList creative_ads; - CreativeInlineContentAdInfo creative_ad_1 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo"; creative_ads.push_back(creative_ad_1); - CreativeInlineContentAdInfo creative_ad_2 = BuildCreativeInlineContentAd(); + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar"; creative_ads.push_back(creative_ad_2); @@ -84,7 +89,7 @@ TEST_F(BatAdsEligibleInlineContentAdsV2Test, GetAdsForNoSegments) { /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), - "200x100", + /*dimensions*/ "200x100", base::BindOnce([](const bool had_opportunity, const CreativeInlineContentAdList& creative_ads) { // Assert @@ -99,11 +104,11 @@ TEST_F(BatAdsEligibleInlineContentAdsV2Test, // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"interest-foo", "interest-bar"}, - /*latent_interest_segments*/ {}, - {"intent-foo", "intent-bar"}, - /*text_embedding_html_events*/ {}), - "?x?", + targeting::BuildUserModel( + {/*interest_segments*/ "interest-foo", "interest-bar"}, + /*latent_interest_segments*/ {}, {"intent-foo", "intent-bar"}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "?x?", base::BindOnce([](const bool had_opportunity, const CreativeInlineContentAdList& creative_ads) { // Assert @@ -117,11 +122,11 @@ TEST_F(BatAdsEligibleInlineContentAdsV2Test, DoNotGetAdsIfNoEligibleAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"interest-foo", "interest-bar"}, - /*latent_interest_segments*/ {}, - {"intent-foo", "intent-bar"}, - /*text_embedding_html_events*/ {}), - "200x100", + targeting::BuildUserModel( + {/*interest_segments*/ "interest-foo", "interest-bar"}, + /*latent_interest_segments*/ {}, {"intent-foo", "intent-bar"}, + /*text_embedding_html_events*/ {}), + /*dimensions*/ "200x100", base::BindOnce([](const bool had_opportunity, const CreativeInlineContentAdList& creative_ads) { // Assert diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v1_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v1_unittest.cc index 8099ae87a6ce..e1bebf829c07 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v1_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v1_unittest.cc @@ -45,11 +45,13 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForChildSegment) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "technology & computing-software"; creative_ads.push_back(creative_ad_2); @@ -59,10 +61,11 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForChildSegment) { CreativeNewTabPageAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing-software"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing-software"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool had_opportunity, @@ -76,20 +79,20 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForChildSegment) { TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForParentSegment) { // Arrange - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeNewTabPageAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing-software"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing-software"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool had_opportunity, @@ -103,17 +106,16 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForParentSegment) { TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForUntargetedSegment) { // Arrange - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad.segment = "untargeted"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeNewTabPageAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"finance-banking"}, + targeting::BuildUserModel({/*interest_segments*/ "finance-banking"}, /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), @@ -132,15 +134,18 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForMultipleSegments) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "finance-banking"; creative_ads.push_back(creative_ad_2); - CreativeNewTabPageAdInfo creative_ad_3 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_3 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ads.push_back(creative_ad_3); @@ -151,10 +156,11 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForMultipleSegments) { creative_ad_3}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool had_opportunity, @@ -168,38 +174,38 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForMultipleSegments) { TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetAdsForNoSegments) { // Arrange - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad.segment = "untargeted"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeNewTabPageAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - {}, base::BindOnce( - [](const CreativeNewTabPageAdList& expected_creative_ads, - const bool had_opportunity, - const CreativeNewTabPageAdList& creative_ads) { - // Assert - EXPECT_TRUE(had_opportunity); - EXPECT_EQ(expected_creative_ads, creative_ads); - }, - std::move(expected_creative_ads))); + /*user_model*/ {}, + base::BindOnce( + [](const CreativeNewTabPageAdList& expected_creative_ads, + const bool had_opportunity, + const CreativeNewTabPageAdList& creative_ads) { + // Assert + EXPECT_TRUE(had_opportunity); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsEligibleNewTabPageAdsV1Test, DoNotGetAdsForUnmatchedSegments) { // Arrange - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"UNMATCHED"}, /*latent_interest_segments*/ {}, + targeting::BuildUserModel({/*interest_segments*/ "UNMATCHED"}, + /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, @@ -215,10 +221,11 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, DoNotGetAdsIfNoEligibleAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, const CreativeNewTabPageAdList& creative_ads) { // Assert @@ -231,11 +238,13 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, DoNotGetAdsIfAlreadySeen) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ads.push_back(creative_ad_2); @@ -248,10 +257,11 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, DoNotGetAdsIfAlreadySeen) { CreativeNewTabPageAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool had_opportunity, @@ -267,12 +277,14 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, DoNotGetPacedAds) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ad_1.ptr = 0.1; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ad_2.ptr = 0.5; creative_ads.push_back(creative_ad_2); @@ -285,10 +297,11 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, DoNotGetPacedAds) { CreativeNewTabPageAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool had_opportunity, @@ -304,17 +317,20 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetPrioritizedAds) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ad_1.priority = 1; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "finance-banking"; creative_ad_2.priority = 1; creative_ads.push_back(creative_ad_2); - CreativeNewTabPageAdInfo creative_ad_3 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_3 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ad_3.priority = 2; creative_ads.push_back(creative_ad_3); @@ -325,10 +341,11 @@ TEST_F(BatAdsEligibleNewTabPageAdsV1Test, GetPrioritizedAds) { CreativeNewTabPageAdList expected_creative_ads = {creative_ad_1}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool had_opportunity, diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc index d283a0aaf147..e1e8115f4171 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_v2_unittest.cc @@ -40,11 +40,13 @@ TEST_F(BatAdsEligibleNewTabPageAdsV2Test, GetAds) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo-bar1"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar3"; creative_ads.push_back(creative_ad_2); @@ -52,7 +54,8 @@ TEST_F(BatAdsEligibleNewTabPageAdsV2Test, GetAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"foo-bar3"}, /*latent_interest_segments*/ {}, + targeting::BuildUserModel({/*interest_segments*/ "foo-bar3"}, + /*latent_interest_segments*/ {}, {"foo-bar1", "foo-bar2"}, /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, @@ -67,11 +70,13 @@ TEST_F(BatAdsEligibleNewTabPageAdsV2Test, GetAdsForNoSegments) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar"; creative_ads.push_back(creative_ad_2); @@ -96,10 +101,10 @@ TEST_F(BatAdsEligibleNewTabPageAdsV2Test, DoNotGetAdsIfNoEligibleAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"interest-foo", "interest-bar"}, - /*latent_interest_segments*/ {}, - {"intent-foo", "intent-bar"}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "interest-foo", "interest-bar"}, + /*latent_interest_segments*/ {}, {"intent-foo", "intent-bar"}, + /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, const CreativeNewTabPageAdList& creative_ads) { // Assert diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_issue_17199_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_issue_17199_unittest.cc index 1f59237a4bde..62b89abe9fee 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_issue_17199_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_issue_17199_unittest.cc @@ -40,10 +40,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Issue17199Test, GetEligibleAds) { EligibleAdsV1 eligible_ads(&subdivision_targeting, &anti_targeting_resource); eligible_ads.GetForUserModel( - targeting::BuildUserModel({"technology & computing-computing"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing-computing"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, const CreativeNotificationAdList& creative_ads) { EXPECT_TRUE(had_opportunity); diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_unittest.cc index 972473234ea9..35b1aca44ac3 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v1_unittest.cc @@ -45,11 +45,13 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForChildSegment) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "technology & computing-software"; creative_ads.push_back(creative_ad_2); @@ -59,10 +61,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForChildSegment) { CreativeNotificationAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing-software"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing-software"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool had_opportunity, @@ -76,20 +79,20 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForChildSegment) { TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForParentSegment) { // Arrange - CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeNotificationAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing-software"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing-software"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool had_opportunity, @@ -103,17 +106,16 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForParentSegment) { TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForUntargetedSegment) { // Arrange - CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.segment = "untargeted"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeNotificationAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"finance-banking"}, + targeting::BuildUserModel({/*interest_segments*/ "finance-banking"}, /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), @@ -132,15 +134,18 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForMultipleSegments) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "finance-banking"; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ads.push_back(creative_ad_3); @@ -151,10 +156,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForMultipleSegments) { creative_ad_3}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool had_opportunity, @@ -168,38 +174,38 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForMultipleSegments) { TEST_F(BatAdsEligibleNotificationAdsV1Test, GetAdsForNoSegments) { // Arrange - CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.segment = "untargeted"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act CreativeNotificationAdList expected_creative_ads = {creative_ad}; eligible_ads_->GetForUserModel( - {}, base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool had_opportunity, - const CreativeNotificationAdList& creative_ads) { - // Assert - EXPECT_TRUE(had_opportunity); - EXPECT_EQ(expected_creative_ads, creative_ads); - }, - std::move(expected_creative_ads))); + /*user_model*/ {}, + base::BindOnce( + [](const CreativeNotificationAdList& expected_creative_ads, + const bool had_opportunity, + const CreativeNotificationAdList& creative_ads) { + // Assert + EXPECT_TRUE(had_opportunity); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsEligibleNotificationAdsV1Test, DoNotGetAdsForUnmatchedSegments) { // Arrange - CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.segment = "technology & computing"; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"UNMATCHED"}, /*latent_interest_segments*/ {}, + targeting::BuildUserModel({/*interest_segments*/ "UNMATCHED"}, + /*latent_interest_segments*/ {}, /*purchase_intent_segments*/ {}, /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, @@ -215,10 +221,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, DoNotGetAdsIfNoEligibleAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, const CreativeNotificationAdList& creative_ads) { // Assert @@ -231,11 +238,13 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, DoNotGetAdsIfAlreadySeen) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ads.push_back(creative_ad_2); @@ -248,10 +257,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, DoNotGetAdsIfAlreadySeen) { CreativeNotificationAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool had_opportunity, @@ -267,12 +277,14 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, DoNotGetPacedAds) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ad_1.ptr = 0.1; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ad_2.ptr = 0.5; creative_ads.push_back(creative_ad_2); @@ -285,10 +297,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, DoNotGetPacedAds) { CreativeNotificationAdList expected_creative_ads = {creative_ad_2}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool had_opportunity, @@ -304,17 +317,20 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetPrioritizedAds) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing"; creative_ad_1.priority = 1; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "finance-banking"; creative_ad_2.priority = 1; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ad_3.priority = 2; creative_ads.push_back(creative_ad_3); @@ -325,10 +341,11 @@ TEST_F(BatAdsEligibleNotificationAdsV1Test, GetPrioritizedAds) { CreativeNotificationAdList expected_creative_ads = {creative_ad_1}; eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"technology & computing", "food & drink"}, - /*latent_interest_segments*/ {}, - /*purchase_intent_segments*/ {}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "technology & computing", "food & drink"}, + /*latent_interest_segments*/ {}, + /*purchase_intent_segments*/ {}, + /*text_embedding_html_events*/ {}), base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool had_opportunity, diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc index 397c2a5ddecd..c134ac10f13a 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v2_unittest.cc @@ -40,11 +40,13 @@ TEST_F(BatAdsEligibleNotificationAdsV2Test, GetAds) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo-bar1"; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar3"; creative_ads.push_back(creative_ad_2); @@ -52,7 +54,8 @@ TEST_F(BatAdsEligibleNotificationAdsV2Test, GetAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"foo-bar3"}, /*latent_interest_segments*/ {}, + targeting::BuildUserModel({/*interest_segments*/ "foo-bar3"}, + /*latent_interest_segments*/ {}, {"foo-bar1", "foo-bar2"}, /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, @@ -67,11 +70,13 @@ TEST_F(BatAdsEligibleNotificationAdsV2Test, GetAdsForNoSegments) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "foo"; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "foo-bar"; creative_ads.push_back(creative_ad_2); @@ -96,10 +101,10 @@ TEST_F(BatAdsEligibleNotificationAdsV2Test, DoNotGetAdsIfNoEligibleAds) { // Act eligible_ads_->GetForUserModel( - targeting::BuildUserModel({"interest-foo", "interest-bar"}, - /*latent_interest_segments*/ {}, - {"intent-foo", "intent-bar"}, - /*text_embedding_html_events*/ {}), + targeting::BuildUserModel( + {/*interest_segments*/ "interest-foo", "interest-bar"}, + /*latent_interest_segments*/ {}, {"intent-foo", "intent-bar"}, + /*text_embedding_html_events*/ {}), base::BindOnce([](const bool had_opportunity, const CreativeNotificationAdList& creative_ads) { // Assert diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v3_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v3_unittest.cc index e4117efd94c5..a59ddd68a816 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v3_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_v3_unittest.cc @@ -48,11 +48,13 @@ TEST_F(BatAdsEligibleNotificationAdsV3Test, GetAds) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.embedding = {0.1, 0.2, 0.3}; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.embedding = {-0.3, 0.0, -0.2}; creative_ads.push_back(creative_ad_2); @@ -83,11 +85,13 @@ TEST_F(BatAdsEligibleNotificationAdsV3Test, GetAdsForNoStoredTextEmbeddings) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.embedding = {0.1, 0.2, 0.3, 0.4, 0.5}; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.embedding = {-0.3, 0.0, -0.2, 0.6, 0.8}; creative_ads.push_back(creative_ad_2); @@ -121,16 +125,8 @@ TEST_F(BatAdsEligibleNotificationAdsV3Test, scoped_feature_list.InitWithFeaturesAndParameters(enabled_features, disabled_features); - CreativeNotificationAdList creative_ads; - - const CreativeNotificationAdInfo creative_ad_1 = - BuildCreativeNotificationAd(); - creative_ads.push_back(creative_ad_1); - - const CreativeNotificationAdInfo creative_ad_2 = - BuildCreativeNotificationAd(); - creative_ads.push_back(creative_ad_2); - + const CreativeNotificationAdList creative_ads = + BuildCreativeNotificationAds(/*count*/ 2); SaveCreativeAds(creative_ads); const TextEmbeddingHtmlEventInfo text_embedding_event = diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/priority/priority_unittest.cc b/components/brave_ads/core/internal/ads/serving/eligible_ads/priority/priority_unittest.cc index 08d1b75e3ea7..0329e6f7d7c3 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/priority/priority_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/priority/priority_unittest.cc @@ -29,7 +29,9 @@ TEST(BatAdsPriorityTest, PrioritizeNoCreativeAds) { TEST(BatAdsPriorityTest, PrioritizeSingleCreativeAd) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + + CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad.priority = 1; creative_ads.push_back(creative_ad); @@ -47,15 +49,18 @@ TEST(BatAdsPriorityTest, PrioritizeMultipleCreativeAds) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.priority = 1; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.priority = 2; creative_ads.push_back(creative_ad_2); - CreativeNotificationAdInfo creative_ad_3 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_3.priority = 1; creative_ads.push_back(creative_ad_3); @@ -74,11 +79,13 @@ TEST(BatAdsPriorityTest, DoNotPrioritizeZeroPriorityCreativeAds) { // Arrange CreativeNotificationAdList creative_ads; - CreativeNotificationAdInfo creative_ad_1 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_1.priority = 1; creative_ads.push_back(creative_ad_1); - CreativeNotificationAdInfo creative_ad_2 = BuildCreativeNotificationAd(); + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); creative_ad_2.priority = 0; creative_ads.push_back(creative_ad_2); diff --git a/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving_unittest.cc b/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving_unittest.cc index 109f98c9f9cf..a5bd6dac3651 100644 --- a/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving_unittest.cc @@ -102,11 +102,9 @@ TEST_F(BatAdsInlineContentAdServingTest, ServeAd) { // Arrange ForcePermissionRulesForTesting(); - CreativeInlineContentAdList creative_ads; const CreativeInlineContentAdInfo creative_ad = - BuildCreativeInlineContentAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd( @@ -128,11 +126,9 @@ TEST_F(BatAdsInlineContentAdServingTest, DoNotServeAdForNonExistentDimensions) { // Arrange ForcePermissionRulesForTesting(); - CreativeInlineContentAdList creative_ads; const CreativeInlineContentAdInfo creative_ad = - BuildCreativeInlineContentAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd( @@ -154,11 +150,9 @@ TEST_F(BatAdsInlineContentAdServingTest, DoNotServeAdForNonExistentDimensions) { TEST_F(BatAdsInlineContentAdServingTest, DoNotServeAdIfNotAllowedDueToPermissionRules) { // Arrange - CreativeInlineContentAdList creative_ads; const CreativeInlineContentAdInfo creative_ad = - BuildCreativeInlineContentAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd( diff --git a/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving_unittest.cc b/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving_unittest.cc index d658aad007c2..41d2a4a953fa 100644 --- a/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving_unittest.cc @@ -101,10 +101,9 @@ TEST_F(BatAdsNewTabPageAdServingTest, ServeAd) { // Arrange ForcePermissionRulesForTesting(); - CreativeNewTabPageAdList creative_ads; - const CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + const CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd(base::BindOnce( @@ -124,11 +123,10 @@ TEST_F(BatAdsNewTabPageAdServingTest, DoNotServeAdIfMissingWallpapers) { // Arrange ForcePermissionRulesForTesting(); - CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad.wallpapers = {}; - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd(base::BindOnce( @@ -163,10 +161,9 @@ TEST_F(BatAdsNewTabPageAdServingTest, DoNotServeAdIfNoEligibleAdsFound) { TEST_F(BatAdsNewTabPageAdServingTest, DoNotServeAdIfNotAllowedDueToPermissionRules) { // Arrange - CreativeNewTabPageAdList creative_ads; - const CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + const CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd(base::BindOnce( diff --git a/components/brave_ads/core/internal/ads/serving/notification_ad_serving_unittest.cc b/components/brave_ads/core/internal/ads/serving/notification_ad_serving_unittest.cc index 8152c1e4ae53..1424414817b6 100644 --- a/components/brave_ads/core/internal/ads/serving/notification_ad_serving_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/notification_ad_serving_unittest.cc @@ -83,10 +83,9 @@ TEST_F(BatAdsNotificationAdServingTest, ServeAd) { // Arrange ForcePermissionRulesForTesting(); - CreativeNotificationAdList creative_ads; - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd(); @@ -117,10 +116,9 @@ TEST_F(BatAdsNotificationAdServingTest, DoNotServeAdIfNoEligibleAdsFound) { TEST_F(BatAdsNotificationAdServingTest, DoNotServeAdIfNotAllowedDueToPermissionRules) { // Arrange - CreativeNotificationAdList creative_ads; - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); - creative_ads.push_back(creative_ad); - SaveCreativeAds(creative_ads); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + SaveCreativeAds({creative_ad}); // Act serving_->MaybeServeAd(); diff --git a/components/brave_ads/core/internal/ads/serving/targeting/behavioral/multi_armed_bandits/epsilon_greedy_bandit_model_unittest.cc b/components/brave_ads/core/internal/ads/serving/targeting/behavioral/multi_armed_bandits/epsilon_greedy_bandit_model_unittest.cc index f0f7d82c92a9..e19827a5230a 100644 --- a/components/brave_ads/core/internal/ads/serving/targeting/behavioral/multi_armed_bandits/epsilon_greedy_bandit_model_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/targeting/behavioral/multi_armed_bandits/epsilon_greedy_bandit_model_unittest.cc @@ -149,8 +149,9 @@ TEST_F(BatAdsEpsilonGreedyBanditModelTest, GetSegmentsForExploitation) { processor::EpsilonGreedyBandit::Process( {segment_3, mojom::NotificationAdEventType::kClicked}); - // Act const EpsilonGreedyBandit model; + + // Act const SegmentList segments = model.GetSegments(); // Assert @@ -202,13 +203,13 @@ TEST_F(BatAdsEpsilonGreedyBanditModelTest, GetSegmentsForEligibleSegments) { processor::EpsilonGreedyBandit::Process( {segment_3, mojom::NotificationAdEventType::kClicked}); - // Act const EpsilonGreedyBandit model; + + // Act const SegmentList segments = model.GetSegments(); // Assert const SegmentList expected_segments = {"science", "technology & computing"}; - EXPECT_EQ(expected_segments, segments); } diff --git a/components/brave_ads/core/internal/ads/serving/targeting/behavioral/purchase_intent/purchase_intent_model_unittest.cc b/components/brave_ads/core/internal/ads/serving/targeting/behavioral/purchase_intent/purchase_intent_model_unittest.cc index 005c67922b60..deb4eeda43df 100644 --- a/components/brave_ads/core/internal/ads/serving/targeting/behavioral/purchase_intent/purchase_intent_model_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/targeting/behavioral/purchase_intent/purchase_intent_model_unittest.cc @@ -24,14 +24,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, DoNotGetSegmentsForUnitializedResource) { const GURL url = GURL("https://www.brave.com/test?foo=bar"); processor.Process(url); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsPurchaseIntentModelTest, DoNotGetSegmentsForExpiredSignals) { @@ -50,14 +49,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, DoNotGetSegmentsForExpiredSignals) { const GURL url_2 = GURL("https://www.basicattentiontoken.org/test?bar=foo"); processor.Process(url_2); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsPurchaseIntentModelTest, DoNotGetSegmentsIfNeverProcessed) { @@ -66,14 +64,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, DoNotGetSegmentsIfNeverProcessed) { resource.Load(); task_environment_.RunUntilIdle(); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsPurchaseIntentModelTest, @@ -88,14 +85,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, const GURL url = GURL("https://duckduckgo.com/?q=segment+keyword+1"); processor.Process(url); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsPurchaseIntentModelTest, GetSegmentsForPreviouslyMatchedSite) { @@ -114,13 +110,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, GetSegmentsForPreviouslyMatchedSite) { processor.Process(url_1); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert const SegmentList expected_segments = {"segment 3", "segment 2"}; - EXPECT_EQ(expected_segments, segments); } @@ -138,13 +134,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, processor.Process(url); processor.Process(url); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert const SegmentList expected_segments = {"segment 1"}; - EXPECT_EQ(expected_segments, segments); } @@ -161,13 +157,13 @@ TEST_F(BatAdsPurchaseIntentModelTest, GURL("https://duckduckgo.com/?q=segment+keyword+1+funnel+keyword+2"); processor.Process(url); - // Act const PurchaseIntent model; + + // Act const SegmentList segments = model.GetSegments(); // Assert const SegmentList expected_segments = {"segment 1"}; - EXPECT_EQ(expected_segments, segments); } diff --git a/components/brave_ads/core/internal/ads/serving/targeting/contextual/text_classification/text_classification_model_unittest.cc b/components/brave_ads/core/internal/ads/serving/targeting/contextual/text_classification/text_classification_model_unittest.cc index ab1939335788..3c8285121840 100644 --- a/components/brave_ads/core/internal/ads/serving/targeting/contextual/text_classification/text_classification_model_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/targeting/contextual/text_classification/text_classification_model_unittest.cc @@ -37,39 +37,40 @@ TEST_F(BatAdsTextClassificationModelTest, processor::TextClassification processor(&uninitialized_resource); processor.Process(text); - // Act const TextClassification model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsTextClassificationModelTest, DoNotGetSegmentsForEmptyText) { + // Arrange const std::string text; processor::TextClassification processor(&resource_); processor.Process(text); - // Act const TextClassification model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsTextClassificationModelTest, GetSegmentsForPreviouslyClassifiedText) { + // Arrange const std::string text = "Some content about technology & computing"; processor::TextClassification processor(&resource_); processor.Process(text); - // Act const TextClassification model; + + // Act const SegmentList segments = model.GetSegments(); // Assert @@ -136,6 +137,7 @@ TEST_F(BatAdsTextClassificationModelTest, TEST_F(BatAdsTextClassificationModelTest, GetSegmentsForPreviouslyClassifiedTexts) { + // Arrange const std::vector texts = { "Some content about cooking food", "Some content about finance & banking", "Some content about technology & computing"}; @@ -145,8 +147,9 @@ TEST_F(BatAdsTextClassificationModelTest, processor.Process(text); } - // Act const TextClassification model; + + // Act const SegmentList segments = model.GetSegments(); // Assert @@ -253,14 +256,14 @@ TEST_F(BatAdsTextClassificationModelTest, } TEST_F(BatAdsTextClassificationModelTest, DoNotGetSegmentsIfNeverProcessed) { - // Act + // Arrange const TextClassification model; + + // Act const SegmentList segments = model.GetSegments(); // Assert - const SegmentList expected_segments; - - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } } // namespace brave_ads::targeting::model diff --git a/components/brave_ads/core/internal/ads/serving/targeting/top_segments_unittest.cc b/components/brave_ads/core/internal/ads/serving/targeting/top_segments_unittest.cc index 0dfdf4e90987..e77cd8442eb2 100644 --- a/components/brave_ads/core/internal/ads/serving/targeting/top_segments_unittest.cc +++ b/components/brave_ads/core/internal/ads/serving/targeting/top_segments_unittest.cc @@ -215,22 +215,22 @@ TEST_P(BatAdsTopSegmentsTest, GetSegments) { } static std::string GetTestCaseName( - ::testing::TestParamInfo param_info) { + ::testing::TestParamInfo test_param) { const std::string epsilon_greedy_bandits_enabled = - param_info.param.epsilon_greedy_bandits_enabled + test_param.param.epsilon_greedy_bandits_enabled ? "EpsilonGreedyBanditEnabledAnd" : ""; const std::string purchase_intent_enabled = - param_info.param.purchase_intent_enabled ? "PurchaseIntentEnabledAnd" + test_param.param.purchase_intent_enabled ? "PurchaseIntentEnabledAnd" : ""; const std::string text_classification_enabled = - param_info.param.text_classification_enabled + test_param.param.text_classification_enabled ? "TextClassificationEnabledAnd" : ""; - const std::string previously_processed = param_info.param.previously_processed + const std::string previously_processed = test_param.param.previously_processed ? "PreviouslyProcessed" : "NeverProcessed"; diff --git a/components/brave_ads/core/internal/catalog/catalog_json_reader_unittest.cc b/components/brave_ads/core/internal/catalog/catalog_json_reader_unittest.cc index f3bcb5046729..1f8978b49c6f 100644 --- a/components/brave_ads/core/internal/catalog/catalog_json_reader_unittest.cc +++ b/components/brave_ads/core/internal/catalog/catalog_json_reader_unittest.cc @@ -20,6 +20,7 @@ #include "brave/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_creative_notification_ad_info.h" #include "brave/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_creative_promoted_content_ad_info.h" #include "brave/components/brave_ads/core/internal/catalog/catalog_info.h" +#include "brave/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_file_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -148,7 +149,7 @@ CatalogCampaignInfo BuildCatalogCampaign1() { CatalogCreativeInlineContentAdInfo catalog_creative_inline_content_ad; catalog_creative_inline_content_ad.creative_instance_id = - "30db5f7b-dba3-48a3-b299-c9bd9c67da65"; + "b0615969-6ee0-4559-b50c-f84be23302e4"; CatalogTypeInfo catalog_type_inline_content_ad_type; catalog_type_inline_content_ad_type.code = "inline_content_all_v1"; catalog_type_inline_content_ad_type.name = "inline_content"; @@ -451,7 +452,7 @@ TEST_F(BatAdsCatalogJsonReaderTest, ParseCatalogWithSingleCampaign) { // Assert CatalogInfo expected_catalog; - expected_catalog.id = "29e5c8bc0ba319069980bb390d8e8f9b58c05a20"; + expected_catalog.id = kCatalogId; expected_catalog.version = 9; expected_catalog.ping = base::Milliseconds(7'200'000); expected_catalog.campaigns.push_back(BuildCatalogCampaign1()); @@ -471,7 +472,7 @@ TEST_F(BatAdsCatalogJsonReaderTest, ParseCatalogWithMultipleCampaigns) { // Assert CatalogInfo expected_catalog; - expected_catalog.id = "29e5c8bc0ba319069980bb390d8e8f9b58c05a20"; + expected_catalog.id = kCatalogId; expected_catalog.version = 9; expected_catalog.ping = base::Milliseconds(7'200'000); expected_catalog.campaigns.push_back(BuildCatalogCampaign1()); @@ -492,7 +493,7 @@ TEST_F(BatAdsCatalogJsonReaderTest, ParseEmptyCatalog) { // Assert CatalogInfo expected_catalog; - expected_catalog.id = "29e5c8bc0ba319069980bb390d8e8f9b58c05a20"; + expected_catalog.id = kCatalogId; expected_catalog.version = 9; expected_catalog.ping = base::Milliseconds(7'200'000); diff --git a/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h b/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h new file mode 100644 index 000000000000..adf231f734f1 --- /dev/null +++ b/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h @@ -0,0 +1,15 @@ +/* Copyright (c) 2020 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CATALOG_CATALOG_UNITTEST_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CATALOG_CATALOG_UNITTEST_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kCatalogId[] = "29e5c8bc0ba319069980bb390d8e8f9b58c05a20"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CATALOG_CATALOG_UNITTEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc b/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc index 93e60a7593ac..80d26f37f6b8 100644 --- a/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc +++ b/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/catalog/catalog_util.h" #include "brave/components/brave_ads/common/pref_names.h" +#include "brave/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -57,7 +58,7 @@ TEST_F(BatAdsCatalogUtilTest, CatalogDoesNotExist) { TEST_F(BatAdsCatalogUtilTest, CatalogHasChanged) { // Arrange - SetCatalogId("29e5c8bc0ba319069980bb390d8e8f9b58c05a20"); + SetCatalogId(kCatalogId); // Act @@ -69,13 +70,12 @@ TEST_F(BatAdsCatalogUtilTest, CatalogHasChanged) { TEST_F(BatAdsCatalogUtilTest, CatalogHasNotChanged) { // Arrange - SetCatalogId("29e5c8bc0ba319069980bb390d8e8f9b58c05a20"); + SetCatalogId(kCatalogId); // Act // Assert - const bool has_changed = - HasCatalogChanged("29e5c8bc0ba319069980bb390d8e8f9b58c05a20"); + const bool has_changed = HasCatalogChanged(kCatalogId); EXPECT_FALSE(has_changed); } diff --git a/components/brave_ads/core/internal/common/calendar/calendar_util_unittest.cc b/components/brave_ads/core/internal/common/calendar/calendar_util_unittest.cc index c9828026a2dd..2824ed0132d8 100644 --- a/components/brave_ads/core/internal/common/calendar/calendar_util_unittest.cc +++ b/components/brave_ads/core/internal/common/calendar/calendar_util_unittest.cc @@ -57,8 +57,7 @@ TEST(BatAdsCalendarUtilTest, GetDayOfWeekForYearMonthAndDay) { const int day_of_week = GetDayOfWeek(year, month, day); // Assert - const int expected_day_of_week = 6; // Saturday - EXPECT_EQ(expected_day_of_week, day_of_week); + EXPECT_EQ(6, day_of_week); } TEST(BatAdsCalendarUtilTest, GetDayOfWeek) { @@ -70,8 +69,7 @@ TEST(BatAdsCalendarUtilTest, GetDayOfWeek) { const int day_of_week = GetDayOfWeek(time, /*is_local*/ false); // Assert - const int expected_day_of_week = 3; // Wednesday - EXPECT_EQ(expected_day_of_week, day_of_week); + EXPECT_EQ(3, day_of_week); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc b/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc index 1b4bf0a9cb13..c15ddd013b15 100644 --- a/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc +++ b/components/brave_ads/core/internal/common/crypto/crypto_util_unittest.cc @@ -32,7 +32,6 @@ TEST(BatAdsCryptoUtilTest, Sha256) { // Assert const std::string expected_sha256_base64 = "16j7swfXgJRpypq8sAguT41WUeRtPNt2LQLQvzfJ5ZI="; - EXPECT_EQ(expected_sha256_base64, base::Base64Encode(sha256)); } diff --git a/components/brave_ads/core/internal/common/database/database_bind_util.cc b/components/brave_ads/core/internal/common/database/database_bind_util.cc index bebfb5ea7572..20871fd9ce20 100644 --- a/components/brave_ads/core/internal/common/database/database_bind_util.cc +++ b/components/brave_ads/core/internal/common/database/database_bind_util.cc @@ -16,7 +16,7 @@ namespace brave_ads::database { std::string BuildBindingParameterPlaceholder(const size_t parameters_count) { - DCHECK_NE(0UL, parameters_count); + DCHECK_NE(0U, parameters_count); const std::vector placeholders(parameters_count, "?"); @@ -26,7 +26,7 @@ std::string BuildBindingParameterPlaceholder(const size_t parameters_count) { std::string BuildBindingParameterPlaceholders(const size_t parameters_count, const size_t values_count) { - DCHECK_NE(0UL, values_count); + DCHECK_NE(0U, values_count); std::string value = BuildBindingParameterPlaceholder(parameters_count); if (values_count == 1) { diff --git a/components/brave_ads/core/internal/common/locale/subdivision_code_util.cc b/components/brave_ads/core/internal/common/locale/subdivision_code_util.cc index 0c8bb4904072..2dcc02c8bc76 100644 --- a/components/brave_ads/core/internal/common/locale/subdivision_code_util.cc +++ b/components/brave_ads/core/internal/common/locale/subdivision_code_util.cc @@ -16,7 +16,7 @@ std::string GetCountryCode(const std::string& code) { const std::vector components = base::SplitString(code, "-", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); - DCHECK_EQ(2UL, components.size()); + DCHECK_EQ(2U, components.size()); return components.front(); } @@ -25,7 +25,7 @@ std::string GetSubdivisionCode(const std::string& code) { const std::vector components = base::SplitString(code, "-", base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); - DCHECK_EQ(2UL, components.size()); + DCHECK_EQ(2U, components.size()); return components.back(); } diff --git a/components/brave_ads/core/internal/common/strings/string_html_parser_util_unittest.cc b/components/brave_ads/core/internal/common/strings/string_html_parser_util_unittest.cc index 218952f4f5ae..8c477a6d86e9 100644 --- a/components/brave_ads/core/internal/common/strings/string_html_parser_util_unittest.cc +++ b/components/brave_ads/core/internal/common/strings/string_html_parser_util_unittest.cc @@ -66,6 +66,7 @@ TEST_F(BatAdsStringHtmlParserUtilTest, ParseHtmlTagAttributeSimple) { // Act const std::string html_tag_attribute = ParseHtmlTagAttribute(html, tag_substr, tag_attribute); + // Assert EXPECT_EQ(expected_html_tag_attribute, html_tag_attribute); } diff --git a/components/brave_ads/core/internal/common/unittest/unittest_base.cc b/components/brave_ads/core/internal/common/unittest/unittest_base.cc index bc2219564a78..b3cca0468dfd 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_base.cc +++ b/components/brave_ads/core/internal/common/unittest/unittest_base.cc @@ -13,6 +13,7 @@ #include "brave/components/brave_ads/common/pref_names.h" #include "brave/components/brave_ads/core/ads_client_notifier_observer.h" #include "brave/components/brave_ads/core/database.h" +#include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h" #include "brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_command_line_switch_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_constants.h" @@ -333,8 +334,7 @@ void UnitTestBase::SetUpIntegrationTest() { ads_ = std::make_unique(ads_client_mock_.get()); - ads_->OnRewardsWalletDidChange(GetWalletPaymentIdForTesting(), // IN-TEST - GetWalletRecoverySeedForTesting()); // IN-TEST + ads_->OnRewardsWalletDidChange(kWalletPaymentId, kWalletRecoverySeed); ads_->Initialize( base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); diff --git a/components/brave_ads/core/internal/common/unittest/unittest_base.h b/components/brave_ads/core/internal/common/unittest/unittest_base.h index 3ea1cb90e426..9bbed7f51dab 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_base.h +++ b/components/brave_ads/core/internal/common/unittest/unittest_base.h @@ -123,8 +123,8 @@ class UnitTestBase : public AdsClientNotifier, public testing::Test { bool HasPendingTasks() const; // Unlike |FastForwardClockToNextPendingTask|, |FastForwardClockTo| and - // |FastForwardClockBy| AdvanceClock does not run tasks. See |TaskEnvironment| - // for more detail. + // |FastForwardClockBy|, AdvanceClock does not run tasks. See + // |TaskEnvironment| for more detail. void AdvanceClockBy(base::TimeDelta time_delta); void AdvanceClockTo(base::Time time); void AdvanceClockToMidnight(bool is_local); diff --git a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_search_url_host_unittest.cc b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_search_url_host_unittest.cc index 7cb0c0047fdb..6048e5f14184 100644 --- a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_search_url_host_unittest.cc +++ b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_search_url_host_unittest.cc @@ -20,12 +20,10 @@ TEST_F(BatAdsAnonymousSearchUrlHostTest, GetProductionUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetAnonymousSearchUrlHost(); // Assert - const std::string expected_url_host = - "https://search.anonymous.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://search.anonymous.ads.brave.com", + GetAnonymousSearchUrlHost()); } TEST_F(BatAdsAnonymousSearchUrlHostTest, GetStagingUrlHost) { @@ -34,12 +32,10 @@ TEST_F(BatAdsAnonymousSearchUrlHostTest, GetStagingUrlHost) { EnvironmentType::kStaging); // Act - const std::string url_host = GetAnonymousSearchUrlHost(); // Assert - const std::string expected_url_host = - "https://search.anonymous.ads.bravesoftware.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://search.anonymous.ads.bravesoftware.com", + GetAnonymousSearchUrlHost()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_url_host_unittest.cc b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_url_host_unittest.cc index baec89fb34e5..45052e6df1eb 100644 --- a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_url_host_unittest.cc +++ b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/anonymous_url_host_unittest.cc @@ -20,11 +20,9 @@ TEST_F(BatAdsAnonymousUrlHostTest, GetProductionUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetAnonymousUrlHost(); // Assert - const std::string expected_url_host = "https://anonymous.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://anonymous.ads.brave.com", GetAnonymousUrlHost()); } TEST_F(BatAdsAnonymousUrlHostTest, GetStagingUrlHost) { @@ -33,12 +31,9 @@ TEST_F(BatAdsAnonymousUrlHostTest, GetStagingUrlHost) { EnvironmentType::kStaging); // Act - const std::string url_host = GetAnonymousUrlHost(); // Assert - const std::string expected_url_host = - "https://anonymous.ads.bravesoftware.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://anonymous.ads.bravesoftware.com", GetAnonymousUrlHost()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/geo_url_host_unittest.cc b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/geo_url_host_unittest.cc index c65c085c7203..3a430e787120 100644 --- a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/geo_url_host_unittest.cc +++ b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/geo_url_host_unittest.cc @@ -20,11 +20,9 @@ TEST_F(BatAdsGeoUrlHostTest, GetProductionUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetGeoUrlHost(); // Assert - const std::string expected_url_host = "https://geo.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://geo.ads.brave.com", GetGeoUrlHost()); } TEST_F(BatAdsGeoUrlHostTest, GetStagingUrlHost) { @@ -33,11 +31,9 @@ TEST_F(BatAdsGeoUrlHostTest, GetStagingUrlHost) { EnvironmentType::kStaging); // Act - const std::string url_host = GetGeoUrlHost(); // Assert - const std::string expected_url_host = "https://geo.ads.bravesoftware.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://geo.ads.bravesoftware.com", GetGeoUrlHost()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/non_anonymous_url_host_unittest.cc b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/non_anonymous_url_host_unittest.cc index 05357b75e678..5879a5817efe 100644 --- a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/non_anonymous_url_host_unittest.cc +++ b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/non_anonymous_url_host_unittest.cc @@ -20,11 +20,9 @@ TEST_F(BatAdsNonAnonymousUrlHostTest, GetProductionUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetNonAnonymousUrlHost(); // Assert - const std::string expected_url_host = "https://mywallet.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://mywallet.ads.brave.com", GetNonAnonymousUrlHost()); } TEST_F(BatAdsNonAnonymousUrlHostTest, GetStagingUrlHost) { @@ -33,12 +31,9 @@ TEST_F(BatAdsNonAnonymousUrlHostTest, GetStagingUrlHost) { EnvironmentType::kStaging); // Act - const std::string url_host = GetNonAnonymousUrlHost(); // Assert - const std::string expected_url_host = - "https://mywallet.ads.bravesoftware.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://mywallet.ads.bravesoftware.com", GetNonAnonymousUrlHost()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/static_url_host_unittest.cc b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/static_url_host_unittest.cc index 32c3ea3ffdcf..bc8d1f4ce4ba 100644 --- a/components/brave_ads/core/internal/common/url/request_builder/host/hosts/static_url_host_unittest.cc +++ b/components/brave_ads/core/internal/common/url/request_builder/host/hosts/static_url_host_unittest.cc @@ -20,11 +20,9 @@ TEST_F(BatAdsStaticUrlHostTest, GetProductionUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetStaticUrlHost(); // Assert - const std::string expected_url_host = "https://static.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://static.ads.brave.com", GetStaticUrlHost()); } TEST_F(BatAdsStaticUrlHostTest, GetStagingUrlHost) { @@ -33,11 +31,9 @@ TEST_F(BatAdsStaticUrlHostTest, GetStagingUrlHost) { EnvironmentType::kStaging); // Act - const std::string url_host = GetStaticUrlHost(); // Assert - const std::string expected_url_host = "https://static.ads.bravesoftware.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://static.ads.bravesoftware.com", GetStaticUrlHost()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/url/request_builder/host/url_host_util_unittest.cc b/components/brave_ads/core/internal/common/url/request_builder/host/url_host_util_unittest.cc index 09a3da6a167c..9809a0d44fc1 100644 --- a/components/brave_ads/core/internal/common/url/request_builder/host/url_host_util_unittest.cc +++ b/components/brave_ads/core/internal/common/url/request_builder/host/url_host_util_unittest.cc @@ -21,11 +21,9 @@ TEST_F(BatAdsUrlHostUtilTest, GetStaticUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetStaticUrlHost(); // Assert - const std::string expected_url_host = "https://static.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://static.ads.brave.com", GetStaticUrlHost()); } TEST_F(BatAdsUrlHostUtilTest, GetGeoUrlHost) { @@ -34,11 +32,9 @@ TEST_F(BatAdsUrlHostUtilTest, GetGeoUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetGeoUrlHost(); // Assert - const std::string expected_url_host = "https://geo.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://geo.ads.brave.com", GetGeoUrlHost()); } TEST_F(BatAdsUrlHostUtilTest, GetNonAnonymousUrlHost) { @@ -47,11 +43,9 @@ TEST_F(BatAdsUrlHostUtilTest, GetNonAnonymousUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetNonAnonymousUrlHost(); // Assert - const std::string expected_url_host = "https://mywallet.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://mywallet.ads.brave.com", GetNonAnonymousUrlHost()); } TEST_F(BatAdsUrlHostUtilTest, GetAnonymousUrlHost) { @@ -60,11 +54,9 @@ TEST_F(BatAdsUrlHostUtilTest, GetAnonymousUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetAnonymousUrlHost(); // Assert - const std::string expected_url_host = "https://anonymous.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://anonymous.ads.brave.com", GetAnonymousUrlHost()); } TEST_F(BatAdsUrlHostUtilTest, GetAnonymousSearchUrlHost) { @@ -73,12 +65,10 @@ TEST_F(BatAdsUrlHostUtilTest, GetAnonymousSearchUrlHost) { EnvironmentType::kProduction); // Act - const std::string url_host = GetAnonymousSearchUrlHost(); // Assert - const std::string expected_url_host = - "https://search.anonymous.ads.brave.com"; - EXPECT_EQ(expected_url_host, url_host); + EXPECT_EQ("https://search.anonymous.ads.brave.com", + GetAnonymousSearchUrlHost()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/conversions/conversion_queue_database_table_unittest.cc b/components/brave_ads/core/internal/conversions/conversion_queue_database_table_unittest.cc index 58931d21fede..b041c33640bc 100644 --- a/components/brave_ads/core/internal/conversions/conversion_queue_database_table_unittest.cc +++ b/components/brave_ads/core/internal/conversions/conversion_queue_database_table_unittest.cc @@ -12,6 +12,7 @@ #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" // npm run test -- brave_unit_tests --filter=BatAds* @@ -19,13 +20,7 @@ namespace brave_ads::database::table { class BatAdsConversionQueueDatabaseTableTest : public UnitTestBase { protected: - void SetUp() override { - UnitTestBase::SetUp(); - - database_table_ = std::make_unique(); - } - - std::unique_ptr database_table_; + ConversionQueue database_table_; }; TEST_F(BatAdsConversionQueueDatabaseTableTest, SaveEmptyConversionQueue) { @@ -40,41 +35,23 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, SaveEmptyConversionQueue) { TEST_F(BatAdsConversionQueueDatabaseTableTest, SaveConversionQueue) { // Arrange - ConversionQueueItemList conversion_queue_items; - - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); // Act - SaveConversionQueueItems(conversion_queue_items); + const ConversionQueueItemList conversion_queue_items = + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ false, + /*count*/ 2); // Assert - const ConversionQueueItemList expected_conversion_queue_items = - conversion_queue_items; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); EXPECT_EQ(expected_conversion_queue_items, conversion_queue_items); }, - expected_conversion_queue_items)); + conversion_queue_items)); } TEST_F(BatAdsConversionQueueDatabaseTableTest, @@ -82,14 +59,11 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info; - info.ad_type = AdType::kNotificationAd; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.process_at = Now(); - conversion_queue_items.push_back(info); + const ConversionQueueItemInfo conversion_queue_item = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item); SaveConversionQueueItems(conversion_queue_items); @@ -97,9 +71,10 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, SaveConversionQueueItems(conversion_queue_items); // Assert - const ConversionQueueItemList expected_conversion_queue_items = {info, info}; + const ConversionQueueItemList expected_conversion_queue_items = { + conversion_queue_item, conversion_queue_item}; - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { @@ -112,52 +87,24 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, TEST_F(BatAdsConversionQueueDatabaseTableTest, SaveConversionQueueItemsInBatches) { // Arrange - database_table_->SetBatchSize(2); - - ConversionQueueItemList conversion_queue_items; - - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); - - ConversionQueueItemInfo info_3; - info_3.ad_type = AdType::kNotificationAd; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.process_at = DistantFuture(); - conversion_queue_items.push_back(info_3); + database_table_.SetBatchSize(2); // Act - SaveConversionQueueItems(conversion_queue_items); + const ConversionQueueItemList conversion_queue_items = + BuildAndSaveConversionQueueItems(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true, + /*count*/ 3); // Assert - const ConversionQueueItemList expected_conversion_queue_items = - conversion_queue_items; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); EXPECT_EQ(expected_conversion_queue_items, conversion_queue_items); }, - expected_conversion_queue_items)); + conversion_queue_items)); } TEST_F(BatAdsConversionQueueDatabaseTableTest, @@ -165,36 +112,28 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); + const ConversionQueueItemInfo conversion_queue_item_1 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_1); + + const ConversionQueueItemInfo conversion_queue_item_2 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_2); SaveConversionQueueItems(conversion_queue_items); // Act // Assert - const ConversionQueueItemList expected_conversion_queue_items = {info_2}; - - const std::string creative_instance_id = - "eaa6224a-876d-4ef8-a384-9ac34f238631"; + const ConversionQueueItemList expected_conversion_queue_items = { + conversion_queue_item_2}; - database_table_->GetForCreativeInstanceId( - creative_instance_id, + database_table_.GetForCreativeInstanceId( + conversion_queue_item_2.creative_instance_id, base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const std::string& /*creative_instance_id*/, @@ -210,33 +149,28 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - info_1.was_processed = true; - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); + ConversionQueueItemInfo conversion_queue_item_1 = BuildConversionQueueItem( + AdType::kNotificationAd, kConversionId, kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_item_1.process_at = DistantPast(); + conversion_queue_item_1.was_processed = true; + conversion_queue_items.push_back(conversion_queue_item_1); + + const ConversionQueueItemInfo conversion_queue_item_2 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_2); SaveConversionQueueItems(conversion_queue_items); // Act // Assert - const ConversionQueueItemList expected_conversion_queue_items = {info_2}; + const ConversionQueueItemList expected_conversion_queue_items = { + conversion_queue_item_2}; - database_table_->GetUnprocessed(base::BindOnce( + database_table_.GetUnprocessed(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { @@ -251,32 +185,23 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantFuture(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = DistantPast(); - conversion_queue_items.push_back(info_2); - - ConversionQueueItemInfo info_3; - info_3.ad_type = AdType::kNotificationAd; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.process_at = Now(); - conversion_queue_items.push_back(info_3); + ConversionQueueItemInfo conversion_queue_item_1 = BuildConversionQueueItem( + AdType::kNotificationAd, kConversionId, kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_item_1.process_at = DistantFuture(); + conversion_queue_items.push_back(conversion_queue_item_1); + + ConversionQueueItemInfo conversion_queue_item_2 = BuildConversionQueueItem( + AdType::kNotificationAd, kConversionId, kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_item_2.process_at = DistantPast(); + conversion_queue_items.push_back(conversion_queue_item_2); + + ConversionQueueItemInfo conversion_queue_item_3 = BuildConversionQueueItem( + AdType::kNotificationAd, kConversionId, kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_item_3.process_at = Now(); + conversion_queue_items.push_back(conversion_queue_item_3); SaveConversionQueueItems(conversion_queue_items); @@ -284,9 +209,10 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Assert const ConversionQueueItemList expected_conversion_queue_items = { - info_2, info_3, info_1}; + conversion_queue_item_2, conversion_queue_item_3, + conversion_queue_item_1}; - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { @@ -300,34 +226,30 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, DeleteConversionQueueItem) { // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); + ConversionQueueItemInfo conversion_queue_item_1 = BuildConversionQueueItem( + AdType::kNotificationAd, kConversionId, kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_item_1.process_at = DistantPast(); + conversion_queue_items.push_back(conversion_queue_item_1); + + ConversionQueueItemInfo conversion_queue_item_2 = BuildConversionQueueItem( + AdType::kNotificationAd, kConversionId, kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_item_2.process_at = Now(); + conversion_queue_items.push_back(conversion_queue_item_2); SaveConversionQueueItems(conversion_queue_items); // Act - database_table_->Delete( - info_1, base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); + database_table_.Delete( + conversion_queue_item_1, + base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); // Assert - const ConversionQueueItemList expected_conversion_queue_items = {info_2}; + const ConversionQueueItemList expected_conversion_queue_items = { + conversion_queue_item_2}; - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { @@ -342,88 +264,69 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); + const ConversionQueueItemInfo conversion_queue_item_1 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_1); + + const ConversionQueueItemInfo conversion_queue_item_2 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_2); SaveConversionQueueItems(conversion_queue_items); // Act - ConversionQueueItemInfo invalid_conversion_queue_item; - invalid_conversion_queue_item.creative_instance_id = - "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - invalid_conversion_queue_item.creative_set_id = - "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - invalid_conversion_queue_item.campaign_id = - "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - invalid_conversion_queue_item.advertiser_id = - "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - invalid_conversion_queue_item.process_at = Now(); - - database_table_->Delete( + const ConversionQueueItemInfo invalid_conversion_queue_item = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + + database_table_.Delete( invalid_conversion_queue_item, base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); // Assert - const ConversionQueueItemList expected_conversion_queue_items = - conversion_queue_items; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); EXPECT_EQ(expected_conversion_queue_items, conversion_queue_items); }, - expected_conversion_queue_items)); + conversion_queue_items)); } TEST_F(BatAdsConversionQueueDatabaseTableTest, UpdateConversionQueueItem) { // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); + const ConversionQueueItemInfo conversion_queue_item_1 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_1); + + const ConversionQueueItemInfo conversion_queue_item_2 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_2); SaveConversionQueueItems(conversion_queue_items); // Act - database_table_->Update( - info_1, base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); + database_table_.Update( + conversion_queue_item_1, + base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); // Assert - const ConversionQueueItemList expected_conversion_queue_items = {info_2}; + const ConversionQueueItemList expected_conversion_queue_items = { + conversion_queue_item_2}; - database_table_->GetUnprocessed(base::BindOnce( + database_table_.GetUnprocessed(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { @@ -438,65 +341,48 @@ TEST_F(BatAdsConversionQueueDatabaseTableTest, // Arrange ConversionQueueItemList conversion_queue_items; - ConversionQueueItemInfo info_1; - info_1.ad_type = AdType::kNotificationAd; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.process_at = DistantPast(); - conversion_queue_items.push_back(info_1); - - ConversionQueueItemInfo info_2; - info_2.ad_type = AdType::kNotificationAd; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.process_at = Now(); - conversion_queue_items.push_back(info_2); + const ConversionQueueItemInfo conversion_queue_item_1 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_1); + + const ConversionQueueItemInfo conversion_queue_item_2 = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + conversion_queue_items.push_back(conversion_queue_item_2); SaveConversionQueueItems(conversion_queue_items); // Act - ConversionQueueItemInfo invalid_conversion_queue_item; - invalid_conversion_queue_item.creative_instance_id = - "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - invalid_conversion_queue_item.creative_set_id = - "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - invalid_conversion_queue_item.campaign_id = - "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - invalid_conversion_queue_item.advertiser_id = - "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - invalid_conversion_queue_item.process_at = Now(); - - database_table_->Update( + const ConversionQueueItemInfo invalid_conversion_queue_item = + BuildConversionQueueItem(AdType::kNotificationAd, kConversionId, + kConversionAdvertiserPublicKey, + /*should_use_random_guids*/ true); + + database_table_.Update( invalid_conversion_queue_item, base::BindOnce([](const bool success) { ASSERT_TRUE(success); })); // Assert - const ConversionQueueItemList expected_conversion_queue_items = - conversion_queue_items; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionQueueItemList& expected_conversion_queue_items, const bool success, const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); EXPECT_EQ(expected_conversion_queue_items, conversion_queue_items); }, - expected_conversion_queue_items)); + conversion_queue_items)); } TEST_F(BatAdsConversionQueueDatabaseTableTest, TableName) { // Arrange // Act - const std::string table_name = database_table_->GetTableName(); // Assert - const std::string expected_table_name = "conversion_queue"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("conversion_queue", database_table_.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.cc b/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.cc index 4d7463ee771d..c76a6ee5d781 100644 --- a/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.cc +++ b/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.cc @@ -7,20 +7,14 @@ #include "base/check.h" #include "base/functional/bind.h" +#include "base/guid.h" +#include "brave/components/brave_ads/core/ad_type.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_database_table.h" namespace brave_ads { -namespace { - -constexpr char kCampaignId[] = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; -constexpr char kCreativeSetId[] = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -constexpr char kAdvertiserId[] = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - -} // namespace - void SaveConversionQueueItems( const ConversionQueueItemList& conversion_queue_items) { database::table::ConversionQueue database_table; @@ -30,31 +24,64 @@ void SaveConversionQueueItems( } ConversionQueueItemInfo BuildConversionQueueItem( + const AdType& ad_type, const std::string& conversion_id, - const std::string& advertiser_public_key) { + const std::string& advertiser_public_key, + const bool should_use_random_guids) { ConversionQueueItemInfo conversion_queue_item; - conversion_queue_item.campaign_id = kCampaignId; - conversion_queue_item.creative_set_id = kCreativeSetId; - conversion_queue_item.creative_instance_id = kCreativeInstanceId; - conversion_queue_item.advertiser_id = kAdvertiserId; + + conversion_queue_item.ad_type = ad_type; + + conversion_queue_item.creative_instance_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeInstanceId; + + conversion_queue_item.creative_set_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeSetId; + + conversion_queue_item.campaign_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCampaignId; + + conversion_queue_item.advertiser_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kAdvertiserId; + + conversion_queue_item.segment = kSegment; + conversion_queue_item.conversion_id = conversion_id; + conversion_queue_item.advertiser_public_key = advertiser_public_key; - conversion_queue_item.ad_type = AdType::kNotificationAd; + conversion_queue_item.process_at = Now(); return conversion_queue_item; } -void BuildAndSaveConversionQueueItem(const std::string& conversion_id, - const std::string& advertiser_public_key) { +ConversionQueueItemList BuildAndSaveConversionQueueItems( + const AdType& ad_type, + const std::string& conversion_id, + const std::string& advertiser_public_key, + const bool should_use_random_guids, + const size_t count) { ConversionQueueItemList conversion_queue_items; - const ConversionQueueItemInfo conversion_queue_item = - BuildConversionQueueItem(conversion_id, advertiser_public_key); + for (size_t i = 0; i < count; i++) { + const ConversionQueueItemInfo conversion_queue_item = + BuildConversionQueueItem(ad_type, conversion_id, advertiser_public_key, + should_use_random_guids); - conversion_queue_items.push_back(conversion_queue_item); + conversion_queue_items.push_back(conversion_queue_item); + } SaveConversionQueueItems(conversion_queue_items); + + return conversion_queue_items; } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h b/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h index 74240c9b60a6..1ca0eb068d8c 100644 --- a/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h +++ b/components/brave_ads/core/internal/conversions/conversion_queue_item_unittest_util.h @@ -12,15 +12,23 @@ namespace brave_ads { +class AdType; + void SaveConversionQueueItems( const ConversionQueueItemList& conversion_queue_items); ConversionQueueItemInfo BuildConversionQueueItem( + const AdType& ad_type, const std::string& conversion_id, - const std::string& advertiser_public_key); + const std::string& advertiser_public_key, + bool should_use_random_guids); -void BuildAndSaveConversionQueueItem(const std::string& conversion_id, - const std::string& advertiser_public_key); +ConversionQueueItemList BuildAndSaveConversionQueueItems( + const AdType& ad_type, + const std::string& conversion_id, + const std::string& advertiser_public_key, + bool should_use_random_guids, + size_t count); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/conversions/conversions_database_table_test.cc b/components/brave_ads/core/internal/conversions/conversions_database_table_test.cc index 6f2e1c5bdf09..b7721ed24004 100644 --- a/components/brave_ads/core/internal/conversions/conversions_database_table_test.cc +++ b/components/brave_ads/core/internal/conversions/conversions_database_table_test.cc @@ -38,7 +38,7 @@ TEST_F(BatAdsConversionsDatabaseTableIntegrationTest, conversions.GetAll( base::BindOnce([](const bool success, const ConversionList& conversions) { EXPECT_TRUE(success); - EXPECT_EQ(2UL, conversions.size()); + EXPECT_EQ(2U, conversions.size()); })); } diff --git a/components/brave_ads/core/internal/conversions/conversions_database_table_unittest.cc b/components/brave_ads/core/internal/conversions/conversions_database_table_unittest.cc index 6de6870af689..10a3d3ddb2ae 100644 --- a/components/brave_ads/core/internal/conversions/conversions_database_table_unittest.cc +++ b/components/brave_ads/core/internal/conversions/conversions_database_table_unittest.cc @@ -26,78 +26,69 @@ base::Time CalculateExpireAtTime(const int observation_window) { class BatAdsConversionsDatabaseTableTest : public UnitTestBase { protected: - void SetUp() override { - UnitTestBase::SetUp(); - - database_table_ = std::make_unique(); - } - - std::unique_ptr database_table_; + Conversions database_table_; }; TEST_F(BatAdsConversionsDatabaseTableTest, EmptySave) { // Arrange - const ConversionList conversions; // Act - SaveConversions(conversions); + SaveConversions({}); // Assert - database_table_->GetAll(base::BindOnce( - [](const ConversionList& expected_conversions, const bool success, - const ConversionList& conversions) { + database_table_.GetAll( + base::BindOnce([](const bool success, const ConversionList& conversions) { ASSERT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_conversions, conversions)); - }, - conversions)); + EXPECT_TRUE(conversions.empty()); + })); } TEST_F(BatAdsConversionsDatabaseTableTest, SaveConversions) { // Arrange ConversionList conversions; - ConversionInfo info_1; - info_1.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.type = "postview"; - info_1.url_pattern = "https://www.brave.com/*"; - info_1.observation_window = 3; - info_1.expire_at = CalculateExpireAtTime(info_1.observation_window); - conversions.push_back(info_1); - - ConversionInfo info_2; - info_2.creative_set_id = "eaa6224a-46a4-4c48-9c2b-c264c0067f04"; - info_2.type = "postclick"; - info_2.url_pattern = "https://www.brave.com/signup/*"; - info_2.observation_window = 30; - info_2.expire_at = CalculateExpireAtTime(info_2.observation_window); - conversions.push_back(info_2); + ConversionInfo conversion_1; + conversion_1.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; + conversion_1.type = "postview"; + conversion_1.url_pattern = "https://www.brave.com/*"; + conversion_1.observation_window = 3; + conversion_1.expire_at = + CalculateExpireAtTime(conversion_1.observation_window); + conversions.push_back(conversion_1); + + ConversionInfo conversion_2; + conversion_2.creative_set_id = "eaa6224a-46a4-4c48-9c2b-c264c0067f04"; + conversion_2.type = "postclick"; + conversion_2.url_pattern = "https://www.brave.com/signup/*"; + conversion_2.observation_window = 30; + conversion_2.expire_at = + CalculateExpireAtTime(conversion_2.observation_window); + conversions.push_back(conversion_2); // Act SaveConversions(conversions); // Assert - const ConversionList expected_conversions = conversions; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionList& expected_conversions, const bool success, const ConversionList& conversions) { ASSERT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_conversions, conversions)); }, - expected_conversions)); + conversions)); } TEST_F(BatAdsConversionsDatabaseTableTest, DoNotSaveDuplicateConversion) { // Arrange ConversionList conversions; - ConversionInfo info; - info.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.type = "postview"; - info.url_pattern = "https://www.brave.com/*"; - info.observation_window = 3; - info.expire_at = CalculateExpireAtTime(info.observation_window); - conversions.push_back(info); + ConversionInfo conversion; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; + conversion.type = "postview"; + conversion.url_pattern = "https://www.brave.com/*"; + conversion.observation_window = 3; + conversion.expire_at = CalculateExpireAtTime(conversion.observation_window); + conversions.push_back(conversion); SaveConversions(conversions); @@ -105,44 +96,45 @@ TEST_F(BatAdsConversionsDatabaseTableTest, DoNotSaveDuplicateConversion) { SaveConversions(conversions); // Assert - const ConversionList expected_conversions = conversions; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionList& expected_conversions, const bool success, const ConversionList& conversions) { ASSERT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_conversions, conversions)); + EXPECT_EQ(expected_conversions, conversions); }, - expected_conversions)); + conversions)); } TEST_F(BatAdsConversionsDatabaseTableTest, PurgeExpiredConversions) { // Arrange ConversionList conversions; - ConversionInfo info_1; - info_1.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.type = "postview"; - info_1.url_pattern = "https://www.brave.com/*"; - info_1.observation_window = 7; - info_1.expire_at = CalculateExpireAtTime(info_1.observation_window); - conversions.push_back(info_1); - - ConversionInfo info_2; // Should be purged - info_2.creative_set_id = "eaa6224a-46a4-4c48-9c2b-c264c0067f04"; - info_2.type = "postclick"; - info_2.url_pattern = "https://www.brave.com/signup/*"; - info_2.observation_window = 3; - info_2.expire_at = CalculateExpireAtTime(info_2.observation_window); - conversions.push_back(info_2); - - ConversionInfo info_3; - info_3.creative_set_id = "8e9f0c2f-1640-463c-902d-ca711789287f"; - info_3.type = "postview"; - info_3.url_pattern = "https://www.brave.com/*"; - info_3.observation_window = 30; - info_3.expire_at = CalculateExpireAtTime(info_3.observation_window); - conversions.push_back(info_3); + ConversionInfo conversion_1; + conversion_1.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; + conversion_1.type = "postview"; + conversion_1.url_pattern = "https://www.brave.com/*"; + conversion_1.observation_window = 7; + conversion_1.expire_at = + CalculateExpireAtTime(conversion_1.observation_window); + conversions.push_back(conversion_1); + + ConversionInfo conversion_2; // Should be purged + conversion_2.creative_set_id = "eaa6224a-46a4-4c48-9c2b-c264c0067f04"; + conversion_2.type = "postclick"; + conversion_2.url_pattern = "https://www.brave.com/signup/*"; + conversion_2.observation_window = 3; + conversion_2.expire_at = + CalculateExpireAtTime(conversion_2.observation_window); + conversions.push_back(conversion_2); + + ConversionInfo conversion_3; + conversion_3.creative_set_id = "8e9f0c2f-1640-463c-902d-ca711789287f"; + conversion_3.type = "postview"; + conversion_3.url_pattern = "https://www.brave.com/*"; + conversion_3.observation_window = 30; + conversion_3.expire_at = + CalculateExpireAtTime(conversion_3.observation_window); + conversions.push_back(conversion_3); SaveConversions(conversions); @@ -152,11 +144,9 @@ TEST_F(BatAdsConversionsDatabaseTableTest, PurgeExpiredConversions) { PurgeExpiredConversions(); // Assert - ConversionList expected_conversions; - expected_conversions.push_back(info_1); - expected_conversions.push_back(info_3); + const ConversionList expected_conversions = {conversion_1, conversion_3}; - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionList& expected_conversions, const bool success, const ConversionList& conversions) { ASSERT_TRUE(success); @@ -170,36 +160,37 @@ TEST_F(BatAdsConversionsDatabaseTableTest, // Arrange ConversionList conversions; - ConversionInfo info_1; - info_1.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.type = "postview"; - info_1.url_pattern = "https://www.brave.com/1"; - info_1.observation_window = 3; - info_1.expire_at = CalculateExpireAtTime(info_1.observation_window); - conversions.push_back(info_1); + ConversionInfo conversion_1; + conversion_1.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; + conversion_1.type = "postview"; + conversion_1.url_pattern = "https://www.brave.com/1"; + conversion_1.observation_window = 3; + conversion_1.expire_at = + CalculateExpireAtTime(conversion_1.observation_window); + conversions.push_back(conversion_1); SaveConversions(conversions); // Act - ConversionInfo info_2; // Should supersede info_1 - info_2.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_2.type = "postview"; - info_2.url_pattern = "https://www.brave.com/2"; - info_2.observation_window = 30; - info_2.expire_at = CalculateExpireAtTime(info_2.observation_window); - conversions.push_back(info_2); + ConversionInfo conversion_2; // Should supersede conversion_1 + conversion_2.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; + conversion_2.type = "postview"; + conversion_2.url_pattern = "https://www.brave.com/2"; + conversion_2.observation_window = 30; + conversion_2.expire_at = + CalculateExpireAtTime(conversion_2.observation_window); + conversions.push_back(conversion_2); SaveConversions(conversions); // Assert - ConversionList expected_conversions; - expected_conversions.push_back(info_2); + const ConversionList expected_conversions = {conversion_2}; - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const ConversionList& expected_conversions, const bool success, const ConversionList& conversions) { ASSERT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_conversions, conversions)); + EXPECT_EQ(expected_conversions, conversions); }, expected_conversions)); } @@ -208,11 +199,9 @@ TEST_F(BatAdsConversionsDatabaseTableTest, TableName) { // Arrange // Act - const std::string table_name = database_table_->GetTableName(); // Assert - const std::string expected_table_name = "creative_ad_conversions"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_ad_conversions", database_table_.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/conversions/conversions_unittest.cc b/components/brave_ads/core/internal/conversions/conversions_unittest.cc index f94f71307705..1de863eef535 100644 --- a/components/brave_ads/core/internal/conversions/conversions_unittest.cc +++ b/components/brave_ads/core/internal/conversions/conversions_unittest.cc @@ -17,6 +17,7 @@ #include "brave/components/brave_ads/core/internal/conversions/conversion_queue_database_table.h" #include "brave/components/brave_ads/core/internal/conversions/conversions_database_table.h" #include "brave/components/brave_ads/core/internal/conversions/conversions_database_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" #include "brave/components/brave_ads/core/internal/creatives/creative_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.h" #include "brave/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_info.h" @@ -60,7 +61,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kNotificationAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -96,7 +98,8 @@ TEST_F(BatAdsConversionsTest, ConvertViewedNotificationAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kNotificationAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -125,7 +128,7 @@ TEST_F(BatAdsConversionsTest, ConvertViewedNotificationAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -139,7 +142,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kNotificationAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -178,7 +182,8 @@ TEST_F(BatAdsConversionsTest, ConvertClickedNotificationAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kNotificationAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -210,7 +215,7 @@ TEST_F(BatAdsConversionsTest, ConvertClickedNotificationAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -224,7 +229,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent(creative_ad, AdType::kNewTabPageAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -260,7 +266,8 @@ TEST_F(BatAdsConversionsTest, ConvertViewedNewTabPageAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent(creative_ad, AdType::kNewTabPageAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -289,7 +296,7 @@ TEST_F(BatAdsConversionsTest, ConvertViewedNewTabPageAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -303,7 +310,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kNewTabPageAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -342,7 +350,8 @@ TEST_F(BatAdsConversionsTest, ConvertClickedNewTabPageAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kNewTabPageAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -374,7 +383,7 @@ TEST_F(BatAdsConversionsTest, ConvertClickedNewTabPageAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -388,7 +397,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent(creative_ad, AdType::kPromotedContentAd, ConfirmationType::kViewed, Now()); @@ -425,7 +435,8 @@ TEST_F(BatAdsConversionsTest, ConvertViewedPromotedContentAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent(creative_ad, AdType::kPromotedContentAd, ConfirmationType::kViewed, Now()); @@ -455,7 +466,7 @@ TEST_F(BatAdsConversionsTest, ConvertViewedPromotedContentAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -469,7 +480,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent(creative_ad, AdType::kPromotedContentAd, ConfirmationType::kViewed, Now()); @@ -511,7 +523,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent(creative_ad, AdType::kPromotedContentAd, ConfirmationType::kViewed, Now()); @@ -545,7 +558,7 @@ TEST_F(BatAdsConversionsTest, const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -559,7 +572,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kInlineContentAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -596,7 +610,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kInlineContentAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -632,7 +647,8 @@ TEST_F(BatAdsConversionsTest, ConvertClickedInlineContentAdWhenAdsAreDisabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kInlineContentAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -664,7 +680,7 @@ TEST_F(BatAdsConversionsTest, ConvertClickedInlineContentAdWhenAdsAreDisabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -677,7 +693,8 @@ TEST_F(BatAdsConversionsTest, ConvertClickedInlineContentAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kInlineContentAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -709,7 +726,7 @@ TEST_F(BatAdsConversionsTest, ConvertClickedInlineContentAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -723,7 +740,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kSearchResultAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -759,7 +777,8 @@ TEST_F(BatAdsConversionsTest, ConvertViewedSearchResultAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kSearchResultAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event); @@ -788,7 +807,7 @@ TEST_F(BatAdsConversionsTest, ConvertViewedSearchResultAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -802,7 +821,8 @@ TEST_F(BatAdsConversionsTest, // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, false); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kSearchResultAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -841,7 +861,8 @@ TEST_F(BatAdsConversionsTest, ConvertClickedSearchResultAdWhenAdsAreEnabled) { // Arrange AdsClientHelper::GetInstance()->SetBooleanPref(prefs::kEnabled, true); - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event_1 = BuildAdEvent( creative_ad, AdType::kSearchResultAd, ConfirmationType::kViewed, Now()); FireAdEvent(ad_event_1); @@ -873,7 +894,7 @@ TEST_F(BatAdsConversionsTest, ConvertClickedSearchResultAdWhenAdsAreEnabled) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -887,7 +908,7 @@ TEST_F(BatAdsConversionsTest, ConvertMultipleAds) { ConversionList conversions; ConversionInfo conversion_1; - conversion_1.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion_1.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion_1.type = "postview"; conversion_1.url_pattern = "https://www.foo.com/*"; conversion_1.observation_window = 3; @@ -941,7 +962,7 @@ TEST_F(BatAdsConversionsTest, ConvertMultipleAds) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(2UL, ad_events.size()); + EXPECT_EQ(2U, ad_events.size()); const ConversionInfo& conversion_1 = conversions.at(0); const AdEventInfo& ad_event_1 = ad_events.at(1); @@ -959,7 +980,7 @@ TEST_F(BatAdsConversionsTest, ConvertViewedAdWhenAdWasDismissed) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://www.foo.com/*bar*"; conversion.observation_window = 3; @@ -989,7 +1010,7 @@ TEST_F(BatAdsConversionsTest, ConvertViewedAdWhenAdWasDismissed) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -1003,7 +1024,7 @@ TEST_F(BatAdsConversionsTest, DoNotConvertNonViewedOrClickedAds) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postclick"; conversion.url_pattern = "https://www.foo.com/bar"; conversion.observation_window = 3; @@ -1056,7 +1077,7 @@ TEST_F(BatAdsConversionsTest, DoNotConvertViewedAdForPostClick) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postclick"; conversion.url_pattern = "https://www.foo.com/bar"; conversion.observation_window = 3; @@ -1088,7 +1109,7 @@ TEST_F(BatAdsConversionsTest, DoNotConvertViewedAdForPostClick) { TEST_F(BatAdsConversionsTest, DoNotConvertAdIfConversionDoesNotExist) { // Arrange - const std::string creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + const std::string creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; const AdEventInfo ad_event = BuildAdEvent(creative_set_id, ConfirmationType::kViewed); @@ -1117,7 +1138,7 @@ TEST_F(BatAdsConversionsTest, ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://www.foo.com/*"; conversion.observation_window = 3; @@ -1146,7 +1167,7 @@ TEST_F(BatAdsConversionsTest, const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -1161,7 +1182,7 @@ TEST_F(BatAdsConversionsTest, ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://www.foo.com/bar/*"; conversion.observation_window = 3; @@ -1196,7 +1217,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdWhenTheConversionIsOnTheCuspOfExpiring) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://*.bar.com/*"; conversion.observation_window = 3; @@ -1225,7 +1246,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdWhenTheConversionIsOnTheCuspOfExpiring) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -1239,7 +1260,7 @@ TEST_F(BatAdsConversionsTest, DoNotConvertAdWhenTheConversionHasExpired) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://www.foo.com/b*r/*"; conversion.observation_window = 3; @@ -1276,7 +1297,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdForRedirectChainIntermediateUrl) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://foo.com/baz"; conversion.observation_window = 3; @@ -1306,7 +1327,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdForRedirectChainIntermediateUrl) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -1320,7 +1341,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdForRedirectChainOriginalUrl) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://foo.com/bar"; conversion.observation_window = 3; @@ -1350,7 +1371,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdForRedirectChainOriginalUrl) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -1364,7 +1385,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdForRedirectChainUrl) { ConversionList conversions; ConversionInfo conversion; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://foo.com/qux"; conversion.observation_window = 3; @@ -1394,7 +1415,7 @@ TEST_F(BatAdsConversionsTest, ConvertAdForRedirectChainUrl) { const AdEventList& ad_events) { ASSERT_TRUE(success); - EXPECT_EQ(1UL, ad_events.size()); + EXPECT_EQ(1U, ad_events.size()); const AdEventInfo& ad_event = ad_events.front(); EXPECT_EQ(conversion.creative_set_id, @@ -1412,9 +1433,8 @@ TEST_F(BatAdsConversionsTest, ExtractConversionId) { ConversionList conversions; ConversionInfo conversion; - conversion.advertiser_public_key = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.advertiser_public_key = kConversionAdvertiserPublicKey; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://brave.com/thankyou"; conversion.observation_window = 3; @@ -1439,7 +1459,7 @@ TEST_F(BatAdsConversionsTest, ExtractConversionId) { const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); - ASSERT_EQ(1UL, conversion_queue_items.size()); + ASSERT_EQ(1U, conversion_queue_items.size()); const ConversionQueueItemInfo& conversion_queue_item = conversion_queue_items.front(); @@ -1448,8 +1468,7 @@ TEST_F(BatAdsConversionsTest, ExtractConversionId) { ASSERT_EQ(conversion.advertiser_public_key, conversion_queue_item.advertiser_public_key); - const std::string expected_conversion_id = "abc123"; - EXPECT_EQ(expected_conversion_id, conversion_queue_item.conversion_id); + EXPECT_EQ("abc123", conversion_queue_item.conversion_id); }, conversion)); } @@ -1463,9 +1482,8 @@ TEST_F(BatAdsConversionsTest, ExtractConversionIdWithResourcePatternFromHtml) { ConversionList conversions; ConversionInfo conversion; - conversion.advertiser_public_key = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.advertiser_public_key = kConversionAdvertiserPublicKey; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://brave.com/foobar"; conversion.observation_window = 3; @@ -1492,7 +1510,7 @@ TEST_F(BatAdsConversionsTest, ExtractConversionIdWithResourcePatternFromHtml) { const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); - ASSERT_EQ(1UL, conversion_queue_items.size()); + ASSERT_EQ(1U, conversion_queue_items.size()); const ConversionQueueItemInfo& conversion_queue_item = conversion_queue_items.front(); @@ -1501,8 +1519,7 @@ TEST_F(BatAdsConversionsTest, ExtractConversionIdWithResourcePatternFromHtml) { ASSERT_EQ(conversion.advertiser_public_key, conversion_queue_item.advertiser_public_key); - const std::string expected_conversion_id = "abc123"; - EXPECT_EQ(expected_conversion_id, conversion_queue_item.conversion_id); + EXPECT_EQ("abc123", conversion_queue_item.conversion_id); }, conversion)); } @@ -1516,9 +1533,8 @@ TEST_F(BatAdsConversionsTest, ExtractConversionIdWithResourcePatternFromUrl) { ConversionList conversions; ConversionInfo conversion; - conversion.advertiser_public_key = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - conversion.creative_set_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + conversion.advertiser_public_key = kConversionAdvertiserPublicKey; + conversion.creative_set_id = "340c927f-696e-4060-9933-3eafc56c3f31"; conversion.type = "postview"; conversion.url_pattern = "https://brave.com/foobar?conversion_id=*"; conversion.observation_window = 3; @@ -1546,7 +1562,7 @@ TEST_F(BatAdsConversionsTest, ExtractConversionIdWithResourcePatternFromUrl) { const ConversionQueueItemList& conversion_queue_items) { ASSERT_TRUE(success); - ASSERT_EQ(1UL, conversion_queue_items.size()); + ASSERT_EQ(1U, conversion_queue_items.size()); const ConversionQueueItemInfo& conversion_queue_item = conversion_queue_items.front(); @@ -1555,8 +1571,7 @@ TEST_F(BatAdsConversionsTest, ExtractConversionIdWithResourcePatternFromUrl) { ASSERT_EQ(conversion.advertiser_public_key, conversion_queue_item.advertiser_public_key); - const std::string expected_conversion_id = "abc123"; - EXPECT_EQ(expected_conversion_id, conversion_queue_item.conversion_id); + EXPECT_EQ("abc123", conversion_queue_item.conversion_id); }, conversion)); } diff --git a/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h b/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h new file mode 100644 index 000000000000..df2a0b7a6dfd --- /dev/null +++ b/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h @@ -0,0 +1,25 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UNITTEST_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UNITTEST_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kConversionId[] = "smartbrownfoxes42"; +constexpr char kInvalidConversionId[] = "smart brown foxes 16"; +constexpr char kEmptyConversionId[] = ""; + +constexpr char kConversionAdvertiserPublicKey[] = + "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; +constexpr char kEmptyConversionAdvertiserPublicKey[] = ""; + +constexpr char kConversionAdvertiserSecretKey[] = + "Ete7+aKfrX25gt0eN4kBV1LqeF9YmB1go8OqnGXUGG4="; +constexpr char kInvalidConversionAdvertiserPublicKey[] = "INVALID"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UNITTEST_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/conversions/conversions_util.cc b/components/brave_ads/core/internal/conversions/conversions_util.cc index 130797285116..c74aba8c2730 100644 --- a/components/brave_ads/core/internal/conversions/conversions_util.cc +++ b/components/brave_ads/core/internal/conversions/conversions_util.cc @@ -6,13 +6,13 @@ #include "brave/components/brave_ads/core/internal/conversions/conversions_util.h" #include -#include #include #include "base/base64.h" #include "base/check_op.h" #include "brave/components/brave_ads/core/internal/common/crypto/crypto_util.h" #include "brave/components/brave_ads/core/internal/common/crypto/key_pair_info.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_util_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_info.h" #include "third_party/re2/src/re2/re2.h" @@ -23,11 +23,7 @@ namespace brave_ads::security { namespace { constexpr char kAlgorithm[] = "crypto_box_curve25519xsalsa20poly1305"; -constexpr size_t kCryptoBoxZeroBytes = crypto_box_BOXZEROBYTES; -constexpr size_t kCryptoBoxPublicKeyBytes = crypto_box_PUBLICKEYBYTES; -constexpr size_t kVacCipherTextLength = 32; -constexpr size_t kVacMessageMaxLength = 30; -constexpr size_t kVacMessageMinLength = 1; +constexpr size_t kCipherTextLength = 32; bool IsConversionIdValid(const std::string& conversion_id) { return RE2::FullMatch(conversion_id, "^[a-zA-Z0-9-]*$"); @@ -35,13 +31,17 @@ bool IsConversionIdValid(const std::string& conversion_id) { } // namespace +std::string GetAlgorithm() { + return kAlgorithm; +} + absl::optional SealEnvelope( const VerifiableConversionInfo& verifiable_conversion) { const std::string message = verifiable_conversion.id; const std::string public_key_base64 = verifiable_conversion.public_key; - if (message.length() < kVacMessageMinLength || - message.length() > kVacMessageMaxLength) { + if (message.length() < kMinVerifiableConversionMessageLength || + message.length() > kMaxVerifiableConversionMessageLength) { return absl::nullopt; } @@ -51,16 +51,15 @@ absl::optional SealEnvelope( // Protocol requires at least 2 trailing zero-padding bytes std::vector plaintext(message.cbegin(), message.cend()); - plaintext.insert(plaintext.cend(), kVacCipherTextLength - plaintext.size(), - 0); - DCHECK_EQ(kVacCipherTextLength, plaintext.size()); + plaintext.insert(plaintext.cend(), kCipherTextLength - plaintext.size(), 0); + DCHECK_EQ(kCipherTextLength, plaintext.size()); const absl::optional> public_key = base::Base64Decode(public_key_base64); if (!public_key) { return absl::nullopt; } - if (public_key->size() != kCryptoBoxPublicKeyBytes) { + if (public_key->size() != crypto_box_PUBLICKEYBYTES) { return absl::nullopt; } @@ -77,11 +76,11 @@ absl::optional SealEnvelope( // The first 16 bytes of the resulting ciphertext is left as padding by the // C API and should be removed before sending out extraneously. const std::vector ciphertext( - padded_ciphertext.cbegin() + kCryptoBoxZeroBytes, + padded_ciphertext.cbegin() + crypto_box_BOXZEROBYTES, padded_ciphertext.cend()); VerifiableConversionEnvelopeInfo envelope; - envelope.algorithm = kAlgorithm; + envelope.algorithm = GetAlgorithm(); envelope.ciphertext = base::Base64Encode(ciphertext); envelope.ephemeral_public_key = base::Base64Encode(ephemeral_key_pair.public_key); diff --git a/components/brave_ads/core/internal/conversions/conversions_util.h b/components/brave_ads/core/internal/conversions/conversions_util.h index d6fe6eb2467d..01b7a9342462 100644 --- a/components/brave_ads/core/internal/conversions/conversions_util.h +++ b/components/brave_ads/core/internal/conversions/conversions_util.h @@ -6,6 +6,8 @@ #ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UTIL_H_ #define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UTIL_H_ +#include + #include "third_party/abseil-cpp/absl/types/optional.h" namespace brave_ads { @@ -16,6 +18,8 @@ namespace security { struct VerifiableConversionEnvelopeInfo; +std::string GetAlgorithm(); + absl::optional SealEnvelope( const VerifiableConversionInfo& verifiable_conversion); diff --git a/components/brave_ads/core/internal/conversions/conversions_util_constants.h b/components/brave_ads/core/internal/conversions/conversions_util_constants.h new file mode 100644 index 000000000000..2db2d1475969 --- /dev/null +++ b/components/brave_ads/core/internal/conversions/conversions_util_constants.h @@ -0,0 +1,18 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UTIL_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UTIL_CONSTANTS_H_ + +#include + +namespace brave_ads::security { + +constexpr size_t kMinVerifiableConversionMessageLength = 1; +constexpr size_t kMaxVerifiableConversionMessageLength = 30; + +} // namespace brave_ads::security + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_CONVERSIONS_UTIL_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/conversions/conversions_util_unittest.cc b/components/brave_ads/core/internal/conversions/conversions_util_unittest.cc index 7d8b880b3553..bc15e41b41b5 100644 --- a/components/brave_ads/core/internal/conversions/conversions_util_unittest.cc +++ b/components/brave_ads/core/internal/conversions/conversions_util_unittest.cc @@ -7,6 +7,8 @@ #include +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_util_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_info.h" @@ -16,26 +18,12 @@ namespace brave_ads::security { -namespace { - -constexpr char kAdvertiserPublicKey[] = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; -constexpr char kInvalidAdvertiserPublicKey[] = "invalid"; -constexpr char kAdvertiserSecretKey[] = - "Ete7+aKfrX25gt0eN4kBV1LqeF9YmB1go8OqnGXUGG4="; - -constexpr char kShortMessage[] = ""; -constexpr char kLongMessage[] = "thismessageistoolongthismessageistoolong"; -constexpr char kValidMessage[] = "smartbrownfoxes42"; -constexpr char kInvalidMessage[] = "smart brown foxes 16"; - -} // namespace - TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithShortMessage) { // Arrange VerifiableConversionInfo verifiable_conversion; - verifiable_conversion.id = kShortMessage; - verifiable_conversion.public_key = kAdvertiserPublicKey; + verifiable_conversion.id = + std::string(kMinVerifiableConversionMessageLength - 1, '-'); + verifiable_conversion.public_key = kConversionAdvertiserPublicKey; // Act const absl::optional @@ -48,8 +36,9 @@ TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithShortMessage) { TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithLongMessage) { // Arrange VerifiableConversionInfo verifiable_conversion; - verifiable_conversion.id = kLongMessage; - verifiable_conversion.public_key = kAdvertiserPublicKey; + verifiable_conversion.id = + std::string(kMaxVerifiableConversionMessageLength + 1, '-'); + verifiable_conversion.public_key = kConversionAdvertiserPublicKey; // Act const absl::optional @@ -62,8 +51,8 @@ TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithLongMessage) { TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithInvalidMessage) { // Arrange VerifiableConversionInfo verifiable_conversion; - verifiable_conversion.id = kInvalidMessage; - verifiable_conversion.public_key = kAdvertiserPublicKey; + verifiable_conversion.id = kInvalidConversionId; + verifiable_conversion.public_key = kConversionAdvertiserPublicKey; // Act const absl::optional @@ -76,8 +65,8 @@ TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithInvalidMessage) { TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithInvalidPublicKey) { // Arrange VerifiableConversionInfo verifiable_conversion; - verifiable_conversion.id = kValidMessage; - verifiable_conversion.public_key = kInvalidAdvertiserPublicKey; + verifiable_conversion.id = kConversionId; + verifiable_conversion.public_key = kInvalidConversionAdvertiserPublicKey; // Act const absl::optional @@ -90,16 +79,16 @@ TEST(BatAdsConversionsUtilTest, DoNotSealEnvelopeWithInvalidPublicKey) { TEST(BatAdsConversionsUtilTest, SealEnvelope) { // Arrange VerifiableConversionInfo verifiable_conversion; - verifiable_conversion.id = kValidMessage; - verifiable_conversion.public_key = kAdvertiserPublicKey; + verifiable_conversion.id = kConversionId; + verifiable_conversion.public_key = kConversionAdvertiserPublicKey; // Act const absl::optional verifiable_conversion_envelope = SealEnvelope(verifiable_conversion); ASSERT_TRUE(verifiable_conversion_envelope); - const absl::optional message = - OpenEnvelope(*verifiable_conversion_envelope, kAdvertiserSecretKey); + const absl::optional message = OpenEnvelope( + *verifiable_conversion_envelope, kConversionAdvertiserSecretKey); ASSERT_TRUE(message); // Assert diff --git a/components/brave_ads/core/internal/conversions/sorts/conversions_sort_unittest.cc b/components/brave_ads/core/internal/conversions/sorts/conversions_sort_unittest.cc index 3a4492f23703..2bbb69c68b12 100644 --- a/components/brave_ads/core/internal/conversions/sorts/conversions_sort_unittest.cc +++ b/components/brave_ads/core/internal/conversions/sorts/conversions_sort_unittest.cc @@ -81,9 +81,7 @@ TEST(BatConversionsSortTest, DescendingSortOrderForEmptyList) { conversions = sort->Apply(conversions); // Assert - const ConversionList expected_conversions; - - EXPECT_EQ(expected_conversions, conversions); + EXPECT_TRUE(conversions.empty()); } TEST(BatConversionsSortTest, AscendingSortOrder) { diff --git a/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_constants.h b/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_constants.h new file mode 100644 index 000000000000..2125e34af767 --- /dev/null +++ b/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_constants.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_VERIFIABLE_CONVERSION_ENVELOPE_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_VERIFIABLE_CONVERSION_ENVELOPE_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kVerifiableConversionEnvelopeKey[] = "conversionEnvelope"; +constexpr char kVerifiableConversionEnvelopeAlgorithmKey[] = "alg"; +constexpr char kVerifiableConversionEnvelopeCipherTextKey[] = "ciphertext"; +constexpr char kVerifiableConversionEnvelopeEphemeralPublicKeyKey[] = "epk"; +constexpr char kVerifiableConversionEnvelopeNonceKey[] = "nonce"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_CONVERSIONS_VERIFIABLE_CONVERSION_ENVELOPE_CONSTANTS_H_ diff --git a/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.cc b/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.cc index 9d0818409b8b..339d5d8d87a4 100644 --- a/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.cc +++ b/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.cc @@ -10,41 +10,42 @@ #include "base/base64.h" #include "brave/components/brave_ads/core/internal/common/crypto/crypto_util.h" +#include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_constants.h" #include "brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h" #include "tweetnacl.h" // NOLINT namespace brave_ads::security { -namespace { -constexpr size_t kCryptoBoxZeroBytes = crypto_box_BOXZEROBYTES; -} // namespace - absl::optional GetVerifiableConversionEnvelopeForUserData(const base::Value::Dict& user_data) { const base::Value::Dict* const value = - user_data.FindDict("conversionEnvelope"); + user_data.FindDict(kVerifiableConversionEnvelopeKey); if (!value) { return absl::nullopt; } VerifiableConversionEnvelopeInfo verifiable_conversion_envelope; - const std::string* const algorithm = value->FindString("alg"); + const std::string* const algorithm = + value->FindString(kVerifiableConversionEnvelopeAlgorithmKey); if (algorithm) { verifiable_conversion_envelope.algorithm = *algorithm; } - const std::string* const ciphertext = value->FindString("ciphertext"); + const std::string* const ciphertext = + value->FindString(kVerifiableConversionEnvelopeCipherTextKey); if (ciphertext) { verifiable_conversion_envelope.ciphertext = *ciphertext; } - const std::string* const ephemeral_public_key = value->FindString("epk"); + const std::string* const ephemeral_public_key = + value->FindString(kVerifiableConversionEnvelopeEphemeralPublicKeyKey); if (ephemeral_public_key) { verifiable_conversion_envelope.ephemeral_public_key = *ephemeral_public_key; } - const std::string* const nonce = value->FindString("nonce"); + const std::string* const nonce = + value->FindString(kVerifiableConversionEnvelopeNonceKey); if (nonce) { verifiable_conversion_envelope.nonce = *nonce; } @@ -72,7 +73,7 @@ absl::optional OpenEnvelope( } // API requires 16 leading zero-padding bytes - ciphertext->insert(ciphertext->cbegin(), kCryptoBoxZeroBytes, 0); + ciphertext->insert(ciphertext->cbegin(), crypto_box_BOXZEROBYTES, 0); const absl::optional> nonce = base::Base64Decode(verifiable_conversion_envelope.nonce); diff --git a/components/brave_ads/core/internal/creatives/campaigns_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/campaigns_database_table_unittest.cc index e9d096f094fc..3e4d56aba285 100644 --- a/components/brave_ads/core/internal/creatives/campaigns_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/campaigns_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsCampaignsDatabaseTableTest, TableName) { const Campaigns database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "campaigns"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("campaigns", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.cc b/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.cc index 8864adfe6218..96b0388ee44a 100644 --- a/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.cc +++ b/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.cc @@ -6,21 +6,13 @@ #include "brave/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.h" #include "base/guid.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" #include "brave/components/brave_ads/core/internal/creatives/creative_ad_info.h" #include "url/gurl.h" namespace brave_ads { -namespace { - -constexpr char kCreativeInstanceId[] = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; -constexpr char kCreativeSetId[] = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; -constexpr char kCampaignId[] = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; -constexpr char kAdvertiserId[] = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - -} // namespace - CreativeAdInfo BuildCreativeAd(const bool should_use_random_guids) { CreativeAdInfo creative_ad; @@ -28,33 +20,48 @@ CreativeAdInfo BuildCreativeAd(const bool should_use_random_guids) { should_use_random_guids ? base::GUID::GenerateRandomV4().AsLowercaseString() : kCreativeInstanceId; + creative_ad.creative_set_id = should_use_random_guids ? base::GUID::GenerateRandomV4().AsLowercaseString() : kCreativeSetId; + creative_ad.campaign_id = should_use_random_guids ? base::GUID::GenerateRandomV4().AsLowercaseString() : kCampaignId; - creative_ad.start_at = DistantPast(); - creative_ad.end_at = DistantFuture(); - creative_ad.daily_cap = 2; + creative_ad.advertiser_id = should_use_random_guids ? base::GUID::GenerateRandomV4().AsLowercaseString() : kAdvertiserId; + + creative_ad.start_at = DistantPast(); + creative_ad.end_at = DistantFuture(); + + creative_ad.daily_cap = 2; + creative_ad.priority = 2; + creative_ad.ptr = 1.0; + creative_ad.per_day = 3; creative_ad.per_week = 4; creative_ad.per_month = 5; + creative_ad.total_max = 6; - creative_ad.value = 2.0; + + creative_ad.value = 1.0; + creative_ad.segment = "untargeted"; + creative_ad.split_test_group = ""; - const CreativeDaypartInfo daypart; - creative_ad.dayparts = {daypart}; + + creative_ad.dayparts = { + {.dow = "0123456", .start_minute = 0, .end_minute = 1439}}; + creative_ad.geo_targets = {"US"}; + creative_ad.target_url = GURL("https://brave.com"); return creative_ad; diff --git a/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.h b/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.h index f3126692de6c..aea66ec7e8ba 100644 --- a/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.h +++ b/components/brave_ads/core/internal/creatives/creative_ad_unittest_util.h @@ -10,7 +10,7 @@ namespace brave_ads { struct CreativeAdInfo; -CreativeAdInfo BuildCreativeAd(bool should_use_random_guids = true); +CreativeAdInfo BuildCreativeAd(bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/creative_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/creative_ads_database_table_unittest.cc index 7a41becfdbfa..f75165101f77 100644 --- a/components/brave_ads/core/internal/creatives/creative_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/creative_ads_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsCreativeAdsDatabaseTableTest, TableName) { const CreativeAds database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "creative_ads"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_ads", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/dayparts_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/dayparts_database_table_unittest.cc index f7b5fcfd1673..e94e6832b89c 100644 --- a/components/brave_ads/core/internal/creatives/dayparts_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/dayparts_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsDayPartsDatabaseTableTest, TableName) { const Dayparts database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "dayparts"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("dayparts", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/embeddings_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/embeddings_database_table_unittest.cc index 731638d919ca..3860711d128a 100644 --- a/components/brave_ads/core/internal/creatives/embeddings_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/embeddings_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsEmbeddingsDatabaseTableTest, TableName) { const Embeddings database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "embeddings"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("embeddings", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/geo_targets_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/geo_targets_database_table_unittest.cc index 71d9965f1b81..e131223babdc 100644 --- a/components/brave_ads/core/internal/creatives/geo_targets_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/geo_targets_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsGeoTargetsDatabaseTableTest, TableName) { const GeoTargets database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "geo_targets"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("geo_targets", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h index be5da502cf52..85a4fba36502 100644 --- a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h +++ b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h @@ -14,7 +14,7 @@ void SaveCreativeAds(const CreativeInlineContentAdList& creative_ads); CreativeInlineContentAdList BuildCreativeInlineContentAds(int count); CreativeInlineContentAdInfo BuildCreativeInlineContentAd( - bool should_use_random_guids = true); + bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_test.cc b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_test.cc index 6f8e60b76e77..7040288a7345 100644 --- a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_test.cc +++ b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_test.cc @@ -37,15 +37,13 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableIntegrationTest, // Act // Assert - const std::vector segments = {"technology & computing"}; - const database::table::CreativeInlineContentAds creative_ads; creative_ads.GetForSegmentsAndDimensions( - segments, "200x100", + /*segments*/ {"technology & computing"}, /*dimensions*/ "200x100", base::BindOnce([](const bool success, const SegmentList& /*segments*/, const CreativeInlineContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_EQ(1UL, creative_ads.size()); + EXPECT_EQ(1U, creative_ads.size()); })); } @@ -62,7 +60,7 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableIntegrationTest, base::BindOnce([](const bool success, const CreativeInlineContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_EQ(1UL, creative_ads.size()); + EXPECT_EQ(1U, creative_ads.size()); })); } diff --git a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc index 35679d069072..542600dabdca 100644 --- a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table_unittest.cc @@ -8,11 +8,11 @@ #include #include "base/functional/bind.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_container_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" -#include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_util.h" -#include "url/gurl.h" +#include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h" // npm run test -- brave_unit_tests --filter=BatAds* @@ -20,22 +20,15 @@ namespace brave_ads::database::table { class BatAdsCreativeInlineContentAdsDatabaseTableTest : public UnitTestBase { protected: - void SetUp() override { - UnitTestBase::SetUp(); - - database_table_ = std::make_unique(); - } - - std::unique_ptr database_table_; + CreativeInlineContentAds database_table_; }; TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, SaveEmptyCreativeInlineContentAds) { // Arrange - const CreativeInlineContentAdList creative_ads; // Act - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds({}); // Assert } @@ -43,167 +36,43 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, SaveCreativeInlineContentAds) { // Arrange - CreativeInlineContentAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.total_max = 4; - info_1.value = 1.0; - info_1.segment = "food & drink"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com/1"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Description"; - info_1.image_url = GURL("https://www.brave.com/1/image.png"); - info_1.dimensions = "200x100"; - info_1.cta_text = "Call to Action Text 1"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeInlineContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 5; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 6; - info_2.per_day = 7; - info_2.total_max = 8; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com/2"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Description"; - info_2.image_url = GURL("https://www.brave.com/2/image.png"); - info_2.dimensions = "200x100"; - info_2.cta_text = "Call to Action Text 2"; - info_2.ptr = 0.9; - creative_ads.push_back(info_2); + const CreativeInlineContentAdList creative_ads = + BuildCreativeInlineContentAds(/*count*/ 2); // Act - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds(creative_ads); // Assert - CreativeInlineContentAdList expected_creative_ads = creative_ads; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, const CreativeInlineContentAdList& creative_ads) { EXPECT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); }, - std::move(expected_creative_ads))); + creative_ads)); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, SaveCreativeInlineContentAdsInBatches) { // Arrange - database_table_->SetBatchSize(2); + database_table_.SetBatchSize(2); - CreativeInlineContentAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.total_max = 4; - info_1.value = 1.0; - info_1.segment = "food & drink"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com/1"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Description"; - info_1.image_url = GURL("https://www.brave.com/1/image.png"); - info_1.dimensions = "200x100"; - info_1.cta_text = "Call to Action Text 1"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeInlineContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 5; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 6; - info_2.per_day = 7; - info_2.total_max = 8; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com/2"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Description"; - info_2.image_url = GURL("https://www.brave.com/2/image.png"); - info_2.dimensions = "200x100"; - info_2.cta_text = "Call to Action Text 2"; - info_2.ptr = 0.9; - creative_ads.push_back(info_2); - - CreativeInlineContentAdInfo info_3; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.start_at = DistantPast(); - info_3.end_at = DistantFuture(); - info_3.daily_cap = 1; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.priority = 2; - info_3.per_day = 3; - info_3.total_max = 4; - info_3.value = 1.0; - info_3.segment = "finance-banking"; - info_3.dayparts.push_back(daypart_info); - info_3.geo_targets = {"US"}; - info_3.target_url = GURL("https://brave.com/3"); - info_3.title = "Test Ad 3 Title"; - info_3.description = "Test Ad 3 Description"; - info_3.image_url = GURL("https://www.brave.com/3/image.png"); - info_3.dimensions = "200x100"; - info_3.cta_text = "Call to Action Text 3"; - info_3.ptr = 1.0; - creative_ads.push_back(info_3); + const CreativeInlineContentAdList creative_ads = + BuildCreativeInlineContentAds(/*count*/ 3); // Act - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds(creative_ads); // Assert - CreativeInlineContentAdList expected_creative_ads = creative_ads; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, const CreativeInlineContentAdList& creative_ads) { EXPECT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); }, - std::move(expected_creative_ads))); + creative_ads)); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, @@ -211,47 +80,24 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, // Arrange CreativeInlineContentAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.total_max = 4; - info.value = 1.0; - info.segment = "food & drink"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad Title"; - info.description = "Test Ad Description"; - info.image_url = GURL("https://www.brave.com/image.png"); - info.dimensions = "200x100"; - info.cta_text = "Call to Action Text"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeInlineContentAds(creative_ads); + const CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ads.push_back(creative_ad); + + SaveCreativeAds(creative_ads); // Act - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds(creative_ads); // Assert - CreativeInlineContentAdList expected_creative_ads = creative_ads; - - database_table_->GetAll(base::BindOnce( + database_table_.GetAll(base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, const CreativeInlineContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + EXPECT_EQ(expected_creative_ads, creative_ads); }, - std::move(expected_creative_ads))); + creative_ads)); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, @@ -259,70 +105,41 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, // Arrange CreativeInlineContentAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.total_max = 4; - info_1.value = 1.0; - info_1.segment = "food & drink"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com/1"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Description"; - info_1.image_url = GURL("https://www.brave.com/1/image.png"); - info_1.dimensions = "200x100"; - info_1.cta_text = "Call to Action Text 1"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeInlineContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 5; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 6; - info_2.per_day = 7; - info_2.total_max = 8; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com/2"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Description"; - info_2.image_url = GURL("https://www.brave.com/2/image.png"); - info_2.dimensions = "200x100"; - info_2.cta_text = "Call to Action Text 2"; - info_2.ptr = 0.9; - creative_ads.push_back(info_2); - - SaveCreativeInlineContentAds(creative_ads); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "food & drink"; + creative_ad_1.dimensions = "200x100"; + creative_ads.push_back(creative_ad_1); + + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "technology & computing-software"; + creative_ad_2.dimensions = "300x200"; + creative_ads.push_back(creative_ad_2); + + CreativeInlineContentAdInfo creative_ad_3 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_3.segment = "food & drink"; + creative_ad_3.dimensions = "150x150"; + creative_ads.push_back(creative_ad_3); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativeInlineContentAdList expected_creative_ads = creative_ads; + CreativeInlineContentAdList expected_creative_ads = {creative_ad_1}; - database_table_->GetAll(base::BindOnce( - [](const CreativeInlineContentAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeInlineContentAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetForSegmentsAndDimensions( + /*segments*/ {"food & drink"}, /*dimensions*/ "200x100", + base::BindOnce( + [](const CreativeInlineContentAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeInlineContentAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, @@ -330,50 +147,23 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, // Arrange CreativeInlineContentAdList creative_ads; - CreativeDaypartInfo daypart_info_1; - daypart_info_1.dow = "0"; - daypart_info_1.start_minute = 0; - daypart_info_1.end_minute = 719; - CreativeDaypartInfo daypart_info_2; - daypart_info_2.dow = "1"; - daypart_info_2.start_minute = 720; - daypart_info_2.end_minute = 1439; - - CreativeInlineContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.total_max = 4; - info.value = 1.0; - info.segment = "food & drink"; - info.dayparts.push_back(daypart_info_1); - info.dayparts.push_back(daypart_info_2); - info.geo_targets = {"US-FL", "US-CA"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad Title"; - info.description = "Test Ad Description"; - info.image_url = GURL("https://www.brave.com/image.png"); - info.dimensions = "200x100"; - info.cta_text = "Call to Action Text"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeInlineContentAds(creative_ads); + const CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ads.push_back(creative_ad_1); + + const CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act // Assert - const std::string creative_instance_id = - "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + const CreativeInlineContentAdInfo expected_creative_ad = creative_ad_1; - database_table_->GetForCreativeInstanceId( - creative_instance_id, + database_table_.GetForCreativeInstanceId( + expected_creative_ad.creative_instance_id, base::BindOnce( [](const CreativeInlineContentAdInfo& expected_creative_ad, const bool success, const std::string& /*creative_instance_id*/, @@ -381,49 +171,22 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, ASSERT_TRUE(success); EXPECT_EQ(expected_creative_ad, creative_ad); }, - info)); + expected_creative_ad)); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, GetCreativeInlineContentAdsForNonExistentCreativeInstanceId) { // Arrange - CreativeInlineContentAdList creative_ads; + const CreativeInlineContentAdList creative_ads = + BuildCreativeInlineContentAds(/*count*/ 1); - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.total_max = 4; - info.value = 1.0; - info.segment = "food & drink"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad Title"; - info.description = "Test Ad Description"; - info.image_url = GURL("https://www.brave.com/image.png"); - info.dimensions = "200x100"; - info.cta_text = "Call to Action Text"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds(creative_ads); // Act // Assert - const std::string creative_instance_id = - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - - database_table_->GetForCreativeInstanceId( - creative_instance_id, + database_table_.GetForCreativeInstanceId( + kMissingCreativeInstanceId, base::BindOnce([](const bool success, const std::string& /*creative_instance_id*/, const CreativeInlineContentAdInfo& /*creative_ad*/) { @@ -434,103 +197,41 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, GetCreativeInlineContentAdsForEmptySegments) { // Arrange - CreativeInlineContentAdList creative_ads; + const CreativeInlineContentAdList creative_ads = + BuildCreativeInlineContentAds(/*count*/ 1); - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.total_max = 4; - info.value = 1.0; - info.segment = "food & drink"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad Title"; - info.description = "Test Ad Description"; - info.image_url = GURL("https://www.brave.com/image.png"); - info.dimensions = "200x100"; - info.cta_text = "Call to Action Text"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds(creative_ads); // Act // Assert - CreativeInlineContentAdList expected_creative_ads; - - const SegmentList segments; - - database_table_->GetForSegmentsAndDimensions( - segments, "200x100", - base::BindOnce( - [](const CreativeInlineContentAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeInlineContentAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetForSegmentsAndDimensions( + /*segments*/ {}, /*dimensions*/ "200x100", + base::BindOnce([](const bool success, const SegmentList& /*segments*/, + const CreativeInlineContentAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_TRUE(creative_ads.empty()); + })); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, GetCreativeInlineContentAdsForNonExistentCategory) { // Arrange - CreativeInlineContentAdList creative_ads; + const CreativeInlineContentAdList creative_ads = + BuildCreativeInlineContentAds(/*count*/ 1); - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.total_max = 4; - info.value = 1.0; - info.segment = "food & drink"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad Title"; - info.description = "Test Ad Description"; - info.image_url = GURL("https://www.brave.com/image.png"); - info.dimensions = "200x100"; - info.cta_text = "Call to Action Text"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeInlineContentAds(creative_ads); + SaveCreativeAds(creative_ads); // Act // Assert - CreativeInlineContentAdList expected_creative_ads; - - const SegmentList segments = {"technology & computing"}; - - database_table_->GetForSegmentsAndDimensions( - segments, "200x100", - base::BindOnce( - [](const CreativeInlineContentAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeInlineContentAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetForSegmentsAndDimensions( + /*segments*/ {"FOOBAR"}, /*dimensions*/ "200x100", + base::BindOnce([](const bool success, const SegmentList& /*segments*/, + const CreativeInlineContentAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_TRUE(creative_ads.empty()); + })); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, @@ -538,93 +239,32 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, // Arrange CreativeInlineContentAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.total_max = 4; - info_1.value = 1.0; - info_1.segment = "food & drink"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com/1"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Description"; - info_1.image_url = GURL("https://www.brave.com/1/image.png"); - info_1.dimensions = "200x100"; - info_1.cta_text = "Call to Action Text 1"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeInlineContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 5; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 6; - info_2.per_day = 7; - info_2.total_max = 8; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com/2"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Description"; - info_2.image_url = GURL("https://www.brave.com/2/image.png"); - info_2.dimensions = "200x100"; - info_2.cta_text = "Call to Action Text 2"; - info_2.ptr = 0.9; - creative_ads.push_back(info_2); - - CreativeInlineContentAdInfo info_3; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.start_at = DistantPast(); - info_3.end_at = DistantFuture(); - info_3.daily_cap = 1; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.priority = 2; - info_3.per_day = 3; - info_3.total_max = 4; - info_3.value = 1.0; - info_3.segment = "finance-banking"; - info_3.dayparts.push_back(daypart_info); - info_3.geo_targets = {"US"}; - info_3.target_url = GURL("https://brave.com/3"); - info_3.title = "Test Ad 3 Title"; - info_3.description = "Test Ad 3 Description"; - info_3.image_url = GURL("https://www.brave.com/3/image.png"); - info_3.dimensions = "200x100"; - info_3.cta_text = "Call to Action Text 3"; - info_3.ptr = 1.0; - creative_ads.push_back(info_3); - - SaveCreativeInlineContentAds(creative_ads); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_1); + + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "food & drink"; + creative_ads.push_back(creative_ad_2); + + CreativeInlineContentAdInfo creative_ad_3 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_3.segment = "automobiles"; + creative_ads.push_back(creative_ad_3); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativeInlineContentAdList expected_creative_ads; - expected_creative_ads.push_back(info_1); - expected_creative_ads.push_back(info_2); - - const SegmentList segments = {"technology & computing-software", - "food & drink"}; + CreativeInlineContentAdList expected_creative_ads = {creative_ad_1, + creative_ad_2}; - database_table_->GetForSegmentsAndDimensions( - segments, "200x100", + database_table_.GetForSegmentsAndDimensions( + /*segments*/ {creative_ad_1.segment, creative_ad_2.segment}, + /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -640,76 +280,34 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, // Arrange CreativeInlineContentAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = Now(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.total_max = 4; - info_1.value = 1.0; - info_1.segment = "food & drink"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com/1"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Description"; - info_1.image_url = GURL("https://www.brave.com/1/image.png"); - info_1.dimensions = "200x100"; - info_1.cta_text = "Call to Action Text 1"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeInlineContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 5; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 6; - info_2.per_day = 7; - info_2.total_max = 8; - info_2.value = 1.0; - info_2.segment = "food & drink"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com/2"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Description"; - info_2.image_url = GURL("https://www.brave.com/2/image.png"); - info_2.dimensions = "200x100"; - info_2.cta_text = "Call to Action Text 2"; - info_2.ptr = 0.9; - creative_ads.push_back(info_2); - - SaveCreativeInlineContentAds(creative_ads); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_1.start_at = DistantPast(); + creative_ad_1.end_at = Now(); + creative_ads.push_back(creative_ad_1); + + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_2.start_at = DistantPast(); + creative_ad_2.end_at = DistantFuture(); + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act AdvanceClockBy(base::Hours(1)); // Assert - CreativeInlineContentAdList expected_creative_ads; - expected_creative_ads.push_back(info_2); - - const SegmentList segments = {"food & drink"}; + CreativeInlineContentAdList expected_creative_ads = {creative_ad_2}; - database_table_->GetForSegmentsAndDimensions( - segments, "200x100", - base::BindOnce( - [](const CreativeInlineContentAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeInlineContentAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetAll(base::BindOnce( + [](const CreativeInlineContentAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeInlineContentAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, @@ -717,73 +315,31 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, // Arrange CreativeInlineContentAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeInlineContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.total_max = 4; - info_1.value = 1.0; - info_1.segment = "food & drink"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com/1"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Description"; - info_1.image_url = GURL("https://www.brave.com/1/image.png"); - info_1.dimensions = "200x100"; - info_1.cta_text = "Call to Action Text 1"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeInlineContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 5; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 6; - info_2.per_day = 7; - info_2.total_max = 8; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com/2"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Description"; - info_2.image_url = GURL("https://www.brave.com/2/image.png"); - info_2.dimensions = "200x100"; - info_2.cta_text = "Call to Action Text 2"; - info_2.ptr = 0.9; - creative_ads.push_back(info_2); - - SaveCreativeInlineContentAds(creative_ads); + CreativeInlineContentAdInfo creative_ad_1 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_1); + + CreativeInlineContentAdInfo creative_ad_2 = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "food & drink"; + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativeInlineContentAdList expected_creative_ads; - expected_creative_ads.push_back(info_1); + CreativeInlineContentAdList expected_creative_ads = {creative_ad_2}; - const SegmentList segments = {"FoOd & DrInK"}; - - database_table_->GetForSegmentsAndDimensions( - segments, "200x100", + database_table_.GetForSegmentsAndDimensions( + /*segments*/ {"FoOd & DrInK"}, /*dimensions*/ "200x100", base::BindOnce( [](const CreativeInlineContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, const CreativeInlineContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + EXPECT_EQ(expected_creative_ads, creative_ads); }, std::move(expected_creative_ads))); } @@ -792,11 +348,9 @@ TEST_F(BatAdsCreativeInlineContentAdsDatabaseTableTest, TableName) { // Arrange // Act - const std::string table_name = database_table_->GetTableName(); // Assert - const std::string expected_table_name = "creative_inline_content_ads"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_inline_content_ads", database_table_.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h index bb7c9254f909..8e05a6bf4319 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h @@ -14,7 +14,7 @@ void SaveCreativeAds(const CreativeNewTabPageAdList& creative_ads); CreativeNewTabPageAdList BuildCreativeNewTabPageAds(int count); CreativeNewTabPageAdInfo BuildCreativeNewTabPageAd( - bool should_use_random_guids = true); + bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpapers_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpapers_database_table_unittest.cc index 04cbd2f811df..4e1a9960de1f 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpapers_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpapers_database_table_unittest.cc @@ -16,11 +16,10 @@ TEST(BatAdsCreativeNewTabPageAdWallpapersDatabaseTableTest, TableName) { const CreativeNewTabPageAdWallpapers database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "creative_new_tab_page_ad_wallpapers"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_new_tab_page_ad_wallpapers", + database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_test.cc b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_test.cc index 2447611c7a56..ad5957d7e60c 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_test.cc +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_test.cc @@ -35,15 +35,13 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableIntegrationTest, // Act // Assert - const SegmentList segments = {"technology & computing"}; - const database::table::CreativeNewTabPageAds database_table; database_table.GetForSegments( - segments, + /*segments*/ {"technology & computing"}, base::BindOnce([](const bool success, const SegmentList& /*segments*/, const CreativeNewTabPageAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_EQ(1UL, creative_ads.size()); + EXPECT_EQ(1U, creative_ads.size()); })); } diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc index c4f0e6a08216..b9b87737a594 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table_unittest.cc @@ -8,6 +8,7 @@ #include #include "base/functional/bind.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_container_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" @@ -35,14 +36,13 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, SaveCreativeNewTabPageAds) { // Arrange - const CreativeNewTabPageAdList creative_ads = BuildCreativeNewTabPageAds(2); + const CreativeNewTabPageAdList creative_ads = + BuildCreativeNewTabPageAds(/*count*/ 2); // Act SaveCreativeAds(creative_ads); // Assert - CreativeNewTabPageAdList expected_creative_ads = creative_ads; - database_table_.GetAll(base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -50,7 +50,7 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, ASSERT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); }, - std::move(expected_creative_ads))); + creative_ads)); } TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, @@ -58,14 +58,13 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Arrange database_table_.SetBatchSize(2); - const CreativeNewTabPageAdList creative_ads = BuildCreativeNewTabPageAds(3); + const CreativeNewTabPageAdList creative_ads = + BuildCreativeNewTabPageAds(/*count*/ 3); // Act SaveCreativeAds(creative_ads); // Assert - CreativeNewTabPageAdList expected_creative_ads = creative_ads; - database_table_.GetAll(base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -73,7 +72,7 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, ASSERT_TRUE(success); EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); }, - std::move(expected_creative_ads))); + creative_ads)); } TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, @@ -81,7 +80,8 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Arrange CreativeNewTabPageAdList creative_ads; - const CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + const CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ads.push_back(creative_ad); SaveCreativeAds(creative_ads); @@ -90,9 +90,6 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, SaveCreativeAds(creative_ads); // Assert - CreativeNewTabPageAdList expected_creative_ads; - expected_creative_ads.push_back(creative_ad); - database_table_.GetAll(base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -100,22 +97,25 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, ASSERT_TRUE(success); EXPECT_EQ(expected_creative_ads, creative_ads); }, - std::move(expected_creative_ads))); + creative_ads)); } TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, GetForSegments) { // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "food & drink"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "technology & computing-software"; creative_ads.push_back(creative_ad_2); - CreativeNewTabPageAdInfo creative_ad_3 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_3 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "food & drink"; creative_ads.push_back(creative_ad_3); @@ -124,14 +124,11 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, GetForSegments) { // Act // Assert - CreativeNewTabPageAdList expected_creative_ads; - expected_creative_ads.push_back(creative_ad_1); - expected_creative_ads.push_back(creative_ad_3); - - const SegmentList segments = {"food & drink"}; + CreativeNewTabPageAdList expected_creative_ads = {creative_ad_1, + creative_ad_3}; database_table_.GetForSegments( - segments, + /*segments*/ {"food & drink"}, base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -147,10 +144,12 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Arrange CreativeNewTabPageAdList creative_ads; - const CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + const CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ads.push_back(creative_ad_1); - const CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + const CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ads.push_back(creative_ad_2); SaveCreativeAds(creative_ads); @@ -158,7 +157,7 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Act // Assert - CreativeNewTabPageAdInfo expected_creative_ad = creative_ad_1; + const CreativeNewTabPageAdInfo expected_creative_ad = creative_ad_1; database_table_.GetForCreativeInstanceId( expected_creative_ad.creative_instance_id, @@ -175,7 +174,8 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, GetCreativeNewTabPageAdsForNonExistentCreativeInstanceId) { // Arrange - const CreativeNewTabPageAdList creative_ads = BuildCreativeNewTabPageAds(1); + const CreativeNewTabPageAdList creative_ads = + BuildCreativeNewTabPageAds(/*count*/ 1); SaveCreativeAds(creative_ads); @@ -183,7 +183,7 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Assert database_table_.GetForCreativeInstanceId( - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", + kMissingCreativeInstanceId, base::BindOnce([](const bool success, const std::string& /*creative_instance_id*/, const CreativeNewTabPageAdInfo& /*creative_ad*/) { @@ -194,17 +194,16 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, GetCreativeNewTabPageAdsForEmptySegments) { // Arrange - const CreativeNewTabPageAdList creative_ads = BuildCreativeNewTabPageAds(1); + const CreativeNewTabPageAdList creative_ads = + BuildCreativeNewTabPageAds(/*count*/ 1); SaveCreativeAds(creative_ads); // Act // Assert - const SegmentList segments = {""}; - database_table_.GetForSegments( - segments, + /*segments*/ {}, base::BindOnce([](const bool success, const SegmentList& /*segments*/, const CreativeNewTabPageAdList& creative_ads) { ASSERT_TRUE(success); @@ -215,17 +214,16 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, GetCreativeNewTabPageAdsForNonExistentSegment) { // Arrange - const CreativeNewTabPageAdList creative_ads = BuildCreativeNewTabPageAds(1); + const CreativeNewTabPageAdList creative_ads = + BuildCreativeNewTabPageAds(/*count*/ 1); SaveCreativeAds(creative_ads); // Act // Assert - const SegmentList segments = {"FOOBAR"}; - database_table_.GetForSegments( - segments, + /*segments*/ {"FOOBAR"}, base::BindOnce([](const bool success, const SegmentList& /*segments*/, const CreativeNewTabPageAdList& creative_ads) { ASSERT_TRUE(success); @@ -238,15 +236,18 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing-software"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ads.push_back(creative_ad_2); - CreativeNewTabPageAdInfo creative_ad_3 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_3 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_3.segment = "automobiles"; creative_ads.push_back(creative_ad_3); @@ -255,14 +256,11 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Act // Assert - CreativeNewTabPageAdList expected_creative_ads; - expected_creative_ads.push_back(creative_ad_1); - expected_creative_ads.push_back(creative_ad_2); - - const SegmentList segments = {creative_ad_1.segment, creative_ad_2.segment}; + CreativeNewTabPageAdList expected_creative_ads = {creative_ad_1, + creative_ad_2}; database_table_.GetForSegments( - segments, + /*segments*/ {creative_ad_1.segment, creative_ad_2.segment}, base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -278,12 +276,14 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.start_at = DistantPast(); creative_ad_1.end_at = Now(); creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.start_at = DistantPast(); creative_ad_2.end_at = DistantFuture(); creative_ads.push_back(creative_ad_2); @@ -294,8 +294,7 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, AdvanceClockBy(base::Seconds(1)); // Assert - CreativeNewTabPageAdList expected_creative_ads; - expected_creative_ads.push_back(creative_ad_2); + CreativeNewTabPageAdList expected_creative_ads = {creative_ad_2}; database_table_.GetAll(base::BindOnce( [](const CreativeNewTabPageAdList& expected_creative_ads, @@ -312,11 +311,13 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Arrange CreativeNewTabPageAdList creative_ads; - CreativeNewTabPageAdInfo creative_ad_1 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_1 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_1.segment = "technology & computing-software"; creative_ads.push_back(creative_ad_1); - CreativeNewTabPageAdInfo creative_ad_2 = BuildCreativeNewTabPageAd(); + CreativeNewTabPageAdInfo creative_ad_2 = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); creative_ad_2.segment = "food & drink"; creative_ads.push_back(creative_ad_2); @@ -325,31 +326,27 @@ TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, // Act // Assert - CreativeNewTabPageAdList expected_creative_ads; - expected_creative_ads.push_back(creative_ad_2); - - const SegmentList segments = {"FoOd & DrInK"}; + CreativeNewTabPageAdList expected_creative_ads = {creative_ad_2}; database_table_.GetForSegments( - segments, base::BindOnce( - [](const CreativeNewTabPageAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNewTabPageAdList& creative_ads) { - ASSERT_TRUE(success); - EXPECT_EQ(expected_creative_ads, creative_ads); - }, - std::move(expected_creative_ads))); + /*segments*/ {"FoOd & DrInK"}, + base::BindOnce( + [](const CreativeNewTabPageAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeNewTabPageAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativeNewTabPageAdsDatabaseTableTest, TableName) { // Arrange // Act - const std::string table_name = database_table_.GetTableName(); // Assert - const std::string expected_table_name = "creative_new_tab_page_ads"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_new_tab_page_ads", database_table_.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h index f74d7c154def..b4908192fc42 100644 --- a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h +++ b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h @@ -14,7 +14,7 @@ void SaveCreativeAds(const CreativeNotificationAdList& creative_ads); CreativeNotificationAdList BuildCreativeNotificationAds(int count); CreativeNotificationAdInfo BuildCreativeNotificationAd( - bool should_use_random_guids = true); + bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_test.cc b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_test.cc index 8a23141dc0ca..48e9dc232bb5 100644 --- a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_test.cc +++ b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_test.cc @@ -34,15 +34,13 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableIntegrationTest, // Act // Assert - const std::vector segments = {"technology & computing"}; - const database::table::CreativeNotificationAds creative_ads; creative_ads.GetForSegments( - segments, + /*segments*/ {"technology & computing"}, base::BindOnce([](const bool success, const SegmentList& /*segments*/, const CreativeNotificationAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_EQ(2UL, creative_ads.size()); + EXPECT_EQ(2U, creative_ads.size()); })); } diff --git a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_unittest.cc index ce16488203c4..3a695291ed68 100644 --- a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table_unittest.cc @@ -11,8 +11,7 @@ #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_container_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" -#include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_util.h" -#include "url/gurl.h" +#include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" // npm run test -- brave_unit_tests --filter=BatAds* @@ -20,22 +19,15 @@ namespace brave_ads::database::table { class BatAdsCreativeNotificationAdsDatabaseTableTest : public UnitTestBase { protected: - void SetUp() override { - UnitTestBase::SetUp(); - - database_table_ = std::make_unique(); - } - - std::unique_ptr database_table_; + CreativeNotificationAds database_table_; }; TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, SaveEmptyCreativeNotificationAds) { // Arrange - const CreativeNotificationAdList creative_ads; // Act - SaveCreativeNotificationAds(creative_ads); + SaveCreativeAds({}); // Assert } @@ -43,296 +35,95 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, SaveCreativeNotificationAds) { // Arrange - CreativeNotificationAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.body = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeNotificationAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.body = "Test Ad 2 Body"; - info_2.ptr = 0.8; - creative_ads.push_back(info_2); + const CreativeNotificationAdList creative_ads = + BuildCreativeNotificationAds(/*count*/ 2); // Act - SaveCreativeNotificationAds(creative_ads); + SaveCreativeAds(creative_ads); // Assert - CreativeNotificationAdList expected_creative_ads = creative_ads; - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNotificationAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetAll(base::BindOnce( + [](const CreativeNotificationAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeNotificationAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + }, + creative_ads)); } TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, SaveCreativeNotificationAdsInBatches) { // Arrange - database_table_->SetBatchSize(2); + database_table_.SetBatchSize(2); - CreativeNotificationAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.body = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeNotificationAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.body = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_ads.push_back(info_2); - - CreativeNotificationAdInfo info_3; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.start_at = DistantPast(); - info_3.end_at = DistantFuture(); - info_3.daily_cap = 1; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.priority = 2; - info_3.per_day = 3; - info_3.per_week = 4; - info_3.per_month = 5; - info_3.total_max = 6; - info_3.value = 1.0; - info_3.segment = "technology & computing-software"; - info_3.dayparts.push_back(daypart_info); - info_3.geo_targets = {"US"}; - info_3.target_url = GURL("https://brave.com"); - info_3.title = "Test Ad 3 Title"; - info_3.body = "Test Ad 3 Body"; - info_3.ptr = 1.0; - creative_ads.push_back(info_3); + const CreativeNotificationAdList creative_ads = + BuildCreativeNotificationAds(/*count*/ 3); // Act - SaveCreativeNotificationAds(creative_ads); + SaveCreativeAds(creative_ads); // Assert - CreativeNotificationAdList expected_creative_ads = creative_ads; - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNotificationAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetAll(base::BindOnce( + [](const CreativeNotificationAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeNotificationAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + }, + creative_ads)); } TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, DoNotSaveDuplicateCreativeNotificationAds) { // Arrange - CreativeNotificationAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.body = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeNotificationAds(creative_ads); + const CreativeNotificationAdList creative_ads = + BuildCreativeNotificationAds(/*count*/ 1); + SaveCreativeAds(creative_ads); // Act - SaveCreativeNotificationAds(creative_ads); + SaveCreativeAds(creative_ads); // Assert - CreativeNotificationAdList expected_creative_ads = creative_ads; - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNotificationAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetAll(base::BindOnce( + [](const CreativeNotificationAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeNotificationAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + creative_ads)); } -TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, - GetCreativeNotificationAds) { +TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, GetForSegments) { // Arrange CreativeNotificationAdList creative_ads; - CreativeDaypartInfo daypart_info_1; - daypart_info_1.dow = "0"; - daypart_info_1.start_minute = 0; - daypart_info_1.end_minute = 719; - CreativeDaypartInfo daypart_info_2; - daypart_info_2.dow = "1"; - daypart_info_2.start_minute = 720; - daypart_info_2.end_minute = 1439; - - CreativeNotificationAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info_1); - info_1.dayparts.push_back(daypart_info_2); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.body = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeNotificationAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info_1); - info_2.dayparts.push_back(daypart_info_2); - info_2.geo_targets = {"US-FL", "US-CA"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.body = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_ads.push_back(info_2); - - SaveCreativeNotificationAds(creative_ads); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "food & drink"; + creative_ads.push_back(creative_ad_1); + + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_2); + + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_3.segment = "food & drink"; + creative_ads.push_back(creative_ad_3); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativeNotificationAdList expected_creative_ads = creative_ads; + CreativeNotificationAdList expected_creative_ads = {creative_ad_1, + creative_ad_3}; - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, + database_table_.GetForSegments( + /*segments*/ {"food & drink"}, base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -346,101 +137,39 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, GetCreativeNotificationAdsForEmptySegments) { // Arrange - CreativeNotificationAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.body = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeNotificationAds(creative_ads); + const CreativeNotificationAdList creative_ads = + BuildCreativeNotificationAds(/*count*/ 1); + SaveCreativeAds(creative_ads); // Act // Assert - CreativeNotificationAdList expected_creative_ads; - - const SegmentList segments; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNotificationAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetForSegments( + /*segments*/ {}, + base::BindOnce([](const bool success, const SegmentList& /*segments*/, + const CreativeNotificationAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_TRUE(creative_ads.empty()); + })); } TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, GetCreativeNotificationAdsForNonExistentSegment) { // Arrange - CreativeNotificationAdList creative_ads; - - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.body = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_ads.push_back(info); - - SaveCreativeNotificationAds(creative_ads); + const CreativeNotificationAdList creative_ads = + BuildCreativeNotificationAds(/*count*/ 1); + SaveCreativeAds(creative_ads); // Act // Assert - CreativeNotificationAdList expected_creative_ads; - - const SegmentList segments = {"food & drink"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNotificationAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + database_table_.GetForSegments( + /*segments*/ {"FOOBAR"}, + base::BindOnce([](const bool success, const SegmentList& /*segments*/, + const CreativeNotificationAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_TRUE(creative_ads.empty()); + })); } TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, @@ -448,90 +177,31 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, // Arrange CreativeNotificationAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.body = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeNotificationAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "food & drink"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.body = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_ads.push_back(info_2); - - CreativeNotificationAdInfo info_3; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.start_at = DistantPast(); - info_3.end_at = DistantFuture(); - info_3.daily_cap = 1; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.priority = 2; - info_3.per_day = 3; - info_3.per_week = 4; - info_3.per_month = 5; - info_3.total_max = 6; - info_3.value = 1.0; - info_3.segment = "automobiles"; - info_3.dayparts.push_back(daypart_info); - info_3.geo_targets = {"US"}; - info_3.target_url = GURL("https://brave.com"); - info_3.title = "Test Ad 3 Title"; - info_3.body = "Test Ad 3 Body"; - info_3.ptr = 1.0; - creative_ads.push_back(info_3); - - SaveCreativeNotificationAds(creative_ads); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_1); + + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "food & drink"; + creative_ads.push_back(creative_ad_2); + + CreativeNotificationAdInfo creative_ad_3 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_3.segment = "automobiles"; + creative_ads.push_back(creative_ad_3); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativeNotificationAdList expected_creative_ads; - expected_creative_ads.push_back(info_1); - expected_creative_ads.push_back(info_2); - - const std::vector segments = {"technology & computing-software", - "food & drink"}; + CreativeNotificationAdList expected_creative_ads = {creative_ad_1, + creative_ad_2}; - database_table_->GetForSegments( - segments, + database_table_.GetForSegments( + /*segments*/ {creative_ad_1.segment, creative_ad_2.segment}, base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, @@ -547,74 +217,34 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, // Arrange CreativeNotificationAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = Now(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.body = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeNotificationAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.body = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_ads.push_back(info_2); - - SaveCreativeNotificationAds(creative_ads); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_1.start_at = DistantPast(); + creative_ad_1.end_at = Now(); + creative_ads.push_back(creative_ad_1); + + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_2.start_at = DistantPast(); + creative_ad_2.end_at = DistantFuture(); + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act AdvanceClockBy(base::Hours(1)); // Assert - CreativeNotificationAdList expected_creative_ads; - expected_creative_ads.push_back(info_2); - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativeNotificationAdList& expected_creative_ads, - const bool success, const SegmentList& /*segments*/, - const CreativeNotificationAdList& creative_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); - }, - std::move(expected_creative_ads))); + CreativeNotificationAdList expected_creative_ads = {creative_ad_2}; + + database_table_.GetAll(base::BindOnce( + [](const CreativeNotificationAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativeNotificationAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, @@ -622,71 +252,31 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, // Arrange CreativeNotificationAdList creative_ads; - const CreativeDaypartInfo daypart_info; - CreativeNotificationAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.body = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_ads.push_back(info_1); - - CreativeNotificationAdInfo info_2; - info_2.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_2.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_2.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "food & drink"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.body = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_ads.push_back(info_2); - - SaveCreativeNotificationAds(creative_ads); + CreativeNotificationAdInfo creative_ad_1 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_1); + + CreativeNotificationAdInfo creative_ad_2 = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "food & drink"; + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativeNotificationAdList expected_creative_ads; - expected_creative_ads.push_back(info_2); + CreativeNotificationAdList expected_creative_ads = {creative_ad_2}; - const SegmentList segments = {"FoOd & DrInK"}; - - database_table_->GetForSegments( - segments, + database_table_.GetForSegments( + /*segments*/ {"FoOd & DrInK"}, base::BindOnce( [](const CreativeNotificationAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, const CreativeNotificationAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + EXPECT_EQ(expected_creative_ads, creative_ads); }, std::move(expected_creative_ads))); } @@ -695,11 +285,9 @@ TEST_F(BatAdsCreativeNotificationAdsDatabaseTableTest, TableName) { // Arrange // Act - const std::string table_name = database_table_->GetTableName(); // Assert - const std::string expected_table_name = "creative_ad_notifications"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_ad_notifications", database_table_.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h index 924e40f7503e..439cb8d5d93c 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h @@ -14,7 +14,7 @@ void SaveCreativeAds(const CreativePromotedContentAdList& creative_ads); CreativePromotedContentAdList BuildCreativePromotedContentAds(int count); CreativePromotedContentAdInfo BuildCreativePromotedContentAd( - bool should_use_random_guids = true); + bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.cc b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.cc index fdd1bf8cc22d..f7b27b888dd2 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.cc +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.cc @@ -282,6 +282,7 @@ void CreativePromotedContentAds::GetForCreativeInstanceId( const std::string& creative_instance_id, GetCreativePromotedContentAdCallback callback) const { if (creative_instance_id.empty()) { + DCHECK(false) << "FOOBAR"; return std::move(callback).Run(/*success*/ false, creative_instance_id, {}); } diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_test.cc b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_test.cc index 8c53d1309a37..fde49ce6a9cc 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_test.cc +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_test.cc @@ -35,17 +35,15 @@ TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableIntegrationTest, // Act // Assert - const std::vector segments = {"technology & computing"}; - const database::table::CreativePromotedContentAds creative_promoted_content_ads; creative_promoted_content_ads.GetForSegments( - segments, + /*segments*/ {"technology & computing"}, base::BindOnce([](const bool success, const SegmentList& /*segments*/, const CreativePromotedContentAdList& creative_promoted_content_ads) { EXPECT_TRUE(success); - EXPECT_EQ(1UL, creative_promoted_content_ads.size()); + EXPECT_EQ(1U, creative_promoted_content_ads.size()); })); } diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc index 4a1858026c16..aebec063cf06 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table_unittest.cc @@ -5,11 +5,14 @@ #include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.h" +#include + +#include "base/functional/bind.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_container_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" -#include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_util.h" -#include "url/gurl.h" +#include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h" // npm run test -- brave_unit_tests --filter=BatAds* @@ -17,22 +20,15 @@ namespace brave_ads::database::table { class BatAdsCreativePromotedContentAdsDatabaseTableTest : public UnitTestBase { protected: - void SetUp() override { - UnitTestBase::SetUp(); - - database_table_ = std::make_unique(); - } - - std::unique_ptr database_table_; + CreativePromotedContentAds database_table_; }; TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, SaveEmptyCreativePromotedContentAds) { // Arrange - const CreativePromotedContentAdList creative_promoted_content_ads; // Act - SaveCreativePromotedContentAds(creative_promoted_content_ads); + SaveCreativeAds({}); // Assert } @@ -40,794 +36,316 @@ TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, SaveCreativePromotedContentAds) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_promoted_content_ads.push_back(info_1); - - CreativePromotedContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Body"; - info_2.ptr = 0.8; - creative_promoted_content_ads.push_back(info_2); + const CreativePromotedContentAdList creative_ads = + BuildCreativePromotedContentAds(/*count*/ 2); // Act - SaveCreativePromotedContentAds(creative_promoted_content_ads); + SaveCreativeAds(creative_ads); // Assert - const CreativePromotedContentAdList expected_creative_promoted_content_ads = - creative_promoted_content_ads; - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, - const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); - }, - expected_creative_promoted_content_ads)); + database_table_.GetAll(base::BindOnce( + [](const CreativePromotedContentAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativePromotedContentAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + }, + creative_ads)); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, SaveCreativePromotedContentAdsInBatches) { // Arrange - database_table_->SetBatchSize(2); - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdList creative_promoted_content_ads; - - CreativePromotedContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_promoted_content_ads.push_back(info_1); - - CreativePromotedContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_promoted_content_ads.push_back(info_2); - - CreativePromotedContentAdInfo info_3; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.start_at = DistantPast(); - info_3.end_at = DistantFuture(); - info_3.daily_cap = 1; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.priority = 2; - info_3.per_day = 3; - info_3.per_week = 4; - info_3.per_month = 5; - info_3.total_max = 6; - info_3.value = 1.0; - info_3.segment = "technology & computing-software"; - info_3.dayparts.push_back(daypart_info); - info_3.geo_targets = {"US"}; - info_3.target_url = GURL("https://brave.com"); - info_3.title = "Test Ad 3 Title"; - info_3.description = "Test Ad 3 Body"; - info_3.ptr = 1.0; - creative_promoted_content_ads.push_back(info_3); + database_table_.SetBatchSize(2); + + const CreativePromotedContentAdList creative_ads = + BuildCreativePromotedContentAds(/*count*/ 3); // Act - SaveCreativePromotedContentAds(creative_promoted_content_ads); + SaveCreativeAds(creative_ads); // Assert - const CreativePromotedContentAdList expected_creative_promoted_content_ads = - creative_promoted_content_ads; - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, - const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); - }, - expected_creative_promoted_content_ads)); + database_table_.GetAll(base::BindOnce( + [](const CreativePromotedContentAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativePromotedContentAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); + }, + creative_ads)); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, DoNotSaveDuplicateCreativePromotedContentAds) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.description = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_promoted_content_ads.push_back(info); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + CreativePromotedContentAdList creative_ads; - // Act - SaveCreativePromotedContentAds(creative_promoted_content_ads); + const CreativePromotedContentAdInfo creative_ad = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ads.push_back(creative_ad); - // Assert - const CreativePromotedContentAdList expected_creative_promoted_content_ads = - creative_promoted_content_ads; + SaveCreativeAds(creative_ads); - const SegmentList segments = {"technology & computing-software"}; + // Act + SaveCreativeAds(creative_ads); - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, - const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); - }, - expected_creative_promoted_content_ads)); + // Assert + database_table_.GetAll(base::BindOnce( + [](const CreativePromotedContentAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativePromotedContentAdList& creative_ads) { + EXPECT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + creative_ads)); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetForSegments) { // Arrange + CreativePromotedContentAdList creative_ads; + + CreativePromotedContentAdInfo creative_ad_1 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "food & drink"; + creative_ads.push_back(creative_ad_1); + + CreativePromotedContentAdInfo creative_ad_2 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_2); - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_promoted_content_ads.push_back(info_1); - - CreativePromotedContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_promoted_content_ads.push_back(info_2); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + CreativePromotedContentAdInfo creative_ad_3 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_3.segment = "food & drink"; + creative_ads.push_back(creative_ad_3); + + SaveCreativeAds(creative_ads); // Act // Assert - const CreativePromotedContentAdList expected_creative_promoted_content_ads = - creative_promoted_content_ads; - - const SegmentList segments = {"technology & computing-software"}; + CreativePromotedContentAdList expected_creative_ads = {creative_ad_1, + creative_ad_3}; - database_table_->GetForSegments( - segments, + database_table_.GetForSegments( + /*segments*/ {"food & drink"}, base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, + [](const CreativePromotedContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { + const CreativePromotedContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); + EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); }, - expected_creative_promoted_content_ads)); + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetCreativePromotedContentAdsForCreativeInstanceId) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - CreativeDaypartInfo daypart_info_1; - daypart_info_1.dow = "0"; - daypart_info_1.start_minute = 0; - daypart_info_1.end_minute = 719; - CreativeDaypartInfo daypart_info_2; - daypart_info_2.dow = "1"; - daypart_info_2.start_minute = 720; - daypart_info_2.end_minute = 1439; - - CreativePromotedContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info_1); - info.dayparts.push_back(daypart_info_2); - info.geo_targets = {"US-FL", "US-CA"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.description = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_promoted_content_ads.push_back(info); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + CreativePromotedContentAdList creative_ads; + + const CreativePromotedContentAdInfo creative_ad_1 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ads.push_back(creative_ad_1); + + const CreativePromotedContentAdInfo creative_ad_2 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act // Assert - const CreativePromotedContentAdInfo expected_creative_promoted_content_ad = - info; - - const std::string creative_instance_id = - "3519f52c-46a4-4c48-9c2b-c264c0067f04"; + const CreativePromotedContentAdInfo expected_creative_ad = creative_ad_1; - database_table_->GetForCreativeInstanceId( - creative_instance_id, + database_table_.GetForCreativeInstanceId( + expected_creative_ad.creative_instance_id, base::BindOnce( - [](const CreativePromotedContentAdInfo& - expected_creative_promoted_content_ad, + [](const CreativePromotedContentAdInfo& expected_creative_ad, const bool success, const std::string& /*creative_instance_id*/, - const CreativePromotedContentAdInfo& - creative_promoted_content_ad) { + const CreativePromotedContentAdInfo& creative_ad) { ASSERT_TRUE(success); - EXPECT_EQ(expected_creative_promoted_content_ad, - creative_promoted_content_ad); + EXPECT_EQ(expected_creative_ad, creative_ad); }, - expected_creative_promoted_content_ad)); + expected_creative_ad)); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetCreativePromotedContentAdsForNonExistentCreativeInstanceId) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.description = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_promoted_content_ads.push_back(info); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + const CreativePromotedContentAdList creative_ads = + BuildCreativePromotedContentAds(/*count*/ 1); + + SaveCreativeAds(creative_ads); // Act // Assert - const std::string creative_instance_id = - "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - - database_table_->GetForCreativeInstanceId( - creative_instance_id, - base::BindOnce( - [](const bool success, const std::string& /*creative_instance_id*/, - const CreativePromotedContentAdInfo& - /*creative_promoted_content_ad*/) { EXPECT_FALSE(success); })); + database_table_.GetForCreativeInstanceId( + kMissingCreativeInstanceId, + base::BindOnce([](const bool success, + const std::string& /*creative_instance_id*/, + const CreativePromotedContentAdInfo& + /*creative_ads*/) { EXPECT_FALSE(success); })); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetCreativePromotedContentAdsForEmptySegments) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.description = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_promoted_content_ads.push_back(info); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + const CreativePromotedContentAdList creative_ads = + BuildCreativePromotedContentAds(/*count*/ 1); + + SaveCreativeAds(creative_ads); // Act // Assert - const CreativePromotedContentAdList expected_creative_promoted_content_ads = - {}; - - const SegmentList segments; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, - const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); - }, - expected_creative_promoted_content_ads)); + database_table_.GetForSegments( + /*segments*/ {}, + base::BindOnce([](const bool success, const SegmentList& /*segments*/, + const CreativePromotedContentAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_TRUE(creative_ads.empty()); + })); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetCreativePromotedContentAdsForNonExistentSegment) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info; - info.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info.start_at = DistantPast(); - info.end_at = DistantFuture(); - info.daily_cap = 1; - info.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info.priority = 2; - info.per_day = 3; - info.per_week = 4; - info.per_month = 5; - info.total_max = 6; - info.value = 1.0; - info.segment = "technology & computing-software"; - info.dayparts.push_back(daypart_info); - info.geo_targets = {"US"}; - info.target_url = GURL("https://brave.com"); - info.title = "Test Ad 1 Title"; - info.description = "Test Ad 1 Body"; - info.ptr = 1.0; - creative_promoted_content_ads.push_back(info); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + const CreativePromotedContentAdList creative_ads = + BuildCreativePromotedContentAds(/*count*/ 1); + + SaveCreativeAds(creative_ads); // Act // Assert - const CreativePromotedContentAdList expected_creative_promoted_content_ads = - {}; - - const SegmentList segments = {"food & drink"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, - const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); - }, - expected_creative_promoted_content_ads)); + database_table_.GetForSegments( + /*segments*/ {"FOOBAR"}, + base::BindOnce([](const bool success, const SegmentList& /*segments*/, + const CreativePromotedContentAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_TRUE(creative_ads.empty()); + })); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetCreativePromotedContentAdsFromMultipleSegments) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_promoted_content_ads.push_back(info_1); - - CreativePromotedContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "food & drink"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_promoted_content_ads.push_back(info_2); - - CreativePromotedContentAdInfo info_3; - info_3.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_3.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_3.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_3.start_at = DistantPast(); - info_3.end_at = DistantFuture(); - info_3.daily_cap = 1; - info_3.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_3.priority = 2; - info_3.per_day = 3; - info_3.per_week = 4; - info_3.per_month = 5; - info_3.total_max = 6; - info_3.value = 1.0; - info_3.segment = "automobiles"; - info_3.dayparts.push_back(daypart_info); - info_3.geo_targets = {"US"}; - info_3.target_url = GURL("https://brave.com"); - info_3.title = "Test Ad 3 Title"; - info_3.description = "Test Ad 3 Body"; - info_3.ptr = 1.0; - creative_promoted_content_ads.push_back(info_3); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + CreativePromotedContentAdList creative_ads; + + CreativePromotedContentAdInfo creative_ad_1 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_1); + + CreativePromotedContentAdInfo creative_ad_2 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "food & drink"; + creative_ads.push_back(creative_ad_2); + + CreativePromotedContentAdInfo creative_ad_3 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_3.segment = "automobiles"; + creative_ads.push_back(creative_ad_3); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativePromotedContentAdList expected_creative_promoted_content_ads; - expected_creative_promoted_content_ads.push_back(info_1); - expected_creative_promoted_content_ads.push_back(info_2); + CreativePromotedContentAdList expected_creative_ads = {creative_ad_1, + creative_ad_2}; - const SegmentList segments = {"technology & computing-software", - "food & drink"}; - - database_table_->GetForSegments( - segments, + database_table_.GetForSegments( + /*segments*/ {creative_ad_1.segment, creative_ad_2.segment}, base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, + [](const CreativePromotedContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { + const CreativePromotedContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); + EXPECT_TRUE(ContainersEq(expected_creative_ads, creative_ads)); }, - expected_creative_promoted_content_ads)); + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetNonExpiredCreativePromotedContentAds) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = Now(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_promoted_content_ads.push_back(info_1); - - CreativePromotedContentAdInfo info_2; - info_2.creative_instance_id = "eaa6224a-876d-4ef8-a384-9ac34f238631"; - info_2.creative_set_id = "184d1fdd-8e18-4baa-909c-9a3cb62cc7b1"; - info_2.campaign_id = "d1d4a649-502d-4e06-b4b8-dae11c382d26"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "8e3fac86-ce50-4409-ae29-9aa5636aa9a2"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "technology & computing-software"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_promoted_content_ads.push_back(info_2); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + CreativePromotedContentAdList creative_ads; + + CreativePromotedContentAdInfo creative_ad_1 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_1.start_at = DistantPast(); + creative_ad_1.end_at = Now(); + creative_ads.push_back(creative_ad_1); + + CreativePromotedContentAdInfo creative_ad_2 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_2.start_at = DistantPast(); + creative_ad_2.end_at = DistantFuture(); + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act AdvanceClockBy(base::Hours(1)); // Assert - CreativePromotedContentAdList expected_creative_promoted_content_ads; - expected_creative_promoted_content_ads.push_back(info_2); - - const SegmentList segments = {"technology & computing-software"}; - - database_table_->GetForSegments( - segments, - base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, - const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { - EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); - }, - expected_creative_promoted_content_ads)); + CreativePromotedContentAdList expected_creative_ads = {creative_ad_2}; + + database_table_.GetAll(base::BindOnce( + [](const CreativePromotedContentAdList& expected_creative_ads, + const bool success, const SegmentList& /*segments*/, + const CreativePromotedContentAdList& creative_ads) { + ASSERT_TRUE(success); + EXPECT_EQ(expected_creative_ads, creative_ads); + }, + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, GetCreativePromotedContentAdsMatchingCaseInsensitiveSegments) { // Arrange - CreativePromotedContentAdList creative_promoted_content_ads; - - const CreativeDaypartInfo daypart_info; - CreativePromotedContentAdInfo info_1; - info_1.creative_instance_id = "3519f52c-46a4-4c48-9c2b-c264c0067f04"; - info_1.creative_set_id = "c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123"; - info_1.campaign_id = "84197fc8-830a-4a8e-8339-7a70c2bfa104"; - info_1.start_at = DistantPast(); - info_1.end_at = DistantFuture(); - info_1.daily_cap = 1; - info_1.advertiser_id = "5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2"; - info_1.priority = 2; - info_1.per_day = 3; - info_1.per_week = 4; - info_1.per_month = 5; - info_1.total_max = 6; - info_1.value = 1.0; - info_1.segment = "technology & computing-software"; - info_1.dayparts.push_back(daypart_info); - info_1.geo_targets = {"US"}; - info_1.target_url = GURL("https://brave.com"); - info_1.title = "Test Ad 1 Title"; - info_1.description = "Test Ad 1 Body"; - info_1.ptr = 1.0; - creative_promoted_content_ads.push_back(info_1); - - CreativePromotedContentAdInfo info_2; - info_2.creative_instance_id = "a1ac44c2-675f-43e6-ab6d-500614cafe63"; - info_2.creative_set_id = "5800049f-cee5-4bcb-90c7-85246d5f5e7c"; - info_2.campaign_id = "3d62eca2-324a-4161-a0c5-7d9f29d10ab0"; - info_2.start_at = DistantPast(); - info_2.end_at = DistantFuture(); - info_2.daily_cap = 1; - info_2.advertiser_id = "9a11b60f-e29d-4446-8d1f-318311e36e0a"; - info_2.priority = 2; - info_2.per_day = 3; - info_2.per_week = 4; - info_2.per_month = 5; - info_2.total_max = 6; - info_2.value = 1.0; - info_2.segment = "food & drink"; - info_2.dayparts.push_back(daypart_info); - info_2.geo_targets = {"US"}; - info_2.target_url = GURL("https://brave.com"); - info_2.title = "Test Ad 2 Title"; - info_2.description = "Test Ad 2 Body"; - info_2.ptr = 1.0; - creative_promoted_content_ads.push_back(info_2); - - SaveCreativePromotedContentAds(creative_promoted_content_ads); + CreativePromotedContentAdList creative_ads; + + CreativePromotedContentAdInfo creative_ad_1 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_1.segment = "technology & computing-software"; + creative_ads.push_back(creative_ad_1); + + CreativePromotedContentAdInfo creative_ad_2 = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); + creative_ad_2.segment = "food & drink"; + creative_ads.push_back(creative_ad_2); + + SaveCreativeAds(creative_ads); // Act // Assert - CreativePromotedContentAdList expected_creative_promoted_content_ads; - expected_creative_promoted_content_ads.push_back(info_2); - - const SegmentList segments = {"FoOd & DrInK"}; + CreativePromotedContentAdList expected_creative_ads = {creative_ad_2}; - database_table_->GetForSegments( - segments, + database_table_.GetForSegments( + /*segments*/ {"FoOd & DrInK"}, base::BindOnce( - [](const CreativePromotedContentAdList& - expected_creative_promoted_content_ads, + [](const CreativePromotedContentAdList& expected_creative_ads, const bool success, const SegmentList& /*segments*/, - const CreativePromotedContentAdList& - creative_promoted_content_ads) { + const CreativePromotedContentAdList& creative_ads) { EXPECT_TRUE(success); - EXPECT_TRUE(ContainersEq(expected_creative_promoted_content_ads, - creative_promoted_content_ads)); + EXPECT_EQ(expected_creative_ads, creative_ads); }, - expected_creative_promoted_content_ads)); + std::move(expected_creative_ads))); } TEST_F(BatAdsCreativePromotedContentAdsDatabaseTableTest, TableName) { // Arrange // Act - const std::string table_name = database_table_->GetTableName(); // Assert - const std::string expected_table_name = "creative_promoted_content_ads"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("creative_promoted_content_ads", database_table_.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.cc b/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.cc index 3860090e5336..944cec901444 100644 --- a/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.cc +++ b/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.cc @@ -5,32 +5,79 @@ #include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h" +#include "base/check.h" #include "base/guid.h" #include "brave/components/brave_ads/common/interfaces/ads.mojom.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" +#include "brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h" #include "url/gurl.h" namespace brave_ads { -mojom::SearchResultAdInfoPtr BuildSearchResultAd() { +namespace { + +constexpr char kHeadlineText[] = "headline"; +constexpr char kDescription[] = "description"; +constexpr int kValue = 1.0; + +constexpr char kConversionType[] = "postview"; +constexpr char kConversionUrlPattern[] = "https://brave.com/*"; +constexpr int kConversionObservationWindow = 3; +const base::Time kConversionExpireAt = DistantFuture(); + +} // namespace + +mojom::SearchResultAdInfoPtr BuildSearchResultAd( + const bool should_use_random_guids) { mojom::SearchResultAdInfoPtr ad = mojom::SearchResultAdInfo::New(); - ad->creative_instance_id = base::GUID::GenerateRandomV4().AsLowercaseString(); - ad->placement_id = base::GUID::GenerateRandomV4().AsLowercaseString(); - ad->creative_set_id = base::GUID::GenerateRandomV4().AsLowercaseString(); - ad->campaign_id = base::GUID::GenerateRandomV4().AsLowercaseString(); - ad->advertiser_id = base::GUID::GenerateRandomV4().AsLowercaseString(); + ad->placement_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kPlacementId; + + ad->creative_instance_id = + should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeInstanceId; + + ad->creative_set_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCreativeSetId; + + ad->campaign_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kCampaignId; + + ad->advertiser_id = should_use_random_guids + ? base::GUID::GenerateRandomV4().AsLowercaseString() + : kAdvertiserId; + ad->target_url = GURL("https://brave.com"); - ad->headline_text = "headline"; - ad->description = "description"; - ad->value = 1.0; + + ad->headline_text = kHeadlineText; + + ad->description = kDescription; + + ad->value = kValue; + ad->conversion = mojom::ConversionInfo::New(); - ad->conversion->type = "postview"; - ad->conversion->url_pattern = "https://brave.com/*"; - ad->conversion->advertiser_public_key = - "ofIveUY/bM7qlL9eIkAv/xbjDItFs1xRTTYKRZZsPHI="; - ad->conversion->observation_window = 3; - ad->conversion->expire_at = DistantFuture(); + + return ad; +} + +mojom::SearchResultAdInfoPtr BuildSearchResultAdWithConversion( + const bool should_use_random_guids) { + mojom::SearchResultAdInfoPtr ad = + BuildSearchResultAd(should_use_random_guids); + CHECK(ad); + CHECK(ad->conversion); + + ad->conversion->type = kConversionType; + ad->conversion->url_pattern = kConversionUrlPattern; + ad->conversion->advertiser_public_key = kConversionAdvertiserPublicKey; + ad->conversion->observation_window = kConversionObservationWindow; + ad->conversion->expire_at = kConversionExpireAt; return ad; } diff --git a/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h b/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h index d0d81e881331..1b09111c2f0c 100644 --- a/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h +++ b/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h @@ -10,7 +10,9 @@ namespace brave_ads { -mojom::SearchResultAdInfoPtr BuildSearchResultAd(); +mojom::SearchResultAdInfoPtr BuildSearchResultAd(bool should_use_random_guids); +mojom::SearchResultAdInfoPtr BuildSearchResultAdWithConversion( + bool should_use_random_guids); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/segments_database_table_unittest.cc b/components/brave_ads/core/internal/creatives/segments_database_table_unittest.cc index 871373e56e87..f9ec5346a3f9 100644 --- a/components/brave_ads/core/internal/creatives/segments_database_table_unittest.cc +++ b/components/brave_ads/core/internal/creatives/segments_database_table_unittest.cc @@ -16,11 +16,9 @@ TEST(BatAdsSegmentsDatabaseTableTest, TableName) { const Segments database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "segments"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("segments", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc b/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc index f62d6d985623..9c9732ea31db 100644 --- a/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc +++ b/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info_unittest.cc @@ -38,24 +38,23 @@ constexpr char kSampleAdPreferencesInfoJson[] = R"( void ParseJsonAndCompareWithSampleAdPreferencesInfo(const std::string& json) { // Arrange - AdPreferencesInfo ad_preferences_info; + AdPreferencesInfo ad_preferences; // Act - EXPECT_TRUE(ad_preferences_info.FromJson(json)); + EXPECT_TRUE(ad_preferences.FromJson(json)); // Assert - ASSERT_EQ(1U, ad_preferences_info.filtered_advertisers.size()); + ASSERT_EQ(1U, ad_preferences.filtered_advertisers.size()); EXPECT_EQ("filtered_advertiser_id", - ad_preferences_info.filtered_advertisers[0].id); - ASSERT_EQ(1U, ad_preferences_info.filtered_categories.size()); + ad_preferences.filtered_advertisers[0].id); + ASSERT_EQ(1U, ad_preferences.filtered_categories.size()); EXPECT_EQ("filtered_category_name", - ad_preferences_info.filtered_categories[0].name); - ASSERT_EQ(1U, ad_preferences_info.saved_ads.size()); + ad_preferences.filtered_categories[0].name); + ASSERT_EQ(1U, ad_preferences.saved_ads.size()); EXPECT_EQ("creative_instance_id", - ad_preferences_info.saved_ads[0].creative_instance_id); - ASSERT_EQ(1U, ad_preferences_info.flagged_ads.size()); - EXPECT_EQ("creative_set_id", - ad_preferences_info.flagged_ads[0].creative_set_id); + ad_preferences.saved_ads[0].creative_instance_id); + ASSERT_EQ(1U, ad_preferences.flagged_ads.size()); + EXPECT_EQ("creative_set_id", ad_preferences.flagged_ads[0].creative_set_id); } } // namespace @@ -64,57 +63,57 @@ class BatAdsAdPreferencesInfoTest : public UnitTestBase {}; TEST_F(BatAdsAdPreferencesInfoTest, SerializeSampleAdPreferencesInfo) { // Arrange - AdPreferencesInfo ad_preferences_info; + AdPreferencesInfo ad_preferences; FilteredAdvertiserInfo filtered_advertiser; filtered_advertiser.id = "filtered_advertiser_id"; - ad_preferences_info.filtered_advertisers.push_back(filtered_advertiser); + ad_preferences.filtered_advertisers.push_back(filtered_advertiser); FilteredCategoryInfo filtered_category; filtered_category.name = "filtered_category_name"; - ad_preferences_info.filtered_categories.push_back(filtered_category); + ad_preferences.filtered_categories.push_back(filtered_category); SavedAdInfo saved_ad; saved_ad.creative_instance_id = "creative_instance_id"; - ad_preferences_info.saved_ads.push_back(saved_ad); + ad_preferences.saved_ads.push_back(saved_ad); FlaggedAdInfo flagged_ad; flagged_ad.creative_set_id = "creative_set_id"; - ad_preferences_info.flagged_ads.push_back(flagged_ad); + ad_preferences.flagged_ads.push_back(flagged_ad); // Act - const std::string json = ad_preferences_info.ToJson(); + const std::string json = ad_preferences.ToJson(); // Assert ParseJsonAndCompareWithSampleAdPreferencesInfo(json); } TEST_F(BatAdsAdPreferencesInfoTest, ParseSampleAdPreferencesInfoJson) { - const AdPreferencesInfo ad_preferences_info; + const AdPreferencesInfo ad_preferences; ParseJsonAndCompareWithSampleAdPreferencesInfo(kSampleAdPreferencesInfoJson); } TEST_F(BatAdsAdPreferencesInfoTest, ParseEmptyJson) { // Arrange - AdPreferencesInfo ad_preferences_info; + AdPreferencesInfo ad_preferences; // Act - EXPECT_TRUE(ad_preferences_info.FromJson("{}")); + EXPECT_TRUE(ad_preferences.FromJson("{}")); // Assert - EXPECT_EQ(0U, ad_preferences_info.filtered_advertisers.size()); - EXPECT_EQ(0U, ad_preferences_info.filtered_categories.size()); - EXPECT_EQ(0U, ad_preferences_info.saved_ads.size()); - EXPECT_EQ(0U, ad_preferences_info.flagged_ads.size()); + EXPECT_EQ(0U, ad_preferences.filtered_advertisers.size()); + EXPECT_EQ(0U, ad_preferences.filtered_categories.size()); + EXPECT_EQ(0U, ad_preferences.saved_ads.size()); + EXPECT_EQ(0U, ad_preferences.flagged_ads.size()); } TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { // Arrange - AdPreferencesInfo ad_preferences_info; + AdPreferencesInfo ad_preferences; // Act & Assert // filtered_advertisers - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "filtered_advertisers": [ { @@ -122,7 +121,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { } ] })")); - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "filtered_advertisers": [ { @@ -132,7 +131,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { })")); // filtered_categories - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "filtered_categories": [ { @@ -140,7 +139,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { } ] })")); - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "filtered_categories": [ { @@ -150,7 +149,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { })")); // saved_ads - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "saved_ads": [ { @@ -158,7 +157,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { } ] })")); - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "saved_ads": [ { @@ -168,7 +167,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { })")); // flagged_ads - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "flagged_ads": [ { @@ -176,7 +175,7 @@ TEST_F(BatAdsAdPreferencesInfoTest, ParsePreferencesWithNotValidMembers) { } ] })")); - EXPECT_FALSE(ad_preferences_info.FromJson(R"({ + EXPECT_FALSE(ad_preferences.FromJson(R"({ { "flagged_ads": [ { diff --git a/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc b/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc index f26c44352d7e..43acaac53ba7 100644 --- a/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc +++ b/components/brave_ads/core/internal/diagnostics/diagnostic_manager_unittest.cc @@ -7,7 +7,6 @@ #include "base/test/values_test_util.h" #include "base/values.h" -#include "brave/components/brave_ads/common/pref_names.h" #include "brave/components/brave_ads/core/internal/catalog/catalog_util.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" diff --git a/components/brave_ads/core/internal/fl/predictors/variables/average_clickthrough_rate_predictor_variable_unittest.cc b/components/brave_ads/core/internal/fl/predictors/variables/average_clickthrough_rate_predictor_variable_unittest.cc index 9f0d7ff33e5e..f9d24f139192 100644 --- a/components/brave_ads/core/internal/fl/predictors/variables/average_clickthrough_rate_predictor_variable_unittest.cc +++ b/components/brave_ads/core/internal/fl/predictors/variables/average_clickthrough_rate_predictor_variable_unittest.cc @@ -9,6 +9,8 @@ #include "brave/components/brave_ads/core/history_item_info.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" +#include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" +#include "brave/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_builder.h" #include "brave/components/brave_ads/core/internal/history/history_manager.h" #include "brave/components/brave_ads/core/notification_ad_info.h" @@ -49,7 +51,10 @@ TEST_F(BatAdsAverageClickthroughRatePredictorVariableTest, std::unique_ptr predictor_variable = std::make_unique(base::Days(1)); - const NotificationAdInfo ad; + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + const NotificationAdInfo ad = BuildNotificationAd(creative_ad); + HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kClicked); @@ -68,7 +73,10 @@ TEST_F(BatAdsAverageClickthroughRatePredictorVariableTest, std::unique_ptr predictor_variable = std::make_unique(base::Days(1)); - const NotificationAdInfo ad; + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + const NotificationAdInfo ad = BuildNotificationAd(creative_ad); + HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); // Act @@ -83,7 +91,10 @@ TEST_F(BatAdsAverageClickthroughRatePredictorVariableTest, std::unique_ptr predictor_variable = std::make_unique(base::Days(1)); - const NotificationAdInfo ad; + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + const NotificationAdInfo ad = BuildNotificationAd(creative_ad); + HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kClicked); @@ -99,7 +110,10 @@ TEST_F(BatAdsAverageClickthroughRatePredictorVariableTest, std::unique_ptr predictor_variable = std::make_unique(base::Days(1)); - const NotificationAdInfo ad; + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + const NotificationAdInfo ad = BuildNotificationAd(creative_ad); + HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kClicked); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kClicked); @@ -115,7 +129,10 @@ TEST_F(BatAdsAverageClickthroughRatePredictorVariableTest, GetValue) { std::unique_ptr predictor_variable = std::make_unique(base::Days(1)); - const NotificationAdInfo ad; + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + const NotificationAdInfo ad = BuildNotificationAd(creative_ad); + HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); diff --git a/components/brave_ads/core/internal/history/ad_content_util_unittest.cc b/components/brave_ads/core/internal/history/ad_content_util_unittest.cc index 4b9aa5493224..67e1530b774c 100644 --- a/components/brave_ads/core/internal/history/ad_content_util_unittest.cc +++ b/components/brave_ads/core/internal/history/ad_content_util_unittest.cc @@ -28,7 +28,8 @@ class BatAdsAdContentUtilTest : public UnitTestBase {}; TEST_F(BatAdsAdContentUtilTest, Build) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); // Act diff --git a/components/brave_ads/core/internal/history/category_content_util_unittest.cc b/components/brave_ads/core/internal/history/category_content_util_unittest.cc index 3578d0f92e21..31e915d14d46 100644 --- a/components/brave_ads/core/internal/history/category_content_util_unittest.cc +++ b/components/brave_ads/core/internal/history/category_content_util_unittest.cc @@ -6,16 +6,13 @@ #include "brave/components/brave_ads/core/internal/history/category_content_util.h" #include "brave/components/brave_ads/core/category_content_action_types.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" // npm run test -- brave_unit_tests --filter=BatAds* namespace brave_ads { -namespace { -constexpr char kSegment[] = "segment"; -} // namespace - class BatAdsCategoryContentUtilTest : public UnitTestBase {}; TEST_F(BatAdsCategoryContentUtilTest, Build) { diff --git a/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc b/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc index 0b7e3493ec85..bd3abe7867f6 100644 --- a/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc +++ b/components/brave_ads/core/internal/history/category_content_value_util_unittest.cc @@ -7,6 +7,7 @@ #include "base/test/values_test_util.h" #include "brave/components/brave_ads/core/category_content_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/history/category_content_util.h" @@ -15,11 +16,7 @@ namespace brave_ads { namespace { - -constexpr char kSegment[] = "segment"; - -constexpr char kJson[] = R"({"category":"segment","optAction":0})"; - +constexpr char kJson[] = R"({"category":"untargeted","optAction":0})"; } // namespace class BatAdsCategoryContentValueUtilTest : public UnitTestBase {}; diff --git a/components/brave_ads/core/internal/history/filters/date_range_history_filter_unittest.cc b/components/brave_ads/core/internal/history/filters/date_range_history_filter_unittest.cc index 9bdab00bbd63..2622ed4cc127 100644 --- a/components/brave_ads/core/internal/history/filters/date_range_history_filter_unittest.cc +++ b/components/brave_ads/core/internal/history/filters/date_range_history_filter_unittest.cc @@ -77,9 +77,7 @@ TEST(BatAdsDateRangeHistoryFilterTest, history = filter.Apply(history); // Assert - const HistoryItemList expected_history; - - EXPECT_TRUE(base::ranges::equal(expected_history, history)); + EXPECT_TRUE(history.empty()); } TEST(BatAdsDateRangeHistoryFilterTest, @@ -120,9 +118,7 @@ TEST(BatAdsDateRangeHistoryFilterTest, history = filter.Apply(history); // Assert - const HistoryItemList expected_history; - - EXPECT_TRUE(base::ranges::equal(expected_history, history)); + EXPECT_TRUE(history.empty()); } TEST(BatAdsDateRangeHistoryFilterTest, @@ -167,9 +163,7 @@ TEST(BatAdsDateRangeHistoryFilterTest, history = filter.Apply(history); // Assert - const HistoryItemList expected_history; - - EXPECT_TRUE(base::ranges::equal(expected_history, history)); + EXPECT_TRUE(history.empty()); } TEST(BatAdsDateRangeHistoryFilterTest, FilterEmptyHistory) { @@ -184,9 +178,7 @@ TEST(BatAdsDateRangeHistoryFilterTest, FilterEmptyHistory) { history = filter.Apply(history); // Assert - const HistoryItemList expected_history; - - EXPECT_TRUE(base::ranges::equal(expected_history, history)); + EXPECT_TRUE(history.empty()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/history/history_item_util_unittest.cc b/components/brave_ads/core/internal/history/history_item_util_unittest.cc index 56e6aea82522..0f67d6353fc0 100644 --- a/components/brave_ads/core/internal/history/history_item_util_unittest.cc +++ b/components/brave_ads/core/internal/history/history_item_util_unittest.cc @@ -21,7 +21,8 @@ class BatAdsHistoryItemUtilTest : public UnitTestBase {}; TEST_F(BatAdsHistoryItemUtilTest, BuildHistoryItem) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); // Act diff --git a/components/brave_ads/core/internal/history/history_manager.cc b/components/brave_ads/core/internal/history/history_manager.cc index 4e77a6a2b7c6..da38e819570b 100644 --- a/components/brave_ads/core/internal/history/history_manager.cc +++ b/components/brave_ads/core/internal/history/history_manager.cc @@ -60,13 +60,17 @@ void HistoryManager::RemoveObserver(HistoryManagerObserver* observer) { observers_.RemoveObserver(observer); } +// static +const HistoryItemList& HistoryManager::Get() { + return ClientStateManager::GetInstance()->GetHistory(); +} + // static HistoryItemList HistoryManager::Get(const HistoryFilterType filter_type, const HistorySortType sort_type, const base::Time from_time, const base::Time to_time) { - HistoryItemList history_items = - ClientStateManager::GetInstance()->GetHistory(); + HistoryItemList history_items = Get(); const auto date_range_filter = std::make_unique(from_time, to_time); @@ -90,7 +94,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.title, ad.description); - NotifyHistoryDidChange(); + NotifyHistoryDidChange(history_item); return history_item; } @@ -99,7 +103,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.company_name, ad.alt); - NotifyHistoryDidChange(); + NotifyHistoryDidChange(history_item); return history_item; } @@ -108,7 +112,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.title, ad.body); - NotifyHistoryDidChange(); + NotifyHistoryDidChange(history_item); return history_item; } @@ -117,7 +121,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.title, ad.description); - NotifyHistoryDidChange(); + NotifyHistoryDidChange(history_item); return history_item; } @@ -126,7 +130,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.headline_text, ad.description); - NotifyHistoryDidChange(); + NotifyHistoryDidChange(history_item); return history_item; } @@ -208,9 +212,10 @@ bool HistoryManager::ToggleSaveAd(const AdContentInfo& ad_content) const { /////////////////////////////////////////////////////////////////////////////// -void HistoryManager::NotifyHistoryDidChange() const { +void HistoryManager::NotifyHistoryDidChange( + const HistoryItemInfo& history_item) const { for (HistoryManagerObserver& observer : observers_) { - observer.OnHistoryDidChange(); + observer.OnHistoryDidChange(history_item); } } diff --git a/components/brave_ads/core/internal/history/history_manager.h b/components/brave_ads/core/internal/history/history_manager.h index b7ce37d34412..f91af9ca153d 100644 --- a/components/brave_ads/core/internal/history/history_manager.h +++ b/components/brave_ads/core/internal/history/history_manager.h @@ -49,6 +49,7 @@ class HistoryManager final { void AddObserver(HistoryManagerObserver* observer); void RemoveObserver(HistoryManagerObserver* observer); + static const HistoryItemList& Get(); static HistoryItemList Get(HistoryFilterType filter_type, HistorySortType sort_type, base::Time from_time, @@ -80,7 +81,7 @@ class HistoryManager final { bool ToggleSaveAd(const AdContentInfo& ad_content) const; private: - void NotifyHistoryDidChange() const; + void NotifyHistoryDidChange(const HistoryItemInfo& history_item) const; void NotifyDidLikeAd(const AdContentInfo& ad_content) const; void NotifyDidDislikeAd(const AdContentInfo& ad_content) const; void NotifyDidMarkToNoLongerReceiveAdsForCategory( diff --git a/components/brave_ads/core/internal/history/history_manager_observer.h b/components/brave_ads/core/internal/history/history_manager_observer.h index 394e66c6c6ea..8a68af3b4077 100644 --- a/components/brave_ads/core/internal/history/history_manager_observer.h +++ b/components/brave_ads/core/internal/history/history_manager_observer.h @@ -13,11 +13,12 @@ namespace brave_ads { struct AdContentInfo; +struct HistoryItemInfo; class HistoryManagerObserver : public base::CheckedObserver { public: // Invoked when the history has changed. - virtual void OnHistoryDidChange() {} + virtual void OnHistoryDidChange(const HistoryItemInfo& history_item) {} // Invoked when the user likes an ad. virtual void OnDidLikeAd(const AdContentInfo& ad_content) {} diff --git a/components/brave_ads/core/internal/history/history_manager_unittest.cc b/components/brave_ads/core/internal/history/history_manager_unittest.cc index 62f5792fad12..bc52b7bca7b7 100644 --- a/components/brave_ads/core/internal/history/history_manager_unittest.cc +++ b/components/brave_ads/core/internal/history/history_manager_unittest.cc @@ -10,9 +10,17 @@ #include "brave/components/brave_ads/core/history_item_info.h" #include "brave/components/brave_ads/core/inline_content_ad_info.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" +#include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h" +#include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/inline_content_ad_builder.h" +#include "brave/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h" +#include "brave/components/brave_ads/core/internal/creatives/new_tab_page_ads/new_tab_page_ad_builder.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_builder.h" +#include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h" +#include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/promoted_content_ad_builder.h" +#include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_builder.h" #include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_info.h" +#include "brave/components/brave_ads/core/internal/creatives/search_result_ads/search_result_ad_unittest_util.h" #include "brave/components/brave_ads/core/internal/deprecated/client/client_state_manager.h" #include "brave/components/brave_ads/core/new_tab_page_ad_info.h" #include "brave/components/brave_ads/core/notification_ad_info.h" @@ -37,7 +45,9 @@ class BatAdsHistoryManagerTest : public HistoryManagerObserver, UnitTestBase::TearDown(); } - void OnHistoryDidChange() override { history_did_change_ = true; } + void OnHistoryDidChange(const HistoryItemInfo& /*history_item*/) override { + history_did_change_ = true; + } void OnDidLikeAd(const AdContentInfo& /*ad_content*/) override { did_like_ad_ = true; @@ -97,7 +107,9 @@ TEST_F(BatAdsHistoryManagerTest, HasInstance) { TEST_F(BatAdsHistoryManagerTest, AddNotificationAd) { // Arrange - const NotificationAdInfo ad; + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ false); + const NotificationAdInfo ad = BuildNotificationAd(creative_ad); // Act const HistoryItemInfo history_item = @@ -115,7 +127,9 @@ TEST_F(BatAdsHistoryManagerTest, AddNotificationAd) { TEST_F(BatAdsHistoryManagerTest, AddNewTabPageAd) { // Arrange - const NewTabPageAdInfo ad; + const CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ false); + const NewTabPageAdInfo ad = BuildNewTabPageAd(creative_ad); // Act const HistoryItemInfo history_item = @@ -133,7 +147,9 @@ TEST_F(BatAdsHistoryManagerTest, AddNewTabPageAd) { TEST_F(BatAdsHistoryManagerTest, AddPromotedContentAd) { // Arrange - const PromotedContentAdInfo ad; + const CreativePromotedContentAdInfo creative_ad = + BuildCreativePromotedContentAd(/*should_use_random_guids*/ false); + const PromotedContentAdInfo ad = BuildPromotedContentAd(creative_ad); // Act const HistoryItemInfo history_item = @@ -151,7 +167,9 @@ TEST_F(BatAdsHistoryManagerTest, AddPromotedContentAd) { TEST_F(BatAdsHistoryManagerTest, AddInlineContentAd) { // Arrange - const InlineContentAdInfo ad; + const CreativeInlineContentAdInfo creative_ad = + BuildCreativeInlineContentAd(/*should_use_random_guids*/ false); + const InlineContentAdInfo ad = BuildInlineContentAd(creative_ad); // Act const HistoryItemInfo history_item = @@ -169,7 +187,9 @@ TEST_F(BatAdsHistoryManagerTest, AddInlineContentAd) { TEST_F(BatAdsHistoryManagerTest, AddSearchResultAd) { // Arrange - const SearchResultAdInfo ad; + const mojom::SearchResultAdInfoPtr ad_mojom = + BuildSearchResultAd(/*should_use_random_guids*/ false); + const SearchResultAdInfo ad = BuildSearchResultAd(ad_mojom); // Act const HistoryItemInfo history_item = @@ -187,7 +207,8 @@ TEST_F(BatAdsHistoryManagerTest, AddSearchResultAd) { TEST_F(BatAdsHistoryManagerTest, LikeAd) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); const HistoryItemInfo history_item = @@ -203,7 +224,8 @@ TEST_F(BatAdsHistoryManagerTest, LikeAd) { TEST_F(BatAdsHistoryManagerTest, DislikeAd) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); const HistoryItemInfo history_item = @@ -219,7 +241,8 @@ TEST_F(BatAdsHistoryManagerTest, DislikeAd) { TEST_F(BatAdsHistoryManagerTest, MarkToNoLongerReceiveAdsForCategory) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); @@ -235,7 +258,8 @@ TEST_F(BatAdsHistoryManagerTest, MarkToNoLongerReceiveAdsForCategory) { TEST_F(BatAdsHistoryManagerTest, MarkToReceiveAdsForCategory) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); @@ -251,7 +275,8 @@ TEST_F(BatAdsHistoryManagerTest, MarkToReceiveAdsForCategory) { TEST_F(BatAdsHistoryManagerTest, MarkAdAsInappropriate) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); const HistoryItemInfo history_item = @@ -268,7 +293,8 @@ TEST_F(BatAdsHistoryManagerTest, MarkAdAsInappropriate) { TEST_F(BatAdsHistoryManagerTest, MarkAdAsAppropriate) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); HistoryItemInfo history_item = @@ -286,7 +312,8 @@ TEST_F(BatAdsHistoryManagerTest, MarkAdAsAppropriate) { TEST_F(BatAdsHistoryManagerTest, SaveAd) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); const HistoryItemInfo history_item = @@ -302,7 +329,8 @@ TEST_F(BatAdsHistoryManagerTest, SaveAd) { TEST_F(BatAdsHistoryManagerTest, UnsaveAd) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); HistoryItemInfo history_item = diff --git a/components/brave_ads/core/internal/history/history_util.cc b/components/brave_ads/core/internal/history/history_util.cc index b6681b2c2a4e..f54c50049ba5 100644 --- a/components/brave_ads/core/internal/history/history_util.cc +++ b/components/brave_ads/core/internal/history/history_util.cc @@ -17,6 +17,8 @@ HistoryItemInfo AddHistory(const AdInfo& ad, const ConfirmationType& confirmation_type, const std::string& title, const std::string& description) { + DCHECK(ad.IsValid()); + HistoryItemInfo history_item = BuildHistoryItem(ad, confirmation_type, title, description); ClientStateManager::GetInstance()->AppendHistory(history_item); diff --git a/components/brave_ads/core/internal/history/history_util_unittest.cc b/components/brave_ads/core/internal/history/history_util_unittest.cc index b5599fd8f245..f927c1e46213 100644 --- a/components/brave_ads/core/internal/history/history_util_unittest.cc +++ b/components/brave_ads/core/internal/history/history_util_unittest.cc @@ -23,7 +23,8 @@ class BatAdsHistoryUtilTest : public UnitTestBase {}; TEST_F(BatAdsHistoryUtilTest, AddHistory) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); // Act @@ -42,7 +43,7 @@ TEST_F(BatAdsHistoryUtilTest, AddHistory) { TEST_F(BatAdsHistoryUtilTest, PurgeHistoryOlderThanTimeWindow) { // Arrange const CreativeNotificationAdInfo creative_ad_1 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad_1 = BuildNotificationAd(creative_ad_1); HistoryManager::GetInstance()->Add(ad_1, ConfirmationType::kViewed); @@ -50,7 +51,7 @@ TEST_F(BatAdsHistoryUtilTest, PurgeHistoryOlderThanTimeWindow) { // Act const CreativeNotificationAdInfo creative_ad_2 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad_2 = BuildNotificationAd(creative_ad_2); const HistoryItemInfo history_item_2 = HistoryManager::GetInstance()->Add(ad_2, ConfirmationType::kViewed); @@ -67,7 +68,7 @@ TEST_F(BatAdsHistoryUtilTest, PurgeHistoryOlderThanTimeWindow) { TEST_F(BatAdsHistoryUtilTest, DoNotPurgeHistoryWithinTimeWindow) { // Arrange const CreativeNotificationAdInfo creative_ad_1 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad_1 = BuildNotificationAd(creative_ad_1); const HistoryItemInfo history_item_1 = HistoryManager::GetInstance()->Add(ad_1, ConfirmationType::kViewed); @@ -76,7 +77,7 @@ TEST_F(BatAdsHistoryUtilTest, DoNotPurgeHistoryWithinTimeWindow) { // Act const CreativeNotificationAdInfo creative_ad_2 = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad_2 = BuildNotificationAd(creative_ad_2); const HistoryItemInfo history_item_2 = HistoryManager::GetInstance()->Add(ad_2, ConfirmationType::kViewed); diff --git a/components/brave_ads/core/internal/history_item_value_util_unittest.cc b/components/brave_ads/core/internal/history_item_value_util_unittest.cc index 8c76e021dfeb..1dbeb9f363e2 100644 --- a/components/brave_ads/core/internal/history_item_value_util_unittest.cc +++ b/components/brave_ads/core/internal/history_item_value_util_unittest.cc @@ -9,6 +9,7 @@ #include "base/test/values_test_util.h" #include "brave/components/brave_ads/core/confirmation_type.h" #include "brave/components/brave_ads/core/history_item_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_time_util.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" @@ -22,10 +23,8 @@ namespace brave_ads { namespace { -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; - constexpr char kJson[] = - R"([{"ad_content":{"adAction":"view","adType":"ad_notification","advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","brand":"Test Ad Title","brandDisplayUrl":"brave.com","brandInfo":"Test Ad Body","brandUrl":"https://brave.com/","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","flaggedAd":false,"likeAction":0,"placementId":"f0948316-df6f-4e31-814d-d0b5f2a1f28c","savedAd":false,"segment":"untargeted"},"category_content":{"category":"untargeted","optAction":0},"timestamp_in_seconds":"1679443200"},{"ad_content":{"adAction":"view","adType":"ad_notification","advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","brand":"Test Ad Title","brandDisplayUrl":"brave.com","brandInfo":"Test Ad Body","brandUrl":"https://brave.com/","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","flaggedAd":false,"likeAction":0,"placementId":"f0948316-df6f-4e31-814d-d0b5f2a1f28c","savedAd":false,"segment":"untargeted"},"category_content":{"category":"untargeted","optAction":0},"timestamp_in_seconds":"1679443200"}])"; + R"([{"ad_content":{"adAction":"view","adType":"ad_notification","advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","brand":"Test Ad Title","brandDisplayUrl":"brave.com","brandInfo":"Test Ad Body","brandUrl":"https://brave.com/","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","flaggedAd":false,"likeAction":0,"placementId":"8b742869-6e4a-490c-ac31-31b49130098a","savedAd":false,"segment":"untargeted"},"category_content":{"category":"untargeted","optAction":0},"timestamp_in_seconds":"1679443200"},{"ad_content":{"adAction":"view","adType":"ad_notification","advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","brand":"Test Ad Title","brandDisplayUrl":"brave.com","brandInfo":"Test Ad Body","brandUrl":"https://brave.com/","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","flaggedAd":false,"likeAction":0,"placementId":"8b742869-6e4a-490c-ac31-31b49130098a","savedAd":false,"segment":"untargeted"},"category_content":{"category":"untargeted","optAction":0},"timestamp_in_seconds":"1679443200"}])"; HistoryItemList BuildHistoryItems() { const CreativeNotificationAdInfo creative_ad = diff --git a/components/brave_ads/core/internal/inline_content_ad_info_unittest.cc b/components/brave_ads/core/internal/inline_content_ad_info_unittest.cc index a3753f24635d..399d57a39b6e 100644 --- a/components/brave_ads/core/internal/inline_content_ad_info_unittest.cc +++ b/components/brave_ads/core/internal/inline_content_ad_info_unittest.cc @@ -19,7 +19,7 @@ class BatAdsInlineContentAdInfoTest : public UnitTestBase {}; TEST_F(BatAdsInlineContentAdInfoTest, IsValid) { // Arrange const CreativeInlineContentAdInfo creative_ad = - BuildCreativeInlineContentAd(); + BuildCreativeInlineContentAd(/*should_use_random_guids*/ true); const InlineContentAdInfo ad = BuildInlineContentAd(creative_ad); // Act diff --git a/components/brave_ads/core/internal/inline_content_ad_value_util.cc b/components/brave_ads/core/internal/inline_content_ad_value_util.cc index dbdef89e95c3..3b8325de0acd 100644 --- a/components/brave_ads/core/internal/inline_content_ad_value_util.cc +++ b/components/brave_ads/core/internal/inline_content_ad_value_util.cc @@ -5,44 +5,31 @@ #include "brave/components/brave_ads/core/inline_content_ad_value_util.h" +#include "brave/components/brave_ads/core/inline_content_ad_constants.h" #include "brave/components/brave_ads/core/inline_content_ad_info.h" namespace brave_ads { namespace { - constexpr char kTypeKey[] = "type"; -constexpr char kPlacementIdKey[] = "uuid"; -constexpr char kCreativeInstanceIdKey[] = "creativeInstanceId"; -constexpr char kCreativeSetIdKey[] = "creativeSetId"; -constexpr char kCampaignIdKey[] = "campaignId"; -constexpr char kAdvertiserIdKey[] = "advertiserId"; -constexpr char kSegmentKey[] = "segment"; -constexpr char kTitleKey[] = "title"; -constexpr char kDescriptionKey[] = "description"; -constexpr char kImageUrlKey[] = "imageUrl"; -constexpr char kDimensionsKey[] = "dimensions"; -constexpr char kCtaTextKey[] = "ctaText"; -constexpr char kTargetUrlKey[] = "targetUrl"; - } // namespace base::Value::Dict InlineContentAdToValue(const InlineContentAdInfo& ad) { base::Value::Dict dict; dict.Set(kTypeKey, ad.type.ToString()); - dict.Set(kPlacementIdKey, ad.placement_id); - dict.Set(kCreativeInstanceIdKey, ad.creative_instance_id); - dict.Set(kCreativeSetIdKey, ad.creative_set_id); - dict.Set(kCampaignIdKey, ad.campaign_id); - dict.Set(kAdvertiserIdKey, ad.advertiser_id); - dict.Set(kSegmentKey, ad.segment); - dict.Set(kTitleKey, ad.title); - dict.Set(kDescriptionKey, ad.description); - dict.Set(kImageUrlKey, ad.image_url.spec()); - dict.Set(kDimensionsKey, ad.dimensions); - dict.Set(kCtaTextKey, ad.cta_text); - dict.Set(kTargetUrlKey, ad.target_url.spec()); + dict.Set(kInlineContentAdPlacementIdKey, ad.placement_id); + dict.Set(kInlineContentAdCreativeInstanceIdKey, ad.creative_instance_id); + dict.Set(kInlineContentAdCreativeSetIdKey, ad.creative_set_id); + dict.Set(kInlineContentAdCampaignIdKey, ad.campaign_id); + dict.Set(kInlineContentAdAdvertiserIdKey, ad.advertiser_id); + dict.Set(kInlineContentAdSegmentKey, ad.segment); + dict.Set(kInlineContentAdTitleKey, ad.title); + dict.Set(kInlineContentAdDescriptionKey, ad.description); + dict.Set(kInlineContentAdImageUrlKey, ad.image_url.spec()); + dict.Set(kInlineContentAdDimensionsKey, ad.dimensions); + dict.Set(kInlineContentAdCtaTextKey, ad.cta_text); + dict.Set(kInlineContentAdTargetUrlKey, ad.target_url.spec()); return dict; } @@ -54,51 +41,51 @@ InlineContentAdInfo InlineContentAdFromValue(const base::Value::Dict& root) { ad.type = AdType(*value); } - if (const auto* value = root.FindString(kPlacementIdKey)) { + if (const auto* value = root.FindString(kInlineContentAdPlacementIdKey)) { ad.placement_id = *value; } - if (const auto* value = root.FindString(kCreativeInstanceIdKey)) { + if (const auto* value = + root.FindString(kInlineContentAdCreativeInstanceIdKey)) { ad.creative_instance_id = *value; } - if (const auto* value = root.FindString(kCreativeSetIdKey)) { + if (const auto* value = root.FindString(kInlineContentAdCreativeSetIdKey)) { ad.creative_set_id = *value; } - if (const auto* value = root.FindString(kCampaignIdKey)) { + if (const auto* value = root.FindString(kInlineContentAdCampaignIdKey)) { ad.campaign_id = *value; } - if (const auto* value = root.FindString(kAdvertiserIdKey)) { + if (const auto* value = root.FindString(kInlineContentAdAdvertiserIdKey)) { ad.advertiser_id = *value; } - if (const auto* value = root.FindString(kSegmentKey)) { + if (const auto* value = root.FindString(kInlineContentAdSegmentKey)) { ad.segment = *value; } - if (const auto* value = root.FindString(kTitleKey)) { + if (const auto* value = root.FindString(kInlineContentAdTitleKey)) { ad.title = *value; } - - if (const auto* value = root.FindString(kDescriptionKey)) { + if (const auto* value = root.FindString(kInlineContentAdDescriptionKey)) { ad.description = *value; } - if (const auto* value = root.FindString(kImageUrlKey)) { + if (const auto* value = root.FindString(kInlineContentAdImageUrlKey)) { ad.image_url = GURL(*value); } - if (const auto* value = root.FindString(kDimensionsKey)) { + if (const auto* value = root.FindString(kInlineContentAdDimensionsKey)) { ad.dimensions = *value; } - if (const auto* value = root.FindString(kCtaTextKey)) { + if (const auto* value = root.FindString(kInlineContentAdCtaTextKey)) { ad.cta_text = *value; } - if (const auto* value = root.FindString(kTargetUrlKey)) { + if (const auto* value = root.FindString(kInlineContentAdTargetUrlKey)) { ad.target_url = GURL(*value); } diff --git a/components/brave_ads/core/internal/inline_content_ad_value_util_unittest.cc b/components/brave_ads/core/internal/inline_content_ad_value_util_unittest.cc index 516efd601c42..10130b2064f7 100644 --- a/components/brave_ads/core/internal/inline_content_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/inline_content_ad_value_util_unittest.cc @@ -7,6 +7,7 @@ #include "base/test/values_test_util.h" #include "brave/components/brave_ads/core/inline_content_ad_info.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_unittest_util.h" @@ -18,10 +19,8 @@ namespace brave_ads { namespace { -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; - constexpr char kJson[] = - R"({"advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","ctaText":"Call to action text","description":"Test Ad Description","dimensions":"200x100","imageUrl":"https://brave.com/image","segment":"untargeted","targetUrl":"https://brave.com/","title":"Test Ad Title","type":"inline_content_ad","uuid":"f0948316-df6f-4e31-814d-d0b5f2a1f28c"})"; + R"({"advertiserId":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","campaignId":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creativeInstanceId":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creativeSetId":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","ctaText":"Call to action text","description":"Test Ad Description","dimensions":"200x100","imageUrl":"https://brave.com/image","segment":"untargeted","targetUrl":"https://brave.com/","title":"Test Ad Title","type":"inline_content_ad","uuid":"8b742869-6e4a-490c-ac31-31b49130098a"})"; } // namespace diff --git a/components/brave_ads/core/internal/legacy_migration/database/database_migration_issue_17231_unittest.cc b/components/brave_ads/core/internal/legacy_migration/database/database_migration_issue_17231_unittest.cc index 7a40a5405d10..4b75bbbe8cd4 100644 --- a/components/brave_ads/core/internal/legacy_migration/database/database_migration_issue_17231_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/database/database_migration_issue_17231_unittest.cc @@ -541,7 +541,7 @@ TEST_F(BatAdsDatabaseMigrationIssue17231Test, ConversionsDatabase) { ConversionList expected_conversions; - ASSERT_EQ(189UL, conversions.size()); + ASSERT_EQ(189U, conversions.size()); for (int i = 0; i < 189; i++) { ConversionInfo expected_conversion; expected_conversion.creative_set_id = creative_set_ids.at(i); diff --git a/components/brave_ads/core/internal/legacy_migration/database/database_migration_unittest.cc b/components/brave_ads/core/internal/legacy_migration/database/database_migration_unittest.cc index 856482b7b17c..487a0afa206e 100644 --- a/components/brave_ads/core/internal/legacy_migration/database/database_migration_unittest.cc +++ b/components/brave_ads/core/internal/legacy_migration/database/database_migration_unittest.cc @@ -33,7 +33,8 @@ class BatAdsDatabaseMigrationTest : public UnitTestBase, TEST_P(BatAdsDatabaseMigrationTest, MigrateFromSchema) { // Arrange - const CreativeAdInfo creative_ad = BuildCreativeAd(); + const CreativeAdInfo creative_ad = + BuildCreativeAd(/*should_use_random_guids*/ true); const AdEventInfo ad_event = BuildAdEvent( creative_ad, AdType::kNotificationAd, ConfirmationType::kViewed, Now()); @@ -51,8 +52,8 @@ TEST_P(BatAdsDatabaseMigrationTest, MigrateFromSchema) { // Assert } -std::string TestParamToString(::testing::TestParamInfo param_info) { - return base::StringPrintf("%d_to_%d", param_info.param + 1, +std::string TestParamToString(::testing::TestParamInfo test_param) { + return base::StringPrintf("%d_to_%d", test_param.param + 1, database::kVersion); } diff --git a/components/brave_ads/core/internal/ml/data/text_data_unittest.cc b/components/brave_ads/core/internal/ml/data/text_data_unittest.cc index bb343ffd1d94..880083fac7cd 100644 --- a/components/brave_ads/core/internal/ml/data/text_data_unittest.cc +++ b/components/brave_ads/core/internal/ml/data/text_data_unittest.cc @@ -19,10 +19,9 @@ TEST_F(BatAdsTextDataTest, TextDataInitialization) { const TextData text_data(expected_text); // Act - const std::string& text = text_data.GetText(); // Assert - EXPECT_EQ(expected_text, text); + EXPECT_EQ(expected_text, text_data.GetText()); } } // namespace brave_ads::ml diff --git a/components/brave_ads/core/internal/ml/data/vector_data_unittest.cc b/components/brave_ads/core/internal/ml/data/vector_data_unittest.cc index 98a4a173cbd3..59852403039c 100644 --- a/components/brave_ads/core/internal/ml/data/vector_data_unittest.cc +++ b/components/brave_ads/core/internal/ml/data/vector_data_unittest.cc @@ -30,8 +30,9 @@ TEST_F(BatAdsVectorDataTest, DenseVectorDataInitialization) { TEST_F(BatAdsVectorDataTest, SparseVectorDataInitialization) { // Arrange constexpr int kDimensionCount = 6; + const std::map sparse_vector_6 = { - {0UL, 1.0}, {2UL, 3.0}, {3UL, -2.0}}; + {0U, 1.0}, {2U, 3.0}, {3U, -2.0}}; const VectorData sparse_vector_data_6(kDimensionCount, sparse_vector_6); // Act @@ -69,12 +70,12 @@ TEST_F(BatAdsVectorDataTest, SparseSparseProduct) { constexpr double kTolerance = 1e-6; // Dense equivalent is [1, 0, 2] - const std::map sparse_vector_3 = {{0UL, 1.0}, {2UL, 2.0}}; + const std::map sparse_vector_3 = {{0U, 1.0}, {2U, 2.0}}; const VectorData sparse_vector_data_3(3, sparse_vector_3); // Dense equivalent is [1, 0, 3, 2, 0] const std::map sparse_vector_5 = { - {0UL, 1.0}, {2UL, 3.0}, {3UL, -2.0}}; + {0U, 1.0}, {2U, 3.0}, {3U, -2.0}}; const VectorData sparse_vector_data_5(5, sparse_vector_5); // Act @@ -97,12 +98,12 @@ TEST_F(BatAdsVectorDataTest, SparseDenseProduct) { const VectorData dense_vector_data_3(vector_3); // Dense equivalent is [1, 0, 2] - const std::map sparse_vector_3 = {{0UL, 1.0}, {2UL, 2.0}}; + const std::map sparse_vector_3 = {{0U, 1.0}, {2U, 2.0}}; const VectorData sparse_vector_data_3 = VectorData(3, sparse_vector_3); // Dense equivalent is [1, 0, 3, 2, 0] const std::map sparse_vector_5 = { - {0UL, 1.0}, {2UL, 3.0}, {3UL, -2.0}}; + {0U, 1.0}, {2U, 3.0}, {3U, -2.0}}; const VectorData sparse_vector_data_5(5, sparse_vector_5); // Act @@ -131,12 +132,12 @@ TEST_F(BatAdsVectorDataTest, NonsenseProduct) { const VectorData dense_vector_data_3(vector_3); // Dense equivalent is [1, 0, 2] - const std::map sparse_vector_3 = {{0UL, 1.0}, {2UL, 2.0}}; + const std::map sparse_vector_3 = {{0U, 1.0}, {2U, 2.0}}; const VectorData sparse_vector_data_3(3, sparse_vector_3); // Dense equivalent is [1, 0, 3, 2, 0] const std::map sparse_vector_5 = { - {0UL, 1.0}, {2UL, 3.0}, {3UL, -2.0}}; + {0U, 1.0}, {2U, 3.0}, {3U, -2.0}}; const VectorData sparse_vector_data_5(5, sparse_vector_5); // Act @@ -214,7 +215,7 @@ TEST_F(BatAdsVectorDataTest, NormalizeDenseVector) { TEST_F(BatAdsVectorDataTest, NormalizeSparseVector) { constexpr int kDimensionCount = 6; const std::map sparse_vector_5 = { - {0UL, 1.0}, {2UL, 3.0}, {3UL, -2.0}, {10UL, -1.0}, {30UL, 1.0}}; + {0U, 1.0}, {2U, 3.0}, {3U, -2.0}, {10U, -1.0}, {30U, 1.0}}; VectorData sparse_vector_data_5(kDimensionCount, sparse_vector_5); sparse_vector_data_5.Normalize(); EXPECT_EQ(std::vector( diff --git a/components/brave_ads/core/internal/ml/model/linear/linear_unittest.cc b/components/brave_ads/core/internal/ml/model/linear/linear_unittest.cc index a0cb8eff79b3..eefd91212f5b 100644 --- a/components/brave_ads/core/internal/ml/model/linear/linear_unittest.cc +++ b/components/brave_ads/core/internal/ml/model/linear/linear_unittest.cc @@ -71,15 +71,11 @@ TEST_F(BatAdsLinearTest, BiasesPredictionTest) { TEST_F(BatAdsLinearTest, BinaryClassifierPredictionTest) { // Arrange - constexpr size_t kExpectedPredictionSize = 1; const std::vector data = {0.3, 0.2, 0.25}; const std::map weights = { - {"the_only_class", VectorData(data)}, - }; + {"the_only_class", VectorData(data)}}; - const std::map biases = { - {"the_only_class", -0.45}, - }; + const std::map biases = {{"the_only_class", -0.45}}; const model::Linear linear(weights, biases); const VectorData vector_data_0({1.07, 1.52, 0.91}); @@ -87,12 +83,11 @@ TEST_F(BatAdsLinearTest, BinaryClassifierPredictionTest) { // Act const PredictionMap predictions_0 = linear.Predict(vector_data_0); + ASSERT_EQ(1U, predictions_0.size()); const PredictionMap predictions_1 = linear.Predict(vector_data_1); + ASSERT_EQ(1U, predictions_1.size()); // Assert - ASSERT_EQ(kExpectedPredictionSize, predictions_0.size()); - ASSERT_EQ(kExpectedPredictionSize, predictions_1.size()); - EXPECT_TRUE(predictions_0.at("the_only_class") < 0.5 && predictions_1.at("the_only_class") > 0.5); } diff --git a/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing_unittest.cc b/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing_unittest.cc index f913f1cfa5b2..4e7fd816f225 100644 --- a/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing_unittest.cc +++ b/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing_unittest.cc @@ -45,7 +45,6 @@ class BatAdsTextProcessingTest : public UnitTestBase {}; TEST_F(BatAdsTextProcessingTest, BuildSimplePipeline) { // Arrange constexpr double kTolerance = 1e-6; - constexpr unsigned kExpectedLen = 3; constexpr char kTestString[] = "Test String"; TransformationVector transformations; @@ -70,16 +69,17 @@ TEST_F(BatAdsTextProcessingTest, BuildSimplePipeline) { model::Linear linear_model(weights, biases); const PredictionMap data_point_3_predictions = linear_model.Predict(data_point_3); + ASSERT_EQ(3U, data_point_3_predictions.size()); const pipeline::TextProcessing pipeline = pipeline::TextProcessing( std::move(transformations), std::move(linear_model)); // Act const PredictionMap predictions = pipeline.GetTopPredictions(kTestString); + ASSERT_TRUE(!predictions.empty()); + ASSERT_LE(predictions.size(), 3U); // Assert - ASSERT_EQ(kExpectedLen, data_point_3_predictions.size()); - ASSERT_TRUE(!predictions.empty() && predictions.size() <= kExpectedLen); for (const auto& prediction : predictions) { EXPECT_TRUE(prediction.second > -kTolerance && prediction.second < 1.0 + kTolerance); diff --git a/components/brave_ads/core/internal/ml/transformation/hashed_ngrams_transformation_unittest.cc b/components/brave_ads/core/internal/ml/transformation/hashed_ngrams_transformation_unittest.cc index 9e3f28cd3df0..deba05903668 100644 --- a/components/brave_ads/core/internal/ml/transformation/hashed_ngrams_transformation_unittest.cc +++ b/components/brave_ads/core/internal/ml/transformation/hashed_ngrams_transformation_unittest.cc @@ -18,7 +18,6 @@ class BatAdsHashedNGramsTransformationTest : public UnitTestBase {}; TEST_F(BatAdsHashedNGramsTransformationTest, HashingTest) { // Arrange constexpr int kDefaultBucketCount = 10'000; - constexpr size_t kExpectedElementCount = 10; constexpr char kTestString[] = "tiny"; const std::unique_ptr text_data = std::make_unique(kTestString); @@ -38,7 +37,7 @@ TEST_F(BatAdsHashedNGramsTransformationTest, HashingTest) { ASSERT_EQ(kDefaultBucketCount, hashed_vector_data->GetDimensionCount()); // Hashes for [t, i, n, y, ti, in, ny, tin, iny, tiny] -- 10 in total - EXPECT_EQ(kExpectedElementCount, hashed_vector_data->GetData().size()); + EXPECT_EQ(10U, hashed_vector_data->GetData().size()); } TEST_F(BatAdsHashedNGramsTransformationTest, CustomHashingTest) { diff --git a/components/brave_ads/core/internal/ml/transformation/normalization_transformation_unittest.cc b/components/brave_ads/core/internal/ml/transformation/normalization_transformation_unittest.cc index 43f5ed88926e..107c9a536e13 100644 --- a/components/brave_ads/core/internal/ml/transformation/normalization_transformation_unittest.cc +++ b/components/brave_ads/core/internal/ml/transformation/normalization_transformation_unittest.cc @@ -59,7 +59,6 @@ TEST_F(BatAdsNormalizationTransformationTest, NormalizationTest) { TEST_F(BatAdsNormalizationTransformationTest, ChainingTest) { // Arrange constexpr int kDefaultBucketCount = 10'000; - constexpr size_t kExpectedElementCount = 10; constexpr char kTestString[] = "TINY"; TransformationVector chain; @@ -85,7 +84,7 @@ TEST_F(BatAdsNormalizationTransformationTest, ChainingTest) { ASSERT_EQ(kDefaultBucketCount, vector_data->GetDimensionCount()); // Hashes for [t, i, n, y, ti, in, ny, tin, iny, tiny] -- 10 in total - EXPECT_EQ(kExpectedElementCount, vector_data->GetData().size()); + EXPECT_EQ(10U, vector_data->GetData().size()); } } // namespace brave_ads::ml diff --git a/components/brave_ads/core/internal/new_tab_page_ad_info_unittest.cc b/components/brave_ads/core/internal/new_tab_page_ad_info_unittest.cc index 6daf89e878d1..cf4e117bb8a9 100644 --- a/components/brave_ads/core/internal/new_tab_page_ad_info_unittest.cc +++ b/components/brave_ads/core/internal/new_tab_page_ad_info_unittest.cc @@ -18,7 +18,8 @@ class BatAdsNewTabPageAdInfoTest : public UnitTestBase {}; TEST_F(BatAdsNewTabPageAdInfoTest, IsValid) { // Arrange - const CreativeNewTabPageAdInfo creative_ad = BuildCreativeNewTabPageAd(); + const CreativeNewTabPageAdInfo creative_ad = + BuildCreativeNewTabPageAd(/*should_use_random_guids*/ true); const NewTabPageAdInfo ad = BuildNewTabPageAd(creative_ad); // Act diff --git a/components/brave_ads/core/internal/new_tab_page_ad_value_util.cc b/components/brave_ads/core/internal/new_tab_page_ad_value_util.cc index 6b45439e2a47..ea3e7fe54f7e 100644 --- a/components/brave_ads/core/internal/new_tab_page_ad_value_util.cc +++ b/components/brave_ads/core/internal/new_tab_page_ad_value_util.cc @@ -8,58 +8,43 @@ #include #include +#include "brave/components/brave_ads/core/new_tab_page_ad_constants.h" #include "brave/components/brave_ads/core/new_tab_page_ad_info.h" namespace brave_ads { namespace { - constexpr char kTypeKey[] = "type"; -constexpr char kPlacementIdKey[] = "placement_id"; -constexpr char kCreativeInstanceIdKey[] = "creative_instance_id"; -constexpr char kCreativeSetIdKey[] = "creative_set_id"; -constexpr char kCampaignIdKey[] = "campaign_id"; -constexpr char kAdvertiserIdKey[] = "advertiser_id"; -constexpr char kSegmentKey[] = "segment"; -constexpr char kCompanyNameKey[] = "company_name"; -constexpr char kAltKey[] = "alt"; -constexpr char kImageUrlKey[] = "image_url"; -constexpr char kFocalPointKey[] = "focal_point"; -constexpr char kFocalPointXKey[] = "x"; -constexpr char kFocalPointYKey[] = "y"; -constexpr char kWallpapersKey[] = "wallpapers"; -constexpr char kTargetUrlKey[] = "target_url"; - } // namespace base::Value::Dict NewTabPageAdToValue(const NewTabPageAdInfo& ad) { base::Value::Dict dict; dict.Set(kTypeKey, ad.type.ToString()); - dict.Set(kPlacementIdKey, ad.placement_id); - dict.Set(kCreativeInstanceIdKey, ad.creative_instance_id); - dict.Set(kCreativeSetIdKey, ad.creative_set_id); - dict.Set(kCampaignIdKey, ad.campaign_id); - dict.Set(kAdvertiserIdKey, ad.advertiser_id); - dict.Set(kSegmentKey, ad.segment); - dict.Set(kCompanyNameKey, ad.company_name); - dict.Set(kImageUrlKey, ad.image_url.spec()); - dict.Set(kAltKey, ad.alt); - dict.Set(kTargetUrlKey, ad.target_url.spec()); + dict.Set(kNewTabPageAdPlacementIdKey, ad.placement_id); + dict.Set(kNewTabPageAdCreativeInstanceIdKey, ad.creative_instance_id); + dict.Set(kNewTabPageAdCreativeSetIdKey, ad.creative_set_id); + dict.Set(kNewTabPageAdCampaignIdKey, ad.campaign_id); + dict.Set(kNewTabPageAdAdvertiserIdKey, ad.advertiser_id); + dict.Set(kNewTabPageAdSegmentKey, ad.segment); + dict.Set(kNewTabPageAdCompanyNameKey, ad.company_name); + dict.Set(kNewTabPageAdImageUrlKey, ad.image_url.spec()); + dict.Set(kNewTabPageAdAltKey, ad.alt); + dict.Set(kNewTabPageAdTargetUrlKey, ad.target_url.spec()); base::Value::List wallpapers; for (const NewTabPageAdWallpaperInfo& wallpaper : ad.wallpapers) { base::Value::Dict wallpaper_dict; - wallpaper_dict.Set(kImageUrlKey, wallpaper.image_url.spec()); + wallpaper_dict.Set(kNewTabPageAdImageUrlKey, wallpaper.image_url.spec()); base::Value::Dict focal_point; - focal_point.Set(kFocalPointXKey, wallpaper.focal_point.x); - focal_point.Set(kFocalPointYKey, wallpaper.focal_point.y); - wallpaper_dict.Set(kFocalPointKey, std::move(focal_point)); + focal_point.Set(kNewTabPageAdFocalPointXKey, wallpaper.focal_point.x); + focal_point.Set(kNewTabPageAdFocalPointYKey, wallpaper.focal_point.y); + wallpaper_dict.Set(kNewTabPageAdFocalPointKey, std::move(focal_point)); wallpapers.Append(std::move(wallpaper_dict)); } - dict.Set(kWallpapersKey, std::move(wallpapers)); + dict.Set(kNewTabPageAdWallpapersKey, std::move(wallpapers)); return dict; } @@ -71,58 +56,61 @@ NewTabPageAdInfo NewTabPageAdFromValue(const base::Value::Dict& root) { ad.type = AdType(*value); } - if (const auto* value = root.FindString(kPlacementIdKey)) { + if (const auto* value = root.FindString(kNewTabPageAdPlacementIdKey)) { ad.placement_id = *value; } - if (const auto* value = root.FindString(kCreativeInstanceIdKey)) { + if (const auto* value = root.FindString(kNewTabPageAdCreativeInstanceIdKey)) { ad.creative_instance_id = *value; } - if (const auto* value = root.FindString(kCreativeSetIdKey)) { + if (const auto* value = root.FindString(kNewTabPageAdCreativeSetIdKey)) { ad.creative_set_id = *value; } - if (const auto* value = root.FindString(kCampaignIdKey)) { + if (const auto* value = root.FindString(kNewTabPageAdCampaignIdKey)) { ad.campaign_id = *value; } - if (const auto* value = root.FindString(kAdvertiserIdKey)) { + if (const auto* value = root.FindString(kNewTabPageAdAdvertiserIdKey)) { ad.advertiser_id = *value; } - if (const auto* value = root.FindString(kSegmentKey)) { + if (const auto* value = root.FindString(kNewTabPageAdSegmentKey)) { ad.segment = *value; } - if (const auto* value = root.FindString(kCompanyNameKey)) { + if (const auto* value = root.FindString(kNewTabPageAdCompanyNameKey)) { ad.company_name = *value; } - if (const auto* value = root.FindString(kImageUrlKey)) { + if (const auto* value = root.FindString(kNewTabPageAdImageUrlKey)) { ad.image_url = GURL(*value); } - if (const auto* value = root.FindString(kAltKey)) { + if (const auto* value = root.FindString(kNewTabPageAdAltKey)) { ad.alt = *value; } - if (const auto* wallpapers = root.FindList(kWallpapersKey)) { + if (const auto* wallpapers = root.FindList(kNewTabPageAdWallpapersKey)) { for (const auto& value : *wallpapers) { const base::Value::Dict* const dict = value.GetIfDict(); if (!dict) { continue; } - const std::string* const image_url = dict->FindString(kImageUrlKey); + const std::string* const image_url = + dict->FindString(kNewTabPageAdImageUrlKey); const base::Value::Dict* const focal_point = - dict->FindDict(kFocalPointKey); + dict->FindDict(kNewTabPageAdFocalPointKey); if (!image_url || !focal_point) { continue; } - const absl::optional x = focal_point->FindInt(kFocalPointXKey); - const absl::optional y = focal_point->FindInt(kFocalPointYKey); + const absl::optional x = + focal_point->FindInt(kNewTabPageAdFocalPointXKey); + const absl::optional y = + focal_point->FindInt(kNewTabPageAdFocalPointYKey); if (!x || !y) { continue; } @@ -136,7 +124,7 @@ NewTabPageAdInfo NewTabPageAdFromValue(const base::Value::Dict& root) { } } - if (const auto* value = root.FindString(kTargetUrlKey)) { + if (const auto* value = root.FindString(kNewTabPageAdTargetUrlKey)) { ad.target_url = GURL(*value); } diff --git a/components/brave_ads/core/internal/new_tab_page_ad_value_util_unittest.cc b/components/brave_ads/core/internal/new_tab_page_ad_value_util_unittest.cc index 1e1192c19bda..bcf25fc2ea0a 100644 --- a/components/brave_ads/core/internal/new_tab_page_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/new_tab_page_ad_value_util_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/new_tab_page_ad_value_util.h" #include "base/test/values_test_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_unittest_util.h" @@ -18,10 +19,8 @@ namespace brave_ads { namespace { -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; - constexpr char kJson[] = - R"({"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","alt":"Test Ad Alt","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","company_name":"Test Ad Company Name","creative_instance_id":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","image_url":"https://brave.com/image","placement_id":"f0948316-df6f-4e31-814d-d0b5f2a1f28c","segment":"untargeted","target_url":"https://brave.com/","type":"new_tab_page_ad","wallpapers":[{"focal_point":{"x":1280,"y":720},"image_url":"https://brave.com/wallpaper_image"}]})"; + R"({"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","alt":"Test Ad Alt","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","company_name":"Test Ad Company Name","creative_instance_id":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","image_url":"https://brave.com/image","placement_id":"8b742869-6e4a-490c-ac31-31b49130098a","segment":"untargeted","target_url":"https://brave.com/","type":"new_tab_page_ad","wallpapers":[{"focal_point":{"x":1280,"y":720},"image_url":"https://brave.com/wallpaper_image"}]})"; } // namespace diff --git a/components/brave_ads/core/internal/notification_ad_info_unittest.cc b/components/brave_ads/core/internal/notification_ad_info_unittest.cc index 9e0b146826ef..ff4d50263d5b 100644 --- a/components/brave_ads/core/internal/notification_ad_info_unittest.cc +++ b/components/brave_ads/core/internal/notification_ad_info_unittest.cc @@ -18,7 +18,8 @@ class BatAdsNotificationAdInfoTest : public UnitTestBase {}; TEST_F(BatAdsNotificationAdInfoTest, IsValid) { // Arrange - const CreativeNotificationAdInfo creative_ad = BuildCreativeNotificationAd(); + const CreativeNotificationAdInfo creative_ad = + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); // Act diff --git a/components/brave_ads/core/internal/notification_ad_value_util.cc b/components/brave_ads/core/internal/notification_ad_value_util.cc index c8dea082e404..001ec43ffde8 100644 --- a/components/brave_ads/core/internal/notification_ad_value_util.cc +++ b/components/brave_ads/core/internal/notification_ad_value_util.cc @@ -5,39 +5,29 @@ #include "brave/components/brave_ads/core/notification_ad_value_util.h" +#include "brave/components/brave_ads/core/notification_ad_constants.h" #include "brave/components/brave_ads/core/notification_ad_info.h" #include "url/gurl.h" namespace brave_ads { namespace { - constexpr char kTypeKey[] = "type"; -constexpr char kPlacementIdKey[] = "uuid"; -constexpr char kCreativeInstanceIdKey[] = "creative_instance_id"; -constexpr char kCreativeSetIdKey[] = "creative_set_id"; -constexpr char kCampaignIdKey[] = "campaign_id"; -constexpr char kAdvertiserIdKey[] = "advertiser_id"; -constexpr char kSegmentKey[] = "segment"; -constexpr char kTitleKey[] = "title"; -constexpr char kBodyKey[] = "body"; -constexpr char kTargetUrlKey[] = "target_url"; - } // namespace base::Value::Dict NotificationAdToValue(const NotificationAdInfo& ad) { base::Value::Dict dict; dict.Set(kTypeKey, ad.type.ToString()); - dict.Set(kPlacementIdKey, ad.placement_id); - dict.Set(kCreativeInstanceIdKey, ad.creative_instance_id); - dict.Set(kCreativeSetIdKey, ad.creative_set_id); - dict.Set(kCampaignIdKey, ad.campaign_id); - dict.Set(kAdvertiserIdKey, ad.advertiser_id); - dict.Set(kSegmentKey, ad.segment); - dict.Set(kTitleKey, ad.title); - dict.Set(kBodyKey, ad.body); - dict.Set(kTargetUrlKey, ad.target_url.spec()); + dict.Set(kNotificationAdPlacementIdKey, ad.placement_id); + dict.Set(kNotificationAdCreativeInstanceIdKey, ad.creative_instance_id); + dict.Set(kNotificationAdCreativeSetIdKey, ad.creative_set_id); + dict.Set(kNotificationAdCampaignIdKey, ad.campaign_id); + dict.Set(kNotificationAdAdvertiserIdKey, ad.advertiser_id); + dict.Set(kNotificationAdSegmentKey, ad.segment); + dict.Set(kNotificationAdTitleKey, ad.title); + dict.Set(kNotificationAdBodyKey, ad.body); + dict.Set(kNotificationAdTargetUrlKey, ad.target_url.spec()); return dict; } @@ -60,39 +50,40 @@ NotificationAdInfo NotificationAdFromValue(const base::Value::Dict& root) { ad.type = AdType(*value); } - if (const auto* value = root.FindString(kPlacementIdKey)) { + if (const auto* value = root.FindString(kNotificationAdPlacementIdKey)) { ad.placement_id = *value; } - if (const auto* value = root.FindString(kCreativeInstanceIdKey)) { + if (const auto* value = + root.FindString(kNotificationAdCreativeInstanceIdKey)) { ad.creative_instance_id = *value; } - if (const auto* value = root.FindString(kCreativeSetIdKey)) { + if (const auto* value = root.FindString(kNotificationAdCreativeSetIdKey)) { ad.creative_set_id = *value; } - if (const auto* value = root.FindString(kCampaignIdKey)) { + if (const auto* value = root.FindString(kNotificationAdCampaignIdKey)) { ad.campaign_id = *value; } - if (const auto* value = root.FindString(kAdvertiserIdKey)) { + if (const auto* value = root.FindString(kNotificationAdAdvertiserIdKey)) { ad.advertiser_id = *value; } - if (const auto* value = root.FindString(kSegmentKey)) { + if (const auto* value = root.FindString(kNotificationAdSegmentKey)) { ad.segment = *value; } - if (const auto* value = root.FindString(kTitleKey)) { + if (const auto* value = root.FindString(kNotificationAdTitleKey)) { ad.title = *value; } - if (const auto* value = root.FindString(kBodyKey)) { + if (const auto* value = root.FindString(kNotificationAdBodyKey)) { ad.body = *value; } - if (const auto* value = root.FindString(kTargetUrlKey)) { + if (const auto* value = root.FindString(kNotificationAdTargetUrlKey)) { ad.target_url = GURL(*value); } diff --git a/components/brave_ads/core/internal/notification_ad_value_util_unittest.cc b/components/brave_ads/core/internal/notification_ad_value_util_unittest.cc index 01c45ea7778d..61902651757b 100644 --- a/components/brave_ads/core/internal/notification_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/notification_ad_value_util_unittest.cc @@ -8,6 +8,7 @@ #include "base/containers/circular_deque.h" #include "base/ranges/algorithm.h" #include "base/test/values_test_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_unittest_util.h" @@ -20,12 +21,10 @@ namespace brave_ads { namespace { -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; - constexpr char kJson[] = - R"({"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","body":"Test Ad Body","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"ad_notification","uuid":"f0948316-df6f-4e31-814d-d0b5f2a1f28c"})"; + R"({"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","body":"Test Ad Body","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"ad_notification","uuid":"8b742869-6e4a-490c-ac31-31b49130098a"})"; constexpr char kListJson[] = - R"([{"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","body":"Test Ad Body","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"ad_notification","uuid":"f0948316-df6f-4e31-814d-d0b5f2a1f28c"},{"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","body":"Test Ad Body","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"ad_notification","uuid":"f0948316-df6f-4e31-814d-d0b5f2a1f28c"}])"; + R"([{"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","body":"Test Ad Body","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"ad_notification","uuid":"8b742869-6e4a-490c-ac31-31b49130098a"},{"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","body":"Test Ad Body","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"ad_notification","uuid":"8b742869-6e4a-490c-ac31-31b49130098a"}])"; } // namespace diff --git a/components/brave_ads/core/internal/privacy/tokens/token_generator_unittest.cc b/components/brave_ads/core/internal/privacy/tokens/token_generator_unittest.cc index 647adbc0f9eb..f4ee7cd6c8a5 100644 --- a/components/brave_ads/core/internal/privacy/tokens/token_generator_unittest.cc +++ b/components/brave_ads/core/internal/privacy/tokens/token_generator_unittest.cc @@ -21,7 +21,7 @@ TEST(BatAdsTokenGeneratorTest, Generate) { // Assert const size_t count = tokens.size(); - EXPECT_EQ(5UL, count); + EXPECT_EQ(5U, count); } TEST(BatAdsTokenGeneratorTest, GenerateZero) { diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_value_util_unittest.cc b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_value_util_unittest.cc index 814d639b73ce..b1c69efbeb7e 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_value_util_unittest.cc +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_value_util_unittest.cc @@ -96,8 +96,7 @@ TEST_F(BatAdsUnblindedPaymentTokenValueUtilTest, FromEmptyValue) { UnblindedPaymentTokensFromValue(*list); // Assert - const UnblindedPaymentTokenList expected_unblinded_tokens; - EXPECT_EQ(expected_unblinded_tokens, unblinded_tokens); + EXPECT_TRUE(unblinded_tokens.empty()); } } // namespace brave_ads::privacy diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.cc b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.cc index c6095ae1cd70..25821a7a269f 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.cc +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.h" #include "base/check.h" +#include "brave/components/brave_ads/core/ad_type.h" #include "brave/components/brave_ads/core/internal/deprecated/confirmations/confirmation_state_manager.h" #include "brave/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/public_key.h" #include "brave/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/unblinded_token.h" diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.h b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.h index 8875a1d2eaa0..505b4258df05 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.h +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens_unittest_util.h @@ -11,7 +11,11 @@ #include "brave/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_info.h" -namespace brave_ads::privacy { +namespace brave_ads { + +class AdType; + +namespace privacy { class UnblindedPaymentTokens; @@ -30,6 +34,7 @@ UnblindedPaymentTokenList CreateUnblindedPaymentTokens( UnblindedPaymentTokenList GetUnblindedPaymentTokens(int count); UnblindedPaymentTokenInfo GetUnblindedPaymentToken(); -} // namespace brave_ads::privacy +} // namespace privacy +} // namespace brave_ads #endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_PRIVACY_TOKENS_UNBLINDED_PAYMENT_TOKENS_UNBLINDED_PAYMENT_TOKENS_UNITTEST_UTIL_H_ diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_value_util_unittest.cc b/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_value_util_unittest.cc index 046bd20c6833..2af1414e5720 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_value_util_unittest.cc +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_value_util_unittest.cc @@ -86,8 +86,7 @@ TEST_F(BatAdsUnblindedTokenValueUtilTest, FromEmptyValue) { const UnblindedTokenList unblinded_tokens = UnblindedTokensFromValue(*list); // Assert - const UnblindedTokenList expected_unblinded_tokens; - EXPECT_EQ(expected_unblinded_tokens, unblinded_tokens); + EXPECT_TRUE(unblinded_tokens.empty()); } } // namespace brave_ads::privacy diff --git a/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor_unittest.cc b/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor_unittest.cc index 6e8f2eaf833d..949765ba425c 100644 --- a/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor_unittest.cc +++ b/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor_unittest.cc @@ -83,7 +83,7 @@ TEST_F(BatAdsTextClassificationProcessorTest, ProcessText) { ClientStateManager::GetInstance() ->GetTextClassificationProbabilitiesHistory(); - EXPECT_EQ(1UL, list.size()); + EXPECT_EQ(1U, list.size()); } TEST_F(BatAdsTextClassificationProcessorTest, ProcessMultipleText) { @@ -104,7 +104,7 @@ TEST_F(BatAdsTextClassificationProcessorTest, ProcessMultipleText) { ClientStateManager::GetInstance() ->GetTextClassificationProbabilitiesHistory(); - EXPECT_EQ(3UL, list.size()); + EXPECT_EQ(3U, list.size()); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_events_database_table_unittest.cc b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_events_database_table_unittest.cc index a10c82ee333d..25de5d872df8 100644 --- a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_events_database_table_unittest.cc +++ b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_events_database_table_unittest.cc @@ -18,11 +18,9 @@ TEST(BatAdsTextEmbeddingHtmlEventsDatabaseTableTest, TableName) { const TextEmbeddingHtmlEvents database_table; // Act - const std::string table_name = database_table.GetTableName(); // Assert - const std::string expected_table_name = "text_embedding_html_events"; - EXPECT_EQ(expected_table_name, table_name); + EXPECT_EQ("text_embedding_html_events", database_table.GetTableName()); } } // namespace brave_ads::database::table diff --git a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor_util_unittest.cc b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor_util_unittest.cc index 4f10546a59fb..3095759114d3 100644 --- a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor_util_unittest.cc +++ b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor_util_unittest.cc @@ -40,10 +40,9 @@ TEST_F(BatAdsTextEmbeddingProcessorUtilTest, SanitizeHtml) { for (const auto& [html, expected_text] : samples) { // Act - const std::string text = SanitizeHtml(html); // Assert - EXPECT_EQ(expected_text, text); + EXPECT_EQ(expected_text, SanitizeHtml(html)); } } @@ -64,10 +63,9 @@ TEST_F(BatAdsTextEmbeddingProcessorUtilTest, SanitizeText) { for (const auto& [text, expected_sanitized_text] : samples) { // Act - const std::string sanitized_text = SanitizeText(text); // Assert - EXPECT_EQ(expected_sanitized_text, sanitized_text); + EXPECT_EQ(expected_sanitized_text, SanitizeText(text)); } } diff --git a/components/brave_ads/core/internal/promoted_content_ad_info_unittest.cc b/components/brave_ads/core/internal/promoted_content_ad_info_unittest.cc index 265c8059a290..b5dcc2e67df7 100644 --- a/components/brave_ads/core/internal/promoted_content_ad_info_unittest.cc +++ b/components/brave_ads/core/internal/promoted_content_ad_info_unittest.cc @@ -19,7 +19,7 @@ class BatAdsPromotedContentAdInfoTest : public UnitTestBase {}; TEST_F(BatAdsPromotedContentAdInfoTest, IsValid) { // Arrange const CreativePromotedContentAdInfo creative_ad = - BuildCreativePromotedContentAd(); + BuildCreativePromotedContentAd(/*should_use_random_guids*/ true); const PromotedContentAdInfo ad = BuildPromotedContentAd(creative_ad); // Act diff --git a/components/brave_ads/core/internal/promoted_content_ad_value_util.cc b/components/brave_ads/core/internal/promoted_content_ad_value_util.cc index 5fb903e8388e..13434641a53a 100644 --- a/components/brave_ads/core/internal/promoted_content_ad_value_util.cc +++ b/components/brave_ads/core/internal/promoted_content_ad_value_util.cc @@ -5,39 +5,29 @@ #include "brave/components/brave_ads/core/promoted_content_ad_value_util.h" +#include "brave/components/brave_ads/core/promoted_content_ad_constants.h" #include "brave/components/brave_ads/core/promoted_content_ad_info.h" #include "url/gurl.h" namespace brave_ads { namespace { - constexpr char kTypeKey[] = "type"; -constexpr char kPlacementIdKey[] = "uuid"; -constexpr char kCreativeInstanceIdKey[] = "creative_instance_id"; -constexpr char kCreativeSetIdKey[] = "creative_set_id"; -constexpr char kCampaignIdKey[] = "campaign_id"; -constexpr char kAdvertiserIdKey[] = "advertiser_id"; -constexpr char kSegmentKey[] = "segment"; -constexpr char kTitleKey[] = "title"; -constexpr char kDescriptionnKey[] = "description"; -constexpr char kTargetUrlKey[] = "target_url"; - } // namespace base::Value::Dict PromotedContentAdToValue(const PromotedContentAdInfo& ad) { base::Value::Dict dict; dict.Set(kTypeKey, ad.type.ToString()); - dict.Set(kPlacementIdKey, ad.placement_id); - dict.Set(kCreativeInstanceIdKey, ad.creative_instance_id); - dict.Set(kCreativeSetIdKey, ad.creative_set_id); - dict.Set(kCampaignIdKey, ad.campaign_id); - dict.Set(kAdvertiserIdKey, ad.advertiser_id); - dict.Set(kSegmentKey, ad.segment); - dict.Set(kTitleKey, ad.title); - dict.Set(kDescriptionnKey, ad.description); - dict.Set(kTargetUrlKey, ad.target_url.spec()); + dict.Set(kPromotedContentAdPlacementIdKey, ad.placement_id); + dict.Set(kPromotedContentAdCreativeInstanceIdKey, ad.creative_instance_id); + dict.Set(kPromotedContentAdCreativeSetIdKey, ad.creative_set_id); + dict.Set(kPromotedContentAdCampaignIdKey, ad.campaign_id); + dict.Set(kPromotedContentAdAdvertiserIdKey, ad.advertiser_id); + dict.Set(kPromotedContentAdSegmentKey, ad.segment); + dict.Set(kPromotedContentAdTitleKey, ad.title); + dict.Set(kPromotedContentAdDescriptionnKey, ad.description); + dict.Set(kPromotedContentAdTargetUrlKey, ad.target_url.spec()); return dict; } @@ -46,43 +36,44 @@ PromotedContentAdInfo PromotedContentAdFromValue( const base::Value::Dict& root) { PromotedContentAdInfo ad; - if (const auto* value = root.FindString("type")) { + if (const auto* value = root.FindString(kTypeKey)) { ad.type = AdType(*value); } - if (const auto* value = root.FindString("uuid")) { + if (const auto* value = root.FindString(kPromotedContentAdPlacementIdKey)) { ad.placement_id = *value; } - if (const auto* value = root.FindString("creative_instance_id")) { + if (const auto* value = + root.FindString(kPromotedContentAdCreativeInstanceIdKey)) { ad.creative_instance_id = *value; } - if (const auto* value = root.FindString("creative_set_id")) { + if (const auto* value = root.FindString(kPromotedContentAdCreativeSetIdKey)) { ad.creative_set_id = *value; } - if (const auto* value = root.FindString("campaign_id")) { + if (const auto* value = root.FindString(kPromotedContentAdCampaignIdKey)) { ad.campaign_id = *value; } - if (const auto* value = root.FindString("advertiser_id")) { + if (const auto* value = root.FindString(kPromotedContentAdAdvertiserIdKey)) { ad.advertiser_id = *value; } - if (const auto* value = root.FindString("segment")) { + if (const auto* value = root.FindString(kPromotedContentAdSegmentKey)) { ad.segment = *value; } - if (const auto* value = root.FindString("title")) { + if (const auto* value = root.FindString(kPromotedContentAdTitleKey)) { ad.title = *value; } - if (const auto* value = root.FindString("description")) { + if (const auto* value = root.FindString(kPromotedContentAdDescriptionnKey)) { ad.description = *value; } - if (const auto* value = root.FindString("target_url")) { + if (const auto* value = root.FindString(kPromotedContentAdTargetUrlKey)) { ad.target_url = GURL(*value); } diff --git a/components/brave_ads/core/internal/promoted_content_ad_value_util_unittest.cc b/components/brave_ads/core/internal/promoted_content_ad_value_util_unittest.cc index a4f97c35bd00..c7300b50b360 100644 --- a/components/brave_ads/core/internal/promoted_content_ad_value_util_unittest.cc +++ b/components/brave_ads/core/internal/promoted_content_ad_value_util_unittest.cc @@ -6,6 +6,7 @@ #include "brave/components/brave_ads/core/promoted_content_ad_value_util.h" #include "base/test/values_test_util.h" +#include "brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_info.h" #include "brave/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_unittest_util.h" @@ -18,10 +19,8 @@ namespace brave_ads { namespace { -constexpr char kPlacementId[] = "f0948316-df6f-4e31-814d-d0b5f2a1f28c"; - constexpr char kJson[] = - R"({"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"3519f52c-46a4-4c48-9c2b-c264c0067f04","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","description":"Test Ad Description","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"promoted_content_ad","uuid":"f0948316-df6f-4e31-814d-d0b5f2a1f28c"})"; + R"({"advertiser_id":"5484a63f-eb99-4ba5-a3b0-8c25d3c0e4b2","campaign_id":"84197fc8-830a-4a8e-8339-7a70c2bfa104","creative_instance_id":"546fe7b0-5047-4f28-a11c-81f14edcf0f6","creative_set_id":"c2ba3e7d-f688-4bc4-a053-cbe7ac1e6123","description":"Test Ad Description","segment":"untargeted","target_url":"https://brave.com/","title":"Test Ad Title","type":"promoted_content_ad","uuid":"8b742869-6e4a-490c-ac31-31b49130098a"})"; } // namespace diff --git a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc index f94e203d75f6..2288d26f0e18 100644 --- a/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc +++ b/components/brave_ads/core/internal/reminder/reminders/clicked_same_ad_multiple_times_reminder_util_unittest.cc @@ -18,8 +18,6 @@ namespace brave_ads { -using ::testing::_; - namespace { constexpr char kHistoryTitle[] = "title"; diff --git a/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource_unittest.cc b/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource_unittest.cc index 76dfb94696c1..2173da44c14a 100644 --- a/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource_unittest.cc +++ b/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource_unittest.cc @@ -49,11 +49,10 @@ TEST_F(BatAdsEpsilonGreedyBanditResourceTest, SuccessfullyInitializeWithEmptyCatalog) { // Arrange Catalog catalog; - const CatalogInfo catalog_info; // Act EpsilonGreedyBandit resource(&catalog); - resource.LoadFromCatalog(catalog_info); + resource.LoadFromCatalog(/*catalog*/ {}); // Assert EXPECT_TRUE(resource.IsInitialized()); diff --git a/components/brave_ads/core/internal/segments/segment_util_unittest.cc b/components/brave_ads/core/internal/segments/segment_util_unittest.cc index dabdc91cee17..fe3383917782 100644 --- a/components/brave_ads/core/internal/segments/segment_util_unittest.cc +++ b/components/brave_ads/core/internal/segments/segment_util_unittest.cc @@ -28,12 +28,11 @@ TEST_F(BatAdsSegmentUtilTest, GetSegmentsFromCatalog) { ReadFileFromTestPathToString(kCatalog); ASSERT_TRUE(json); - const absl::optional catalog_info = - json::reader::ReadCatalog(*json); - ASSERT_TRUE(catalog_info); + const absl::optional catalog = json::reader::ReadCatalog(*json); + ASSERT_TRUE(catalog); // Act - const SegmentList segments = GetSegments(*catalog_info); + const SegmentList segments = GetSegments(*catalog); // Assert const SegmentList expected_segments = {"technology & computing", @@ -43,40 +42,33 @@ TEST_F(BatAdsSegmentUtilTest, GetSegmentsFromCatalog) { TEST_F(BatAdsSegmentUtilTest, GetSegmentsFromEmptyCatalog) { // Arrange - const CatalogInfo catalog; // Act - const SegmentList segments = GetSegments(catalog); + const SegmentList segments = GetSegments({}); // Assert - const SegmentList expected_segments; - EXPECT_EQ(expected_segments, segments); + EXPECT_TRUE(segments.empty()); } TEST_F(BatAdsSegmentUtilTest, GetParentSegmentFromParentChildSegment) { // Arrange - const std::string segment = "technology & computing-software"; // Act - const std::string parent_segment = GetParentSegment(segment); + const std::string parent_segment = + GetParentSegment("technology & computing-software"); // Assert - const std::string expected_parent_segment = "technology & computing"; - - EXPECT_EQ(expected_parent_segment, parent_segment); + EXPECT_EQ("technology & computing", parent_segment); } TEST_F(BatAdsSegmentUtilTest, GetParentSegmentFromParentSegment) { // Arrange - const std::string segment = "technology & computing"; // Act - const std::string parent_segment = GetParentSegment(segment); + const std::string parent_segment = GetParentSegment("technology & computing"); // Assert - const std::string expected_parent_segment = "technology & computing"; - - EXPECT_EQ(expected_parent_segment, parent_segment); + EXPECT_EQ("technology & computing", parent_segment); } TEST_F(BatAdsSegmentUtilTest, GetParentSegments) { @@ -97,15 +89,12 @@ TEST_F(BatAdsSegmentUtilTest, GetParentSegments) { TEST_F(BatAdsSegmentUtilTest, GetParentSegmentsForEmptyList) { // Arrange - const SegmentList segments; // Act - const SegmentList parent_segments = GetParentSegments(segments); + const SegmentList parent_segments = GetParentSegments({}); // Assert - const SegmentList expected_parent_segments; - - EXPECT_EQ(expected_parent_segments, parent_segments); + EXPECT_TRUE(parent_segments.empty()); } TEST_F(BatAdsSegmentUtilTest, ShouldFilterMatchingParentChildSegment) { diff --git a/components/brave_ads/core/internal/transfer/transfer_unittest.cc b/components/brave_ads/core/internal/transfer/transfer_unittest.cc index 11be88bbfbca..df743398f10d 100644 --- a/components/brave_ads/core/internal/transfer/transfer_unittest.cc +++ b/components/brave_ads/core/internal/transfer/transfer_unittest.cc @@ -46,7 +46,8 @@ class BatAdsTransferTest : public TransferObserver, public UnitTestBase { TEST_F(BatAdsTransferTest, DoNotTransferAdIfUrlIsMissingHTTPOrHTTPSScheme) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); @@ -66,7 +67,8 @@ TEST_F(BatAdsTransferTest, DoNotTransferAdIfUrlIsMissingHTTPOrHTTPSScheme) { TEST_F(BatAdsTransferTest, DoNotTransferAdIfTheUrlDoesNotMatchTheLastClickedAd) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); @@ -85,7 +87,8 @@ TEST_F(BatAdsTransferTest, TEST_F(BatAdsTransferTest, DoNotTransferAdIfTheSameAdIsAlreadyTransferring) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); @@ -107,7 +110,8 @@ TEST_F(BatAdsTransferTest, DoNotTransferAdIfTheSameAdIsAlreadyTransferring) { TEST_F(BatAdsTransferTest, TransferAdIfAnotherAdIsAlreadyTransferring) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); @@ -140,7 +144,8 @@ TEST_F(BatAdsTransferTest, TransferAdIfAnotherAdIsAlreadyTransferring) { TEST_F(BatAdsTransferTest, TransferAdIfTheTabIsVisibleAndTheUrlIsTheSameAsTheDomainOrHost) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); @@ -160,7 +165,8 @@ TEST_F(BatAdsTransferTest, TEST_F(BatAdsTransferTest, FailToTransferAdIfNotVisible) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); @@ -181,7 +187,8 @@ TEST_F(BatAdsTransferTest, FailToTransferAdIfNotVisible) { TEST_F(BatAdsTransferTest, FailToTransferAdIfTheTabUrlIsNotTheSameAsTheDomainOrHost) { // Arrange - const AdInfo ad = BuildAd(); + const AdInfo ad = + BuildAd(AdType::kNotificationAd, /*should_use_random_guids*/ false); transfer_->SetLastClickedAd(ad); diff --git a/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection_util_unittest.cc b/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection_util_unittest.cc index bcc7b50d8819..54f20d401b42 100644 --- a/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection_util_unittest.cc +++ b/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection_util_unittest.cc @@ -187,8 +187,7 @@ TEST_F(BatAdsIdleDetectionUtilTest, UpdateIdleTimeThreshold) { AdsClientHelper::GetInstance()->GetIntegerPref(prefs::kIdleTimeThreshold); // Assert - const int expected_idle_time_threshold = 5; - EXPECT_EQ(expected_idle_time_threshold, idle_time_threshold); + EXPECT_EQ(5, idle_time_threshold); } TEST_F(BatAdsIdleDetectionUtilTest, DoNotUpdateIdleTimeThreshold) { @@ -213,8 +212,7 @@ TEST_F(BatAdsIdleDetectionUtilTest, DoNotUpdateIdleTimeThreshold) { AdsClientHelper::GetInstance()->GetIntegerPref(prefs::kIdleTimeThreshold); // Assert - const int expected_idle_time_threshold = 10; - EXPECT_EQ(expected_idle_time_threshold, idle_time_threshold); + EXPECT_EQ(10, idle_time_threshold); } } // namespace brave_ads::idle_detection diff --git a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_util_unittest.cc b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_util_unittest.cc index 19819db16797..aa4c36c10574 100644 --- a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_util_unittest.cc +++ b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_util_unittest.cc @@ -158,8 +158,7 @@ TEST_F(BatAdsUserActivityUtilTest, GetTimeSinceLastUserActivityEvent) { events, UserActivityEventType::kTabStartedPlayingMedia); // Assert - const int64_t expected_time = 6 * base::Time::kSecondsPerMinute; - EXPECT_EQ(expected_time, time); + EXPECT_EQ(6 * base::Time::kSecondsPerMinute, time); } TEST_F(BatAdsUserActivityUtilTest, diff --git a/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions_unittest.cc b/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions_unittest.cc index 48b5b0cfb0a6..d39d47cc021f 100644 --- a/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions_unittest.cc +++ b/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions_unittest.cc @@ -12,6 +12,7 @@ #include "brave/components/brave_ads/core/confirmation_type.h" #include "brave/components/brave_ads/core/history_item_info.h" #include "brave/components/brave_ads/core/internal/account/account.h" +#include "brave/components/brave_ads/core/internal/account/account_observer.h" #include "brave/components/brave_ads/core/internal/account/transactions/transaction_info.h" #include "brave/components/brave_ads/core/internal/common/unittest/unittest_base.h" #include "brave/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h" @@ -57,7 +58,7 @@ class BatAdsUserReactionsTest : public AccountObserver, public UnitTestBase { static HistoryItemInfo AddHistoryItem() { const CreativeNotificationAdInfo creative_ad = - BuildCreativeNotificationAd(); + BuildCreativeNotificationAd(/*should_use_random_guids*/ true); const NotificationAdInfo ad = BuildNotificationAd(creative_ad); return HistoryManager::GetInstance()->Add(ad, ConfirmationType::kViewed); diff --git a/components/brave_ads/core/new_tab_page_ad_constants.h b/components/brave_ads/core/new_tab_page_ad_constants.h new file mode 100644 index 000000000000..8d213565acf4 --- /dev/null +++ b/components/brave_ads/core/new_tab_page_ad_constants.h @@ -0,0 +1,28 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_NEW_TAB_PAGE_AD_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_NEW_TAB_PAGE_AD_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kNewTabPageAdPlacementIdKey[] = "placement_id"; +constexpr char kNewTabPageAdCreativeInstanceIdKey[] = "creative_instance_id"; +constexpr char kNewTabPageAdCreativeSetIdKey[] = "creative_set_id"; +constexpr char kNewTabPageAdCampaignIdKey[] = "campaign_id"; +constexpr char kNewTabPageAdAdvertiserIdKey[] = "advertiser_id"; +constexpr char kNewTabPageAdSegmentKey[] = "segment"; +constexpr char kNewTabPageAdCompanyNameKey[] = "company_name"; +constexpr char kNewTabPageAdAltKey[] = "alt"; +constexpr char kNewTabPageAdImageUrlKey[] = "image_url"; +constexpr char kNewTabPageAdFocalPointKey[] = "focal_point"; +constexpr char kNewTabPageAdFocalPointXKey[] = "x"; +constexpr char kNewTabPageAdFocalPointYKey[] = "y"; +constexpr char kNewTabPageAdWallpapersKey[] = "wallpapers"; +constexpr char kNewTabPageAdTargetUrlKey[] = "target_url"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_NEW_TAB_PAGE_AD_CONSTANTS_H_ diff --git a/components/brave_ads/core/notification_ad_constants.h b/components/brave_ads/core/notification_ad_constants.h new file mode 100644 index 000000000000..6a8a6b98c478 --- /dev/null +++ b/components/brave_ads/core/notification_ad_constants.h @@ -0,0 +1,23 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_NOTIFICATION_AD_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_NOTIFICATION_AD_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kNotificationAdPlacementIdKey[] = "uuid"; +constexpr char kNotificationAdCreativeInstanceIdKey[] = "creative_instance_id"; +constexpr char kNotificationAdCreativeSetIdKey[] = "creative_set_id"; +constexpr char kNotificationAdCampaignIdKey[] = "campaign_id"; +constexpr char kNotificationAdAdvertiserIdKey[] = "advertiser_id"; +constexpr char kNotificationAdSegmentKey[] = "segment"; +constexpr char kNotificationAdTitleKey[] = "title"; +constexpr char kNotificationAdBodyKey[] = "body"; +constexpr char kNotificationAdTargetUrlKey[] = "target_url"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_NOTIFICATION_AD_CONSTANTS_H_ diff --git a/components/brave_ads/core/promoted_content_ad_constants.h b/components/brave_ads/core/promoted_content_ad_constants.h new file mode 100644 index 000000000000..c61a002b1e76 --- /dev/null +++ b/components/brave_ads/core/promoted_content_ad_constants.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2023 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ + +#ifndef BRAVE_COMPONENTS_BRAVE_ADS_CORE_PROMOTED_CONTENT_AD_CONSTANTS_H_ +#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_PROMOTED_CONTENT_AD_CONSTANTS_H_ + +namespace brave_ads { + +constexpr char kPromotedContentAdPlacementIdKey[] = "uuid"; +constexpr char kPromotedContentAdCreativeInstanceIdKey[] = + "creative_instance_id"; +constexpr char kPromotedContentAdCreativeSetIdKey[] = "creative_set_id"; +constexpr char kPromotedContentAdCampaignIdKey[] = "campaign_id"; +constexpr char kPromotedContentAdAdvertiserIdKey[] = "advertiser_id"; +constexpr char kPromotedContentAdSegmentKey[] = "segment"; +constexpr char kPromotedContentAdTitleKey[] = "title"; +constexpr char kPromotedContentAdDescriptionnKey[] = "description"; +constexpr char kPromotedContentAdTargetUrlKey[] = "target_url"; + +} // namespace brave_ads + +#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_PROMOTED_CONTENT_AD_CONSTANTS_H_ diff --git a/components/brave_ads/core/test/BUILD.gn b/components/brave_ads/core/test/BUILD.gn index 7aeb5b819dc4..1959b9f062bf 100644 --- a/components/brave_ads/core/test/BUILD.gn +++ b/components/brave_ads/core/test/BUILD.gn @@ -82,6 +82,7 @@ source_set("brave_ads_unit_tests") { "//brave/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_unittest.cc", "//brave/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/request_signed_tokens_url_request_builder_unittest.cc", "//brave/components/brave_ads/core/internal/account/wallet/wallet_unittest.cc", + "//brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_constants.h", "//brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.cc", "//brave/components/brave_ads/core/internal/account/wallet/wallet_unittest_util.h", "//brave/components/brave_ads/core/internal/ad_content_info_unittest.cc", @@ -100,6 +101,7 @@ source_set("brave_ads_unit_tests") { "//brave/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler_unittest.cc", "//brave/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler_unittest.cc", "//brave/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler_unittest.cc", + "//brave/components/brave_ads/core/internal/ads/ad_unittest_constants.h", "//brave/components/brave_ads/core/internal/ads/ad_unittest_util.cc", "//brave/components/brave_ads/core/internal/ads/ad_unittest_util.h", "//brave/components/brave_ads/core/internal/ads/inline_content_ad_features_unittest.cc", @@ -212,6 +214,7 @@ source_set("brave_ads_unit_tests") { "//brave/components/brave_ads/core/internal/ads_util_unittest.cc", "//brave/components/brave_ads/core/internal/browser/browser_manager_unittest.cc", "//brave/components/brave_ads/core/internal/catalog/catalog_json_reader_unittest.cc", + "//brave/components/brave_ads/core/internal/catalog/catalog_unittest_constants.h", "//brave/components/brave_ads/core/internal/catalog/catalog_util_unittest.cc", "//brave/components/brave_ads/core/internal/common/calendar/calendar_leap_year_util_unittest.cc", "//brave/components/brave_ads/core/internal/common/calendar/calendar_util_unittest.cc", @@ -272,6 +275,7 @@ source_set("brave_ads_unit_tests") { "//brave/components/brave_ads/core/internal/conversions/conversions_database_table_unittest.cc", "//brave/components/brave_ads/core/internal/conversions/conversions_features_unittest.cc", "//brave/components/brave_ads/core/internal/conversions/conversions_unittest.cc", + "//brave/components/brave_ads/core/internal/conversions/conversions_unittest_constants.h", "//brave/components/brave_ads/core/internal/conversions/conversions_util_unittest.cc", "//brave/components/brave_ads/core/internal/conversions/sorts/conversions_sort_unittest.cc", "//brave/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_unittest_util.cc", diff --git a/components/brave_ads/core/test/data/catalog.json b/components/brave_ads/core/test/data/catalog.json index 2856fab7e7ba..9f71bf81a9b6 100644 --- a/components/brave_ads/core/test/data/catalog.json +++ b/components/brave_ads/core/test/data/catalog.json @@ -7,7 +7,7 @@ { "creatives": [ { - "creativeInstanceId": "18d8df02-68b1-4a6d-81a1-67357b157e2a", + "creativeInstanceId": "546fe7b0-5047-4f28-a11c-81f14edcf0f6", "type": { "code": "notification_all_v1", "name": "notification", @@ -53,7 +53,7 @@ } }, { - "creativeInstanceId": "30db5f7b-dba3-48a3-b299-c9bd9c67da65", + "creativeInstanceId": "b0615969-6ee0-4559-b50c-f84be23302e4", "type": { "code": "inline_content_all_v1", "name": "inline_content", diff --git a/components/brave_ads/core/test/data/catalog_with_inline_content_ad.json b/components/brave_ads/core/test/data/catalog_with_inline_content_ad.json index b889bef4332b..ea2e923a559d 100644 --- a/components/brave_ads/core/test/data/catalog_with_inline_content_ad.json +++ b/components/brave_ads/core/test/data/catalog_with_inline_content_ad.json @@ -7,7 +7,7 @@ { "creatives": [ { - "creativeInstanceId": "30db5f7b-dba3-48a3-b299-c9bd9c67da65", + "creativeInstanceId": "546fe7b0-5047-4f28-a11c-81f14edcf0f6", "type": { "code": "inline_content_all_v1", "name": "inline_content", diff --git a/components/brave_ads/core/test/data/catalog_with_multiple_campaigns.json b/components/brave_ads/core/test/data/catalog_with_multiple_campaigns.json index 53d4cccffaf6..bb7adbbaac55 100644 --- a/components/brave_ads/core/test/data/catalog_with_multiple_campaigns.json +++ b/components/brave_ads/core/test/data/catalog_with_multiple_campaigns.json @@ -72,7 +72,7 @@ } }, { - "creativeInstanceId": "30db5f7b-dba3-48a3-b299-c9bd9c67da65", + "creativeInstanceId": "b0615969-6ee0-4559-b50c-f84be23302e4", "type": { "code": "inline_content_all_v1", "name": "inline_content", diff --git a/components/brave_ads/core/test/data/catalog_with_new_tab_page_ad.json b/components/brave_ads/core/test/data/catalog_with_new_tab_page_ad.json index 93645476f800..49e8839c6d41 100644 --- a/components/brave_ads/core/test/data/catalog_with_new_tab_page_ad.json +++ b/components/brave_ads/core/test/data/catalog_with_new_tab_page_ad.json @@ -7,7 +7,7 @@ { "creatives": [ { - "creativeInstanceId": "7ff400b9-7f8a-46a8-89f1-cb386612edcf", + "creativeInstanceId": "546fe7b0-5047-4f28-a11c-81f14edcf0f6", "type": { "code": "new_tab_page_all_v1", "platform": "all", diff --git a/components/brave_ads/core/test/data/catalog_with_notification_ad.json b/components/brave_ads/core/test/data/catalog_with_notification_ad.json index 5f98653dcac4..104fa70b3719 100644 --- a/components/brave_ads/core/test/data/catalog_with_notification_ad.json +++ b/components/brave_ads/core/test/data/catalog_with_notification_ad.json @@ -7,7 +7,7 @@ { "creatives": [ { - "creativeInstanceId": "18d8df02-68b1-4a6d-81a1-67357b157e2a", + "creativeInstanceId": "546fe7b0-5047-4f28-a11c-81f14edcf0f6", "type": { "code": "notification_all_v1", "name": "notification", diff --git a/components/brave_ads/core/test/data/catalog_with_promoted_content_ad.json b/components/brave_ads/core/test/data/catalog_with_promoted_content_ad.json index dee745e2c4d4..37ae3538bfb2 100644 --- a/components/brave_ads/core/test/data/catalog_with_promoted_content_ad.json +++ b/components/brave_ads/core/test/data/catalog_with_promoted_content_ad.json @@ -7,7 +7,7 @@ { "creatives": [ { - "creativeInstanceId": "75d4cbac-b661-4126-9ccb-7bbb6ee56ef3", + "creativeInstanceId": "546fe7b0-5047-4f28-a11c-81f14edcf0f6", "type": { "code": "promoted_content_all_v1", "name": "promoted_content", diff --git a/components/brave_ads/core/test/data/catalog_with_single_campaign.json b/components/brave_ads/core/test/data/catalog_with_single_campaign.json index b0b69162b34c..7dfac366d376 100644 --- a/components/brave_ads/core/test/data/catalog_with_single_campaign.json +++ b/components/brave_ads/core/test/data/catalog_with_single_campaign.json @@ -72,7 +72,7 @@ } }, { - "creativeInstanceId": "30db5f7b-dba3-48a3-b299-c9bd9c67da65", + "creativeInstanceId": "b0615969-6ee0-4559-b50c-f84be23302e4", "type": { "code": "inline_content_all_v1", "name": "inline_content", From e338e9f772c07b7676448caec6473ab083204cbb Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Wed, 12 Apr 2023 10:23:39 +0100 Subject: [PATCH 3/5] Refactor Brave Ads OnHistoryDidChange to OnDidAddHistory --- .../core/internal/history/history_manager.cc | 14 +++++++------- .../core/internal/history/history_manager.h | 2 +- .../internal/history/history_manager_observer.h | 4 ++-- .../internal/history/history_manager_unittest.cc | 16 ++++++++-------- .../brave_ads/core/internal/reminder/reminder.cc | 2 +- .../brave_ads/core/internal/reminder/reminder.h | 2 +- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/components/brave_ads/core/internal/history/history_manager.cc b/components/brave_ads/core/internal/history/history_manager.cc index da38e819570b..5445b2637ceb 100644 --- a/components/brave_ads/core/internal/history/history_manager.cc +++ b/components/brave_ads/core/internal/history/history_manager.cc @@ -94,7 +94,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.title, ad.description); - NotifyHistoryDidChange(history_item); + NotifyDidAddHistory(history_item); return history_item; } @@ -103,7 +103,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.company_name, ad.alt); - NotifyHistoryDidChange(history_item); + NotifyDidAddHistory(history_item); return history_item; } @@ -112,7 +112,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.title, ad.body); - NotifyHistoryDidChange(history_item); + NotifyDidAddHistory(history_item); return history_item; } @@ -121,7 +121,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.title, ad.description); - NotifyHistoryDidChange(history_item); + NotifyDidAddHistory(history_item); return history_item; } @@ -130,7 +130,7 @@ HistoryItemInfo HistoryManager::Add( const ConfirmationType& confirmation_type) const { HistoryItemInfo history_item = AddHistory(ad, confirmation_type, ad.headline_text, ad.description); - NotifyHistoryDidChange(history_item); + NotifyDidAddHistory(history_item); return history_item; } @@ -212,10 +212,10 @@ bool HistoryManager::ToggleSaveAd(const AdContentInfo& ad_content) const { /////////////////////////////////////////////////////////////////////////////// -void HistoryManager::NotifyHistoryDidChange( +void HistoryManager::NotifyDidAddHistory( const HistoryItemInfo& history_item) const { for (HistoryManagerObserver& observer : observers_) { - observer.OnHistoryDidChange(history_item); + observer.OnDidAddHistory(history_item); } } diff --git a/components/brave_ads/core/internal/history/history_manager.h b/components/brave_ads/core/internal/history/history_manager.h index f91af9ca153d..b1363db0f0a8 100644 --- a/components/brave_ads/core/internal/history/history_manager.h +++ b/components/brave_ads/core/internal/history/history_manager.h @@ -81,7 +81,7 @@ class HistoryManager final { bool ToggleSaveAd(const AdContentInfo& ad_content) const; private: - void NotifyHistoryDidChange(const HistoryItemInfo& history_item) const; + void NotifyDidAddHistory(const HistoryItemInfo& history_item) const; void NotifyDidLikeAd(const AdContentInfo& ad_content) const; void NotifyDidDislikeAd(const AdContentInfo& ad_content) const; void NotifyDidMarkToNoLongerReceiveAdsForCategory( diff --git a/components/brave_ads/core/internal/history/history_manager_observer.h b/components/brave_ads/core/internal/history/history_manager_observer.h index 8a68af3b4077..fc5b886f09d8 100644 --- a/components/brave_ads/core/internal/history/history_manager_observer.h +++ b/components/brave_ads/core/internal/history/history_manager_observer.h @@ -17,8 +17,8 @@ struct HistoryItemInfo; class HistoryManagerObserver : public base::CheckedObserver { public: - // Invoked when the history has changed. - virtual void OnHistoryDidChange(const HistoryItemInfo& history_item) {} + // Invoked when history is added. + virtual void OnDidAddHistory(const HistoryItemInfo& history_item) {} // Invoked when the user likes an ad. virtual void OnDidLikeAd(const AdContentInfo& ad_content) {} diff --git a/components/brave_ads/core/internal/history/history_manager_unittest.cc b/components/brave_ads/core/internal/history/history_manager_unittest.cc index bc52b7bca7b7..b43674acd658 100644 --- a/components/brave_ads/core/internal/history/history_manager_unittest.cc +++ b/components/brave_ads/core/internal/history/history_manager_unittest.cc @@ -45,8 +45,8 @@ class BatAdsHistoryManagerTest : public HistoryManagerObserver, UnitTestBase::TearDown(); } - void OnHistoryDidChange(const HistoryItemInfo& /*history_item*/) override { - history_did_change_ = true; + void OnDidAddHistory(const HistoryItemInfo& /*history_item*/) override { + did_add_history_ = true; } void OnDidLikeAd(const AdContentInfo& /*ad_content*/) override { @@ -84,7 +84,7 @@ class BatAdsHistoryManagerTest : public HistoryManagerObserver, did_unsave_ad_ = true; } - bool history_did_change_ = false; + bool did_add_history_ = false; bool did_like_ad_ = false; bool did_dislike_ad_ = false; bool did_mark_to_no_longer_receive_ads_for_category_ = false; @@ -122,7 +122,7 @@ TEST_F(BatAdsHistoryManagerTest, AddNotificationAd) { ClientStateManager::GetInstance()->GetHistory(); EXPECT_TRUE(base::ranges::equal(expected_history, history)); - EXPECT_TRUE(history_did_change_); + EXPECT_TRUE(did_add_history_); } TEST_F(BatAdsHistoryManagerTest, AddNewTabPageAd) { @@ -142,7 +142,7 @@ TEST_F(BatAdsHistoryManagerTest, AddNewTabPageAd) { ClientStateManager::GetInstance()->GetHistory(); EXPECT_TRUE(base::ranges::equal(expected_history, history)); - EXPECT_TRUE(history_did_change_); + EXPECT_TRUE(did_add_history_); } TEST_F(BatAdsHistoryManagerTest, AddPromotedContentAd) { @@ -162,7 +162,7 @@ TEST_F(BatAdsHistoryManagerTest, AddPromotedContentAd) { ClientStateManager::GetInstance()->GetHistory(); EXPECT_TRUE(base::ranges::equal(expected_history, history)); - EXPECT_TRUE(history_did_change_); + EXPECT_TRUE(did_add_history_); } TEST_F(BatAdsHistoryManagerTest, AddInlineContentAd) { @@ -182,7 +182,7 @@ TEST_F(BatAdsHistoryManagerTest, AddInlineContentAd) { ClientStateManager::GetInstance()->GetHistory(); EXPECT_TRUE(base::ranges::equal(expected_history, history)); - EXPECT_TRUE(history_did_change_); + EXPECT_TRUE(did_add_history_); } TEST_F(BatAdsHistoryManagerTest, AddSearchResultAd) { @@ -202,7 +202,7 @@ TEST_F(BatAdsHistoryManagerTest, AddSearchResultAd) { ClientStateManager::GetInstance()->GetHistory(); EXPECT_TRUE(base::ranges::equal(expected_history, history)); - EXPECT_TRUE(history_did_change_); + EXPECT_TRUE(did_add_history_); } TEST_F(BatAdsHistoryManagerTest, LikeAd) { diff --git a/components/brave_ads/core/internal/reminder/reminder.cc b/components/brave_ads/core/internal/reminder/reminder.cc index f3672a721627..8f46297f2642 100644 --- a/components/brave_ads/core/internal/reminder/reminder.cc +++ b/components/brave_ads/core/internal/reminder/reminder.cc @@ -34,7 +34,7 @@ Reminder::~Reminder() { /////////////////////////////////////////////////////////////////////////////// -void Reminder::OnHistoryDidChange(const HistoryItemInfo& history_item) { +void Reminder::OnDidAddHistory(const HistoryItemInfo& history_item) { MaybeShowReminder(history_item); } diff --git a/components/brave_ads/core/internal/reminder/reminder.h b/components/brave_ads/core/internal/reminder/reminder.h index fce9cc71d85d..9ff4023e260f 100644 --- a/components/brave_ads/core/internal/reminder/reminder.h +++ b/components/brave_ads/core/internal/reminder/reminder.h @@ -26,7 +26,7 @@ class Reminder : public HistoryManagerObserver { private: // HistoryManagerObserver: - void OnHistoryDidChange(const HistoryItemInfo& history_item) override; + void OnDidAddHistory(const HistoryItemInfo& history_item) override; }; } // namespace brave_ads From e4fd35e995aaa56af04b9b883afdb3dc9eb37037 Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Wed, 12 Apr 2023 10:45:51 +0100 Subject: [PATCH 4/5] Cleanup Brave Ads constructors --- browser/brave_ads/ads_service_factory.h | 4 ++-- .../background_helper/background_helper.h | 4 ++-- .../background_helper/background_helper_android.h | 4 ++-- .../background_helper/background_helper_holder.h | 5 ++--- .../background_helper/background_helper_linux.h | 5 ++--- .../background_helper/background_helper_mac.h | 4 ++-- .../background_helper/background_helper_win.h | 4 ++-- .../notification_helper/notification_helper.h | 4 ++-- .../notification_helper/notification_helper_impl.h | 5 ++--- .../notification_helper_impl_android.h | 6 +++--- .../notification_helper_impl_linux.h | 5 ++--- .../notification_helper_impl_mac.h | 5 ++--- .../notification_helper_impl_mock.h | 5 ++--- .../notification_helper_impl_win.h | 5 ++--- .../notification_ad_platform_bridge.h | 4 ++-- browser/brave_ads/tooltips/ads_captcha_tooltip.h | 4 ++-- .../brave_ads/tooltips/ads_tooltips_controller.h | 5 ++--- .../tooltips/ads_tooltips_delegate_impl.h | 4 ++-- browser/ui/brave_ads/notification_ad.h | 8 ++++---- .../ui/brave_ads/notification_ad_popup_handler.h | 5 ++--- .../brave_ads/notification_ad_background_painter.h | 6 +++--- .../notification_ad_control_buttons_view.h | 4 ++-- .../views/brave_ads/notification_ad_header_view.h | 6 +++--- browser/ui/views/brave_ads/notification_ad_popup.h | 4 ++-- .../brave_ads/notification_ad_popup_collection.h | 6 +++--- browser/ui/views/brave_ads/notification_ad_view.h | 4 ++-- browser/ui/views/brave_ads/padded_image_button.h | 4 ++-- browser/ui/views/brave_ads/padded_image_view.h | 4 ++-- .../ui/views/brave_ads/text_notification_ad_view.h | 5 ++--- components/brave_ads/browser/ads_service.h | 4 ++-- components/brave_ads/browser/ads_service_impl.h | 4 ++-- .../browser/component_updater/resource_component.h | 4 ++-- components/brave_ads/browser/device_id.h | 4 ++-- .../brave_ads/browser/frequency_capping_helper.h | 5 ++--- components/brave_ads/browser/mock_ads_service.h | 4 ++-- components/brave_ads/core/ad_content_info.h | 8 ++++---- components/brave_ads/core/ad_event_history.h | 8 ++++---- components/brave_ads/core/ad_info.h | 12 ++++++------ components/brave_ads/core/ads.h | 8 ++++---- components/brave_ads/core/ads_client_notifier.h | 8 ++++---- .../brave_ads/core/ads_client_notifier_observer.h | 9 ++++----- components/brave_ads/core/database.h | 8 ++++---- components/brave_ads/core/inline_content_ad_info.h | 12 ++++++------ .../brave_ads/core/internal/account/account.h | 8 ++++---- .../account/confirmations/confirmation_info.h | 8 ++++---- .../internal/account/confirmations/confirmations.h | 8 ++++---- .../confirmations/confirmations_delegate_mock.h | 7 +++---- .../internal/account/confirmations/opted_in_info.h | 8 ++++---- .../confirmations/opted_in_user_data_info.h | 8 ++++---- .../core/internal/account/issuers/issuer_info.h | 12 ++++++------ .../core/internal/account/issuers/issuers.h | 8 ++++---- .../account/issuers/issuers_delegate_mock.h | 8 ++++---- .../core/internal/account/issuers/issuers_info.h | 12 ++++++------ .../account/transactions/transaction_info.h | 12 ++++++------ .../redeem_confirmation_delegate_mock.h | 8 ++++---- .../redeem_opted_in_confirmation.h | 9 ++++----- .../redeem_opted_out_confirmation.h | 11 +++++------ .../redeem_unblinded_payment_tokens.h | 7 +++---- ...redeem_unblinded_payment_tokens_delegate_mock.h | 8 ++++---- ..._unblinded_payment_tokens_url_request_builder.h | 8 ++++---- ...em_unblinded_payment_tokens_user_data_builder.h | 8 ++++---- .../refill_unblinded_tokens.h | 9 ++++----- .../refill_unblinded_tokens_delegate_mock.h | 6 +++--- .../request_signed_tokens_url_request_builder.h | 8 ++++---- .../core/internal/account/wallet/wallet_info.h | 10 +++++----- .../core/internal/ads/ad_events/ad_event_info.h | 8 ++++---- .../inline_content_ad_event_handler.h | 8 ++++---- .../new_tab_page_ad_event_handler.h | 8 ++++---- .../notification_ad_event_handler.h | 8 ++++---- .../promoted_content_ad_event_handler.h | 8 ++++---- .../search_result_ad_event_handler.h | 8 ++++---- .../core/internal/ads/inline_content_ad_handler.h | 10 ++++------ .../core/internal/ads/new_tab_page_ad_handler.h | 8 ++++---- .../core/internal/ads/notification_ad_handler.h | 9 ++++----- .../internal/ads/promoted_content_ad_handler.h | 8 ++++---- .../core/internal/ads/search_result_ad_handler.h | 8 ++++---- .../anti_targeting_exclusion_rule.h | 7 +++---- .../exclusion_rules/conversion_exclusion_rule.h | 9 ++++----- .../creative_instance_exclusion_rule.h | 11 +++++------ .../exclusion_rules/daily_cap_exclusion_rule.h | 9 ++++----- .../exclusion_rules/exclusion_rules_base.h | 8 ++++---- .../inline_content_ad_exclusion_rules.h | 8 ++++---- .../notification_ad_dismissed_exclusion_rule.h | 10 ++++------ .../notification_ad_exclusion_rules.h | 8 ++++---- .../exclusion_rules/per_day_exclusion_rule.h | 8 ++++---- .../exclusion_rules/per_month_exclusion_rule.h | 9 ++++----- .../exclusion_rules/per_week_exclusion_rule.h | 9 ++++----- .../subdivision_targeting_exclusion_rule.h | 6 +++--- .../exclusion_rules/total_max_exclusion_rule.h | 9 ++++----- .../exclusion_rules/transferred_exclusion_rule.h | 11 +++++------ .../eligible_inline_content_ads_base.h | 8 ++++---- .../eligible_new_tab_page_ads_base.h | 8 ++++---- .../eligible_notification_ads_base.h | 8 ++++---- .../ads/serving/inline_content_ad_serving.h | 8 ++++---- .../internal/ads/serving/new_tab_page_ad_serving.h | 8 ++++---- .../internal/ads/serving/notification_ad_serving.h | 8 ++++---- .../permission_rules/permission_rules_base.h | 8 ++++---- .../ads/serving/targeting/user_model_info.h | 8 ++++---- .../brave_ads/core/internal/ads_client_helper.h | 8 ++++---- .../brave_ads/core/internal/ads_client_mock.h | 8 ++++---- components/brave_ads/core/internal/ads_impl.h | 8 ++++---- .../core/internal/browser/browser_manager.h | 8 ++++---- .../catalog/campaign/catalog_campaign_info.h | 12 ++++++------ .../creative_set/catalog_creative_set_info.h | 12 ++++++------ .../creative_set/creative/catalog_creative_info.h | 4 ++-- .../creative_set/creative/catalog_type_info.h | 12 ++++++------ .../catalog_creative_inline_content_ad_info.h | 4 ++-- .../catalog_inline_content_ad_payload_info.h | 13 ++++++------- .../catalog_creative_new_tab_page_ad_info.h | 4 ++-- .../catalog_new_tab_page_ad_payload_info.h | 13 ++++++------- .../catalog_new_tab_page_ad_wallpaper_info.h | 4 ++-- .../catalog_creative_notification_ad_info.h | 4 ++-- .../catalog_notification_ad_payload_info.h | 4 ++-- .../catalog_creative_promoted_content_ad_info.h | 4 ++-- .../brave_ads/core/internal/catalog/catalog.h | 8 ++++---- .../brave_ads/core/internal/catalog/catalog_info.h | 12 ++++++------ .../core/internal/common/crypto/key_pair_info.h | 12 ++++++------ .../internal/common/platform/platform_helper_mac.h | 8 ++++---- .../common/platform/platform_helper_mock.h | 8 ++++---- .../brave_ads/core/internal/common/timer/timer.h | 8 ++++---- .../core/internal/common/unittest/unittest_base.h | 8 ++++---- .../core/internal/conversions/conversion_info.h | 12 ++++++------ .../conversions/conversion_queue_item_info.h | 12 ++++++------ .../core/internal/conversions/conversions.h | 8 ++++---- .../verifiable_conversion_envelope_info.h | 14 ++++++-------- .../conversions/verifiable_conversion_info.h | 4 ++-- .../core/internal/creatives/creative_ad_info.h | 12 ++++++------ .../core/internal/creatives/creatives_info.h | 8 ++++---- .../creative_inline_content_ad_info.h | 13 ++++++------- .../creative_inline_content_ads_database_table.h | 11 +++++------ .../creative_new_tab_page_ad_info.h | 13 ++++++------- .../creative_new_tab_page_ad_wallpaper_info.h | 4 ++-- .../creative_new_tab_page_ads_database_table.h | 9 ++++----- .../creative_notification_ad_info.h | 4 ++-- .../creative_notification_ads_database_table.h | 9 ++++----- .../notification_ads/notification_ad_manager.h | 9 ++++----- .../creative_promoted_content_ad_info.h | 4 ++-- .../creative_promoted_content_ads_database_table.h | 7 +++---- .../core/internal/database/database_manager.h | 8 ++++---- .../core/internal/deprecated/client/client_info.h | 8 ++++---- .../deprecated/client/client_state_manager.h | 8 ++++---- .../client/preferences/ad_preferences_info.h | 8 ++++---- .../confirmations/confirmation_state_manager.h | 11 +++++------ .../core/internal/diagnostics/diagnostic_manager.h | 8 ++++---- .../internal/fl/predictors/predictors_manager.h | 8 ++++---- .../brave_ads/core/internal/flags/flag_manager.h | 8 ++++---- .../geographic/subdivision/subdivision_targeting.h | 9 ++++----- .../core/internal/history/history_manager.h | 8 ++++---- components/brave_ads/core/internal/ml/data/data.h | 8 ++++---- .../core/internal/ml/model/linear/linear.h | 8 ++++---- .../internal/ml/pipeline/embedding_pipeline_info.h | 8 ++++---- .../core/internal/ml/pipeline/pipeline_info.h | 4 ++-- .../ml/pipeline/text_processing/embedding_info.h | 8 ++++---- .../ml/pipeline/text_processing/text_processing.h | 8 ++++---- .../internal/ml/transformation/hash_vectorizer.h | 8 ++++---- .../challenge_bypass_ristretto/batch_dleq_proof.h | 12 ++++++------ .../challenge_bypass_ristretto/blinded_token.h | 12 ++++++------ .../challenge_bypass_ristretto/dleq_proof.h | 12 ++++++------ .../challenge_bypass_ristretto/public_key.h | 12 ++++++------ .../challenge_bypass_ristretto/signed_token.h | 12 ++++++------ .../challenge_bypass_ristretto/signing_key.h | 12 ++++++------ .../privacy/challenge_bypass_ristretto/token.h | 12 ++++++------ .../challenge_bypass_ristretto/token_preimage.h | 12 ++++++------ .../challenge_bypass_ristretto/unblinded_token.h | 12 ++++++------ .../verification_signature.h | 12 ++++++------ .../internal/privacy/tokens/token_generator_mock.h | 8 ++++---- .../unblinded_payment_token_info.h | 13 ++++++------- .../unblinded_payment_tokens.h | 10 ++++------ .../tokens/unblinded_tokens/unblinded_token_info.h | 4 ++-- .../tokens/unblinded_tokens/unblinded_tokens.h | 8 ++++---- .../epsilon_greedy_bandit_arm_info.h | 4 ++-- .../purchase_intent/purchase_intent_processor.h | 8 ++++---- .../purchase_intent/purchase_intent_signal_info.h | 9 ++++----- .../text_classification_processor.h | 8 ++++---- .../text_embedding_html_event_info.h | 10 ++++------ .../text_embedding/text_embedding_processor.h | 8 ++++---- .../brave_ads/core/internal/reminder/reminder.h | 8 ++++---- .../anti_targeting/anti_targeting_info.h | 8 ++++---- .../anti_targeting/anti_targeting_resource.h | 8 ++++---- .../behavioral/conversions/conversions_info.h | 8 ++++---- .../behavioral/conversions/conversions_resource.h | 8 ++++---- .../epsilon_greedy_bandit_resource.h | 8 ++++---- .../purchase_intent/purchase_intent_info.h | 8 ++++---- .../purchase_intent/purchase_intent_resource.h | 8 ++++---- .../purchase_intent_segment_keyword_info.h | 10 ++++------ .../purchase_intent/purchase_intent_site_info.h | 12 ++++++------ .../text_classification_resource.h | 8 ++++---- .../text_embedding/text_embedding_resource.h | 8 ++++---- components/brave_ads/core/internal/tabs/tab_info.h | 12 ++++++------ .../brave_ads/core/internal/tabs/tab_manager.h | 8 ++++---- .../brave_ads/core/internal/transfer/transfer.h | 8 ++++---- .../user_attention/idle_detection/idle_detection.h | 8 ++++---- .../user_activity/user_activity_manager.h | 8 ++++---- .../user_attention/user_reactions/user_reactions.h | 8 ++++---- components/brave_ads/core/new_tab_page_ad_info.h | 12 ++++++------ 195 files changed, 752 insertions(+), 803 deletions(-) diff --git a/browser/brave_ads/ads_service_factory.h b/browser/brave_ads/ads_service_factory.h index bee20f12203d..3b9d76360fae 100644 --- a/browser/brave_ads/ads_service_factory.h +++ b/browser/brave_ads/ads_service_factory.h @@ -23,8 +23,8 @@ class AdsServiceFactory : public BrowserContextKeyedServiceFactory { AdsServiceFactory(const AdsServiceFactory&) = delete; AdsServiceFactory& operator=(const AdsServiceFactory&) = delete; - AdsServiceFactory(AdsServiceFactory&& other) noexcept = delete; - AdsServiceFactory& operator=(AdsServiceFactory&& other) noexcept = delete; + AdsServiceFactory(AdsServiceFactory&&) noexcept = delete; + AdsServiceFactory& operator=(AdsServiceFactory&&) noexcept = delete; static AdsService* GetForProfile(Profile* profile); diff --git a/browser/brave_ads/background_helper/background_helper.h b/browser/brave_ads/background_helper/background_helper.h index 5081ba62e4d9..37775c3a4926 100644 --- a/browser/brave_ads/background_helper/background_helper.h +++ b/browser/brave_ads/background_helper/background_helper.h @@ -23,8 +23,8 @@ class BackgroundHelper { BackgroundHelper(const BackgroundHelper&) = delete; BackgroundHelper& operator=(const BackgroundHelper&) = delete; - BackgroundHelper(BackgroundHelper&& other) noexcept = delete; - BackgroundHelper& operator=(BackgroundHelper&& other) noexcept = delete; + BackgroundHelper(BackgroundHelper&&) noexcept = delete; + BackgroundHelper& operator=(BackgroundHelper&&) noexcept = delete; virtual ~BackgroundHelper(); diff --git a/browser/brave_ads/background_helper/background_helper_android.h b/browser/brave_ads/background_helper/background_helper_android.h index c14fdc4ae03c..88f98e7246e0 100644 --- a/browser/brave_ads/background_helper/background_helper_android.h +++ b/browser/brave_ads/background_helper/background_helper_android.h @@ -21,8 +21,8 @@ class BackgroundHelperAndroid BackgroundHelperAndroid(const BackgroundHelperAndroid&) = delete; BackgroundHelperAndroid& operator=(const BackgroundHelperAndroid&) = delete; - BackgroundHelperAndroid(BackgroundHelperAndroid&& other) noexcept = delete; - BackgroundHelperAndroid& operator=(BackgroundHelperAndroid&& other) noexcept = + BackgroundHelperAndroid(BackgroundHelperAndroid&&) noexcept = delete; + BackgroundHelperAndroid& operator=(BackgroundHelperAndroid&&) noexcept = delete; ~BackgroundHelperAndroid() override; diff --git a/browser/brave_ads/background_helper/background_helper_holder.h b/browser/brave_ads/background_helper/background_helper_holder.h index c42d265991e5..02898a3ad563 100644 --- a/browser/brave_ads/background_helper/background_helper_holder.h +++ b/browser/brave_ads/background_helper/background_helper_holder.h @@ -22,9 +22,8 @@ class BackgroundHelperHolder final { BackgroundHelperHolder(const BackgroundHelperHolder&) = delete; BackgroundHelperHolder& operator=(const BackgroundHelperHolder&) = delete; - BackgroundHelperHolder(BackgroundHelperHolder&& other) noexcept = delete; - BackgroundHelperHolder& operator=(BackgroundHelperHolder&& other) noexcept = - delete; + BackgroundHelperHolder(BackgroundHelperHolder&&) noexcept = delete; + BackgroundHelperHolder& operator=(BackgroundHelperHolder&&) noexcept = delete; static BackgroundHelperHolder* GetInstance(); diff --git a/browser/brave_ads/background_helper/background_helper_linux.h b/browser/brave_ads/background_helper/background_helper_linux.h index 7556100cee8f..df0cba657959 100644 --- a/browser/brave_ads/background_helper/background_helper_linux.h +++ b/browser/brave_ads/background_helper/background_helper_linux.h @@ -20,9 +20,8 @@ class BackgroundHelperLinux BackgroundHelperLinux(const BackgroundHelperLinux&) = delete; BackgroundHelperLinux& operator=(const BackgroundHelperLinux&) = delete; - BackgroundHelperLinux(BackgroundHelperLinux&& other) noexcept = delete; - BackgroundHelperLinux& operator=(BackgroundHelperLinux&& other) noexcept = - delete; + BackgroundHelperLinux(BackgroundHelperLinux&&) noexcept = delete; + BackgroundHelperLinux& operator=(BackgroundHelperLinux&&) noexcept = delete; ~BackgroundHelperLinux() override; diff --git a/browser/brave_ads/background_helper/background_helper_mac.h b/browser/brave_ads/background_helper/background_helper_mac.h index 0238015a2981..a5fa91b0ede8 100644 --- a/browser/brave_ads/background_helper/background_helper_mac.h +++ b/browser/brave_ads/background_helper/background_helper_mac.h @@ -17,8 +17,8 @@ class BackgroundHelperMac : public BackgroundHelper { BackgroundHelperMac(const BackgroundHelperMac&) = delete; BackgroundHelperMac& operator=(const BackgroundHelperMac&) = delete; - BackgroundHelperMac(BackgroundHelperMac&& other) noexcept = delete; - BackgroundHelperMac& operator=(BackgroundHelperMac&& other) noexcept = delete; + BackgroundHelperMac(BackgroundHelperMac&&) noexcept = delete; + BackgroundHelperMac& operator=(BackgroundHelperMac&&) noexcept = delete; ~BackgroundHelperMac() override; diff --git a/browser/brave_ads/background_helper/background_helper_win.h b/browser/brave_ads/background_helper/background_helper_win.h index c0ca5e5d76ff..c28921aa528b 100644 --- a/browser/brave_ads/background_helper/background_helper_win.h +++ b/browser/brave_ads/background_helper/background_helper_win.h @@ -19,8 +19,8 @@ class BackgroundHelperWin : public BackgroundHelper { BackgroundHelperWin(const BackgroundHelperWin&) = delete; BackgroundHelperWin& operator=(const BackgroundHelperWin&) = delete; - BackgroundHelperWin(BackgroundHelperWin&& other) noexcept = delete; - BackgroundHelperWin& operator=(BackgroundHelperWin&& other) noexcept = delete; + BackgroundHelperWin(BackgroundHelperWin&&) noexcept = delete; + BackgroundHelperWin& operator=(BackgroundHelperWin&&) noexcept = delete; ~BackgroundHelperWin() override; diff --git a/browser/brave_ads/notification_helper/notification_helper.h b/browser/brave_ads/notification_helper/notification_helper.h index 84a0d749af22..a6bacd0aa785 100644 --- a/browser/brave_ads/notification_helper/notification_helper.h +++ b/browser/brave_ads/notification_helper/notification_helper.h @@ -26,8 +26,8 @@ class NotificationHelper final { NotificationHelper(const NotificationHelper&) = delete; NotificationHelper& operator=(const NotificationHelper&) = delete; - NotificationHelper(NotificationHelper&& other) noexcept = delete; - NotificationHelper& operator=(NotificationHelper&& other) noexcept = delete; + NotificationHelper(NotificationHelper&&) noexcept = delete; + NotificationHelper& operator=(NotificationHelper&&) noexcept = delete; static NotificationHelper* GetInstance(); diff --git a/browser/brave_ads/notification_helper/notification_helper_impl.h b/browser/brave_ads/notification_helper/notification_helper_impl.h index 4ae433e4ac77..b4d3f5c6d4cc 100644 --- a/browser/brave_ads/notification_helper/notification_helper_impl.h +++ b/browser/brave_ads/notification_helper/notification_helper_impl.h @@ -13,9 +13,8 @@ class NotificationHelperImpl { NotificationHelperImpl(const NotificationHelperImpl&) = delete; NotificationHelperImpl& operator=(const NotificationHelperImpl&) = delete; - NotificationHelperImpl(NotificationHelperImpl&& other) noexcept = delete; - NotificationHelperImpl& operator=(NotificationHelperImpl&& other) noexcept = - delete; + NotificationHelperImpl(NotificationHelperImpl&&) noexcept = delete; + NotificationHelperImpl& operator=(NotificationHelperImpl&&) noexcept = delete; virtual ~NotificationHelperImpl(); diff --git a/browser/brave_ads/notification_helper/notification_helper_impl_android.h b/browser/brave_ads/notification_helper/notification_helper_impl_android.h index 8e231f4ce5eb..ddcde0a02f81 100644 --- a/browser/brave_ads/notification_helper/notification_helper_impl_android.h +++ b/browser/brave_ads/notification_helper/notification_helper_impl_android.h @@ -19,10 +19,10 @@ class NotificationHelperImplAndroid NotificationHelperImplAndroid& operator=( const NotificationHelperImplAndroid&) = delete; - NotificationHelperImplAndroid( - NotificationHelperImplAndroid&& other) noexcept = delete; + NotificationHelperImplAndroid(NotificationHelperImplAndroid&&) noexcept = + delete; NotificationHelperImplAndroid& operator=( - NotificationHelperImplAndroid&& other) noexcept = delete; + NotificationHelperImplAndroid&&) noexcept = delete; ~NotificationHelperImplAndroid() override; diff --git a/browser/brave_ads/notification_helper/notification_helper_impl_linux.h b/browser/brave_ads/notification_helper/notification_helper_impl_linux.h index 5c58dd86dcc8..027218870804 100644 --- a/browser/brave_ads/notification_helper/notification_helper_impl_linux.h +++ b/browser/brave_ads/notification_helper/notification_helper_impl_linux.h @@ -19,10 +19,9 @@ class NotificationHelperImplLinux NotificationHelperImplLinux& operator=(const NotificationHelperImplLinux&) = delete; - NotificationHelperImplLinux(NotificationHelperImplLinux&& other) noexcept = - delete; + NotificationHelperImplLinux(NotificationHelperImplLinux&&) noexcept = delete; NotificationHelperImplLinux& operator=( - NotificationHelperImplLinux&& other) noexcept = delete; + NotificationHelperImplLinux&&) noexcept = delete; ~NotificationHelperImplLinux() override; diff --git a/browser/brave_ads/notification_helper/notification_helper_impl_mac.h b/browser/brave_ads/notification_helper/notification_helper_impl_mac.h index 042fbb5cc6e7..16f658b05847 100644 --- a/browser/brave_ads/notification_helper/notification_helper_impl_mac.h +++ b/browser/brave_ads/notification_helper/notification_helper_impl_mac.h @@ -19,10 +19,9 @@ class NotificationHelperImplMac NotificationHelperImplMac& operator=(const NotificationHelperImplMac&) = delete; - NotificationHelperImplMac(NotificationHelperImplMac&& other) noexcept = + NotificationHelperImplMac(NotificationHelperImplMac&&) noexcept = delete; + NotificationHelperImplMac& operator=(NotificationHelperImplMac&&) noexcept = delete; - NotificationHelperImplMac& operator=( - NotificationHelperImplMac&& other) noexcept = delete; ~NotificationHelperImplMac() override; diff --git a/browser/brave_ads/notification_helper/notification_helper_impl_mock.h b/browser/brave_ads/notification_helper/notification_helper_impl_mock.h index 8d08215c249e..918a534e6cb1 100644 --- a/browser/brave_ads/notification_helper/notification_helper_impl_mock.h +++ b/browser/brave_ads/notification_helper/notification_helper_impl_mock.h @@ -19,10 +19,9 @@ class NotificationHelperImplMock : public NotificationHelperImpl { NotificationHelperImplMock& operator=(const NotificationHelperImplMock&) = delete; - NotificationHelperImplMock(NotificationHelperImplMock&& other) noexcept = + NotificationHelperImplMock(NotificationHelperImplMock&&) noexcept = delete; + NotificationHelperImplMock& operator=(NotificationHelperImplMock&&) noexcept = delete; - NotificationHelperImplMock& operator=( - NotificationHelperImplMock&& other) noexcept = delete; ~NotificationHelperImplMock() override; diff --git a/browser/brave_ads/notification_helper/notification_helper_impl_win.h b/browser/brave_ads/notification_helper/notification_helper_impl_win.h index e0b48319dd3b..f6eccf25f5da 100644 --- a/browser/brave_ads/notification_helper/notification_helper_impl_win.h +++ b/browser/brave_ads/notification_helper/notification_helper_impl_win.h @@ -22,10 +22,9 @@ class NotificationHelperImplWin NotificationHelperImplWin& operator=(const NotificationHelperImplWin&) = delete; - NotificationHelperImplWin(NotificationHelperImplWin&& other) noexcept = + NotificationHelperImplWin(NotificationHelperImplWin&&) noexcept = delete; + NotificationHelperImplWin& operator=(NotificationHelperImplWin&&) noexcept = delete; - NotificationHelperImplWin& operator=( - NotificationHelperImplWin&& other) noexcept = delete; ~NotificationHelperImplWin() override; diff --git a/browser/brave_ads/notifications/notification_ad_platform_bridge.h b/browser/brave_ads/notifications/notification_ad_platform_bridge.h index 5fcf466c88c1..6da793060b2c 100644 --- a/browser/brave_ads/notifications/notification_ad_platform_bridge.h +++ b/browser/brave_ads/notifications/notification_ad_platform_bridge.h @@ -22,10 +22,10 @@ class NotificationAdPlatformBridge { NotificationAdPlatformBridge& operator=(const NotificationAdPlatformBridge&) = delete; - NotificationAdPlatformBridge(NotificationAdPlatformBridge&& other) noexcept = + NotificationAdPlatformBridge(NotificationAdPlatformBridge&&) noexcept = delete; NotificationAdPlatformBridge& operator=( - NotificationAdPlatformBridge&& other) noexcept = delete; + NotificationAdPlatformBridge&&) noexcept = delete; ~NotificationAdPlatformBridge(); diff --git a/browser/brave_ads/tooltips/ads_captcha_tooltip.h b/browser/brave_ads/tooltips/ads_captcha_tooltip.h index 8ecf3e537d18..e792b11121ce 100644 --- a/browser/brave_ads/tooltips/ads_captcha_tooltip.h +++ b/browser/brave_ads/tooltips/ads_captcha_tooltip.h @@ -28,8 +28,8 @@ class AdsCaptchaTooltip : public brave_tooltips::BraveTooltip { AdsCaptchaTooltip(const AdsCaptchaTooltip&) = delete; AdsCaptchaTooltip& operator=(const AdsCaptchaTooltip&) = delete; - AdsCaptchaTooltip(AdsCaptchaTooltip&& other) noexcept = delete; - AdsCaptchaTooltip& operator=(AdsCaptchaTooltip&& other) noexcept = delete; + AdsCaptchaTooltip(AdsCaptchaTooltip&&) noexcept = delete; + AdsCaptchaTooltip& operator=(AdsCaptchaTooltip&&) noexcept = delete; ~AdsCaptchaTooltip() override; diff --git a/browser/brave_ads/tooltips/ads_tooltips_controller.h b/browser/brave_ads/tooltips/ads_tooltips_controller.h index 2a99f7e465d3..f76d7a692e61 100644 --- a/browser/brave_ads/tooltips/ads_tooltips_controller.h +++ b/browser/brave_ads/tooltips/ads_tooltips_controller.h @@ -25,9 +25,8 @@ class AdsTooltipsController : public AdsTooltipsDelegate, AdsTooltipsController(const AdsTooltipsController&) = delete; AdsTooltipsController& operator=(const AdsTooltipsController&) = delete; - AdsTooltipsController(AdsTooltipsController&& other) noexcept = delete; - AdsTooltipsController& operator=(AdsTooltipsController&& other) noexcept = - delete; + AdsTooltipsController(AdsTooltipsController&&) noexcept = delete; + AdsTooltipsController& operator=(AdsTooltipsController&&) noexcept = delete; ~AdsTooltipsController() override; diff --git a/browser/brave_ads/tooltips/ads_tooltips_delegate_impl.h b/browser/brave_ads/tooltips/ads_tooltips_delegate_impl.h index f434b7a6a7ae..a1887084db94 100644 --- a/browser/brave_ads/tooltips/ads_tooltips_delegate_impl.h +++ b/browser/brave_ads/tooltips/ads_tooltips_delegate_impl.h @@ -22,8 +22,8 @@ class AdsTooltipsDelegateImpl : public AdsTooltipsDelegate { AdsTooltipsDelegateImpl(const AdsTooltipsDelegateImpl&) = delete; AdsTooltipsDelegateImpl& operator=(const AdsTooltipsDelegateImpl&) = delete; - AdsTooltipsDelegateImpl(AdsTooltipsDelegateImpl&& other) noexcept = delete; - AdsTooltipsDelegateImpl& operator=(AdsTooltipsDelegateImpl&& other) noexcept = + AdsTooltipsDelegateImpl(AdsTooltipsDelegateImpl&&) noexcept = delete; + AdsTooltipsDelegateImpl& operator=(AdsTooltipsDelegateImpl&&) noexcept = delete; ~AdsTooltipsDelegateImpl() override = default; diff --git a/browser/ui/brave_ads/notification_ad.h b/browser/ui/brave_ads/notification_ad.h index 98fcccb39f23..1414307c553d 100644 --- a/browser/ui/brave_ads/notification_ad.h +++ b/browser/ui/brave_ads/notification_ad.h @@ -27,18 +27,18 @@ class NotificationAd { // Creates a copy of the |other| notification ad. The delegate, if any, will // be identical for both notification ad instances. The |id| of the ad // notification will be replaced by the given value - NotificationAd(const std::string& id, const NotificationAd& other); + NotificationAd(const std::string& id, const NotificationAd&); // Creates a copy of the |other| notification ad. The delegate will be // replaced by |delegate| NotificationAd(scoped_refptr delegate, - const NotificationAd& other); + const NotificationAd&); // Creates a copy of the |other| notification ad. The delegate, if any, will // be identical for both notification ad instances - NotificationAd(const NotificationAd& other); + NotificationAd(const NotificationAd&); - NotificationAd& operator=(const NotificationAd& other); + NotificationAd& operator=(const NotificationAd&); virtual ~NotificationAd(); diff --git a/browser/ui/brave_ads/notification_ad_popup_handler.h b/browser/ui/brave_ads/notification_ad_popup_handler.h index 34aaf5325c4a..28819e8b4724 100644 --- a/browser/ui/brave_ads/notification_ad_popup_handler.h +++ b/browser/ui/brave_ads/notification_ad_popup_handler.h @@ -28,10 +28,9 @@ class NotificationAdPopupHandler final { NotificationAdPopupHandler& operator=(const NotificationAdPopupHandler&) = delete; - NotificationAdPopupHandler(NotificationAdPopupHandler&& other) noexcept = + NotificationAdPopupHandler(NotificationAdPopupHandler&&) noexcept = delete; + NotificationAdPopupHandler& operator=(NotificationAdPopupHandler&&) noexcept = delete; - NotificationAdPopupHandler& operator=( - NotificationAdPopupHandler&& other) noexcept = delete; ~NotificationAdPopupHandler(); diff --git a/browser/ui/views/brave_ads/notification_ad_background_painter.h b/browser/ui/views/brave_ads/notification_ad_background_painter.h index e57b27110f57..3ea8e10b382d 100644 --- a/browser/ui/views/brave_ads/notification_ad_background_painter.h +++ b/browser/ui/views/brave_ads/notification_ad_background_painter.h @@ -24,10 +24,10 @@ class NotificationAdBackgroundPainter : public views::Painter { NotificationAdBackgroundPainter& operator=( const NotificationAdBackgroundPainter&) = delete; - NotificationAdBackgroundPainter( - NotificationAdBackgroundPainter&& other) noexcept = delete; + NotificationAdBackgroundPainter(NotificationAdBackgroundPainter&&) noexcept = + delete; NotificationAdBackgroundPainter& operator=( - NotificationAdBackgroundPainter&& other) noexcept = delete; + NotificationAdBackgroundPainter&&) noexcept = delete; ~NotificationAdBackgroundPainter() override; diff --git a/browser/ui/views/brave_ads/notification_ad_control_buttons_view.h b/browser/ui/views/brave_ads/notification_ad_control_buttons_view.h index 4a4f57826700..0e8128d1524e 100644 --- a/browser/ui/views/brave_ads/notification_ad_control_buttons_view.h +++ b/browser/ui/views/brave_ads/notification_ad_control_buttons_view.h @@ -32,9 +32,9 @@ class NotificationAdControlButtonsView : public views::View { const NotificationAdControlButtonsView&) = delete; NotificationAdControlButtonsView( - NotificationAdControlButtonsView&& other) noexcept = delete; + NotificationAdControlButtonsView&&) noexcept = delete; NotificationAdControlButtonsView& operator=( - NotificationAdControlButtonsView&& other) noexcept = delete; + NotificationAdControlButtonsView&&) noexcept = delete; ~NotificationAdControlButtonsView() override; diff --git a/browser/ui/views/brave_ads/notification_ad_header_view.h b/browser/ui/views/brave_ads/notification_ad_header_view.h index 363f8177ab08..193b2be63638 100644 --- a/browser/ui/views/brave_ads/notification_ad_header_view.h +++ b/browser/ui/views/brave_ads/notification_ad_header_view.h @@ -25,9 +25,9 @@ class NotificationAdHeaderView : public views::View { NotificationAdHeaderView(const NotificationAdHeaderView&) = delete; NotificationAdHeaderView& operator=(const NotificationAdHeaderView&) = delete; - NotificationAdHeaderView(NotificationAdHeaderView&& other) noexcept = delete; - NotificationAdHeaderView& operator=( - NotificationAdHeaderView&& other) noexcept = delete; + NotificationAdHeaderView(NotificationAdHeaderView&&) noexcept = delete; + NotificationAdHeaderView& operator=(NotificationAdHeaderView&&) noexcept = + delete; ~NotificationAdHeaderView() override; diff --git a/browser/ui/views/brave_ads/notification_ad_popup.h b/browser/ui/views/brave_ads/notification_ad_popup.h index 09820ccc25b7..bca7c1a72730 100644 --- a/browser/ui/views/brave_ads/notification_ad_popup.h +++ b/browser/ui/views/brave_ads/notification_ad_popup.h @@ -56,8 +56,8 @@ class NotificationAdPopup : public views::WidgetDelegateView, NotificationAdPopup(const NotificationAdPopup&) = delete; NotificationAdPopup& operator=(const NotificationAdPopup&) = delete; - NotificationAdPopup(NotificationAdPopup&& other) noexcept = delete; - NotificationAdPopup& operator=(NotificationAdPopup&& other) noexcept = delete; + NotificationAdPopup(NotificationAdPopup&&) noexcept = delete; + NotificationAdPopup& operator=(NotificationAdPopup&&) noexcept = delete; ~NotificationAdPopup() override; diff --git a/browser/ui/views/brave_ads/notification_ad_popup_collection.h b/browser/ui/views/brave_ads/notification_ad_popup_collection.h index 6a9e110a9fc7..92726d8f1534 100644 --- a/browser/ui/views/brave_ads/notification_ad_popup_collection.h +++ b/browser/ui/views/brave_ads/notification_ad_popup_collection.h @@ -20,10 +20,10 @@ class NotificationAdPopupCollection final { NotificationAdPopupCollection& operator=( const NotificationAdPopupCollection&) = delete; - NotificationAdPopupCollection( - NotificationAdPopupCollection&& other) noexcept = delete; + NotificationAdPopupCollection(NotificationAdPopupCollection&&) noexcept = + delete; NotificationAdPopupCollection& operator=( - NotificationAdPopupCollection&& other) noexcept = delete; + NotificationAdPopupCollection&&) noexcept = delete; ~NotificationAdPopupCollection(); diff --git a/browser/ui/views/brave_ads/notification_ad_view.h b/browser/ui/views/brave_ads/notification_ad_view.h index c141c7b4663e..9e4e6e0c49d0 100644 --- a/browser/ui/views/brave_ads/notification_ad_view.h +++ b/browser/ui/views/brave_ads/notification_ad_view.h @@ -26,8 +26,8 @@ class NotificationAdView : public views::View { NotificationAdView(const NotificationAdView&) = delete; NotificationAdView& operator=(const NotificationAdView&) = delete; - NotificationAdView(NotificationAdView&& other) noexcept = delete; - NotificationAdView& operator=(NotificationAdView&& other) noexcept = delete; + NotificationAdView(NotificationAdView&&) noexcept = delete; + NotificationAdView& operator=(NotificationAdView&&) noexcept = delete; ~NotificationAdView() override; diff --git a/browser/ui/views/brave_ads/padded_image_button.h b/browser/ui/views/brave_ads/padded_image_button.h index 76df5efeb270..ec8e8ef9598f 100644 --- a/browser/ui/views/brave_ads/padded_image_button.h +++ b/browser/ui/views/brave_ads/padded_image_button.h @@ -28,8 +28,8 @@ class PaddedImageButton : public views::ImageButton { PaddedImageButton(const PaddedImageButton&) = delete; PaddedImageButton& operator=(const PaddedImageButton&) = delete; - PaddedImageButton(PaddedImageButton&& other) noexcept = delete; - PaddedImageButton& operator=(PaddedImageButton&& other) noexcept = delete; + PaddedImageButton(PaddedImageButton&&) noexcept = delete; + PaddedImageButton& operator=(PaddedImageButton&&) noexcept = delete; ~PaddedImageButton() override = default; diff --git a/browser/ui/views/brave_ads/padded_image_view.h b/browser/ui/views/brave_ads/padded_image_view.h index 1ac2e98b85a1..ed420feab318 100644 --- a/browser/ui/views/brave_ads/padded_image_view.h +++ b/browser/ui/views/brave_ads/padded_image_view.h @@ -20,8 +20,8 @@ class PaddedImageView : public views::ImageView { PaddedImageView(const PaddedImageView&) = delete; PaddedImageView& operator=(const PaddedImageView&) = delete; - PaddedImageView(PaddedImageView&& other) noexcept = delete; - PaddedImageView& operator=(PaddedImageView&& other) noexcept = delete; + PaddedImageView(PaddedImageView&&) noexcept = delete; + PaddedImageView& operator=(PaddedImageView&&) noexcept = delete; ~PaddedImageView() override = default; }; diff --git a/browser/ui/views/brave_ads/text_notification_ad_view.h b/browser/ui/views/brave_ads/text_notification_ad_view.h index c3fd1837b466..97accdb24aae 100644 --- a/browser/ui/views/brave_ads/text_notification_ad_view.h +++ b/browser/ui/views/brave_ads/text_notification_ad_view.h @@ -26,9 +26,8 @@ class TextNotificationAdView : public NotificationAdView { TextNotificationAdView(const TextNotificationAdView&) = delete; TextNotificationAdView& operator=(const TextNotificationAdView&) = delete; - TextNotificationAdView(TextNotificationAdView&& other) noexcept = delete; - TextNotificationAdView& operator=(TextNotificationAdView&& other) noexcept = - delete; + TextNotificationAdView(TextNotificationAdView&&) noexcept = delete; + TextNotificationAdView& operator=(TextNotificationAdView&&) noexcept = delete; ~TextNotificationAdView() override; diff --git a/components/brave_ads/browser/ads_service.h b/components/brave_ads/browser/ads_service.h index feb147f5bf1b..d423b70ab0cc 100644 --- a/components/brave_ads/browser/ads_service.h +++ b/components/brave_ads/browser/ads_service.h @@ -34,8 +34,8 @@ class AdsService : public KeyedService { AdsService(const AdsService&) = delete; AdsService& operator=(const AdsService&) = delete; - AdsService(AdsService&& other) noexcept = delete; - AdsService& operator=(AdsService&& other) noexcept = delete; + AdsService(AdsService&&) noexcept = delete; + AdsService& operator=(AdsService&&) noexcept = delete; ~AdsService() override; diff --git a/components/brave_ads/browser/ads_service_impl.h b/components/brave_ads/browser/ads_service_impl.h index 62c41bbbdd44..4f270c67d012 100644 --- a/components/brave_ads/browser/ads_service_impl.h +++ b/components/brave_ads/browser/ads_service_impl.h @@ -83,8 +83,8 @@ class AdsServiceImpl : public AdsService, AdsServiceImpl(const AdsServiceImpl&) = delete; AdsServiceImpl& operator=(const AdsServiceImpl&) = delete; - AdsServiceImpl(AdsServiceImpl&& other) noexcept = delete; - AdsServiceImpl& operator=(AdsServiceImpl&& other) noexcept = delete; + AdsServiceImpl(AdsServiceImpl&&) noexcept = delete; + AdsServiceImpl& operator=(AdsServiceImpl&&) noexcept = delete; ~AdsServiceImpl() override; diff --git a/components/brave_ads/browser/component_updater/resource_component.h b/components/brave_ads/browser/component_updater/resource_component.h index 815098e4211d..851fc7aaad6a 100644 --- a/components/brave_ads/browser/component_updater/resource_component.h +++ b/components/brave_ads/browser/component_updater/resource_component.h @@ -26,8 +26,8 @@ class ResourceComponent : public brave_component_updater::BraveComponent { ResourceComponent(const ResourceComponent&) = delete; ResourceComponent& operator=(const ResourceComponent&) = delete; - ResourceComponent(ResourceComponent&& other) noexcept = delete; - ResourceComponent& operator=(ResourceComponent&& other) noexcept = delete; + ResourceComponent(ResourceComponent&&) noexcept = delete; + ResourceComponent& operator=(ResourceComponent&&) noexcept = delete; ~ResourceComponent() override; diff --git a/components/brave_ads/browser/device_id.h b/components/brave_ads/browser/device_id.h index 1e9cb4b5bf60..1965b5213827 100644 --- a/components/brave_ads/browser/device_id.h +++ b/components/brave_ads/browser/device_id.h @@ -21,8 +21,8 @@ class DeviceId { DeviceId(const DeviceId&) = delete; DeviceId& operator=(const DeviceId&) = delete; - DeviceId(DeviceId&& other) noexcept = delete; - DeviceId& operator=(DeviceId&& other) noexcept = delete; + DeviceId(DeviceId&&) noexcept = delete; + DeviceId& operator=(DeviceId&&) noexcept = delete; virtual ~DeviceId(); diff --git a/components/brave_ads/browser/frequency_capping_helper.h b/components/brave_ads/browser/frequency_capping_helper.h index 4a915cefd98b..357bf622a5e9 100644 --- a/components/brave_ads/browser/frequency_capping_helper.h +++ b/components/brave_ads/browser/frequency_capping_helper.h @@ -23,9 +23,8 @@ class FrequencyCappingHelper { FrequencyCappingHelper(const FrequencyCappingHelper&) = delete; FrequencyCappingHelper& operator=(const FrequencyCappingHelper&) = delete; - FrequencyCappingHelper(FrequencyCappingHelper&& other) noexcept = delete; - FrequencyCappingHelper& operator=(FrequencyCappingHelper&& other) noexcept = - delete; + FrequencyCappingHelper(FrequencyCappingHelper&&) noexcept = delete; + FrequencyCappingHelper& operator=(FrequencyCappingHelper&&) noexcept = delete; static FrequencyCappingHelper* GetInstance(); diff --git a/components/brave_ads/browser/mock_ads_service.h b/components/brave_ads/browser/mock_ads_service.h index 119aaa30cbdb..510d42d68908 100644 --- a/components/brave_ads/browser/mock_ads_service.h +++ b/components/brave_ads/browser/mock_ads_service.h @@ -21,8 +21,8 @@ class MockAdsService : public AdsService { MockAdsService(const MockAdsService&) = delete; MockAdsService& operator=(const MockAdsService&) = delete; - MockAdsService(MockAdsService&& other) noexcept = delete; - MockAdsService& operator=(MockAdsService&& other) noexcept = delete; + MockAdsService(MockAdsService&&) noexcept = delete; + MockAdsService& operator=(MockAdsService&&) noexcept = delete; ~MockAdsService() override; diff --git a/components/brave_ads/core/ad_content_info.h b/components/brave_ads/core/ad_content_info.h index a27a51440beb..588c1ad93ba2 100644 --- a/components/brave_ads/core/ad_content_info.h +++ b/components/brave_ads/core/ad_content_info.h @@ -19,11 +19,11 @@ namespace brave_ads { struct ADS_EXPORT AdContentInfo final { AdContentInfo(); - AdContentInfo(const AdContentInfo& other); - AdContentInfo& operator=(const AdContentInfo& other); + AdContentInfo(const AdContentInfo&); + AdContentInfo& operator=(const AdContentInfo&); - AdContentInfo(AdContentInfo&& other) noexcept; - AdContentInfo& operator=(AdContentInfo&& other) noexcept; + AdContentInfo(AdContentInfo&&) noexcept; + AdContentInfo& operator=(AdContentInfo&&) noexcept; ~AdContentInfo(); diff --git a/components/brave_ads/core/ad_event_history.h b/components/brave_ads/core/ad_event_history.h index 0e99a0c4c411..81703de29252 100644 --- a/components/brave_ads/core/ad_event_history.h +++ b/components/brave_ads/core/ad_event_history.h @@ -22,11 +22,11 @@ class ADS_EXPORT AdEventHistory final { public: AdEventHistory(); - AdEventHistory(const AdEventHistory& other) = delete; - AdEventHistory& operator=(const AdEventHistory& other) = delete; + AdEventHistory(const AdEventHistory&) = delete; + AdEventHistory& operator=(const AdEventHistory&) = delete; - AdEventHistory(AdEventHistory&& other) noexcept = delete; - AdEventHistory& operator=(AdEventHistory&& other) noexcept = delete; + AdEventHistory(AdEventHistory&&) noexcept = delete; + AdEventHistory& operator=(AdEventHistory&&) noexcept = delete; ~AdEventHistory(); diff --git a/components/brave_ads/core/ad_info.h b/components/brave_ads/core/ad_info.h index e16b6d2dba66..59003a87767f 100644 --- a/components/brave_ads/core/ad_info.h +++ b/components/brave_ads/core/ad_info.h @@ -17,16 +17,16 @@ namespace brave_ads { struct ADS_EXPORT AdInfo { AdInfo(); - AdInfo(const AdInfo& other); - AdInfo& operator=(const AdInfo& other); + AdInfo(const AdInfo&); + AdInfo& operator=(const AdInfo&); - AdInfo(AdInfo&& other) noexcept; - AdInfo& operator=(AdInfo&& other) noexcept; + AdInfo(AdInfo&&) noexcept; + AdInfo& operator=(AdInfo&&) noexcept; ~AdInfo(); - bool operator==(const AdInfo& other) const; - bool operator!=(const AdInfo& other) const; + bool operator==(const AdInfo&) const; + bool operator!=(const AdInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/ads.h b/components/brave_ads/core/ads.h index 83f78ab7385f..ff1609c35f11 100644 --- a/components/brave_ads/core/ads.h +++ b/components/brave_ads/core/ads.h @@ -33,11 +33,11 @@ class ADS_EXPORT Ads { public: Ads() = default; - Ads(const Ads& other) = delete; - Ads& operator=(const Ads& other) = delete; + Ads(const Ads&) = delete; + Ads& operator=(const Ads&) = delete; - Ads(Ads&& other) noexcept = delete; - Ads& operator=(Ads&& other) noexcept = delete; + Ads(Ads&&) noexcept = delete; + Ads& operator=(Ads&&) noexcept = delete; virtual ~Ads() = default; diff --git a/components/brave_ads/core/ads_client_notifier.h b/components/brave_ads/core/ads_client_notifier.h index 46656af69c23..57e1819e4355 100644 --- a/components/brave_ads/core/ads_client_notifier.h +++ b/components/brave_ads/core/ads_client_notifier.h @@ -21,11 +21,11 @@ class AdsClientNotifier { public: AdsClientNotifier(); - AdsClientNotifier(const AdsClientNotifier& other) = delete; - AdsClientNotifier& operator=(const AdsClientNotifier& other) = delete; + AdsClientNotifier(const AdsClientNotifier&) = delete; + AdsClientNotifier& operator=(const AdsClientNotifier&) = delete; - AdsClientNotifier(AdsClientNotifier&& other) noexcept = delete; - AdsClientNotifier& operator=(AdsClientNotifier&& other) noexcept = delete; + AdsClientNotifier(AdsClientNotifier&&) noexcept = delete; + AdsClientNotifier& operator=(AdsClientNotifier&&) noexcept = delete; virtual ~AdsClientNotifier(); diff --git a/components/brave_ads/core/ads_client_notifier_observer.h b/components/brave_ads/core/ads_client_notifier_observer.h index 672d91ca83a6..3bb697511d41 100644 --- a/components/brave_ads/core/ads_client_notifier_observer.h +++ b/components/brave_ads/core/ads_client_notifier_observer.h @@ -20,14 +20,13 @@ class AdsClientNotifierObserver : public base::CheckedObserver { public: AdsClientNotifierObserver(); - AdsClientNotifierObserver(const AdsClientNotifierObserver& other) = delete; - AdsClientNotifierObserver& operator=(const AdsClientNotifierObserver& other) = + AdsClientNotifierObserver(const AdsClientNotifierObserver&) = delete; + AdsClientNotifierObserver& operator=(const AdsClientNotifierObserver&) = delete; - AdsClientNotifierObserver(AdsClientNotifierObserver&& other) noexcept = + AdsClientNotifierObserver(AdsClientNotifierObserver&&) noexcept = delete; + AdsClientNotifierObserver& operator=(AdsClientNotifierObserver&&) noexcept = delete; - AdsClientNotifierObserver& operator=( - AdsClientNotifierObserver&& other) noexcept = delete; ~AdsClientNotifierObserver() override; diff --git a/components/brave_ads/core/database.h b/components/brave_ads/core/database.h index 56f295ca3c8e..2065f649d8dd 100644 --- a/components/brave_ads/core/database.h +++ b/components/brave_ads/core/database.h @@ -24,11 +24,11 @@ class ADS_EXPORT Database final { public: explicit Database(base::FilePath path); - Database(const Database& other) = delete; - Database& operator=(const Database& other) = delete; + Database(const Database&) = delete; + Database& operator=(const Database&) = delete; - Database(Database&& other) noexcept = delete; - Database& operator=(Database&& other) noexcept = delete; + Database(Database&&) noexcept = delete; + Database& operator=(Database&&) noexcept = delete; ~Database(); diff --git a/components/brave_ads/core/inline_content_ad_info.h b/components/brave_ads/core/inline_content_ad_info.h index 6511b9e9cb0d..806fc12eb100 100644 --- a/components/brave_ads/core/inline_content_ad_info.h +++ b/components/brave_ads/core/inline_content_ad_info.h @@ -17,16 +17,16 @@ namespace brave_ads { struct ADS_EXPORT InlineContentAdInfo final : AdInfo { InlineContentAdInfo(); - InlineContentAdInfo(const InlineContentAdInfo& other); - InlineContentAdInfo& operator=(const InlineContentAdInfo& other); + InlineContentAdInfo(const InlineContentAdInfo&); + InlineContentAdInfo& operator=(const InlineContentAdInfo&); - InlineContentAdInfo(InlineContentAdInfo&& other) noexcept; - InlineContentAdInfo& operator=(InlineContentAdInfo&& other) noexcept; + InlineContentAdInfo(InlineContentAdInfo&&) noexcept; + InlineContentAdInfo& operator=(InlineContentAdInfo&&) noexcept; ~InlineContentAdInfo(); - bool operator==(const InlineContentAdInfo& other) const; - bool operator!=(const InlineContentAdInfo& other) const; + bool operator==(const InlineContentAdInfo&) const; + bool operator!=(const InlineContentAdInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/internal/account/account.h b/components/brave_ads/core/internal/account/account.h index b4b680c4c588..579305b5ce75 100644 --- a/components/brave_ads/core/internal/account/account.h +++ b/components/brave_ads/core/internal/account/account.h @@ -46,11 +46,11 @@ class Account final : public AdsClientNotifierObserver, public: explicit Account(privacy::TokenGeneratorInterface* token_generator); - Account(const Account& other) = delete; - Account& operator=(const Account& other) = delete; + Account(const Account&) = delete; + Account& operator=(const Account&) = delete; - Account(Account&& other) noexcept = delete; - Account& operator=(Account&& other) noexcept = delete; + Account(Account&&) noexcept = delete; + Account& operator=(Account&&) noexcept = delete; ~Account() override; diff --git a/components/brave_ads/core/internal/account/confirmations/confirmation_info.h b/components/brave_ads/core/internal/account/confirmations/confirmation_info.h index 706ce5b4be1c..6bb368320d0e 100644 --- a/components/brave_ads/core/internal/account/confirmations/confirmation_info.h +++ b/components/brave_ads/core/internal/account/confirmations/confirmation_info.h @@ -20,11 +20,11 @@ namespace brave_ads { struct ConfirmationInfo final { ConfirmationInfo(); - ConfirmationInfo(const ConfirmationInfo& other); - ConfirmationInfo& operator=(const ConfirmationInfo& other); + ConfirmationInfo(const ConfirmationInfo&); + ConfirmationInfo& operator=(const ConfirmationInfo&); - ConfirmationInfo(ConfirmationInfo&& other) noexcept; - ConfirmationInfo& operator=(ConfirmationInfo&& other) noexcept; + ConfirmationInfo(ConfirmationInfo&&) noexcept; + ConfirmationInfo& operator=(ConfirmationInfo&&) noexcept; ~ConfirmationInfo(); diff --git a/components/brave_ads/core/internal/account/confirmations/confirmations.h b/components/brave_ads/core/internal/account/confirmations/confirmations.h index aa922ff95b2a..35554766de7d 100644 --- a/components/brave_ads/core/internal/account/confirmations/confirmations.h +++ b/components/brave_ads/core/internal/account/confirmations/confirmations.h @@ -26,11 +26,11 @@ class Confirmations final : public RedeemConfirmationDelegate { public: explicit Confirmations(privacy::TokenGeneratorInterface* token_generator); - Confirmations(const Confirmations& other) = delete; - Confirmations& operator=(const Confirmations& other) = delete; + Confirmations(const Confirmations&) = delete; + Confirmations& operator=(const Confirmations&) = delete; - Confirmations(Confirmations&& other) noexcept = delete; - Confirmations& operator=(Confirmations&& other) noexcept = delete; + Confirmations(Confirmations&&) noexcept = delete; + Confirmations& operator=(Confirmations&&) noexcept = delete; ~Confirmations() override; diff --git a/components/brave_ads/core/internal/account/confirmations/confirmations_delegate_mock.h b/components/brave_ads/core/internal/account/confirmations/confirmations_delegate_mock.h index eef302718c49..72e97ac39ddc 100644 --- a/components/brave_ads/core/internal/account/confirmations/confirmations_delegate_mock.h +++ b/components/brave_ads/core/internal/account/confirmations/confirmations_delegate_mock.h @@ -17,14 +17,13 @@ class ConfirmationsDelegateMock : public ConfirmationsDelegate { public: ConfirmationsDelegateMock(); - ConfirmationsDelegateMock(const ConfirmationsDelegateMock& other) = delete; + ConfirmationsDelegateMock(const ConfirmationsDelegateMock&) = delete; ConfirmationsDelegateMock& operator=(const ConfirmationsDelegateMock&) = delete; - ConfirmationsDelegateMock(ConfirmationsDelegateMock&& other) noexcept = + ConfirmationsDelegateMock(ConfirmationsDelegateMock&&) noexcept = delete; + ConfirmationsDelegateMock& operator=(ConfirmationsDelegateMock&&) noexcept = delete; - ConfirmationsDelegateMock& operator=( - ConfirmationsDelegateMock&& other) noexcept = delete; ~ConfirmationsDelegateMock() override; diff --git a/components/brave_ads/core/internal/account/confirmations/opted_in_info.h b/components/brave_ads/core/internal/account/confirmations/opted_in_info.h index 98175c244af5..476c379e4228 100644 --- a/components/brave_ads/core/internal/account/confirmations/opted_in_info.h +++ b/components/brave_ads/core/internal/account/confirmations/opted_in_info.h @@ -19,11 +19,11 @@ namespace brave_ads { struct OptedInInfo final { OptedInInfo(); - OptedInInfo(const OptedInInfo& other); - OptedInInfo& operator=(const OptedInInfo& other); + OptedInInfo(const OptedInInfo&); + OptedInInfo& operator=(const OptedInInfo&); - OptedInInfo(OptedInInfo&& other) noexcept; - OptedInInfo& operator=(OptedInInfo&& other) noexcept; + OptedInInfo(OptedInInfo&&) noexcept; + OptedInInfo& operator=(OptedInInfo&&) noexcept; ~OptedInInfo(); diff --git a/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h b/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h index 1960c7c9529d..cac083d769dc 100644 --- a/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h +++ b/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h @@ -13,11 +13,11 @@ namespace brave_ads { struct OptedInUserDataInfo final { OptedInUserDataInfo(); - OptedInUserDataInfo(const OptedInUserDataInfo& other); - OptedInUserDataInfo& operator=(const OptedInUserDataInfo& other); + OptedInUserDataInfo(const OptedInUserDataInfo&); + OptedInUserDataInfo& operator=(const OptedInUserDataInfo&); - OptedInUserDataInfo(OptedInUserDataInfo&& other) noexcept; - OptedInUserDataInfo& operator=(OptedInUserDataInfo&& other) noexcept; + OptedInUserDataInfo(OptedInUserDataInfo&&) noexcept; + OptedInUserDataInfo& operator=(OptedInUserDataInfo&&) noexcept; ~OptedInUserDataInfo(); diff --git a/components/brave_ads/core/internal/account/issuers/issuer_info.h b/components/brave_ads/core/internal/account/issuers/issuer_info.h index 8dd8067e9668..f14f19e16104 100644 --- a/components/brave_ads/core/internal/account/issuers/issuer_info.h +++ b/components/brave_ads/core/internal/account/issuers/issuer_info.h @@ -16,16 +16,16 @@ namespace brave_ads { struct IssuerInfo final { IssuerInfo(); - IssuerInfo(const IssuerInfo& other); - IssuerInfo& operator=(const IssuerInfo& other); + IssuerInfo(const IssuerInfo&); + IssuerInfo& operator=(const IssuerInfo&); - IssuerInfo(IssuerInfo&& other) noexcept; - IssuerInfo& operator=(IssuerInfo&& other) noexcept; + IssuerInfo(IssuerInfo&&) noexcept; + IssuerInfo& operator=(IssuerInfo&&) noexcept; ~IssuerInfo(); - bool operator==(const IssuerInfo& other) const; - bool operator!=(const IssuerInfo& other) const; + bool operator==(const IssuerInfo&) const; + bool operator!=(const IssuerInfo&) const; IssuerType type = IssuerType::kUndefined; PublicKeyMap public_keys; diff --git a/components/brave_ads/core/internal/account/issuers/issuers.h b/components/brave_ads/core/internal/account/issuers/issuers.h index 6f3508290af7..ea45e564a674 100644 --- a/components/brave_ads/core/internal/account/issuers/issuers.h +++ b/components/brave_ads/core/internal/account/issuers/issuers.h @@ -22,11 +22,11 @@ class Issuers { public: Issuers(); - Issuers(const Issuers& other) = delete; - Issuers& operator=(const Issuers& other) = delete; + Issuers(const Issuers&) = delete; + Issuers& operator=(const Issuers&) = delete; - Issuers(Issuers&& other) noexcept = delete; - Issuers& operator=(Issuers&& other) noexcept = delete; + Issuers(Issuers&&) noexcept = delete; + Issuers& operator=(Issuers&&) noexcept = delete; ~Issuers(); diff --git a/components/brave_ads/core/internal/account/issuers/issuers_delegate_mock.h b/components/brave_ads/core/internal/account/issuers/issuers_delegate_mock.h index 9be29012d8bd..534f8cde4476 100644 --- a/components/brave_ads/core/internal/account/issuers/issuers_delegate_mock.h +++ b/components/brave_ads/core/internal/account/issuers/issuers_delegate_mock.h @@ -17,11 +17,11 @@ class IssuersDelegateMock : public IssuersDelegate { public: IssuersDelegateMock(); - IssuersDelegateMock(const IssuersDelegateMock& other) = delete; - IssuersDelegateMock& operator=(const IssuersDelegateMock& other) = delete; + IssuersDelegateMock(const IssuersDelegateMock&) = delete; + IssuersDelegateMock& operator=(const IssuersDelegateMock&) = delete; - IssuersDelegateMock(IssuersDelegateMock&& other) noexcept = delete; - IssuersDelegateMock& operator=(IssuersDelegateMock&& other) noexcept = delete; + IssuersDelegateMock(IssuersDelegateMock&&) noexcept = delete; + IssuersDelegateMock& operator=(IssuersDelegateMock&&) noexcept = delete; ~IssuersDelegateMock() override; diff --git a/components/brave_ads/core/internal/account/issuers/issuers_info.h b/components/brave_ads/core/internal/account/issuers/issuers_info.h index d44d9bedcd07..4febe6bbf8f1 100644 --- a/components/brave_ads/core/internal/account/issuers/issuers_info.h +++ b/components/brave_ads/core/internal/account/issuers/issuers_info.h @@ -13,16 +13,16 @@ namespace brave_ads { struct IssuersInfo final { IssuersInfo(); - IssuersInfo(const IssuersInfo& other); - IssuersInfo& operator=(const IssuersInfo& other); + IssuersInfo(const IssuersInfo&); + IssuersInfo& operator=(const IssuersInfo&); - IssuersInfo(IssuersInfo&& other) noexcept; - IssuersInfo& operator=(IssuersInfo&& other) noexcept; + IssuersInfo(IssuersInfo&&) noexcept; + IssuersInfo& operator=(IssuersInfo&&) noexcept; ~IssuersInfo(); - bool operator==(const IssuersInfo& other) const; - bool operator!=(const IssuersInfo& other) const; + bool operator==(const IssuersInfo&) const; + bool operator!=(const IssuersInfo&) const; int ping = 0; IssuerList issuers; diff --git a/components/brave_ads/core/internal/account/transactions/transaction_info.h b/components/brave_ads/core/internal/account/transactions/transaction_info.h index 08cd17154322..95a84ba79d1e 100644 --- a/components/brave_ads/core/internal/account/transactions/transaction_info.h +++ b/components/brave_ads/core/internal/account/transactions/transaction_info.h @@ -18,16 +18,16 @@ namespace brave_ads { struct TransactionInfo final { TransactionInfo(); - TransactionInfo(const TransactionInfo& other); - TransactionInfo& operator=(const TransactionInfo& other); + TransactionInfo(const TransactionInfo&); + TransactionInfo& operator=(const TransactionInfo&); - TransactionInfo(TransactionInfo&& other) noexcept; - TransactionInfo& operator=(TransactionInfo&& other) noexcept; + TransactionInfo(TransactionInfo&&) noexcept; + TransactionInfo& operator=(TransactionInfo&&) noexcept; ~TransactionInfo(); - bool operator==(const TransactionInfo& other) const; - bool operator!=(const TransactionInfo& other) const; + bool operator==(const TransactionInfo&) const; + bool operator!=(const TransactionInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_confirmation_delegate_mock.h b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_confirmation_delegate_mock.h index 3417827e1e0b..7cb6f9005aae 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_confirmation_delegate_mock.h +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_confirmation_delegate_mock.h @@ -18,12 +18,12 @@ class RedeemConfirmationDelegateMock : public RedeemConfirmationDelegate { RedeemConfirmationDelegateMock(const RedeemConfirmationDelegateMock&) = delete; RedeemConfirmationDelegateMock& operator=( - const RedeemConfirmationDelegateMock& other) = delete; + const RedeemConfirmationDelegateMock&) = delete; - RedeemConfirmationDelegateMock( - RedeemConfirmationDelegateMock&& other) noexcept = delete; + RedeemConfirmationDelegateMock(RedeemConfirmationDelegateMock&&) noexcept = + delete; RedeemConfirmationDelegateMock& operator=( - RedeemConfirmationDelegateMock&& other) noexcept = delete; + RedeemConfirmationDelegateMock&&) noexcept = delete; ~RedeemConfirmationDelegateMock() override; diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation.h b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation.h index 9e4f97280655..bf5c9c30af13 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation.h +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_in_confirmation.h @@ -22,14 +22,13 @@ struct ConfirmationInfo; // |FailedToRedeemConfirmation|. class RedeemOptedInConfirmation final { public: - RedeemOptedInConfirmation(const RedeemOptedInConfirmation& other) = delete; - RedeemOptedInConfirmation& operator=(const RedeemOptedInConfirmation& other) = + RedeemOptedInConfirmation(const RedeemOptedInConfirmation&) = delete; + RedeemOptedInConfirmation& operator=(const RedeemOptedInConfirmation&) = delete; - RedeemOptedInConfirmation(RedeemOptedInConfirmation&& other) noexcept = + RedeemOptedInConfirmation(RedeemOptedInConfirmation&&) noexcept = delete; + RedeemOptedInConfirmation& operator=(RedeemOptedInConfirmation&&) noexcept = delete; - RedeemOptedInConfirmation& operator=( - RedeemOptedInConfirmation&& other) noexcept = delete; ~RedeemOptedInConfirmation(); diff --git a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_out_confirmation.h b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_out_confirmation.h index 2c5ecbcaf476..035faceac5f3 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_out_confirmation.h +++ b/components/brave_ads/core/internal/account/utility/redeem_confirmation/redeem_opted_out_confirmation.h @@ -18,14 +18,13 @@ struct ConfirmationInfo; // |FailedToRedeemConfirmation|. class RedeemOptedOutConfirmation final { public: - RedeemOptedOutConfirmation(const RedeemOptedOutConfirmation& other) = delete; - RedeemOptedOutConfirmation& operator=( - const RedeemOptedOutConfirmation& other) = delete; + RedeemOptedOutConfirmation(const RedeemOptedOutConfirmation&) = delete; + RedeemOptedOutConfirmation& operator=(const RedeemOptedOutConfirmation&) = + delete; - RedeemOptedOutConfirmation(RedeemOptedOutConfirmation&& other) noexcept = + RedeemOptedOutConfirmation(RedeemOptedOutConfirmation&&) noexcept = delete; + RedeemOptedOutConfirmation& operator=(RedeemOptedOutConfirmation&&) noexcept = delete; - RedeemOptedOutConfirmation& operator=( - RedeemOptedOutConfirmation&& other) noexcept = delete; ~RedeemOptedOutConfirmation(); diff --git a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.h b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.h index c620126cb133..d3f240830ad5 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.h +++ b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens.h @@ -23,15 +23,14 @@ class RedeemUnblindedPaymentTokens final { public: RedeemUnblindedPaymentTokens(); - RedeemUnblindedPaymentTokens(const RedeemUnblindedPaymentTokens& other) = - delete; + RedeemUnblindedPaymentTokens(const RedeemUnblindedPaymentTokens&) = delete; RedeemUnblindedPaymentTokens& operator=(const RedeemUnblindedPaymentTokens&) = delete; - RedeemUnblindedPaymentTokens(RedeemUnblindedPaymentTokens&& other) noexcept = + RedeemUnblindedPaymentTokens(RedeemUnblindedPaymentTokens&&) noexcept = delete; RedeemUnblindedPaymentTokens& operator=( - RedeemUnblindedPaymentTokens&& other) noexcept = delete; + RedeemUnblindedPaymentTokens&&) noexcept = delete; ~RedeemUnblindedPaymentTokens(); diff --git a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_delegate_mock.h b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_delegate_mock.h index 30a590c927ba..36e0485c1bca 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_delegate_mock.h +++ b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_delegate_mock.h @@ -21,14 +21,14 @@ class RedeemUnblindedPaymentTokensDelegateMock RedeemUnblindedPaymentTokensDelegateMock(); RedeemUnblindedPaymentTokensDelegateMock( - const RedeemUnblindedPaymentTokensDelegateMock& other) = delete; + const RedeemUnblindedPaymentTokensDelegateMock&) = delete; RedeemUnblindedPaymentTokensDelegateMock& operator=( - const RedeemUnblindedPaymentTokensDelegateMock& other) = delete; + const RedeemUnblindedPaymentTokensDelegateMock&) = delete; RedeemUnblindedPaymentTokensDelegateMock( - RedeemUnblindedPaymentTokensDelegateMock&& other) noexcept = delete; + RedeemUnblindedPaymentTokensDelegateMock&&) noexcept = delete; RedeemUnblindedPaymentTokensDelegateMock& operator=( - RedeemUnblindedPaymentTokensDelegateMock&& other) noexcept = delete; + RedeemUnblindedPaymentTokensDelegateMock&&) noexcept = delete; ~RedeemUnblindedPaymentTokensDelegateMock() override; diff --git a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_url_request_builder.h b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_url_request_builder.h index bd057053e9f6..49c457f6fa3c 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_url_request_builder.h +++ b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_url_request_builder.h @@ -27,14 +27,14 @@ class RedeemUnblindedPaymentTokensUrlRequestBuilder final base::Value::Dict user_data); RedeemUnblindedPaymentTokensUrlRequestBuilder( - const RedeemUnblindedPaymentTokensUrlRequestBuilder& other) = delete; + const RedeemUnblindedPaymentTokensUrlRequestBuilder&) = delete; RedeemUnblindedPaymentTokensUrlRequestBuilder& operator=( - const RedeemUnblindedPaymentTokensUrlRequestBuilder& other) = delete; + const RedeemUnblindedPaymentTokensUrlRequestBuilder&) = delete; RedeemUnblindedPaymentTokensUrlRequestBuilder( - RedeemUnblindedPaymentTokensUrlRequestBuilder&& other) noexcept = delete; + RedeemUnblindedPaymentTokensUrlRequestBuilder&&) noexcept = delete; RedeemUnblindedPaymentTokensUrlRequestBuilder& operator=( - RedeemUnblindedPaymentTokensUrlRequestBuilder&& other) noexcept = delete; + RedeemUnblindedPaymentTokensUrlRequestBuilder&&) noexcept = delete; ~RedeemUnblindedPaymentTokensUrlRequestBuilder() override; diff --git a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_user_data_builder.h b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_user_data_builder.h index 8b8e5875ddc7..9267f4bfb897 100644 --- a/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_user_data_builder.h +++ b/components/brave_ads/core/internal/account/utility/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_user_data_builder.h @@ -18,14 +18,14 @@ class RedeemUnblindedPaymentTokensUserDataBuilder final privacy::UnblindedPaymentTokenList unblinded_payment_tokens); RedeemUnblindedPaymentTokensUserDataBuilder( - const RedeemUnblindedPaymentTokensUserDataBuilder& other) = delete; + const RedeemUnblindedPaymentTokensUserDataBuilder&) = delete; RedeemUnblindedPaymentTokensUserDataBuilder& operator=( - const RedeemUnblindedPaymentTokensUserDataBuilder& other) = delete; + const RedeemUnblindedPaymentTokensUserDataBuilder&) = delete; RedeemUnblindedPaymentTokensUserDataBuilder( - RedeemUnblindedPaymentTokensUserDataBuilder&& other) noexcept = delete; + RedeemUnblindedPaymentTokensUserDataBuilder&&) noexcept = delete; RedeemUnblindedPaymentTokensUserDataBuilder& operator=( - RedeemUnblindedPaymentTokensUserDataBuilder&& other) noexcept = delete; + RedeemUnblindedPaymentTokensUserDataBuilder&&) noexcept = delete; ~RedeemUnblindedPaymentTokensUserDataBuilder() override; diff --git a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.h b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.h index ba780c5a49cc..4228c1651b3d 100644 --- a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.h +++ b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens.h @@ -30,12 +30,11 @@ class RefillUnblindedTokens final { explicit RefillUnblindedTokens( privacy::TokenGeneratorInterface* token_generator); - RefillUnblindedTokens(const RefillUnblindedTokens& other) = delete; - RefillUnblindedTokens& operator=(const RefillUnblindedTokens& other) = delete; + RefillUnblindedTokens(const RefillUnblindedTokens&) = delete; + RefillUnblindedTokens& operator=(const RefillUnblindedTokens&) = delete; - RefillUnblindedTokens(RefillUnblindedTokens&& other) noexcept = delete; - RefillUnblindedTokens& operator=(RefillUnblindedTokens&& other) noexcept = - delete; + RefillUnblindedTokens(RefillUnblindedTokens&&) noexcept = delete; + RefillUnblindedTokens& operator=(RefillUnblindedTokens&&) noexcept = delete; ~RefillUnblindedTokens(); diff --git a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_delegate_mock.h b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_delegate_mock.h index 8c1248920c9b..7da2117c14e4 100644 --- a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_delegate_mock.h +++ b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/refill_unblinded_tokens_delegate_mock.h @@ -20,12 +20,12 @@ class RefillUnblindedTokensDelegateMock : public RefillUnblindedTokensDelegate { RefillUnblindedTokensDelegateMock(const RefillUnblindedTokensDelegateMock&) = delete; RefillUnblindedTokensDelegateMock& operator=( - const RefillUnblindedTokensDelegateMock& other) = delete; + const RefillUnblindedTokensDelegateMock&) = delete; RefillUnblindedTokensDelegateMock( - RefillUnblindedTokensDelegateMock&& other) noexcept = delete; + RefillUnblindedTokensDelegateMock&&) noexcept = delete; RefillUnblindedTokensDelegateMock& operator=( - RefillUnblindedTokensDelegateMock&& other) noexcept = delete; + RefillUnblindedTokensDelegateMock&&) noexcept = delete; ~RefillUnblindedTokensDelegateMock() override; diff --git a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/request_signed_tokens_url_request_builder.h b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/request_signed_tokens_url_request_builder.h index 32ae2b024651..5e680f075e2e 100644 --- a/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/request_signed_tokens_url_request_builder.h +++ b/components/brave_ads/core/internal/account/utility/refill_unblinded_tokens/request_signed_tokens_url_request_builder.h @@ -26,14 +26,14 @@ class RequestSignedTokensUrlRequestBuilder final std::vector tokens); RequestSignedTokensUrlRequestBuilder( - const RequestSignedTokensUrlRequestBuilder& other) = delete; + const RequestSignedTokensUrlRequestBuilder&) = delete; RequestSignedTokensUrlRequestBuilder& operator=( - const RequestSignedTokensUrlRequestBuilder& other) = delete; + const RequestSignedTokensUrlRequestBuilder&) = delete; RequestSignedTokensUrlRequestBuilder( - RequestSignedTokensUrlRequestBuilder&& other) noexcept = delete; + RequestSignedTokensUrlRequestBuilder&&) noexcept = delete; RequestSignedTokensUrlRequestBuilder& operator=( - RequestSignedTokensUrlRequestBuilder&& other) noexcept = delete; + RequestSignedTokensUrlRequestBuilder&&) noexcept = delete; ~RequestSignedTokensUrlRequestBuilder() override; diff --git a/components/brave_ads/core/internal/account/wallet/wallet_info.h b/components/brave_ads/core/internal/account/wallet/wallet_info.h index 3fd7430be7ed..03e59d9dce1d 100644 --- a/components/brave_ads/core/internal/account/wallet/wallet_info.h +++ b/components/brave_ads/core/internal/account/wallet/wallet_info.h @@ -13,12 +13,12 @@ namespace brave_ads { struct WalletInfo final { bool IsValid() const; - bool WasCreated(const WalletInfo& other) const; - bool WasUpdated(const WalletInfo& other) const; - bool HasChanged(const WalletInfo& other) const; + bool WasCreated(const WalletInfo&) const; + bool WasUpdated(const WalletInfo&) const; + bool HasChanged(const WalletInfo&) const; - bool operator==(const WalletInfo& other) const; - bool operator!=(const WalletInfo& other) const; + bool operator==(const WalletInfo&) const; + bool operator!=(const WalletInfo&) const; std::string payment_id; std::string public_key; diff --git a/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h b/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h index 67a0c2e9250f..4a5a6f536a6a 100644 --- a/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h +++ b/components/brave_ads/core/internal/ads/ad_events/ad_event_info.h @@ -18,11 +18,11 @@ namespace brave_ads { struct AdEventInfo final { AdEventInfo(); - AdEventInfo(const AdEventInfo& other); - AdEventInfo& operator=(const AdEventInfo& other); + AdEventInfo(const AdEventInfo&); + AdEventInfo& operator=(const AdEventInfo&); - AdEventInfo(AdEventInfo&& other) noexcept; - AdEventInfo& operator=(AdEventInfo&& other) noexcept; + AdEventInfo(AdEventInfo&&) noexcept; + AdEventInfo& operator=(AdEventInfo&&) noexcept; ~AdEventInfo(); diff --git a/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler.h b/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler.h index 2dc25ce24519..663c3cb6b931 100644 --- a/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler.h +++ b/components/brave_ads/core/internal/ads/ad_events/inline_content_ads/inline_content_ad_event_handler.h @@ -24,11 +24,11 @@ class EventHandler final : public EventHandlerObserver { public: EventHandler(); - EventHandler(const EventHandler& other) = delete; - EventHandler& operator=(const EventHandler& other) = delete; + EventHandler(const EventHandler&) = delete; + EventHandler& operator=(const EventHandler&) = delete; - EventHandler(EventHandler&& other) noexcept = delete; - EventHandler& operator=(EventHandler&& other) noexcept = delete; + EventHandler(EventHandler&&) noexcept = delete; + EventHandler& operator=(EventHandler&&) noexcept = delete; ~EventHandler() override; diff --git a/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler.h b/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler.h index 51060ee99438..99018e0a07c5 100644 --- a/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler.h +++ b/components/brave_ads/core/internal/ads/ad_events/new_tab_page_ads/new_tab_page_ad_event_handler.h @@ -25,11 +25,11 @@ class EventHandler final : public EventHandlerObserver { public: EventHandler(); - EventHandler(const EventHandler& other) = delete; - EventHandler& operator=(const EventHandler& other) = delete; + EventHandler(const EventHandler&) = delete; + EventHandler& operator=(const EventHandler&) = delete; - EventHandler(EventHandler&& other) noexcept = delete; - EventHandler& operator=(EventHandler&& other) noexcept = delete; + EventHandler(EventHandler&&) noexcept = delete; + EventHandler& operator=(EventHandler&&) noexcept = delete; ~EventHandler() override; diff --git a/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler.h b/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler.h index 548d3cda88e7..01c34ddbbfec 100644 --- a/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler.h +++ b/components/brave_ads/core/internal/ads/ad_events/notification_ads/notification_ad_event_handler.h @@ -22,11 +22,11 @@ class EventHandler final : public EventHandlerObserver { public: EventHandler(); - EventHandler(const EventHandler& other) = delete; - EventHandler& operator=(const EventHandler& other) = delete; + EventHandler(const EventHandler&) = delete; + EventHandler& operator=(const EventHandler&) = delete; - EventHandler(EventHandler&& other) noexcept = delete; - EventHandler& operator=(EventHandler&& other) noexcept = delete; + EventHandler(EventHandler&&) noexcept = delete; + EventHandler& operator=(EventHandler&&) noexcept = delete; ~EventHandler() override; diff --git a/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler.h b/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler.h index 1c5ec597a7c2..8181c1252202 100644 --- a/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler.h +++ b/components/brave_ads/core/internal/ads/ad_events/promoted_content_ads/promoted_content_ad_event_handler.h @@ -25,11 +25,11 @@ class EventHandler final : public EventHandlerObserver { public: EventHandler(); - EventHandler(const EventHandler& other) = delete; - EventHandler& operator=(const EventHandler& other) = delete; + EventHandler(const EventHandler&) = delete; + EventHandler& operator=(const EventHandler&) = delete; - EventHandler(EventHandler&& other) noexcept = delete; - EventHandler& operator=(EventHandler&& other) noexcept = delete; + EventHandler(EventHandler&&) noexcept = delete; + EventHandler& operator=(EventHandler&&) noexcept = delete; ~EventHandler() override; diff --git a/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler.h b/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler.h index 493e3fc55cf2..7f052c50b3e4 100644 --- a/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler.h +++ b/components/brave_ads/core/internal/ads/ad_events/search_result_ads/search_result_ad_event_handler.h @@ -29,11 +29,11 @@ class EventHandler final : public EventHandlerObserver { public: EventHandler(); - EventHandler(const EventHandler& other) = delete; - EventHandler& operator=(const EventHandler& other) = delete; + EventHandler(const EventHandler&) = delete; + EventHandler& operator=(const EventHandler&) = delete; - EventHandler(EventHandler&& other) noexcept = delete; - EventHandler& operator=(EventHandler&& other) noexcept = delete; + EventHandler(EventHandler&&) noexcept = delete; + EventHandler& operator=(EventHandler&&) noexcept = delete; ~EventHandler() override; diff --git a/components/brave_ads/core/internal/ads/inline_content_ad_handler.h b/components/brave_ads/core/internal/ads/inline_content_ad_handler.h index a857d5e60d3a..9f638ae7af58 100644 --- a/components/brave_ads/core/internal/ads/inline_content_ad_handler.h +++ b/components/brave_ads/core/internal/ads/inline_content_ad_handler.h @@ -44,13 +44,11 @@ class InlineContentAdHandler final geographic::SubdivisionTargeting* subdivision_targeting, resource::AntiTargeting* anti_targeting_resource); - InlineContentAdHandler(const InlineContentAdHandler& other) = delete; - InlineContentAdHandler& operator=(const InlineContentAdHandler& other) = - delete; + InlineContentAdHandler(const InlineContentAdHandler&) = delete; + InlineContentAdHandler& operator=(const InlineContentAdHandler&) = delete; - InlineContentAdHandler(InlineContentAdHandler&& other) noexcept = delete; - InlineContentAdHandler& operator=(InlineContentAdHandler&& other) noexcept = - delete; + InlineContentAdHandler(InlineContentAdHandler&&) noexcept = delete; + InlineContentAdHandler& operator=(InlineContentAdHandler&&) noexcept = delete; ~InlineContentAdHandler() override; diff --git a/components/brave_ads/core/internal/ads/new_tab_page_ad_handler.h b/components/brave_ads/core/internal/ads/new_tab_page_ad_handler.h index 211776c63138..4b77f3a2ad1f 100644 --- a/components/brave_ads/core/internal/ads/new_tab_page_ad_handler.h +++ b/components/brave_ads/core/internal/ads/new_tab_page_ad_handler.h @@ -42,11 +42,11 @@ class NewTabPageAdHandler final : public new_tab_page_ads::EventHandlerObserver, geographic::SubdivisionTargeting* subdivision_targeting, resource::AntiTargeting* anti_targeting_resource); - NewTabPageAdHandler(const NewTabPageAdHandler& other) = delete; - NewTabPageAdHandler& operator=(const NewTabPageAdHandler& other) = delete; + NewTabPageAdHandler(const NewTabPageAdHandler&) = delete; + NewTabPageAdHandler& operator=(const NewTabPageAdHandler&) = delete; - NewTabPageAdHandler(NewTabPageAdHandler&& other) noexcept = delete; - NewTabPageAdHandler& operator=(NewTabPageAdHandler&& other) noexcept = delete; + NewTabPageAdHandler(NewTabPageAdHandler&&) noexcept = delete; + NewTabPageAdHandler& operator=(NewTabPageAdHandler&&) noexcept = delete; ~NewTabPageAdHandler() override; diff --git a/components/brave_ads/core/internal/ads/notification_ad_handler.h b/components/brave_ads/core/internal/ads/notification_ad_handler.h index 4fbec40d5736..64e6d65bcba9 100644 --- a/components/brave_ads/core/internal/ads/notification_ad_handler.h +++ b/components/brave_ads/core/internal/ads/notification_ad_handler.h @@ -60,12 +60,11 @@ class NotificationAdHandler final geographic::SubdivisionTargeting* subdivision_targeting, resource::AntiTargeting* anti_targeting_resource); - NotificationAdHandler(const NotificationAdHandler& other) = delete; - NotificationAdHandler& operator=(const NotificationAdHandler& other) = delete; + NotificationAdHandler(const NotificationAdHandler&) = delete; + NotificationAdHandler& operator=(const NotificationAdHandler&) = delete; - NotificationAdHandler(NotificationAdHandler&& other) noexcept = delete; - NotificationAdHandler& operator=(NotificationAdHandler&& other) noexcept = - delete; + NotificationAdHandler(NotificationAdHandler&&) noexcept = delete; + NotificationAdHandler& operator=(NotificationAdHandler&&) noexcept = delete; ~NotificationAdHandler() override; diff --git a/components/brave_ads/core/internal/ads/promoted_content_ad_handler.h b/components/brave_ads/core/internal/ads/promoted_content_ad_handler.h index 005dba7052a2..04093509c376 100644 --- a/components/brave_ads/core/internal/ads/promoted_content_ad_handler.h +++ b/components/brave_ads/core/internal/ads/promoted_content_ad_handler.h @@ -28,11 +28,11 @@ class PromotedContentAd final public: PromotedContentAd(Account* account, Transfer* transfer); - PromotedContentAd(const PromotedContentAd& other) = delete; - PromotedContentAd& operator=(const PromotedContentAd& other) = delete; + PromotedContentAd(const PromotedContentAd&) = delete; + PromotedContentAd& operator=(const PromotedContentAd&) = delete; - PromotedContentAd(PromotedContentAd&& other) noexcept = delete; - PromotedContentAd& operator=(PromotedContentAd&& other) noexcept = delete; + PromotedContentAd(PromotedContentAd&&) noexcept = delete; + PromotedContentAd& operator=(PromotedContentAd&&) noexcept = delete; ~PromotedContentAd() override; diff --git a/components/brave_ads/core/internal/ads/search_result_ad_handler.h b/components/brave_ads/core/internal/ads/search_result_ad_handler.h index 0a18ed2ffe2f..641bc59ff9a3 100644 --- a/components/brave_ads/core/internal/ads/search_result_ad_handler.h +++ b/components/brave_ads/core/internal/ads/search_result_ad_handler.h @@ -30,11 +30,11 @@ class SearchResultAd final : public search_result_ads::EventHandlerObserver { public: SearchResultAd(Account* account, Transfer* transfer); - SearchResultAd(const SearchResultAd& other) = delete; - SearchResultAd& operator=(const SearchResultAd& other) = delete; + SearchResultAd(const SearchResultAd&) = delete; + SearchResultAd& operator=(const SearchResultAd&) = delete; - SearchResultAd(SearchResultAd&& other) noexcept = delete; - SearchResultAd& operator=(SearchResultAd&& other) noexcept = delete; + SearchResultAd(SearchResultAd&&) noexcept = delete; + SearchResultAd& operator=(SearchResultAd&&) noexcept = delete; ~SearchResultAd() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule.h index a86f28bfa867..65d7ef66fd7c 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/anti_targeting_exclusion_rule.h @@ -26,14 +26,13 @@ class AntiTargetingExclusionRule final AntiTargetingExclusionRule(resource::AntiTargeting* anti_targeting_resource, BrowsingHistoryList browsing_history); - AntiTargetingExclusionRule(const AntiTargetingExclusionRule& other) = delete; + AntiTargetingExclusionRule(const AntiTargetingExclusionRule&) = delete; AntiTargetingExclusionRule& operator=(const AntiTargetingExclusionRule&) = delete; - AntiTargetingExclusionRule(AntiTargetingExclusionRule&& other) noexcept = + AntiTargetingExclusionRule(AntiTargetingExclusionRule&&) noexcept = delete; + AntiTargetingExclusionRule& operator=(AntiTargetingExclusionRule&&) noexcept = delete; - AntiTargetingExclusionRule& operator=( - AntiTargetingExclusionRule&& other) noexcept = delete; ~AntiTargetingExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule.h index dbc20de6a2d1..40e96b1fc668 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/conversion_exclusion_rule.h @@ -20,12 +20,11 @@ class ConversionExclusionRule final public: explicit ConversionExclusionRule(AdEventList ad_events); - ConversionExclusionRule(const ConversionExclusionRule& other) = delete; - ConversionExclusionRule& operator=(const ConversionExclusionRule& other) = - delete; + ConversionExclusionRule(const ConversionExclusionRule&) = delete; + ConversionExclusionRule& operator=(const ConversionExclusionRule&) = delete; - ConversionExclusionRule(ConversionExclusionRule&& other) noexcept = delete; - ConversionExclusionRule& operator=(ConversionExclusionRule&& other) noexcept = + ConversionExclusionRule(ConversionExclusionRule&&) noexcept = delete; + ConversionExclusionRule& operator=(ConversionExclusionRule&&) noexcept = delete; ~ConversionExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule.h index 129d95842b54..82ee9c3d3d52 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/creative_instance_exclusion_rule.h @@ -20,15 +20,14 @@ class CreativeInstanceExclusionRule final public: explicit CreativeInstanceExclusionRule(AdEventList ad_events); - CreativeInstanceExclusionRule(const CreativeInstanceExclusionRule& other) = - delete; + CreativeInstanceExclusionRule(const CreativeInstanceExclusionRule&) = delete; CreativeInstanceExclusionRule& operator=( - const CreativeInstanceExclusionRule& other) = delete; + const CreativeInstanceExclusionRule&) = delete; - CreativeInstanceExclusionRule( - CreativeInstanceExclusionRule&& other) noexcept = delete; + CreativeInstanceExclusionRule(CreativeInstanceExclusionRule&&) noexcept = + delete; CreativeInstanceExclusionRule& operator=( - CreativeInstanceExclusionRule&& other) noexcept = delete; + CreativeInstanceExclusionRule&&) noexcept = delete; ~CreativeInstanceExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daily_cap_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daily_cap_exclusion_rule.h index b7d29a37a826..e383ddd44bb7 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daily_cap_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/daily_cap_exclusion_rule.h @@ -20,12 +20,11 @@ class DailyCapExclusionRule final public: explicit DailyCapExclusionRule(AdEventList ad_events); - DailyCapExclusionRule(const DailyCapExclusionRule& other) = delete; - DailyCapExclusionRule& operator=(const DailyCapExclusionRule& other) = delete; + DailyCapExclusionRule(const DailyCapExclusionRule&) = delete; + DailyCapExclusionRule& operator=(const DailyCapExclusionRule&) = delete; - DailyCapExclusionRule(DailyCapExclusionRule&& other) noexcept = delete; - DailyCapExclusionRule& operator=(DailyCapExclusionRule&& other) noexcept = - delete; + DailyCapExclusionRule(DailyCapExclusionRule&&) noexcept = delete; + DailyCapExclusionRule& operator=(DailyCapExclusionRule&&) noexcept = delete; ~DailyCapExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rules_base.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rules_base.h index df17136d27f2..5089dcef3752 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rules_base.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/exclusion_rules_base.h @@ -43,11 +43,11 @@ struct CreativeAdInfo; class ExclusionRulesBase { public: - ExclusionRulesBase(const ExclusionRulesBase& other) = delete; - ExclusionRulesBase& operator=(const ExclusionRulesBase& other) = delete; + ExclusionRulesBase(const ExclusionRulesBase&) = delete; + ExclusionRulesBase& operator=(const ExclusionRulesBase&) = delete; - ExclusionRulesBase(ExclusionRulesBase&& other) noexcept = delete; - ExclusionRulesBase& operator=(ExclusionRulesBase&& other) noexcept = delete; + ExclusionRulesBase(ExclusionRulesBase&&) noexcept = delete; + ExclusionRulesBase& operator=(ExclusionRulesBase&&) noexcept = delete; virtual ~ExclusionRulesBase(); diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/inline_content_ads/inline_content_ad_exclusion_rules.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/inline_content_ads/inline_content_ad_exclusion_rules.h index 18101954de3b..c34ceb039f7a 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/inline_content_ads/inline_content_ad_exclusion_rules.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/inline_content_ads/inline_content_ad_exclusion_rules.h @@ -31,11 +31,11 @@ class ExclusionRules final : public ExclusionRulesBase { resource::AntiTargeting* anti_targeting_resource, const BrowsingHistoryList& browsing_history); - ExclusionRules(const ExclusionRules& other) = delete; - ExclusionRules& operator=(const ExclusionRules& other) = delete; + ExclusionRules(const ExclusionRules&) = delete; + ExclusionRules& operator=(const ExclusionRules&) = delete; - ExclusionRules(ExclusionRules&& other) noexcept = delete; - ExclusionRules& operator=(ExclusionRules&& other) noexcept = delete; + ExclusionRules(ExclusionRules&&) noexcept = delete; + ExclusionRules& operator=(ExclusionRules&&) noexcept = delete; ~ExclusionRules() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule.h index a01b188c7740..29d7a10f1084 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_dismissed_exclusion_rule.h @@ -22,13 +22,11 @@ class DismissedExclusionRule final public: explicit DismissedExclusionRule(AdEventList ad_events); - DismissedExclusionRule(const DismissedExclusionRule& other) = delete; - DismissedExclusionRule& operator=(const DismissedExclusionRule& other) = - delete; + DismissedExclusionRule(const DismissedExclusionRule&) = delete; + DismissedExclusionRule& operator=(const DismissedExclusionRule&) = delete; - DismissedExclusionRule(DismissedExclusionRule&& other) noexcept = delete; - DismissedExclusionRule& operator=(DismissedExclusionRule&& other) noexcept = - delete; + DismissedExclusionRule(DismissedExclusionRule&&) noexcept = delete; + DismissedExclusionRule& operator=(DismissedExclusionRule&&) noexcept = delete; ~DismissedExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_exclusion_rules.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_exclusion_rules.h index 19e5b14113b1..90b9282b09f0 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_exclusion_rules.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/notification_ads/notification_ad_exclusion_rules.h @@ -34,11 +34,11 @@ class ExclusionRules final : public ExclusionRulesBase { resource::AntiTargeting* anti_targeting_resource, const BrowsingHistoryList& browsing_history); - ExclusionRules(const ExclusionRules& other) = delete; - ExclusionRules& operator=(const ExclusionRules& other) = delete; + ExclusionRules(const ExclusionRules&) = delete; + ExclusionRules& operator=(const ExclusionRules&) = delete; - ExclusionRules(ExclusionRules&& other) noexcept = delete; - ExclusionRules& operator=(ExclusionRules&& other) noexcept = delete; + ExclusionRules(ExclusionRules&&) noexcept = delete; + ExclusionRules& operator=(ExclusionRules&&) noexcept = delete; ~ExclusionRules() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule.h index 41d0704fe3c0..5e44b55956f0 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_day_exclusion_rule.h @@ -20,11 +20,11 @@ class PerDayExclusionRule final public: explicit PerDayExclusionRule(AdEventList ad_events); - PerDayExclusionRule(const PerDayExclusionRule& other) = delete; - PerDayExclusionRule& operator=(const PerDayExclusionRule& other) = delete; + PerDayExclusionRule(const PerDayExclusionRule&) = delete; + PerDayExclusionRule& operator=(const PerDayExclusionRule&) = delete; - PerDayExclusionRule(PerDayExclusionRule&& other) noexcept = delete; - PerDayExclusionRule& operator=(PerDayExclusionRule&& other) noexcept = delete; + PerDayExclusionRule(PerDayExclusionRule&&) noexcept = delete; + PerDayExclusionRule& operator=(PerDayExclusionRule&&) noexcept = delete; ~PerDayExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule.h index 16db527667d7..505abe539f8b 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_month_exclusion_rule.h @@ -20,12 +20,11 @@ class PerMonthExclusionRule final public: explicit PerMonthExclusionRule(AdEventList ad_events); - PerMonthExclusionRule(const PerMonthExclusionRule& other) = delete; - PerMonthExclusionRule& operator=(const PerMonthExclusionRule& other) = delete; + PerMonthExclusionRule(const PerMonthExclusionRule&) = delete; + PerMonthExclusionRule& operator=(const PerMonthExclusionRule&) = delete; - PerMonthExclusionRule(PerMonthExclusionRule&& other) noexcept = delete; - PerMonthExclusionRule& operator=(PerMonthExclusionRule&& other) noexcept = - delete; + PerMonthExclusionRule(PerMonthExclusionRule&&) noexcept = delete; + PerMonthExclusionRule& operator=(PerMonthExclusionRule&&) noexcept = delete; ~PerMonthExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule.h index c64066c9e69f..443d85d9bc32 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/per_week_exclusion_rule.h @@ -20,12 +20,11 @@ class PerWeekExclusionRule final public: explicit PerWeekExclusionRule(AdEventList ad_events); - PerWeekExclusionRule(const PerWeekExclusionRule& other) = delete; - PerWeekExclusionRule& operator=(const PerWeekExclusionRule& other) = delete; + PerWeekExclusionRule(const PerWeekExclusionRule&) = delete; + PerWeekExclusionRule& operator=(const PerWeekExclusionRule&) = delete; - PerWeekExclusionRule(PerWeekExclusionRule&& other) noexcept = delete; - PerWeekExclusionRule& operator=(PerWeekExclusionRule&& other) noexcept = - delete; + PerWeekExclusionRule(PerWeekExclusionRule&&) noexcept = delete; + PerWeekExclusionRule& operator=(PerWeekExclusionRule&&) noexcept = delete; ~PerWeekExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule.h index c8b974823ca1..db949268957f 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/subdivision_targeting_exclusion_rule.h @@ -28,12 +28,12 @@ class SubdivisionTargetingExclusionRule final SubdivisionTargetingExclusionRule(const SubdivisionTargetingExclusionRule&) = delete; SubdivisionTargetingExclusionRule& operator=( - const SubdivisionTargetingExclusionRule& other) = delete; + const SubdivisionTargetingExclusionRule&) = delete; SubdivisionTargetingExclusionRule( - SubdivisionTargetingExclusionRule&& other) noexcept = delete; + SubdivisionTargetingExclusionRule&&) noexcept = delete; SubdivisionTargetingExclusionRule& operator=( - SubdivisionTargetingExclusionRule&& other) noexcept = delete; + SubdivisionTargetingExclusionRule&&) noexcept = delete; ~SubdivisionTargetingExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/total_max_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/total_max_exclusion_rule.h index 75a441953255..e480820cb70d 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/total_max_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/total_max_exclusion_rule.h @@ -20,12 +20,11 @@ class TotalMaxExclusionRule final public: explicit TotalMaxExclusionRule(AdEventList ad_events); - TotalMaxExclusionRule(const TotalMaxExclusionRule& other) = delete; - TotalMaxExclusionRule& operator=(const TotalMaxExclusionRule& other) = delete; + TotalMaxExclusionRule(const TotalMaxExclusionRule&) = delete; + TotalMaxExclusionRule& operator=(const TotalMaxExclusionRule&) = delete; - TotalMaxExclusionRule(TotalMaxExclusionRule&& other) noexcept = delete; - TotalMaxExclusionRule& operator=(TotalMaxExclusionRule&& other) noexcept = - delete; + TotalMaxExclusionRule(TotalMaxExclusionRule&&) noexcept = delete; + TotalMaxExclusionRule& operator=(TotalMaxExclusionRule&&) noexcept = delete; ~TotalMaxExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule.h index faa56bcf8e1b..9dcc00a51372 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/exclusion_rules/transferred_exclusion_rule.h @@ -20,13 +20,12 @@ class TransferredExclusionRule final public: explicit TransferredExclusionRule(AdEventList ad_events); - TransferredExclusionRule(const TransferredExclusionRule& other) = delete; - TransferredExclusionRule& operator=(const TransferredExclusionRule& other) = - delete; + TransferredExclusionRule(const TransferredExclusionRule&) = delete; + TransferredExclusionRule& operator=(const TransferredExclusionRule&) = delete; - TransferredExclusionRule(TransferredExclusionRule&& other) noexcept = delete; - TransferredExclusionRule& operator=( - TransferredExclusionRule&& other) noexcept = delete; + TransferredExclusionRule(TransferredExclusionRule&&) noexcept = delete; + TransferredExclusionRule& operator=(TransferredExclusionRule&&) noexcept = + delete; ~TransferredExclusionRule() override; diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_base.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_base.h index 3b4a2ec01c91..b310d3a38a4f 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_base.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/inline_content_ads/eligible_inline_content_ads_base.h @@ -31,11 +31,11 @@ namespace inline_content_ads { class EligibleAdsBase { public: - EligibleAdsBase(const EligibleAdsBase& other) = delete; - EligibleAdsBase& operator=(const EligibleAdsBase& other) = delete; + EligibleAdsBase(const EligibleAdsBase&) = delete; + EligibleAdsBase& operator=(const EligibleAdsBase&) = delete; - EligibleAdsBase(EligibleAdsBase&& other) noexcept = delete; - EligibleAdsBase& operator=(EligibleAdsBase&& other) noexcept = delete; + EligibleAdsBase(EligibleAdsBase&&) noexcept = delete; + EligibleAdsBase& operator=(EligibleAdsBase&&) noexcept = delete; virtual ~EligibleAdsBase(); diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_base.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_base.h index 1090830da097..74220c93288d 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_base.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/new_tab_page_ads/eligible_new_tab_page_ads_base.h @@ -29,11 +29,11 @@ namespace new_tab_page_ads { class EligibleAdsBase { public: - EligibleAdsBase(const EligibleAdsBase& other) = delete; - EligibleAdsBase& operator=(const EligibleAdsBase& other) = delete; + EligibleAdsBase(const EligibleAdsBase&) = delete; + EligibleAdsBase& operator=(const EligibleAdsBase&) = delete; - EligibleAdsBase(EligibleAdsBase&& other) noexcept = delete; - EligibleAdsBase& operator=(EligibleAdsBase&& other) noexcept = delete; + EligibleAdsBase(EligibleAdsBase&&) noexcept = delete; + EligibleAdsBase& operator=(EligibleAdsBase&&) noexcept = delete; virtual ~EligibleAdsBase(); diff --git a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_base.h b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_base.h index 5e1b58748442..720e53863be0 100644 --- a/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_base.h +++ b/components/brave_ads/core/internal/ads/serving/eligible_ads/pipelines/notification_ads/eligible_notification_ads_base.h @@ -29,11 +29,11 @@ namespace notification_ads { class EligibleAdsBase { public: - EligibleAdsBase(const EligibleAdsBase& other) = delete; - EligibleAdsBase& operator=(const EligibleAdsBase& other) = delete; + EligibleAdsBase(const EligibleAdsBase&) = delete; + EligibleAdsBase& operator=(const EligibleAdsBase&) = delete; - EligibleAdsBase(EligibleAdsBase&& other) noexcept = delete; - EligibleAdsBase& operator=(EligibleAdsBase&& other) noexcept = delete; + EligibleAdsBase(EligibleAdsBase&&) noexcept = delete; + EligibleAdsBase& operator=(EligibleAdsBase&&) noexcept = delete; virtual ~EligibleAdsBase(); diff --git a/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving.h b/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving.h index c16b42cf6aab..599e703ab1ae 100644 --- a/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving.h +++ b/components/brave_ads/core/internal/ads/serving/inline_content_ad_serving.h @@ -41,11 +41,11 @@ class Serving final { Serving(geographic::SubdivisionTargeting* subdivision_targeting, resource::AntiTargeting* anti_targeting_resource); - Serving(const Serving& other) = delete; - Serving& operator=(const Serving& other) = delete; + Serving(const Serving&) = delete; + Serving& operator=(const Serving&) = delete; - Serving(Serving&& other) noexcept = delete; - Serving& operator=(Serving&& other) noexcept = delete; + Serving(Serving&&) noexcept = delete; + Serving& operator=(Serving&&) noexcept = delete; ~Serving(); diff --git a/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving.h b/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving.h index 57caeae8606e..35bc848ec037 100644 --- a/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving.h +++ b/components/brave_ads/core/internal/ads/serving/new_tab_page_ad_serving.h @@ -40,11 +40,11 @@ class Serving final { Serving(geographic::SubdivisionTargeting* subdivision_targeting, resource::AntiTargeting* anti_targeting_resource); - Serving(const Serving& other) = delete; - Serving& operator=(const Serving& other) = delete; + Serving(const Serving&) = delete; + Serving& operator=(const Serving&) = delete; - Serving(Serving&& other) noexcept = delete; - Serving& operator=(Serving&& other) noexcept = delete; + Serving(Serving&&) noexcept = delete; + Serving& operator=(Serving&&) noexcept = delete; ~Serving(); diff --git a/components/brave_ads/core/internal/ads/serving/notification_ad_serving.h b/components/brave_ads/core/internal/ads/serving/notification_ad_serving.h index 87bc6afe8e92..ddc937ca7dd1 100644 --- a/components/brave_ads/core/internal/ads/serving/notification_ad_serving.h +++ b/components/brave_ads/core/internal/ads/serving/notification_ad_serving.h @@ -47,11 +47,11 @@ class Serving final : public AdsClientNotifierObserver { Serving(geographic::SubdivisionTargeting* subdivision_targeting, resource::AntiTargeting* anti_targeting_resource); - Serving(const Serving& other) = delete; - Serving& operator=(const Serving& other) = delete; + Serving(const Serving&) = delete; + Serving& operator=(const Serving&) = delete; - Serving(Serving&& other) noexcept = delete; - Serving& operator=(Serving&& other) noexcept = delete; + Serving(Serving&&) noexcept = delete; + Serving& operator=(Serving&&) noexcept = delete; ~Serving() override; diff --git a/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_base.h b/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_base.h index 549a184d3265..685351a90904 100644 --- a/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_base.h +++ b/components/brave_ads/core/internal/ads/serving/permission_rules/permission_rules_base.h @@ -10,11 +10,11 @@ namespace brave_ads { class PermissionRulesBase { public: - PermissionRulesBase(const PermissionRulesBase& other) = delete; - PermissionRulesBase& operator=(const PermissionRulesBase& other) = delete; + PermissionRulesBase(const PermissionRulesBase&) = delete; + PermissionRulesBase& operator=(const PermissionRulesBase&) = delete; - PermissionRulesBase(PermissionRulesBase&& other) noexcept = delete; - PermissionRulesBase& operator=(PermissionRulesBase&& other) noexcept = delete; + PermissionRulesBase(PermissionRulesBase&&) noexcept = delete; + PermissionRulesBase& operator=(PermissionRulesBase&&) noexcept = delete; virtual ~PermissionRulesBase(); diff --git a/components/brave_ads/core/internal/ads/serving/targeting/user_model_info.h b/components/brave_ads/core/internal/ads/serving/targeting/user_model_info.h index f886667d2dad..35857857d7a5 100644 --- a/components/brave_ads/core/internal/ads/serving/targeting/user_model_info.h +++ b/components/brave_ads/core/internal/ads/serving/targeting/user_model_info.h @@ -14,11 +14,11 @@ namespace brave_ads::targeting { struct UserModelInfo final { UserModelInfo(); - UserModelInfo(const UserModelInfo& other); - UserModelInfo& operator=(const UserModelInfo& other); + UserModelInfo(const UserModelInfo&); + UserModelInfo& operator=(const UserModelInfo&); - UserModelInfo(UserModelInfo&& other) noexcept; - UserModelInfo& operator=(UserModelInfo&& other) noexcept; + UserModelInfo(UserModelInfo&&) noexcept; + UserModelInfo& operator=(UserModelInfo&&) noexcept; ~UserModelInfo(); diff --git a/components/brave_ads/core/internal/ads_client_helper.h b/components/brave_ads/core/internal/ads_client_helper.h index 321f0b79f62f..e08b67f8d2ed 100644 --- a/components/brave_ads/core/internal/ads_client_helper.h +++ b/components/brave_ads/core/internal/ads_client_helper.h @@ -16,11 +16,11 @@ class AdsClientHelper final { public: explicit AdsClientHelper(AdsClient* ads_client); - AdsClientHelper(const AdsClientHelper& other) = delete; - AdsClientHelper& operator=(const AdsClientHelper& other) = delete; + AdsClientHelper(const AdsClientHelper&) = delete; + AdsClientHelper& operator=(const AdsClientHelper&) = delete; - AdsClientHelper(AdsClientHelper&& other) noexcept = delete; - AdsClientHelper& operator=(AdsClientHelper&& other) noexcept = delete; + AdsClientHelper(AdsClientHelper&&) noexcept = delete; + AdsClientHelper& operator=(AdsClientHelper&&) noexcept = delete; ~AdsClientHelper(); diff --git a/components/brave_ads/core/internal/ads_client_mock.h b/components/brave_ads/core/internal/ads_client_mock.h index 9e216a4e44ac..b584da74dfbd 100644 --- a/components/brave_ads/core/internal/ads_client_mock.h +++ b/components/brave_ads/core/internal/ads_client_mock.h @@ -20,11 +20,11 @@ class AdsClientMock : public AdsClient { public: AdsClientMock(); - AdsClientMock(const AdsClientMock& other) = delete; - AdsClientMock& operator=(const AdsClientMock& other) = delete; + AdsClientMock(const AdsClientMock&) = delete; + AdsClientMock& operator=(const AdsClientMock&) = delete; - AdsClientMock(AdsClientMock&& other) noexcept = delete; - AdsClientMock& operator=(AdsClientMock&& other) noexcept = delete; + AdsClientMock(AdsClientMock&&) noexcept = delete; + AdsClientMock& operator=(AdsClientMock&&) noexcept = delete; ~AdsClientMock() override; diff --git a/components/brave_ads/core/internal/ads_impl.h b/components/brave_ads/core/internal/ads_impl.h index 037edade4d29..f462d4055750 100644 --- a/components/brave_ads/core/internal/ads_impl.h +++ b/components/brave_ads/core/internal/ads_impl.h @@ -87,11 +87,11 @@ class AdsImpl final : public Ads, public: explicit AdsImpl(AdsClient* ads_client); - AdsImpl(const AdsImpl& other) = delete; - AdsImpl& operator=(const AdsImpl& other) = delete; + AdsImpl(const AdsImpl&) = delete; + AdsImpl& operator=(const AdsImpl&) = delete; - AdsImpl(AdsImpl&& other) noexcept = delete; - AdsImpl& operator=(AdsImpl&& other) noexcept = delete; + AdsImpl(AdsImpl&&) noexcept = delete; + AdsImpl& operator=(AdsImpl&&) noexcept = delete; ~AdsImpl() override; diff --git a/components/brave_ads/core/internal/browser/browser_manager.h b/components/brave_ads/core/internal/browser/browser_manager.h index dc8452b1f8f0..c018d60b275d 100644 --- a/components/brave_ads/core/internal/browser/browser_manager.h +++ b/components/brave_ads/core/internal/browser/browser_manager.h @@ -16,11 +16,11 @@ class BrowserManager final : public AdsClientNotifierObserver { public: BrowserManager(); - BrowserManager(const BrowserManager& other) = delete; - BrowserManager& operator=(const BrowserManager& other) = delete; + BrowserManager(const BrowserManager&) = delete; + BrowserManager& operator=(const BrowserManager&) = delete; - BrowserManager(BrowserManager&& other) noexcept = delete; - BrowserManager& operator=(BrowserManager&& other) noexcept = delete; + BrowserManager(BrowserManager&&) noexcept = delete; + BrowserManager& operator=(BrowserManager&&) noexcept = delete; ~BrowserManager() override; diff --git a/components/brave_ads/core/internal/catalog/campaign/catalog_campaign_info.h b/components/brave_ads/core/internal/catalog/campaign/catalog_campaign_info.h index 4403a4785204..e220f1f5769b 100644 --- a/components/brave_ads/core/internal/catalog/campaign/catalog_campaign_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/catalog_campaign_info.h @@ -18,16 +18,16 @@ namespace brave_ads { struct CatalogCampaignInfo final { CatalogCampaignInfo(); - CatalogCampaignInfo(const CatalogCampaignInfo& other); - CatalogCampaignInfo& operator=(const CatalogCampaignInfo& other); + CatalogCampaignInfo(const CatalogCampaignInfo&); + CatalogCampaignInfo& operator=(const CatalogCampaignInfo&); - CatalogCampaignInfo(CatalogCampaignInfo&& other) noexcept; - CatalogCampaignInfo& operator=(CatalogCampaignInfo&& other) noexcept; + CatalogCampaignInfo(CatalogCampaignInfo&&) noexcept; + CatalogCampaignInfo& operator=(CatalogCampaignInfo&&) noexcept; ~CatalogCampaignInfo(); - bool operator==(const CatalogCampaignInfo& other) const; - bool operator!=(const CatalogCampaignInfo& other) const; + bool operator==(const CatalogCampaignInfo&) const; + bool operator!=(const CatalogCampaignInfo&) const; std::string campaign_id; unsigned int priority = 0; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_creative_set_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_creative_set_info.h index 3c018bc87ea8..bcdac6669a43 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_creative_set_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_creative_set_info.h @@ -22,16 +22,16 @@ namespace brave_ads { struct CatalogCreativeSetInfo final { CatalogCreativeSetInfo(); - CatalogCreativeSetInfo(const CatalogCreativeSetInfo& other); - CatalogCreativeSetInfo& operator=(const CatalogCreativeSetInfo& other); + CatalogCreativeSetInfo(const CatalogCreativeSetInfo&); + CatalogCreativeSetInfo& operator=(const CatalogCreativeSetInfo&); - CatalogCreativeSetInfo(CatalogCreativeSetInfo&& other) noexcept; - CatalogCreativeSetInfo& operator=(CatalogCreativeSetInfo&& other) noexcept; + CatalogCreativeSetInfo(CatalogCreativeSetInfo&&) noexcept; + CatalogCreativeSetInfo& operator=(CatalogCreativeSetInfo&&) noexcept; ~CatalogCreativeSetInfo(); - bool operator==(const CatalogCreativeSetInfo& other) const; - bool operator!=(const CatalogCreativeSetInfo& other) const; + bool operator==(const CatalogCreativeSetInfo&) const; + bool operator!=(const CatalogCreativeSetInfo&) const; bool DoesSupportOS() const; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_creative_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_creative_info.h index 1c9af436235f..0727c71b8662 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_creative_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_creative_info.h @@ -13,8 +13,8 @@ namespace brave_ads { struct CatalogCreativeInfo { - bool operator==(const CatalogCreativeInfo& other) const; - bool operator!=(const CatalogCreativeInfo& other) const; + bool operator==(const CatalogCreativeInfo&) const; + bool operator!=(const CatalogCreativeInfo&) const; std::string creative_instance_id; CatalogTypeInfo type; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_type_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_type_info.h index 2a9dd345e9ba..722836d1a944 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_type_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/catalog_type_info.h @@ -14,16 +14,16 @@ namespace brave_ads { struct CatalogTypeInfo final { CatalogTypeInfo(); - CatalogTypeInfo(const CatalogTypeInfo& other); - CatalogTypeInfo& operator=(const CatalogTypeInfo& other); + CatalogTypeInfo(const CatalogTypeInfo&); + CatalogTypeInfo& operator=(const CatalogTypeInfo&); - CatalogTypeInfo(CatalogTypeInfo&& other) noexcept; - CatalogTypeInfo& operator=(CatalogTypeInfo&& other) noexcept; + CatalogTypeInfo(CatalogTypeInfo&&) noexcept; + CatalogTypeInfo& operator=(CatalogTypeInfo&&) noexcept; ~CatalogTypeInfo(); - bool operator==(const CatalogTypeInfo& other) const; - bool operator!=(const CatalogTypeInfo& other) const; + bool operator==(const CatalogTypeInfo&) const; + bool operator!=(const CatalogTypeInfo&) const; std::string code; std::string name; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_creative_inline_content_ad_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_creative_inline_content_ad_info.h index 1c65c6eb418d..9d29493e1636 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_creative_inline_content_ad_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_creative_inline_content_ad_info.h @@ -14,8 +14,8 @@ namespace brave_ads { struct CatalogCreativeInlineContentAdInfo final : CatalogCreativeInfo { - bool operator==(const CatalogCreativeInlineContentAdInfo& other) const; - bool operator!=(const CatalogCreativeInlineContentAdInfo& other) const; + bool operator==(const CatalogCreativeInlineContentAdInfo&) const; + bool operator!=(const CatalogCreativeInlineContentAdInfo&) const; CatalogInlineContentAdPayloadInfo payload; }; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_inline_content_ad_payload_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_inline_content_ad_payload_info.h index e001d0f47be4..bdc8ac13592c 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_inline_content_ad_payload_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/inline_content_ad/catalog_inline_content_ad_payload_info.h @@ -15,20 +15,19 @@ namespace brave_ads { struct CatalogInlineContentAdPayloadInfo final { CatalogInlineContentAdPayloadInfo(); - CatalogInlineContentAdPayloadInfo( - const CatalogInlineContentAdPayloadInfo& other); + CatalogInlineContentAdPayloadInfo(const CatalogInlineContentAdPayloadInfo&); CatalogInlineContentAdPayloadInfo& operator=( - const CatalogInlineContentAdPayloadInfo& other); + const CatalogInlineContentAdPayloadInfo&); CatalogInlineContentAdPayloadInfo( - CatalogInlineContentAdPayloadInfo&& other) noexcept; + CatalogInlineContentAdPayloadInfo&&) noexcept; CatalogInlineContentAdPayloadInfo& operator=( - CatalogInlineContentAdPayloadInfo&& other) noexcept; + CatalogInlineContentAdPayloadInfo&&) noexcept; ~CatalogInlineContentAdPayloadInfo(); - bool operator==(const CatalogInlineContentAdPayloadInfo& other) const; - bool operator!=(const CatalogInlineContentAdPayloadInfo& other) const; + bool operator==(const CatalogInlineContentAdPayloadInfo&) const; + bool operator!=(const CatalogInlineContentAdPayloadInfo&) const; std::string title; std::string description; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_creative_new_tab_page_ad_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_creative_new_tab_page_ad_info.h index cf34bf452cc4..60759febdd59 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_creative_new_tab_page_ad_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_creative_new_tab_page_ad_info.h @@ -14,8 +14,8 @@ namespace brave_ads { struct CatalogCreativeNewTabPageAdInfo final : CatalogCreativeInfo { - bool operator==(const CatalogCreativeNewTabPageAdInfo& other) const; - bool operator!=(const CatalogCreativeNewTabPageAdInfo& other) const; + bool operator==(const CatalogCreativeNewTabPageAdInfo&) const; + bool operator!=(const CatalogCreativeNewTabPageAdInfo&) const; CatalogNewTabPageAdPayloadInfo payload; }; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_payload_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_payload_info.h index a882274c3174..83e4ef1bd2a6 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_payload_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_payload_info.h @@ -16,19 +16,18 @@ namespace brave_ads { struct CatalogNewTabPageAdPayloadInfo final { CatalogNewTabPageAdPayloadInfo(); - CatalogNewTabPageAdPayloadInfo(const CatalogNewTabPageAdPayloadInfo& other); + CatalogNewTabPageAdPayloadInfo(const CatalogNewTabPageAdPayloadInfo&); CatalogNewTabPageAdPayloadInfo& operator=( - const CatalogNewTabPageAdPayloadInfo& other); + const CatalogNewTabPageAdPayloadInfo&); - CatalogNewTabPageAdPayloadInfo( - CatalogNewTabPageAdPayloadInfo&& other) noexcept; + CatalogNewTabPageAdPayloadInfo(CatalogNewTabPageAdPayloadInfo&&) noexcept; CatalogNewTabPageAdPayloadInfo& operator=( - CatalogNewTabPageAdPayloadInfo&& other) noexcept; + CatalogNewTabPageAdPayloadInfo&&) noexcept; ~CatalogNewTabPageAdPayloadInfo(); - bool operator==(const CatalogNewTabPageAdPayloadInfo& other) const; - bool operator!=(const CatalogNewTabPageAdPayloadInfo& other) const; + bool operator==(const CatalogNewTabPageAdPayloadInfo&) const; + bool operator!=(const CatalogNewTabPageAdPayloadInfo&) const; std::string company_name; GURL image_url; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_info.h index b273574f33e8..fa9fe1ca7538 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_info.h @@ -14,8 +14,8 @@ namespace brave_ads { struct CatalogNewTabPageAdWallpaperInfo final { - bool operator==(const CatalogNewTabPageAdWallpaperInfo& other) const; - bool operator!=(const CatalogNewTabPageAdWallpaperInfo& other) const; + bool operator==(const CatalogNewTabPageAdWallpaperInfo&) const; + bool operator!=(const CatalogNewTabPageAdWallpaperInfo&) const; GURL image_url; CatalogNewTabPageAdWallpaperFocalPointInfo focal_point; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_creative_notification_ad_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_creative_notification_ad_info.h index f2d1fcd69485..4cab59c8aaf8 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_creative_notification_ad_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_creative_notification_ad_info.h @@ -14,8 +14,8 @@ namespace brave_ads { struct CatalogCreativeNotificationAdInfo final : CatalogCreativeInfo { - bool operator==(const CatalogCreativeNotificationAdInfo& other) const; - bool operator!=(const CatalogCreativeNotificationAdInfo& other) const; + bool operator==(const CatalogCreativeNotificationAdInfo&) const; + bool operator!=(const CatalogCreativeNotificationAdInfo&) const; CatalogNotificationAdPayloadInfo payload; }; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_notification_ad_payload_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_notification_ad_payload_info.h index 3431a05b6f8b..61088bfacc59 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_notification_ad_payload_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/notification_ad/catalog_notification_ad_payload_info.h @@ -13,8 +13,8 @@ namespace brave_ads { struct CatalogNotificationAdPayloadInfo final { - bool operator==(const CatalogNotificationAdPayloadInfo& other) const; - bool operator!=(const CatalogNotificationAdPayloadInfo& other) const; + bool operator==(const CatalogNotificationAdPayloadInfo&) const; + bool operator!=(const CatalogNotificationAdPayloadInfo&) const; std::string body; std::string title; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_creative_promoted_content_ad_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_creative_promoted_content_ad_info.h index 198ea1e05d0d..121b746a1f6e 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_creative_promoted_content_ad_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_creative_promoted_content_ad_info.h @@ -14,8 +14,8 @@ namespace brave_ads { struct CatalogCreativePromotedContentAdInfo final : CatalogCreativeInfo { - bool operator==(const CatalogCreativePromotedContentAdInfo& other) const; - bool operator!=(const CatalogCreativePromotedContentAdInfo& other) const; + bool operator==(const CatalogCreativePromotedContentAdInfo&) const; + bool operator!=(const CatalogCreativePromotedContentAdInfo&) const; CatalogPromotedContentAdPayloadInfo payload; }; diff --git a/components/brave_ads/core/internal/catalog/catalog.h b/components/brave_ads/core/internal/catalog/catalog.h index 1327aceb6e33..988176377bd9 100644 --- a/components/brave_ads/core/internal/catalog/catalog.h +++ b/components/brave_ads/core/internal/catalog/catalog.h @@ -22,11 +22,11 @@ class Catalog final : public DatabaseManagerObserver { public: Catalog(); - Catalog(const Catalog& other) = delete; - Catalog& operator=(const Catalog& other) = delete; + Catalog(const Catalog&) = delete; + Catalog& operator=(const Catalog&) = delete; - Catalog(Catalog&& other) noexcept = delete; - Catalog& operator=(Catalog&& other) noexcept = delete; + Catalog(Catalog&&) noexcept = delete; + Catalog& operator=(Catalog&&) noexcept = delete; ~Catalog() override; diff --git a/components/brave_ads/core/internal/catalog/catalog_info.h b/components/brave_ads/core/internal/catalog/catalog_info.h index 94437587f507..9757c54b98e9 100644 --- a/components/brave_ads/core/internal/catalog/catalog_info.h +++ b/components/brave_ads/core/internal/catalog/catalog_info.h @@ -16,16 +16,16 @@ namespace brave_ads { struct CatalogInfo final { CatalogInfo(); - CatalogInfo(const CatalogInfo& other); - CatalogInfo& operator=(const CatalogInfo& other); + CatalogInfo(const CatalogInfo&); + CatalogInfo& operator=(const CatalogInfo&); - CatalogInfo(CatalogInfo&& other) noexcept; - CatalogInfo& operator=(CatalogInfo&& other) noexcept; + CatalogInfo(CatalogInfo&&) noexcept; + CatalogInfo& operator=(CatalogInfo&&) noexcept; ~CatalogInfo(); - bool operator==(const CatalogInfo& other) const; - bool operator!=(const CatalogInfo& other) const; + bool operator==(const CatalogInfo&) const; + bool operator!=(const CatalogInfo&) const; std::string id; int version = 0; diff --git a/components/brave_ads/core/internal/common/crypto/key_pair_info.h b/components/brave_ads/core/internal/common/crypto/key_pair_info.h index 33ee3b7738ac..75a1fe4222e6 100644 --- a/components/brave_ads/core/internal/common/crypto/key_pair_info.h +++ b/components/brave_ads/core/internal/common/crypto/key_pair_info.h @@ -14,16 +14,16 @@ namespace brave_ads::crypto { struct KeyPairInfo final { KeyPairInfo(); - KeyPairInfo(const KeyPairInfo& other); - KeyPairInfo& operator=(const KeyPairInfo& other); + KeyPairInfo(const KeyPairInfo&); + KeyPairInfo& operator=(const KeyPairInfo&); - KeyPairInfo(KeyPairInfo&& other) noexcept; - KeyPairInfo& operator=(KeyPairInfo&& other) noexcept; + KeyPairInfo(KeyPairInfo&&) noexcept; + KeyPairInfo& operator=(KeyPairInfo&&) noexcept; ~KeyPairInfo(); - bool operator==(const KeyPairInfo& other) const; - bool operator!=(const KeyPairInfo& other) const; + bool operator==(const KeyPairInfo&) const; + bool operator!=(const KeyPairInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/internal/common/platform/platform_helper_mac.h b/components/brave_ads/core/internal/common/platform/platform_helper_mac.h index 669c01cf2fe1..b4c67c34aa4d 100644 --- a/components/brave_ads/core/internal/common/platform/platform_helper_mac.h +++ b/components/brave_ads/core/internal/common/platform/platform_helper_mac.h @@ -16,11 +16,11 @@ namespace brave_ads { class PlatformHelperMac final : public PlatformHelper { public: - PlatformHelperMac(const PlatformHelperMac& other) = delete; - PlatformHelperMac& operator=(const PlatformHelperMac& other) = delete; + PlatformHelperMac(const PlatformHelperMac&) = delete; + PlatformHelperMac& operator=(const PlatformHelperMac&) = delete; - PlatformHelperMac(PlatformHelperMac&& other) noexcept = delete; - PlatformHelperMac& operator=(PlatformHelperMac&& other) noexcept = delete; + PlatformHelperMac(PlatformHelperMac&&) noexcept = delete; + PlatformHelperMac& operator=(PlatformHelperMac&&) noexcept = delete; protected: friend class base::NoDestructor; diff --git a/components/brave_ads/core/internal/common/platform/platform_helper_mock.h b/components/brave_ads/core/internal/common/platform/platform_helper_mock.h index b603c622e299..1d552a6fd654 100644 --- a/components/brave_ads/core/internal/common/platform/platform_helper_mock.h +++ b/components/brave_ads/core/internal/common/platform/platform_helper_mock.h @@ -18,11 +18,11 @@ class PlatformHelperMock : public PlatformHelper { public: PlatformHelperMock(); - PlatformHelperMock(const PlatformHelperMock& other) = delete; - PlatformHelperMock& operator=(const PlatformHelperMock& other) = delete; + PlatformHelperMock(const PlatformHelperMock&) = delete; + PlatformHelperMock& operator=(const PlatformHelperMock&) = delete; - PlatformHelperMock(PlatformHelperMock&& other) noexcept = delete; - PlatformHelperMock& operator=(PlatformHelperMock&& other) noexcept = delete; + PlatformHelperMock(PlatformHelperMock&&) noexcept = delete; + PlatformHelperMock& operator=(PlatformHelperMock&&) noexcept = delete; ~PlatformHelperMock() override; diff --git a/components/brave_ads/core/internal/common/timer/timer.h b/components/brave_ads/core/internal/common/timer/timer.h index 53912bb5fbaa..31299475a543 100644 --- a/components/brave_ads/core/internal/common/timer/timer.h +++ b/components/brave_ads/core/internal/common/timer/timer.h @@ -23,11 +23,11 @@ class Timer final { public: Timer(); - Timer(const Timer& other) = delete; - Timer& operator=(const Timer& other) = delete; + Timer(const Timer&) = delete; + Timer& operator=(const Timer&) = delete; - Timer(Timer&& other) noexcept = delete; - Timer& operator=(Timer&& other) noexcept = delete; + Timer(Timer&&) noexcept = delete; + Timer& operator=(Timer&&) noexcept = delete; ~Timer(); diff --git a/components/brave_ads/core/internal/common/unittest/unittest_base.h b/components/brave_ads/core/internal/common/unittest/unittest_base.h index 9bbed7f51dab..fd3d720c4779 100644 --- a/components/brave_ads/core/internal/common/unittest/unittest_base.h +++ b/components/brave_ads/core/internal/common/unittest/unittest_base.h @@ -48,11 +48,11 @@ class UnitTestBase : public AdsClientNotifier, public testing::Test { public: UnitTestBase(); - UnitTestBase(const UnitTestBase& other) = delete; - UnitTestBase& operator=(const UnitTestBase& other) = delete; + UnitTestBase(const UnitTestBase&) = delete; + UnitTestBase& operator=(const UnitTestBase&) = delete; - UnitTestBase(UnitTestBase&& other) noexcept = delete; - UnitTestBase& operator=(UnitTestBase&& other) noexcept = delete; + UnitTestBase(UnitTestBase&&) noexcept = delete; + UnitTestBase& operator=(UnitTestBase&&) noexcept = delete; ~UnitTestBase() override; diff --git a/components/brave_ads/core/internal/conversions/conversion_info.h b/components/brave_ads/core/internal/conversions/conversion_info.h index 75f2e1d37a57..b50d04de6118 100644 --- a/components/brave_ads/core/internal/conversions/conversion_info.h +++ b/components/brave_ads/core/internal/conversions/conversion_info.h @@ -16,18 +16,18 @@ namespace brave_ads { struct ConversionInfo final { ConversionInfo(); - ConversionInfo(const ConversionInfo& other); - ConversionInfo& operator=(const ConversionInfo& other); + ConversionInfo(const ConversionInfo&); + ConversionInfo& operator=(const ConversionInfo&); - ConversionInfo(ConversionInfo&& other) noexcept; - ConversionInfo& operator=(ConversionInfo&& other) noexcept; + ConversionInfo(ConversionInfo&&) noexcept; + ConversionInfo& operator=(ConversionInfo&&) noexcept; ~ConversionInfo(); bool IsValid() const; - bool operator==(const ConversionInfo& other) const; - bool operator!=(const ConversionInfo& other) const; + bool operator==(const ConversionInfo&) const; + bool operator!=(const ConversionInfo&) const; std::string creative_set_id; std::string type; diff --git a/components/brave_ads/core/internal/conversions/conversion_queue_item_info.h b/components/brave_ads/core/internal/conversions/conversion_queue_item_info.h index 9e6bd5e50b7c..2391254f99e5 100644 --- a/components/brave_ads/core/internal/conversions/conversion_queue_item_info.h +++ b/components/brave_ads/core/internal/conversions/conversion_queue_item_info.h @@ -17,16 +17,16 @@ namespace brave_ads { struct ConversionQueueItemInfo final { ConversionQueueItemInfo(); - ConversionQueueItemInfo(const ConversionQueueItemInfo& other); - ConversionQueueItemInfo& operator=(const ConversionQueueItemInfo& other); + ConversionQueueItemInfo(const ConversionQueueItemInfo&); + ConversionQueueItemInfo& operator=(const ConversionQueueItemInfo&); - ConversionQueueItemInfo(ConversionQueueItemInfo&& other) noexcept; - ConversionQueueItemInfo& operator=(ConversionQueueItemInfo&& other) noexcept; + ConversionQueueItemInfo(ConversionQueueItemInfo&&) noexcept; + ConversionQueueItemInfo& operator=(ConversionQueueItemInfo&&) noexcept; ~ConversionQueueItemInfo(); - bool operator==(const ConversionQueueItemInfo& other) const; - bool operator!=(const ConversionQueueItemInfo& other) const; + bool operator==(const ConversionQueueItemInfo&) const; + bool operator!=(const ConversionQueueItemInfo&) const; AdType ad_type = AdType::kUndefined; std::string creative_instance_id; diff --git a/components/brave_ads/core/internal/conversions/conversions.h b/components/brave_ads/core/internal/conversions/conversions.h index d312152490c8..e3023147bef6 100644 --- a/components/brave_ads/core/internal/conversions/conversions.h +++ b/components/brave_ads/core/internal/conversions/conversions.h @@ -38,11 +38,11 @@ class Conversions final : public AdsClientNotifierObserver, public: Conversions(); - Conversions(const Conversions& other) = delete; - Conversions& operator=(const Conversions& other) = delete; + Conversions(const Conversions&) = delete; + Conversions& operator=(const Conversions&) = delete; - Conversions(Conversions&& other) noexcept = delete; - Conversions& operator=(Conversions&& other) noexcept = delete; + Conversions(Conversions&&) noexcept = delete; + Conversions& operator=(Conversions&&) noexcept = delete; ~Conversions() override; diff --git a/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h b/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h index 55e0e8cd1dd9..f77245a12811 100644 --- a/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h +++ b/components/brave_ads/core/internal/conversions/verifiable_conversion_envelope_info.h @@ -13,20 +13,18 @@ namespace brave_ads::security { struct VerifiableConversionEnvelopeInfo final { VerifiableConversionEnvelopeInfo(); - VerifiableConversionEnvelopeInfo( - const VerifiableConversionEnvelopeInfo& other); + VerifiableConversionEnvelopeInfo(const VerifiableConversionEnvelopeInfo&); VerifiableConversionEnvelopeInfo& operator=( - const VerifiableConversionEnvelopeInfo& other); + const VerifiableConversionEnvelopeInfo&); - VerifiableConversionEnvelopeInfo( - VerifiableConversionEnvelopeInfo&& other) noexcept; + VerifiableConversionEnvelopeInfo(VerifiableConversionEnvelopeInfo&&) noexcept; VerifiableConversionEnvelopeInfo& operator=( - VerifiableConversionEnvelopeInfo&& other) noexcept; + VerifiableConversionEnvelopeInfo&&) noexcept; ~VerifiableConversionEnvelopeInfo(); - bool operator==(const VerifiableConversionEnvelopeInfo& other) const; - bool operator!=(const VerifiableConversionEnvelopeInfo& other) const; + bool operator==(const VerifiableConversionEnvelopeInfo&) const; + bool operator!=(const VerifiableConversionEnvelopeInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/internal/conversions/verifiable_conversion_info.h b/components/brave_ads/core/internal/conversions/verifiable_conversion_info.h index 8293632855ac..050420601983 100644 --- a/components/brave_ads/core/internal/conversions/verifiable_conversion_info.h +++ b/components/brave_ads/core/internal/conversions/verifiable_conversion_info.h @@ -11,8 +11,8 @@ namespace brave_ads { struct VerifiableConversionInfo final { - bool operator==(const VerifiableConversionInfo& other) const; - bool operator!=(const VerifiableConversionInfo& other) const; + bool operator==(const VerifiableConversionInfo&) const; + bool operator!=(const VerifiableConversionInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/internal/creatives/creative_ad_info.h b/components/brave_ads/core/internal/creatives/creative_ad_info.h index cd6a95e09c78..39030688cd0d 100644 --- a/components/brave_ads/core/internal/creatives/creative_ad_info.h +++ b/components/brave_ads/core/internal/creatives/creative_ad_info.h @@ -19,16 +19,16 @@ namespace brave_ads { struct CreativeAdInfo { CreativeAdInfo(); - CreativeAdInfo(const CreativeAdInfo& other); - CreativeAdInfo& operator=(const CreativeAdInfo& other); + CreativeAdInfo(const CreativeAdInfo&); + CreativeAdInfo& operator=(const CreativeAdInfo&); - CreativeAdInfo(CreativeAdInfo&& other) noexcept; - CreativeAdInfo& operator=(CreativeAdInfo&& other) noexcept; + CreativeAdInfo(CreativeAdInfo&&) noexcept; + CreativeAdInfo& operator=(CreativeAdInfo&&) noexcept; ~CreativeAdInfo(); - bool operator==(const CreativeAdInfo& other) const; - bool operator!=(const CreativeAdInfo& other) const; + bool operator==(const CreativeAdInfo&) const; + bool operator!=(const CreativeAdInfo&) const; std::string creative_instance_id; std::string creative_set_id; diff --git a/components/brave_ads/core/internal/creatives/creatives_info.h b/components/brave_ads/core/internal/creatives/creatives_info.h index f808f47b1221..882b2a1dc8b7 100644 --- a/components/brave_ads/core/internal/creatives/creatives_info.h +++ b/components/brave_ads/core/internal/creatives/creatives_info.h @@ -17,11 +17,11 @@ namespace brave_ads { struct CreativesInfo final { CreativesInfo(); - CreativesInfo(const CreativesInfo& other); - CreativesInfo& operator=(const CreativesInfo& other); + CreativesInfo(const CreativesInfo&); + CreativesInfo& operator=(const CreativesInfo&); - CreativesInfo(CreativesInfo&& other) noexcept; - CreativesInfo& operator=(CreativesInfo&& other) noexcept; + CreativesInfo(CreativesInfo&&) noexcept; + CreativesInfo& operator=(CreativesInfo&&) noexcept; ~CreativesInfo(); diff --git a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_info.h b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_info.h index 9442258c11d3..80d7470a2e7a 100644 --- a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_info.h +++ b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ad_info.h @@ -18,18 +18,17 @@ struct CreativeInlineContentAdInfo final : CreativeAdInfo { CreativeInlineContentAdInfo(); explicit CreativeInlineContentAdInfo(const CreativeAdInfo& creative_ad); - CreativeInlineContentAdInfo(const CreativeInlineContentAdInfo& other); - CreativeInlineContentAdInfo& operator=( - const CreativeInlineContentAdInfo& other); + CreativeInlineContentAdInfo(const CreativeInlineContentAdInfo&); + CreativeInlineContentAdInfo& operator=(const CreativeInlineContentAdInfo&); - CreativeInlineContentAdInfo(CreativeInlineContentAdInfo&& other) noexcept; + CreativeInlineContentAdInfo(CreativeInlineContentAdInfo&&) noexcept; CreativeInlineContentAdInfo& operator=( - CreativeInlineContentAdInfo&& other) noexcept; + CreativeInlineContentAdInfo&&) noexcept; ~CreativeInlineContentAdInfo(); - bool operator==(const CreativeInlineContentAdInfo& other) const; - bool operator!=(const CreativeInlineContentAdInfo& other) const; + bool operator==(const CreativeInlineContentAdInfo&) const; + bool operator!=(const CreativeInlineContentAdInfo&) const; std::string title; std::string description; diff --git a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table.h b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table.h index 86b099be74cf..a83f86c411b1 100644 --- a/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table.h +++ b/components/brave_ads/core/internal/creatives/inline_content_ads/creative_inline_content_ads_database_table.h @@ -44,13 +44,12 @@ class CreativeInlineContentAds final : public TableInterface { public: CreativeInlineContentAds(); - CreativeInlineContentAds(const CreativeInlineContentAds& other) = delete; - CreativeInlineContentAds& operator=(const CreativeInlineContentAds& other) = - delete; + CreativeInlineContentAds(const CreativeInlineContentAds&) = delete; + CreativeInlineContentAds& operator=(const CreativeInlineContentAds&) = delete; - CreativeInlineContentAds(CreativeInlineContentAds&& other) noexcept = delete; - CreativeInlineContentAds& operator=( - CreativeInlineContentAds&& other) noexcept = delete; + CreativeInlineContentAds(CreativeInlineContentAds&&) noexcept = delete; + CreativeInlineContentAds& operator=(CreativeInlineContentAds&&) noexcept = + delete; ~CreativeInlineContentAds() override; diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_info.h b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_info.h index 719a5c605db5..114535510399 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_info.h +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_info.h @@ -19,17 +19,16 @@ struct CreativeNewTabPageAdInfo final : CreativeAdInfo { CreativeNewTabPageAdInfo(); explicit CreativeNewTabPageAdInfo(const CreativeAdInfo& creative_ad); - CreativeNewTabPageAdInfo(const CreativeNewTabPageAdInfo& other); - CreativeNewTabPageAdInfo& operator=(const CreativeNewTabPageAdInfo& other); + CreativeNewTabPageAdInfo(const CreativeNewTabPageAdInfo&); + CreativeNewTabPageAdInfo& operator=(const CreativeNewTabPageAdInfo&); - CreativeNewTabPageAdInfo(CreativeNewTabPageAdInfo&& other) noexcept; - CreativeNewTabPageAdInfo& operator=( - CreativeNewTabPageAdInfo&& other) noexcept; + CreativeNewTabPageAdInfo(CreativeNewTabPageAdInfo&&) noexcept; + CreativeNewTabPageAdInfo& operator=(CreativeNewTabPageAdInfo&&) noexcept; ~CreativeNewTabPageAdInfo(); - bool operator==(const CreativeNewTabPageAdInfo& other) const; - bool operator!=(const CreativeNewTabPageAdInfo& other) const; + bool operator==(const CreativeNewTabPageAdInfo&) const; + bool operator!=(const CreativeNewTabPageAdInfo&) const; std::string company_name; GURL image_url; diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_info.h b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_info.h index a94cb506b87e..d7a4b868ab1c 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_info.h +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_info.h @@ -14,8 +14,8 @@ namespace brave_ads { struct CreativeNewTabPageAdWallpaperInfo final { - bool operator==(const CreativeNewTabPageAdWallpaperInfo& other) const; - bool operator!=(const CreativeNewTabPageAdWallpaperInfo& other) const; + bool operator==(const CreativeNewTabPageAdWallpaperInfo&) const; + bool operator!=(const CreativeNewTabPageAdWallpaperInfo&) const; GURL image_url; CreativeNewTabPageAdWallpaperFocalPointInfo focal_point; diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table.h b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table.h index eec2936281d4..c3a9e7cd5e14 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table.h +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ads_database_table.h @@ -42,12 +42,11 @@ class CreativeNewTabPageAds final : public TableInterface { public: CreativeNewTabPageAds(); - CreativeNewTabPageAds(const CreativeNewTabPageAds& other) = delete; - CreativeNewTabPageAds& operator=(const CreativeNewTabPageAds& other) = delete; + CreativeNewTabPageAds(const CreativeNewTabPageAds&) = delete; + CreativeNewTabPageAds& operator=(const CreativeNewTabPageAds&) = delete; - CreativeNewTabPageAds(CreativeNewTabPageAds&& other) noexcept = delete; - CreativeNewTabPageAds& operator=(CreativeNewTabPageAds&& other) noexcept = - delete; + CreativeNewTabPageAds(CreativeNewTabPageAds&&) noexcept = delete; + CreativeNewTabPageAds& operator=(CreativeNewTabPageAds&&) noexcept = delete; ~CreativeNewTabPageAds() override; diff --git a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h index 893412f6fbe5..275d3d290532 100644 --- a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h +++ b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ad_info.h @@ -17,8 +17,8 @@ struct CreativeNotificationAdInfo final : CreativeAdInfo { CreativeNotificationAdInfo(); explicit CreativeNotificationAdInfo(const CreativeAdInfo& creative_ad); - bool operator==(const CreativeNotificationAdInfo& other) const; - bool operator!=(const CreativeNotificationAdInfo& other) const; + bool operator==(const CreativeNotificationAdInfo&) const; + bool operator!=(const CreativeNotificationAdInfo&) const; std::string title; std::string body; diff --git a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table.h b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table.h index 840831e1887d..665a22e57725 100644 --- a/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table.h +++ b/components/brave_ads/core/internal/creatives/notification_ads/creative_notification_ads_database_table.h @@ -36,12 +36,11 @@ class CreativeNotificationAds final : public TableInterface { public: CreativeNotificationAds(); - CreativeNotificationAds(const CreativeNotificationAds& other) = delete; - CreativeNotificationAds& operator=(const CreativeNotificationAds& other) = - delete; + CreativeNotificationAds(const CreativeNotificationAds&) = delete; + CreativeNotificationAds& operator=(const CreativeNotificationAds&) = delete; - CreativeNotificationAds(CreativeNotificationAds&& other) noexcept = delete; - CreativeNotificationAds& operator=(CreativeNotificationAds&& other) noexcept = + CreativeNotificationAds(CreativeNotificationAds&&) noexcept = delete; + CreativeNotificationAds& operator=(CreativeNotificationAds&&) noexcept = delete; ~CreativeNotificationAds() override; diff --git a/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_manager.h b/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_manager.h index 0b1bd15522b1..90249098c5b0 100644 --- a/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_manager.h +++ b/components/brave_ads/core/internal/creatives/notification_ads/notification_ad_manager.h @@ -18,12 +18,11 @@ class NotificationAdManager final { public: NotificationAdManager(); - NotificationAdManager(const NotificationAdManager& other) = delete; - NotificationAdManager& operator=(const NotificationAdManager& other) = delete; + NotificationAdManager(const NotificationAdManager&) = delete; + NotificationAdManager& operator=(const NotificationAdManager&) = delete; - NotificationAdManager(NotificationAdManager&& other) noexcept = delete; - NotificationAdManager& operator=(NotificationAdManager&& other) noexcept = - delete; + NotificationAdManager(NotificationAdManager&&) noexcept = delete; + NotificationAdManager& operator=(NotificationAdManager&&) noexcept = delete; ~NotificationAdManager(); diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_info.h b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_info.h index f0f6835ba008..a4eae33e6e45 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_info.h +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ad_info.h @@ -17,8 +17,8 @@ struct CreativePromotedContentAdInfo final : CreativeAdInfo { CreativePromotedContentAdInfo(); explicit CreativePromotedContentAdInfo(const CreativeAdInfo& creative_ad); - bool operator==(const CreativePromotedContentAdInfo& other) const; - bool operator!=(const CreativePromotedContentAdInfo& other) const; + bool operator==(const CreativePromotedContentAdInfo&) const; + bool operator!=(const CreativePromotedContentAdInfo&) const; std::string title; std::string description; diff --git a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.h b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.h index a040889f2973..e96fc38b72b8 100644 --- a/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.h +++ b/components/brave_ads/core/internal/creatives/promoted_content_ads/creative_promoted_content_ads_database_table.h @@ -41,14 +41,13 @@ class CreativePromotedContentAds final : public TableInterface { public: CreativePromotedContentAds(); - CreativePromotedContentAds(const CreativePromotedContentAds& other) = delete; + CreativePromotedContentAds(const CreativePromotedContentAds&) = delete; CreativePromotedContentAds& operator=(const CreativePromotedContentAds&) = delete; - CreativePromotedContentAds(CreativePromotedContentAds&& other) noexcept = + CreativePromotedContentAds(CreativePromotedContentAds&&) noexcept = delete; + CreativePromotedContentAds& operator=(CreativePromotedContentAds&&) noexcept = delete; - CreativePromotedContentAds& operator=( - CreativePromotedContentAds&& other) noexcept = delete; ~CreativePromotedContentAds() override; diff --git a/components/brave_ads/core/internal/database/database_manager.h b/components/brave_ads/core/internal/database/database_manager.h index 51a0492b577b..835c791c99d5 100644 --- a/components/brave_ads/core/internal/database/database_manager.h +++ b/components/brave_ads/core/internal/database/database_manager.h @@ -17,11 +17,11 @@ class DatabaseManager final { public: DatabaseManager(); - DatabaseManager(const DatabaseManager& other) = delete; - DatabaseManager& operator=(const DatabaseManager& other) = delete; + DatabaseManager(const DatabaseManager&) = delete; + DatabaseManager& operator=(const DatabaseManager&) = delete; - DatabaseManager(DatabaseManager&& other) noexcept = delete; - DatabaseManager& operator=(DatabaseManager&& other) noexcept = delete; + DatabaseManager(DatabaseManager&&) noexcept = delete; + DatabaseManager& operator=(DatabaseManager&&) noexcept = delete; ~DatabaseManager(); diff --git a/components/brave_ads/core/internal/deprecated/client/client_info.h b/components/brave_ads/core/internal/deprecated/client/client_info.h index 4fbd709d4876..720aabfaf320 100644 --- a/components/brave_ads/core/internal/deprecated/client/client_info.h +++ b/components/brave_ads/core/internal/deprecated/client/client_info.h @@ -21,11 +21,11 @@ namespace brave_ads { struct ClientInfo final { ClientInfo(); - ClientInfo(const ClientInfo& other); - ClientInfo& operator=(const ClientInfo& other); + ClientInfo(const ClientInfo&); + ClientInfo& operator=(const ClientInfo&); - ClientInfo(ClientInfo&& other) noexcept; - ClientInfo& operator=(ClientInfo&& other) noexcept; + ClientInfo(ClientInfo&&) noexcept; + ClientInfo& operator=(ClientInfo&&) noexcept; ~ClientInfo(); diff --git a/components/brave_ads/core/internal/deprecated/client/client_state_manager.h b/components/brave_ads/core/internal/deprecated/client/client_state_manager.h index a1140125f7f8..5fd7cefb0b6a 100644 --- a/components/brave_ads/core/internal/deprecated/client/client_state_manager.h +++ b/components/brave_ads/core/internal/deprecated/client/client_state_manager.h @@ -33,11 +33,11 @@ class ClientStateManager final { public: ClientStateManager(); - ClientStateManager(const ClientStateManager& other) = delete; - ClientStateManager& operator=(const ClientStateManager& other) = delete; + ClientStateManager(const ClientStateManager&) = delete; + ClientStateManager& operator=(const ClientStateManager&) = delete; - ClientStateManager(ClientStateManager&& other) noexcept = delete; - ClientStateManager& operator=(ClientStateManager&& other) noexcept = delete; + ClientStateManager(ClientStateManager&&) noexcept = delete; + ClientStateManager& operator=(ClientStateManager&&) noexcept = delete; ~ClientStateManager(); diff --git a/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info.h b/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info.h index 5430b29bc3a9..85ddd2c4cf89 100644 --- a/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info.h +++ b/components/brave_ads/core/internal/deprecated/client/preferences/ad_preferences_info.h @@ -19,11 +19,11 @@ namespace brave_ads { struct AdPreferencesInfo final { AdPreferencesInfo(); - AdPreferencesInfo(const AdPreferencesInfo& other); - AdPreferencesInfo& operator=(const AdPreferencesInfo& other); + AdPreferencesInfo(const AdPreferencesInfo&); + AdPreferencesInfo& operator=(const AdPreferencesInfo&); - AdPreferencesInfo(AdPreferencesInfo&& other) noexcept; - AdPreferencesInfo& operator=(AdPreferencesInfo&& other) noexcept; + AdPreferencesInfo(AdPreferencesInfo&&) noexcept; + AdPreferencesInfo& operator=(AdPreferencesInfo&&) noexcept; ~AdPreferencesInfo(); diff --git a/components/brave_ads/core/internal/deprecated/confirmations/confirmation_state_manager.h b/components/brave_ads/core/internal/deprecated/confirmations/confirmation_state_manager.h index 619dea838e5b..97447fcff778 100644 --- a/components/brave_ads/core/internal/deprecated/confirmations/confirmation_state_manager.h +++ b/components/brave_ads/core/internal/deprecated/confirmations/confirmation_state_manager.h @@ -27,13 +27,12 @@ class ConfirmationStateManager final { public: ConfirmationStateManager(); - ConfirmationStateManager(const ConfirmationStateManager& other) = delete; - ConfirmationStateManager& operator=(const ConfirmationStateManager& other) = - delete; + ConfirmationStateManager(const ConfirmationStateManager&) = delete; + ConfirmationStateManager& operator=(const ConfirmationStateManager&) = delete; - ConfirmationStateManager(ConfirmationStateManager&& other) noexcept = delete; - ConfirmationStateManager& operator=( - ConfirmationStateManager&& other) noexcept = delete; + ConfirmationStateManager(ConfirmationStateManager&&) noexcept = delete; + ConfirmationStateManager& operator=(ConfirmationStateManager&&) noexcept = + delete; ~ConfirmationStateManager(); diff --git a/components/brave_ads/core/internal/diagnostics/diagnostic_manager.h b/components/brave_ads/core/internal/diagnostics/diagnostic_manager.h index d8a3ed281e3e..6bde50a18487 100644 --- a/components/brave_ads/core/internal/diagnostics/diagnostic_manager.h +++ b/components/brave_ads/core/internal/diagnostics/diagnostic_manager.h @@ -17,11 +17,11 @@ class DiagnosticManager final { public: DiagnosticManager(); - DiagnosticManager(const DiagnosticManager& other) = delete; - DiagnosticManager& operator=(const DiagnosticManager& other) = delete; + DiagnosticManager(const DiagnosticManager&) = delete; + DiagnosticManager& operator=(const DiagnosticManager&) = delete; - DiagnosticManager(DiagnosticManager&& other) noexcept = delete; - DiagnosticManager& operator=(DiagnosticManager&& other) noexcept = delete; + DiagnosticManager(DiagnosticManager&&) noexcept = delete; + DiagnosticManager& operator=(DiagnosticManager&&) noexcept = delete; ~DiagnosticManager(); diff --git a/components/brave_ads/core/internal/fl/predictors/predictors_manager.h b/components/brave_ads/core/internal/fl/predictors/predictors_manager.h index ec5697417833..5319c3d81219 100644 --- a/components/brave_ads/core/internal/fl/predictors/predictors_manager.h +++ b/components/brave_ads/core/internal/fl/predictors/predictors_manager.h @@ -25,11 +25,11 @@ class PredictorsManager final { public: PredictorsManager(); - PredictorsManager(const PredictorsManager& other) = delete; - PredictorsManager& operator=(const PredictorsManager& other) = delete; + PredictorsManager(const PredictorsManager&) = delete; + PredictorsManager& operator=(const PredictorsManager&) = delete; - PredictorsManager(PredictorsManager&& other) noexcept = delete; - PredictorsManager& operator=(PredictorsManager&& other) noexcept = delete; + PredictorsManager(PredictorsManager&&) noexcept = delete; + PredictorsManager& operator=(PredictorsManager&&) noexcept = delete; ~PredictorsManager(); diff --git a/components/brave_ads/core/internal/flags/flag_manager.h b/components/brave_ads/core/internal/flags/flag_manager.h index 3f0b86ae155b..c0dc81d886a4 100644 --- a/components/brave_ads/core/internal/flags/flag_manager.h +++ b/components/brave_ads/core/internal/flags/flag_manager.h @@ -14,11 +14,11 @@ class FlagManager final { public: FlagManager(); - FlagManager(const FlagManager& other) = delete; - FlagManager& operator=(const FlagManager& other) = delete; + FlagManager(const FlagManager&) = delete; + FlagManager& operator=(const FlagManager&) = delete; - FlagManager(FlagManager&& other) noexcept = delete; - FlagManager& operator=(FlagManager&& other) noexcept = delete; + FlagManager(FlagManager&&) noexcept = delete; + FlagManager& operator=(FlagManager&&) noexcept = delete; ~FlagManager(); diff --git a/components/brave_ads/core/internal/geographic/subdivision/subdivision_targeting.h b/components/brave_ads/core/internal/geographic/subdivision/subdivision_targeting.h index d824025ef48f..d63eb14d2755 100644 --- a/components/brave_ads/core/internal/geographic/subdivision/subdivision_targeting.h +++ b/components/brave_ads/core/internal/geographic/subdivision/subdivision_targeting.h @@ -21,12 +21,11 @@ class SubdivisionTargeting final : public AdsClientNotifierObserver { public: SubdivisionTargeting(); - SubdivisionTargeting(const SubdivisionTargeting& other) = delete; - SubdivisionTargeting& operator=(const SubdivisionTargeting& other) = delete; + SubdivisionTargeting(const SubdivisionTargeting&) = delete; + SubdivisionTargeting& operator=(const SubdivisionTargeting&) = delete; - SubdivisionTargeting(SubdivisionTargeting&& other) noexcept = delete; - SubdivisionTargeting& operator=(SubdivisionTargeting&& other) noexcept = - delete; + SubdivisionTargeting(SubdivisionTargeting&&) noexcept = delete; + SubdivisionTargeting& operator=(SubdivisionTargeting&&) noexcept = delete; ~SubdivisionTargeting() override; diff --git a/components/brave_ads/core/internal/history/history_manager.h b/components/brave_ads/core/internal/history/history_manager.h index b1363db0f0a8..9d00fb194ca7 100644 --- a/components/brave_ads/core/internal/history/history_manager.h +++ b/components/brave_ads/core/internal/history/history_manager.h @@ -34,11 +34,11 @@ class HistoryManager final { public: HistoryManager(); - HistoryManager(const HistoryManager& other) = delete; - HistoryManager& operator=(const HistoryManager& other) = delete; + HistoryManager(const HistoryManager&) = delete; + HistoryManager& operator=(const HistoryManager&) = delete; - HistoryManager(HistoryManager&& other) noexcept = delete; - HistoryManager& operator=(HistoryManager&& other) noexcept = delete; + HistoryManager(HistoryManager&&) noexcept = delete; + HistoryManager& operator=(HistoryManager&&) noexcept = delete; ~HistoryManager(); diff --git a/components/brave_ads/core/internal/ml/data/data.h b/components/brave_ads/core/internal/ml/data/data.h index 4d7b1092c583..9495ff526774 100644 --- a/components/brave_ads/core/internal/ml/data/data.h +++ b/components/brave_ads/core/internal/ml/data/data.h @@ -14,11 +14,11 @@ class Data { public: explicit Data(const DataType& type); - Data(const Data& other) = delete; - Data& operator=(const Data& other) = delete; + Data(const Data&) = delete; + Data& operator=(const Data&) = delete; - Data(Data&& other) noexcept = delete; - Data& operator=(Data&& other) noexcept = delete; + Data(Data&&) noexcept = delete; + Data& operator=(Data&&) noexcept = delete; virtual ~Data(); diff --git a/components/brave_ads/core/internal/ml/model/linear/linear.h b/components/brave_ads/core/internal/ml/model/linear/linear.h index d9761ea62008..6ef7a12d9f0e 100644 --- a/components/brave_ads/core/internal/ml/model/linear/linear.h +++ b/components/brave_ads/core/internal/ml/model/linear/linear.h @@ -22,11 +22,11 @@ class Linear final { Linear(std::map weights, std::map biases); - Linear(const Linear& other); - Linear& operator=(const Linear& other); + Linear(const Linear&); + Linear& operator=(const Linear&); - Linear(Linear&& other) noexcept; - Linear& operator=(Linear&& other) noexcept; + Linear(Linear&&) noexcept; + Linear& operator=(Linear&&) noexcept; ~Linear(); diff --git a/components/brave_ads/core/internal/ml/pipeline/embedding_pipeline_info.h b/components/brave_ads/core/internal/ml/pipeline/embedding_pipeline_info.h index 8036b33ef659..813bd8877846 100644 --- a/components/brave_ads/core/internal/ml/pipeline/embedding_pipeline_info.h +++ b/components/brave_ads/core/internal/ml/pipeline/embedding_pipeline_info.h @@ -17,11 +17,11 @@ namespace brave_ads::ml::pipeline { struct EmbeddingPipelineInfo final { EmbeddingPipelineInfo(); - EmbeddingPipelineInfo(const EmbeddingPipelineInfo& other); - EmbeddingPipelineInfo& operator=(const EmbeddingPipelineInfo& other); + EmbeddingPipelineInfo(const EmbeddingPipelineInfo&); + EmbeddingPipelineInfo& operator=(const EmbeddingPipelineInfo&); - EmbeddingPipelineInfo(EmbeddingPipelineInfo&& other) noexcept; - EmbeddingPipelineInfo& operator=(EmbeddingPipelineInfo&& other) noexcept; + EmbeddingPipelineInfo(EmbeddingPipelineInfo&&) noexcept; + EmbeddingPipelineInfo& operator=(EmbeddingPipelineInfo&&) noexcept; ~EmbeddingPipelineInfo(); diff --git a/components/brave_ads/core/internal/ml/pipeline/pipeline_info.h b/components/brave_ads/core/internal/ml/pipeline/pipeline_info.h index cddf0f905e51..c65aa2cd8fd3 100644 --- a/components/brave_ads/core/internal/ml/pipeline/pipeline_info.h +++ b/components/brave_ads/core/internal/ml/pipeline/pipeline_info.h @@ -21,8 +21,8 @@ struct PipelineInfo final { TransformationVector transformations, model::Linear linear_model); - PipelineInfo(PipelineInfo&& other) noexcept; - PipelineInfo& operator=(PipelineInfo&& other) noexcept; + PipelineInfo(PipelineInfo&&) noexcept; + PipelineInfo& operator=(PipelineInfo&&) noexcept; ~PipelineInfo(); diff --git a/components/brave_ads/core/internal/ml/pipeline/text_processing/embedding_info.h b/components/brave_ads/core/internal/ml/pipeline/text_processing/embedding_info.h index 8ddd15721e5d..5acdb577bce3 100644 --- a/components/brave_ads/core/internal/ml/pipeline/text_processing/embedding_info.h +++ b/components/brave_ads/core/internal/ml/pipeline/text_processing/embedding_info.h @@ -14,11 +14,11 @@ namespace brave_ads::ml::pipeline { struct TextEmbeddingInfo final { TextEmbeddingInfo(); - TextEmbeddingInfo(const TextEmbeddingInfo& other); - TextEmbeddingInfo& operator=(const TextEmbeddingInfo& other); + TextEmbeddingInfo(const TextEmbeddingInfo&); + TextEmbeddingInfo& operator=(const TextEmbeddingInfo&); - TextEmbeddingInfo(TextEmbeddingInfo&& other) noexcept; - TextEmbeddingInfo& operator=(TextEmbeddingInfo&& other) noexcept; + TextEmbeddingInfo(TextEmbeddingInfo&&) noexcept; + TextEmbeddingInfo& operator=(TextEmbeddingInfo&&) noexcept; ~TextEmbeddingInfo(); diff --git a/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing.h b/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing.h index 4e8029e739d6..3d544da4d435 100644 --- a/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing.h +++ b/components/brave_ads/core/internal/ml/pipeline/text_processing/text_processing.h @@ -31,11 +31,11 @@ class TextProcessing final { TextProcessing(TransformationVector transformations, model::Linear linear_model); - TextProcessing(const TextProcessing& pipeline) = delete; - TextProcessing& operator=(const TextProcessing& pipeline) = delete; + TextProcessing(const TextProcessing&) = delete; + TextProcessing& operator=(const TextProcessing&) = delete; - TextProcessing(TextProcessing&& other) noexcept = delete; - TextProcessing& operator=(TextProcessing&& other) noexcept = delete; + TextProcessing(TextProcessing&&) noexcept = delete; + TextProcessing& operator=(TextProcessing&&) noexcept = delete; ~TextProcessing(); diff --git a/components/brave_ads/core/internal/ml/transformation/hash_vectorizer.h b/components/brave_ads/core/internal/ml/transformation/hash_vectorizer.h index 29a8deba93db..340d0a7444fa 100644 --- a/components/brave_ads/core/internal/ml/transformation/hash_vectorizer.h +++ b/components/brave_ads/core/internal/ml/transformation/hash_vectorizer.h @@ -18,11 +18,11 @@ class HashVectorizer final { HashVectorizer(); HashVectorizer(int bucket_count, const std::vector& subgrams); - HashVectorizer(const HashVectorizer& other) = delete; - HashVectorizer& operator=(const HashVectorizer& other) = delete; + HashVectorizer(const HashVectorizer&) = delete; + HashVectorizer& operator=(const HashVectorizer&) = delete; - HashVectorizer(HashVectorizer&& other) noexcept = delete; - HashVectorizer& operator=(HashVectorizer&& other) noexcept = delete; + HashVectorizer(HashVectorizer&&) noexcept = delete; + HashVectorizer& operator=(HashVectorizer&&) noexcept = delete; ~HashVectorizer(); diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/batch_dleq_proof.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/batch_dleq_proof.h index 32ced3f76b28..624064ffeab3 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/batch_dleq_proof.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/batch_dleq_proof.h @@ -34,16 +34,16 @@ class BatchDLEQProof { const std::vector& signed_tokens, const SigningKey& signing_key); - BatchDLEQProof(const BatchDLEQProof& other) = delete; - BatchDLEQProof& operator=(const BatchDLEQProof& other) = delete; + BatchDLEQProof(const BatchDLEQProof&) = delete; + BatchDLEQProof& operator=(const BatchDLEQProof&) = delete; - BatchDLEQProof(BatchDLEQProof&& other) noexcept = delete; - BatchDLEQProof& operator=(BatchDLEQProof&& other) noexcept = delete; + BatchDLEQProof(BatchDLEQProof&&) noexcept = delete; + BatchDLEQProof& operator=(BatchDLEQProof&&) noexcept = delete; ~BatchDLEQProof(); - bool operator==(const BatchDLEQProof& other) const; - bool operator!=(const BatchDLEQProof& other) const; + bool operator==(const BatchDLEQProof&) const; + bool operator!=(const BatchDLEQProof&) const; bool has_value() const { return batch_dleq_proof_ && batch_dleq_proof_.has_value(); diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/blinded_token.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/blinded_token.h index 096e3c67b4ba..76b105d4522c 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/blinded_token.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/blinded_token.h @@ -26,16 +26,16 @@ class BlindedToken { explicit BlindedToken( const challenge_bypass_ristretto::BlindedToken& blinded_token); - BlindedToken(const BlindedToken& other); - BlindedToken& operator=(const BlindedToken& other); + BlindedToken(const BlindedToken&); + BlindedToken& operator=(const BlindedToken&); - BlindedToken(BlindedToken&& other) noexcept; - BlindedToken& operator=(BlindedToken&& other) noexcept; + BlindedToken(BlindedToken&&) noexcept; + BlindedToken& operator=(BlindedToken&&) noexcept; ~BlindedToken(); - bool operator==(const BlindedToken& other) const; - bool operator!=(const BlindedToken& other) const; + bool operator==(const BlindedToken&) const; + bool operator!=(const BlindedToken&) const; bool has_value() const { return blinded_token_ && blinded_token_.has_value(); diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/dleq_proof.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/dleq_proof.h index c97df3ee51d1..327497f7d423 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/dleq_proof.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/dleq_proof.h @@ -31,16 +31,16 @@ class DLEQProof { const SignedToken& signed_token, const SigningKey& signing_key); - DLEQProof(const DLEQProof& other) = delete; - DLEQProof& operator=(const DLEQProof& other) = delete; + DLEQProof(const DLEQProof&) = delete; + DLEQProof& operator=(const DLEQProof&) = delete; - DLEQProof(DLEQProof&& other) noexcept = delete; - DLEQProof& operator=(DLEQProof&& other) noexcept = delete; + DLEQProof(DLEQProof&&) noexcept = delete; + DLEQProof& operator=(DLEQProof&&) noexcept = delete; ~DLEQProof(); - bool operator==(const DLEQProof& other) const; - bool operator!=(const DLEQProof& other) const; + bool operator==(const DLEQProof&) const; + bool operator!=(const DLEQProof&) const; bool has_value() const { return dleq_proof_.has_value(); } diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/public_key.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/public_key.h index d6b711fc52d8..68aa33b83aec 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/public_key.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/public_key.h @@ -23,16 +23,16 @@ class PublicKey { explicit PublicKey(const std::string& public_key_base64); explicit PublicKey(const challenge_bypass_ristretto::PublicKey& public_key); - PublicKey(const PublicKey& other); - PublicKey& operator=(const PublicKey& other); + PublicKey(const PublicKey&); + PublicKey& operator=(const PublicKey&); - PublicKey(PublicKey&& other) noexcept; - PublicKey& operator=(PublicKey&& other) noexcept; + PublicKey(PublicKey&&) noexcept; + PublicKey& operator=(PublicKey&&) noexcept; ~PublicKey(); - bool operator==(const PublicKey& other) const; - bool operator!=(const PublicKey& other) const; + bool operator==(const PublicKey&) const; + bool operator!=(const PublicKey&) const; bool has_value() const { return public_key_.has_value(); } diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signed_token.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signed_token.h index 346cfe8f4708..20fbc4a78259 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signed_token.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signed_token.h @@ -24,16 +24,16 @@ class SignedToken { explicit SignedToken( const challenge_bypass_ristretto::SignedToken& signed_token); - SignedToken(const SignedToken& other); - SignedToken& operator=(const SignedToken& other); + SignedToken(const SignedToken&); + SignedToken& operator=(const SignedToken&); - SignedToken(SignedToken&& other) noexcept; - SignedToken& operator=(SignedToken&& other) noexcept; + SignedToken(SignedToken&&) noexcept; + SignedToken& operator=(SignedToken&&) noexcept; ~SignedToken(); - bool operator==(const SignedToken& other) const; - bool operator!=(const SignedToken& other) const; + bool operator==(const SignedToken&) const; + bool operator!=(const SignedToken&) const; bool has_value() const { return signed_token_.has_value(); } diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signing_key.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signing_key.h index 90a652445b74..33bf5789645c 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signing_key.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/signing_key.h @@ -31,16 +31,16 @@ class SigningKey { explicit SigningKey( const challenge_bypass_ristretto::SigningKey& signing_key); - SigningKey(const SigningKey& other) = delete; - SigningKey& operator=(const SigningKey& other) = delete; + SigningKey(const SigningKey&) = delete; + SigningKey& operator=(const SigningKey&) = delete; - SigningKey(SigningKey&& other) noexcept = delete; - SigningKey& operator=(SigningKey&& other) noexcept = delete; + SigningKey(SigningKey&&) noexcept = delete; + SigningKey& operator=(SigningKey&&) noexcept = delete; ~SigningKey(); - bool operator==(const SigningKey& other) const; - bool operator!=(const SigningKey& other) const; + bool operator==(const SigningKey&) const; + bool operator!=(const SigningKey&) const; bool has_value() const { return signing_key_.has_value(); } diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token.h index df26c5cc03d4..df6dd9edb336 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token.h @@ -26,16 +26,16 @@ class Token { Token(); explicit Token(const std::string& token_base64); - Token(const Token& other); - Token& operator=(const Token& other); + Token(const Token&); + Token& operator=(const Token&); - Token(Token&& other) noexcept; - Token& operator=(Token&& other) noexcept; + Token(Token&&) noexcept; + Token& operator=(Token&&) noexcept; ~Token(); - bool operator==(const Token& other) const; - bool operator!=(const Token& other) const; + bool operator==(const Token&) const; + bool operator!=(const Token&) const; bool has_value() const { return token_.has_value(); } diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token_preimage.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token_preimage.h index 86cb3658546b..eafabb6e9ab3 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token_preimage.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/token_preimage.h @@ -26,16 +26,16 @@ class TokenPreimage { explicit TokenPreimage( const challenge_bypass_ristretto::TokenPreimage& token_preimage); - TokenPreimage(const TokenPreimage& other); - TokenPreimage& operator=(const TokenPreimage& other); + TokenPreimage(const TokenPreimage&); + TokenPreimage& operator=(const TokenPreimage&); - TokenPreimage(TokenPreimage&& other) noexcept; - TokenPreimage& operator=(TokenPreimage&& other) noexcept; + TokenPreimage(TokenPreimage&&) noexcept; + TokenPreimage& operator=(TokenPreimage&&) noexcept; ~TokenPreimage(); - bool operator==(const TokenPreimage& other) const; - bool operator!=(const TokenPreimage& other) const; + bool operator==(const TokenPreimage&) const; + bool operator!=(const TokenPreimage&) const; bool has_value() const { return token_preimage_ && token_preimage_.has_value(); diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/unblinded_token.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/unblinded_token.h index dd6dc1014c5c..e8b7b0ce88a8 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/unblinded_token.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/unblinded_token.h @@ -29,16 +29,16 @@ class UnblindedToken { explicit UnblindedToken( const challenge_bypass_ristretto::UnblindedToken& unblinded_token); - UnblindedToken(const UnblindedToken& other); - UnblindedToken& operator=(const UnblindedToken& other); + UnblindedToken(const UnblindedToken&); + UnblindedToken& operator=(const UnblindedToken&); - UnblindedToken(UnblindedToken&& other) noexcept; - UnblindedToken& operator=(UnblindedToken&& other) noexcept; + UnblindedToken(UnblindedToken&&) noexcept; + UnblindedToken& operator=(UnblindedToken&&) noexcept; ~UnblindedToken(); - bool operator==(const UnblindedToken& other) const; - bool operator!=(const UnblindedToken& other) const; + bool operator==(const UnblindedToken&) const; + bool operator!=(const UnblindedToken&) const; bool has_value() const { return unblinded_token_ && unblinded_token_.has_value(); diff --git a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/verification_signature.h b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/verification_signature.h index f07c18684917..f57da27c0947 100644 --- a/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/verification_signature.h +++ b/components/brave_ads/core/internal/privacy/challenge_bypass_ristretto/verification_signature.h @@ -27,16 +27,16 @@ class VerificationSignature { const challenge_bypass_ristretto::VerificationSignature& verification_signature); - VerificationSignature(const VerificationSignature& other); - VerificationSignature& operator=(const VerificationSignature& other); + VerificationSignature(const VerificationSignature&); + VerificationSignature& operator=(const VerificationSignature&); - VerificationSignature(VerificationSignature&& other) noexcept; - VerificationSignature& operator=(VerificationSignature&& other) noexcept; + VerificationSignature(VerificationSignature&&) noexcept; + VerificationSignature& operator=(VerificationSignature&&) noexcept; ~VerificationSignature(); - bool operator==(const VerificationSignature& other) const; - bool operator!=(const VerificationSignature& other) const; + bool operator==(const VerificationSignature&) const; + bool operator!=(const VerificationSignature&) const; bool has_value() const { return verification_signature_ && verification_signature_.has_value(); diff --git a/components/brave_ads/core/internal/privacy/tokens/token_generator_mock.h b/components/brave_ads/core/internal/privacy/tokens/token_generator_mock.h index 0dca33585b85..046cf7758e60 100644 --- a/components/brave_ads/core/internal/privacy/tokens/token_generator_mock.h +++ b/components/brave_ads/core/internal/privacy/tokens/token_generator_mock.h @@ -18,11 +18,11 @@ class TokenGeneratorMock : public TokenGenerator { public: TokenGeneratorMock(); - TokenGeneratorMock(const TokenGeneratorMock& other) = delete; - TokenGeneratorMock& operator=(const TokenGeneratorMock& other) = delete; + TokenGeneratorMock(const TokenGeneratorMock&) = delete; + TokenGeneratorMock& operator=(const TokenGeneratorMock&) = delete; - TokenGeneratorMock(TokenGeneratorMock&& other) noexcept = delete; - TokenGeneratorMock& operator=(TokenGeneratorMock&& other) noexcept = delete; + TokenGeneratorMock(TokenGeneratorMock&&) noexcept = delete; + TokenGeneratorMock& operator=(TokenGeneratorMock&&) noexcept = delete; ~TokenGeneratorMock() override; diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_info.h b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_info.h index f662cfcaf366..a61b640a83f8 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_info.h +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_token_info.h @@ -19,17 +19,16 @@ namespace brave_ads::privacy { struct UnblindedPaymentTokenInfo final { UnblindedPaymentTokenInfo(); - UnblindedPaymentTokenInfo(const UnblindedPaymentTokenInfo& other); - UnblindedPaymentTokenInfo& operator=(const UnblindedPaymentTokenInfo& other); + UnblindedPaymentTokenInfo(const UnblindedPaymentTokenInfo&); + UnblindedPaymentTokenInfo& operator=(const UnblindedPaymentTokenInfo&); - UnblindedPaymentTokenInfo(UnblindedPaymentTokenInfo&& other) noexcept; - UnblindedPaymentTokenInfo& operator=( - UnblindedPaymentTokenInfo&& other) noexcept; + UnblindedPaymentTokenInfo(UnblindedPaymentTokenInfo&&) noexcept; + UnblindedPaymentTokenInfo& operator=(UnblindedPaymentTokenInfo&&) noexcept; ~UnblindedPaymentTokenInfo(); - bool operator==(const UnblindedPaymentTokenInfo& other) const; - bool operator!=(const UnblindedPaymentTokenInfo& other) const; + bool operator==(const UnblindedPaymentTokenInfo&) const; + bool operator!=(const UnblindedPaymentTokenInfo&) const; std::string transaction_id; cbr::UnblindedToken value; diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens.h b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens.h index 7cf53ad2c609..e78edec696c1 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens.h +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_payment_tokens/unblinded_payment_tokens.h @@ -14,13 +14,11 @@ class UnblindedPaymentTokens final { public: UnblindedPaymentTokens(); - UnblindedPaymentTokens(const UnblindedPaymentTokens& other) = delete; - UnblindedPaymentTokens& operator=(const UnblindedPaymentTokens& other) = - delete; + UnblindedPaymentTokens(const UnblindedPaymentTokens&) = delete; + UnblindedPaymentTokens& operator=(const UnblindedPaymentTokens&) = delete; - UnblindedPaymentTokens(UnblindedPaymentTokens&& other) noexcept = delete; - UnblindedPaymentTokens& operator=(UnblindedPaymentTokens&& other) noexcept = - delete; + UnblindedPaymentTokens(UnblindedPaymentTokens&&) noexcept = delete; + UnblindedPaymentTokens& operator=(UnblindedPaymentTokens&&) noexcept = delete; ~UnblindedPaymentTokens(); diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_info.h b/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_info.h index c1ce0f99c081..d8ef08e8479d 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_info.h +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_token_info.h @@ -15,8 +15,8 @@ namespace brave_ads::privacy { struct UnblindedTokenInfo final { - bool operator==(const UnblindedTokenInfo& other) const; - bool operator!=(const UnblindedTokenInfo& other) const; + bool operator==(const UnblindedTokenInfo&) const; + bool operator!=(const UnblindedTokenInfo&) const; cbr::UnblindedToken value; cbr::PublicKey public_key; diff --git a/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_tokens.h b/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_tokens.h index ce4d46c29943..080ba9411095 100644 --- a/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_tokens.h +++ b/components/brave_ads/core/internal/privacy/tokens/unblinded_tokens/unblinded_tokens.h @@ -14,11 +14,11 @@ class UnblindedTokens final { public: UnblindedTokens(); - UnblindedTokens(const UnblindedTokens& other) = delete; - UnblindedTokens& operator=(const UnblindedTokens& other) = delete; + UnblindedTokens(const UnblindedTokens&) = delete; + UnblindedTokens& operator=(const UnblindedTokens&) = delete; - UnblindedTokens(UnblindedTokens&& other) noexcept = delete; - UnblindedTokens& operator=(UnblindedTokens&& other) noexcept = delete; + UnblindedTokens(UnblindedTokens&&) noexcept = delete; + UnblindedTokens& operator=(UnblindedTokens&&) noexcept = delete; ~UnblindedTokens(); diff --git a/components/brave_ads/core/internal/processors/behavioral/multi_armed_bandits/epsilon_greedy_bandit_arm_info.h b/components/brave_ads/core/internal/processors/behavioral/multi_armed_bandits/epsilon_greedy_bandit_arm_info.h index f8519edf0a30..3fdfbac8dd36 100644 --- a/components/brave_ads/core/internal/processors/behavioral/multi_armed_bandits/epsilon_greedy_bandit_arm_info.h +++ b/components/brave_ads/core/internal/processors/behavioral/multi_armed_bandits/epsilon_greedy_bandit_arm_info.h @@ -11,8 +11,8 @@ namespace brave_ads::targeting { struct EpsilonGreedyBanditArmInfo final { - bool operator==(const EpsilonGreedyBanditArmInfo& other) const; - bool operator!=(const EpsilonGreedyBanditArmInfo& other) const; + bool operator==(const EpsilonGreedyBanditArmInfo&) const; + bool operator!=(const EpsilonGreedyBanditArmInfo&) const; bool IsValid() const; diff --git a/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_processor.h b/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_processor.h index 06a8fb5dbf5e..aaf944d572a3 100644 --- a/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_processor.h +++ b/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_processor.h @@ -35,11 +35,11 @@ class PurchaseIntent final : public AdsClientNotifierObserver, public: explicit PurchaseIntent(resource::PurchaseIntent* resource); - PurchaseIntent(const PurchaseIntent& other) = delete; - PurchaseIntent& operator=(const PurchaseIntent& other) = delete; + PurchaseIntent(const PurchaseIntent&) = delete; + PurchaseIntent& operator=(const PurchaseIntent&) = delete; - PurchaseIntent(PurchaseIntent&& other) noexcept = delete; - PurchaseIntent& operator=(PurchaseIntent&& other) noexcept = delete; + PurchaseIntent(PurchaseIntent&&) noexcept = delete; + PurchaseIntent& operator=(PurchaseIntent&&) noexcept = delete; ~PurchaseIntent() override; diff --git a/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_signal_info.h b/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_signal_info.h index 3b95f787a43a..78b3a89a5aff 100644 --- a/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_signal_info.h +++ b/components/brave_ads/core/internal/processors/behavioral/purchase_intent/purchase_intent_signal_info.h @@ -16,12 +16,11 @@ namespace brave_ads::targeting { struct PurchaseIntentSignalInfo final { PurchaseIntentSignalInfo(); - PurchaseIntentSignalInfo(const PurchaseIntentSignalInfo& other); - PurchaseIntentSignalInfo& operator=(const PurchaseIntentSignalInfo& other); + PurchaseIntentSignalInfo(const PurchaseIntentSignalInfo&); + PurchaseIntentSignalInfo& operator=(const PurchaseIntentSignalInfo&); - PurchaseIntentSignalInfo(PurchaseIntentSignalInfo&& other) noexcept; - PurchaseIntentSignalInfo& operator=( - PurchaseIntentSignalInfo&& other) noexcept; + PurchaseIntentSignalInfo(PurchaseIntentSignalInfo&&) noexcept; + PurchaseIntentSignalInfo& operator=(PurchaseIntentSignalInfo&&) noexcept; ~PurchaseIntentSignalInfo(); diff --git a/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor.h b/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor.h index 3a6d4d077e9c..d8c05d2d554b 100644 --- a/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor.h +++ b/components/brave_ads/core/internal/processors/contextual/text_classification/text_classification_processor.h @@ -29,11 +29,11 @@ class TextClassification final : public AdsClientNotifierObserver, public: explicit TextClassification(resource::TextClassification* resource); - TextClassification(const TextClassification& other) = delete; - TextClassification& operator=(const TextClassification& other) = delete; + TextClassification(const TextClassification&) = delete; + TextClassification& operator=(const TextClassification&) = delete; - TextClassification(TextClassification&& other) noexcept = delete; - TextClassification& operator=(TextClassification&& other) noexcept = delete; + TextClassification(TextClassification&&) noexcept = delete; + TextClassification& operator=(TextClassification&&) noexcept = delete; ~TextClassification() override; diff --git a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_event_info.h b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_event_info.h index 632f0613d54f..598a6653fca2 100644 --- a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_event_info.h +++ b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_html_event_info.h @@ -16,13 +16,11 @@ namespace brave_ads { struct TextEmbeddingHtmlEventInfo final { TextEmbeddingHtmlEventInfo(); - TextEmbeddingHtmlEventInfo(const TextEmbeddingHtmlEventInfo& other); - TextEmbeddingHtmlEventInfo& operator=( - const TextEmbeddingHtmlEventInfo& other); + TextEmbeddingHtmlEventInfo(const TextEmbeddingHtmlEventInfo&); + TextEmbeddingHtmlEventInfo& operator=(const TextEmbeddingHtmlEventInfo&); - TextEmbeddingHtmlEventInfo(TextEmbeddingHtmlEventInfo&& other) noexcept; - TextEmbeddingHtmlEventInfo& operator=( - TextEmbeddingHtmlEventInfo&& other) noexcept; + TextEmbeddingHtmlEventInfo(TextEmbeddingHtmlEventInfo&&) noexcept; + TextEmbeddingHtmlEventInfo& operator=(TextEmbeddingHtmlEventInfo&&) noexcept; ~TextEmbeddingHtmlEventInfo(); diff --git a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor.h b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor.h index 3d65b45e9919..820bf0df64db 100644 --- a/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor.h +++ b/components/brave_ads/core/internal/processors/contextual/text_embedding/text_embedding_processor.h @@ -29,11 +29,11 @@ class TextEmbedding final : public AdsClientNotifierObserver, public: explicit TextEmbedding(resource::TextEmbedding* resource); - TextEmbedding(const TextEmbedding& other) = delete; - TextEmbedding& operator=(const TextEmbedding& other) = delete; + TextEmbedding(const TextEmbedding&) = delete; + TextEmbedding& operator=(const TextEmbedding&) = delete; - TextEmbedding(TextEmbedding&& other) noexcept = delete; - TextEmbedding& operator=(TextEmbedding&& other) noexcept = delete; + TextEmbedding(TextEmbedding&&) noexcept = delete; + TextEmbedding& operator=(TextEmbedding&&) noexcept = delete; ~TextEmbedding() override; diff --git a/components/brave_ads/core/internal/reminder/reminder.h b/components/brave_ads/core/internal/reminder/reminder.h index 9ff4023e260f..7d0bba3a7d08 100644 --- a/components/brave_ads/core/internal/reminder/reminder.h +++ b/components/brave_ads/core/internal/reminder/reminder.h @@ -16,11 +16,11 @@ class Reminder : public HistoryManagerObserver { public: Reminder(); - Reminder(const Reminder& other) = delete; - Reminder& operator=(const Reminder& other) = delete; + Reminder(const Reminder&) = delete; + Reminder& operator=(const Reminder&) = delete; - Reminder(Reminder&& other) noexcept = delete; - Reminder& operator=(Reminder&& other) noexcept = delete; + Reminder(Reminder&&) noexcept = delete; + Reminder& operator=(Reminder&&) noexcept = delete; ~Reminder() override; diff --git a/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_info.h b/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_info.h index 4e7508f376e1..dfc3f334ec9f 100644 --- a/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_info.h @@ -26,11 +26,11 @@ using AntiTargetingMap = std::map; struct AntiTargetingInfo final { AntiTargetingInfo(); - AntiTargetingInfo(const AntiTargetingInfo& other); - AntiTargetingInfo& operator=(const AntiTargetingInfo& other); + AntiTargetingInfo(const AntiTargetingInfo&); + AntiTargetingInfo& operator=(const AntiTargetingInfo&); - AntiTargetingInfo(AntiTargetingInfo&& other) noexcept; - AntiTargetingInfo& operator=(AntiTargetingInfo&& other) noexcept; + AntiTargetingInfo(AntiTargetingInfo&&) noexcept; + AntiTargetingInfo& operator=(AntiTargetingInfo&&) noexcept; ~AntiTargetingInfo(); diff --git a/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_resource.h b/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_resource.h index 5035bf737b73..1e01470bbced 100644 --- a/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_resource.h +++ b/components/brave_ads/core/internal/resources/behavioral/anti_targeting/anti_targeting_resource.h @@ -20,11 +20,11 @@ class AntiTargeting final : public AdsClientNotifierObserver { public: AntiTargeting(); - AntiTargeting(const AntiTargeting& other) = delete; - AntiTargeting& operator=(const AntiTargeting& other) = delete; + AntiTargeting(const AntiTargeting&) = delete; + AntiTargeting& operator=(const AntiTargeting&) = delete; - AntiTargeting(AntiTargeting&& other) noexcept = delete; - AntiTargeting& operator=(AntiTargeting&& other) noexcept = delete; + AntiTargeting(AntiTargeting&&) noexcept = delete; + AntiTargeting& operator=(AntiTargeting&&) noexcept = delete; ~AntiTargeting() override; diff --git a/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_info.h b/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_info.h index 9ce2cab40580..fb449f8b489b 100644 --- a/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_info.h @@ -20,11 +20,11 @@ namespace brave_ads::resource { struct ConversionsInfo final { ConversionsInfo(); - ConversionsInfo(const ConversionsInfo& other); - ConversionsInfo& operator=(const ConversionsInfo& other); + ConversionsInfo(const ConversionsInfo&); + ConversionsInfo& operator=(const ConversionsInfo&); - ConversionsInfo(ConversionsInfo&& other) noexcept; - ConversionsInfo& operator=(ConversionsInfo&& other) noexcept; + ConversionsInfo(ConversionsInfo&&) noexcept; + ConversionsInfo& operator=(ConversionsInfo&&) noexcept; ~ConversionsInfo(); diff --git a/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_resource.h b/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_resource.h index b4c3beea592c..8b642353b15e 100644 --- a/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_resource.h +++ b/components/brave_ads/core/internal/resources/behavioral/conversions/conversions_resource.h @@ -19,11 +19,11 @@ class Conversions final { public: Conversions(); - Conversions(const Conversions& other) = delete; - Conversions& operator=(const Conversions& other) = delete; + Conversions(const Conversions&) = delete; + Conversions& operator=(const Conversions&) = delete; - Conversions(Conversions&& other) noexcept = delete; - Conversions& operator=(Conversions&& other) noexcept = delete; + Conversions(Conversions&&) noexcept = delete; + Conversions& operator=(Conversions&&) noexcept = delete; ~Conversions(); diff --git a/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource.h b/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource.h index 28ddbea2bc0b..b4ae6c3a850f 100644 --- a/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource.h +++ b/components/brave_ads/core/internal/resources/behavioral/multi_armed_bandits/epsilon_greedy_bandit_resource.h @@ -20,11 +20,11 @@ class EpsilonGreedyBandit final : public CatalogObserver { public: explicit EpsilonGreedyBandit(Catalog* catalog); - EpsilonGreedyBandit(const EpsilonGreedyBandit& other) = delete; - EpsilonGreedyBandit& operator=(const EpsilonGreedyBandit& other) = delete; + EpsilonGreedyBandit(const EpsilonGreedyBandit&) = delete; + EpsilonGreedyBandit& operator=(const EpsilonGreedyBandit&) = delete; - EpsilonGreedyBandit(EpsilonGreedyBandit&& other) noexcept = delete; - EpsilonGreedyBandit& operator=(EpsilonGreedyBandit&& other) noexcept = delete; + EpsilonGreedyBandit(EpsilonGreedyBandit&&) noexcept = delete; + EpsilonGreedyBandit& operator=(EpsilonGreedyBandit&&) noexcept = delete; ~EpsilonGreedyBandit() override; diff --git a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_info.h b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_info.h index 4f6f983e483e..a6e91b8b83ad 100644 --- a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_info.h @@ -24,11 +24,11 @@ namespace brave_ads::targeting { struct PurchaseIntentInfo final { PurchaseIntentInfo(); - PurchaseIntentInfo(const PurchaseIntentInfo& other) = delete; - PurchaseIntentInfo& operator=(const PurchaseIntentInfo& other) = delete; + PurchaseIntentInfo(const PurchaseIntentInfo&) = delete; + PurchaseIntentInfo& operator=(const PurchaseIntentInfo&) = delete; - PurchaseIntentInfo(PurchaseIntentInfo&& other) noexcept = delete; - PurchaseIntentInfo& operator=(PurchaseIntentInfo&& other) noexcept = delete; + PurchaseIntentInfo(PurchaseIntentInfo&&) noexcept = delete; + PurchaseIntentInfo& operator=(PurchaseIntentInfo&&) noexcept = delete; ~PurchaseIntentInfo(); diff --git a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_resource.h b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_resource.h index 4b785d48ed48..9d6fb07266c5 100644 --- a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_resource.h +++ b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_resource.h @@ -23,11 +23,11 @@ class PurchaseIntent final { public: PurchaseIntent(); - PurchaseIntent(const PurchaseIntent& other) = delete; - PurchaseIntent& operator=(const PurchaseIntent& other) = delete; + PurchaseIntent(const PurchaseIntent&) = delete; + PurchaseIntent& operator=(const PurchaseIntent&) = delete; - PurchaseIntent(PurchaseIntent&& other) noexcept = delete; - PurchaseIntent& operator=(PurchaseIntent&& other) noexcept = delete; + PurchaseIntent(PurchaseIntent&&) noexcept = delete; + PurchaseIntent& operator=(PurchaseIntent&&) noexcept = delete; ~PurchaseIntent(); diff --git a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_segment_keyword_info.h b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_segment_keyword_info.h index 7d51aba3ccb2..159e9ff74726 100644 --- a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_segment_keyword_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_segment_keyword_info.h @@ -16,15 +16,13 @@ struct PurchaseIntentSegmentKeywordInfo final { PurchaseIntentSegmentKeywordInfo(); PurchaseIntentSegmentKeywordInfo(SegmentList segments, std::string keywords); - PurchaseIntentSegmentKeywordInfo( - const PurchaseIntentSegmentKeywordInfo& other); + PurchaseIntentSegmentKeywordInfo(const PurchaseIntentSegmentKeywordInfo&); PurchaseIntentSegmentKeywordInfo& operator=( - const PurchaseIntentSegmentKeywordInfo& other); + const PurchaseIntentSegmentKeywordInfo&); - PurchaseIntentSegmentKeywordInfo( - PurchaseIntentSegmentKeywordInfo&& other) noexcept; + PurchaseIntentSegmentKeywordInfo(PurchaseIntentSegmentKeywordInfo&&) noexcept; PurchaseIntentSegmentKeywordInfo& operator=( - PurchaseIntentSegmentKeywordInfo&& other) noexcept; + PurchaseIntentSegmentKeywordInfo&&) noexcept; ~PurchaseIntentSegmentKeywordInfo(); diff --git a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_site_info.h b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_site_info.h index d478ae5ba2db..9fa6ebc60fcf 100644 --- a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_site_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_site_info.h @@ -19,16 +19,16 @@ struct PurchaseIntentSiteInfo final { GURL url_netloc, uint16_t weight); - PurchaseIntentSiteInfo(const PurchaseIntentSiteInfo& other); - PurchaseIntentSiteInfo& operator=(const PurchaseIntentSiteInfo& other); + PurchaseIntentSiteInfo(const PurchaseIntentSiteInfo&); + PurchaseIntentSiteInfo& operator=(const PurchaseIntentSiteInfo&); - PurchaseIntentSiteInfo(PurchaseIntentSiteInfo&& other) noexcept; - PurchaseIntentSiteInfo& operator=(PurchaseIntentSiteInfo&& other) noexcept; + PurchaseIntentSiteInfo(PurchaseIntentSiteInfo&&) noexcept; + PurchaseIntentSiteInfo& operator=(PurchaseIntentSiteInfo&&) noexcept; ~PurchaseIntentSiteInfo(); - bool operator==(const PurchaseIntentSiteInfo& other) const; - bool operator!=(const PurchaseIntentSiteInfo& other) const; + bool operator==(const PurchaseIntentSiteInfo&) const; + bool operator!=(const PurchaseIntentSiteInfo&) const; SegmentList segments; GURL url_netloc; diff --git a/components/brave_ads/core/internal/resources/contextual/text_classification/text_classification_resource.h b/components/brave_ads/core/internal/resources/contextual/text_classification/text_classification_resource.h index 3a6d8eace1f0..1ef040eb93fe 100644 --- a/components/brave_ads/core/internal/resources/contextual/text_classification/text_classification_resource.h +++ b/components/brave_ads/core/internal/resources/contextual/text_classification/text_classification_resource.h @@ -23,11 +23,11 @@ class TextClassification final { public: TextClassification(); - TextClassification(const TextClassification& other) = delete; - TextClassification& operator=(const TextClassification& other) = delete; + TextClassification(const TextClassification&) = delete; + TextClassification& operator=(const TextClassification&) = delete; - TextClassification(TextClassification&& other) noexcept = delete; - TextClassification& operator=(TextClassification&& other) noexcept = delete; + TextClassification(TextClassification&&) noexcept = delete; + TextClassification& operator=(TextClassification&&) noexcept = delete; ~TextClassification(); diff --git a/components/brave_ads/core/internal/resources/contextual/text_embedding/text_embedding_resource.h b/components/brave_ads/core/internal/resources/contextual/text_embedding/text_embedding_resource.h index adc726a2f76e..73108d0f1f5b 100644 --- a/components/brave_ads/core/internal/resources/contextual/text_embedding/text_embedding_resource.h +++ b/components/brave_ads/core/internal/resources/contextual/text_embedding/text_embedding_resource.h @@ -23,11 +23,11 @@ class TextEmbedding final { public: TextEmbedding(); - TextEmbedding(const TextEmbedding& other) = delete; - TextEmbedding& operator=(const TextEmbedding& other) = delete; + TextEmbedding(const TextEmbedding&) = delete; + TextEmbedding& operator=(const TextEmbedding&) = delete; - TextEmbedding(TextEmbedding&& other) noexcept = delete; - TextEmbedding& operator=(TextEmbedding&& other) noexcept = delete; + TextEmbedding(TextEmbedding&&) noexcept = delete; + TextEmbedding& operator=(TextEmbedding&&) noexcept = delete; ~TextEmbedding(); diff --git a/components/brave_ads/core/internal/tabs/tab_info.h b/components/brave_ads/core/internal/tabs/tab_info.h index 00d8274efe36..6dbe84ac5f90 100644 --- a/components/brave_ads/core/internal/tabs/tab_info.h +++ b/components/brave_ads/core/internal/tabs/tab_info.h @@ -16,16 +16,16 @@ namespace brave_ads { struct TabInfo final { TabInfo(); - TabInfo(const TabInfo& other); - TabInfo& operator=(const TabInfo& other); + TabInfo(const TabInfo&); + TabInfo& operator=(const TabInfo&); - TabInfo(TabInfo&& other) noexcept; - TabInfo& operator=(TabInfo&& other) noexcept; + TabInfo(TabInfo&&) noexcept; + TabInfo& operator=(TabInfo&&) noexcept; ~TabInfo(); - bool operator==(const TabInfo& other) const; - bool operator!=(const TabInfo& other) const; + bool operator==(const TabInfo&) const; + bool operator!=(const TabInfo&) const; int32_t id = 0; std::vector redirect_chain; diff --git a/components/brave_ads/core/internal/tabs/tab_manager.h b/components/brave_ads/core/internal/tabs/tab_manager.h index 49bbeb947540..7f287635abea 100644 --- a/components/brave_ads/core/internal/tabs/tab_manager.h +++ b/components/brave_ads/core/internal/tabs/tab_manager.h @@ -25,11 +25,11 @@ class TabManager final : public AdsClientNotifierObserver { public: TabManager(); - TabManager(const TabManager& other) = delete; - TabManager& operator=(const TabManager& other) = delete; + TabManager(const TabManager&) = delete; + TabManager& operator=(const TabManager&) = delete; - TabManager(TabManager&& other) noexcept = delete; - TabManager& operator=(TabManager&& other) noexcept = delete; + TabManager(TabManager&&) noexcept = delete; + TabManager& operator=(TabManager&&) noexcept = delete; ~TabManager() override; diff --git a/components/brave_ads/core/internal/transfer/transfer.h b/components/brave_ads/core/internal/transfer/transfer.h index c9625114857c..badca81b3117 100644 --- a/components/brave_ads/core/internal/transfer/transfer.h +++ b/components/brave_ads/core/internal/transfer/transfer.h @@ -30,11 +30,11 @@ class Transfer final : public TabManagerObserver { public: Transfer(); - Transfer(const Transfer& other) = delete; - Transfer& operator=(const Transfer& other) = delete; + Transfer(const Transfer&) = delete; + Transfer& operator=(const Transfer&) = delete; - Transfer(Transfer&& other) noexcept = delete; - Transfer& operator=(Transfer&& other) noexcept = delete; + Transfer(Transfer&&) noexcept = delete; + Transfer& operator=(Transfer&&) noexcept = delete; ~Transfer() override; diff --git a/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection.h b/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection.h index 9dacb54ca88e..3e58eebc1ccf 100644 --- a/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection.h +++ b/components/brave_ads/core/internal/user_attention/idle_detection/idle_detection.h @@ -18,11 +18,11 @@ class IdleDetection : public AdsClientNotifierObserver { public: IdleDetection(); - IdleDetection(const IdleDetection& other) = delete; - IdleDetection& operator=(const IdleDetection& other) = delete; + IdleDetection(const IdleDetection&) = delete; + IdleDetection& operator=(const IdleDetection&) = delete; - IdleDetection(IdleDetection&& other) noexcept = delete; - IdleDetection& operator=(IdleDetection&& other) noexcept = delete; + IdleDetection(IdleDetection&&) noexcept = delete; + IdleDetection& operator=(IdleDetection&&) noexcept = delete; ~IdleDetection() override; diff --git a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_manager.h b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_manager.h index 840d73a6b569..55ebcfd8683c 100644 --- a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_manager.h +++ b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_manager.h @@ -29,11 +29,11 @@ class UserActivityManager final : public AdsClientNotifierObserver, public: UserActivityManager(); - UserActivityManager(const UserActivityManager& other) = delete; - UserActivityManager& operator=(const UserActivityManager& other) = delete; + UserActivityManager(const UserActivityManager&) = delete; + UserActivityManager& operator=(const UserActivityManager&) = delete; - UserActivityManager(UserActivityManager&& other) noexcept = delete; - UserActivityManager& operator=(UserActivityManager&& other) noexcept = delete; + UserActivityManager(UserActivityManager&&) noexcept = delete; + UserActivityManager& operator=(UserActivityManager&&) noexcept = delete; ~UserActivityManager() override; diff --git a/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions.h b/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions.h index e70e313df0ea..f126d618a91a 100644 --- a/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions.h +++ b/components/brave_ads/core/internal/user_attention/user_reactions/user_reactions.h @@ -18,11 +18,11 @@ class UserReactions final : public HistoryManagerObserver { public: explicit UserReactions(Account* account); - UserReactions(const UserReactions& other) = delete; - UserReactions& operator=(const UserReactions& other) = delete; + UserReactions(const UserReactions&) = delete; + UserReactions& operator=(const UserReactions&) = delete; - UserReactions(UserReactions&& other) noexcept = delete; - UserReactions& operator=(UserReactions&& other) noexcept = delete; + UserReactions(UserReactions&&) noexcept = delete; + UserReactions& operator=(UserReactions&&) noexcept = delete; ~UserReactions() override; diff --git a/components/brave_ads/core/new_tab_page_ad_info.h b/components/brave_ads/core/new_tab_page_ad_info.h index f58df234a7bb..911bfab362aa 100644 --- a/components/brave_ads/core/new_tab_page_ad_info.h +++ b/components/brave_ads/core/new_tab_page_ad_info.h @@ -18,16 +18,16 @@ namespace brave_ads { struct ADS_EXPORT NewTabPageAdInfo final : AdInfo { NewTabPageAdInfo(); - NewTabPageAdInfo(const NewTabPageAdInfo& other); - NewTabPageAdInfo& operator=(const NewTabPageAdInfo& other); + NewTabPageAdInfo(const NewTabPageAdInfo&); + NewTabPageAdInfo& operator=(const NewTabPageAdInfo&); - NewTabPageAdInfo(NewTabPageAdInfo&& other) noexcept; - NewTabPageAdInfo& operator=(NewTabPageAdInfo&& other) noexcept; + NewTabPageAdInfo(NewTabPageAdInfo&&) noexcept; + NewTabPageAdInfo& operator=(NewTabPageAdInfo&&) noexcept; ~NewTabPageAdInfo(); - bool operator==(const NewTabPageAdInfo& other) const; - bool operator!=(const NewTabPageAdInfo& other) const; + bool operator==(const NewTabPageAdInfo&) const; + bool operator!=(const NewTabPageAdInfo&) const; bool IsValid() const; From 678986cb9c47d3eaef24b3064d0c84a3a6908f19 Mon Sep 17 00:00:00 2001 From: Terry Mancey Date: Wed, 12 Apr 2023 11:15:50 +0100 Subject: [PATCH 5/5] Cleanup Brave Ads operators --- components/brave_ads/core/ad_content_info.h | 4 ++-- components/brave_ads/core/ad_type.h | 4 ++-- components/brave_ads/core/category_content_info.h | 4 ++-- components/brave_ads/core/confirmation_type.h | 4 ++-- components/brave_ads/core/history_item_info.h | 4 ++-- .../internal/account/confirmations/confirmation_info.h | 4 ++-- .../core/internal/account/confirmations/opted_in_info.h | 4 ++-- .../account/confirmations/opted_in_user_data_info.h | 4 ++-- .../core/internal/catalog/campaign/catalog_daypart_info.h | 4 ++-- .../internal/catalog/campaign/catalog_geo_target_info.h | 6 ++---- .../catalog/campaign/creative_set/catalog_os_info.h | 4 ++-- .../catalog/campaign/creative_set/catalog_segment_info.h | 4 ++-- .../catalog_new_tab_page_ad_wallpaper_focal_point_info.h | 8 ++++---- .../catalog_promoted_content_ad_payload_info.h | 8 ++++---- components/brave_ads/core/internal/common/url/url_util.h | 2 +- .../core/internal/creatives/creative_daypart_info.h | 4 ++-- .../creative_new_tab_page_ad_wallpaper_focal_point_info.h | 8 ++++---- components/brave_ads/core/internal/ml/data/vector_data.h | 2 +- .../behavioral/conversions/conversion_id_pattern_info.h | 6 ++---- .../purchase_intent/purchase_intent_signal_history_info.h | 8 ++++---- .../brave_ads/core/internal/segments/segment_util.h | 2 +- .../user_activity/user_activity_event_info.h | 6 ++---- .../user_activity/user_activity_trigger_info.h | 6 ++---- .../core/new_tab_page_ad_wallpaper_focal_point_info.h | 8 ++++---- .../brave_ads/core/new_tab_page_ad_wallpaper_info.h | 8 ++++---- 25 files changed, 59 insertions(+), 67 deletions(-) diff --git a/components/brave_ads/core/ad_content_info.h b/components/brave_ads/core/ad_content_info.h index 588c1ad93ba2..6b0f32db961f 100644 --- a/components/brave_ads/core/ad_content_info.h +++ b/components/brave_ads/core/ad_content_info.h @@ -47,8 +47,8 @@ struct ADS_EXPORT AdContentInfo final { bool is_flagged = false; }; -bool operator==(const AdContentInfo& lhs, const AdContentInfo& rhs); -bool operator!=(const AdContentInfo& lhs, const AdContentInfo& rhs); +bool operator==(const AdContentInfo&, const AdContentInfo&); +bool operator!=(const AdContentInfo&, const AdContentInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/ad_type.h b/components/brave_ads/core/ad_type.h index 2db54a51a384..86a32cfa9826 100644 --- a/components/brave_ads/core/ad_type.h +++ b/components/brave_ads/core/ad_type.h @@ -40,8 +40,8 @@ class AdType final { Value value_ = kUndefined; }; -bool operator==(const AdType& lhs, const AdType& rhs); -bool operator!=(const AdType& lhs, const AdType& rhs); +bool operator==(const AdType&, const AdType&); +bool operator!=(const AdType&, const AdType&); std::ostream& operator<<(std::ostream& os, const AdType& type); diff --git a/components/brave_ads/core/category_content_info.h b/components/brave_ads/core/category_content_info.h index 4f7731da0624..e9450795a886 100644 --- a/components/brave_ads/core/category_content_info.h +++ b/components/brave_ads/core/category_content_info.h @@ -19,8 +19,8 @@ struct ADS_EXPORT CategoryContentInfo final { CategoryContentOptActionType::kNone; }; -bool operator==(const CategoryContentInfo& lhs, const CategoryContentInfo& rhs); -bool operator!=(const CategoryContentInfo& lhs, const CategoryContentInfo& rhs); +bool operator==(const CategoryContentInfo&, const CategoryContentInfo&); +bool operator!=(const CategoryContentInfo&, const CategoryContentInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/confirmation_type.h b/components/brave_ads/core/confirmation_type.h index 4e011caa2d0f..2995ff95c27e 100644 --- a/components/brave_ads/core/confirmation_type.h +++ b/components/brave_ads/core/confirmation_type.h @@ -44,8 +44,8 @@ class ConfirmationType final { Value value_ = kUndefined; }; -bool operator==(const ConfirmationType& lhs, const ConfirmationType& rhs); -bool operator!=(const ConfirmationType& lhs, const ConfirmationType& rhs); +bool operator==(const ConfirmationType&, const ConfirmationType&); +bool operator!=(const ConfirmationType&, const ConfirmationType&); std::ostream& operator<<(std::ostream& os, const ConfirmationType& type); diff --git a/components/brave_ads/core/history_item_info.h b/components/brave_ads/core/history_item_info.h index bb7df92871c4..d7e8070ed5f0 100644 --- a/components/brave_ads/core/history_item_info.h +++ b/components/brave_ads/core/history_item_info.h @@ -20,8 +20,8 @@ struct ADS_EXPORT HistoryItemInfo final { CategoryContentInfo category_content; }; -bool operator==(const HistoryItemInfo& lhs, const HistoryItemInfo& rhs); -bool operator!=(const HistoryItemInfo& lhs, const HistoryItemInfo& rhs); +bool operator==(const HistoryItemInfo&, const HistoryItemInfo&); +bool operator!=(const HistoryItemInfo&, const HistoryItemInfo&); using HistoryItemList = base::circular_deque; diff --git a/components/brave_ads/core/internal/account/confirmations/confirmation_info.h b/components/brave_ads/core/internal/account/confirmations/confirmation_info.h index 6bb368320d0e..8d772605e41f 100644 --- a/components/brave_ads/core/internal/account/confirmations/confirmation_info.h +++ b/components/brave_ads/core/internal/account/confirmations/confirmation_info.h @@ -37,8 +37,8 @@ struct ConfirmationInfo final { absl::optional opted_in; }; -bool operator==(const ConfirmationInfo& lhs, const ConfirmationInfo& rhs); -bool operator!=(const ConfirmationInfo& lhs, const ConfirmationInfo& rhs); +bool operator==(const ConfirmationInfo&, const ConfirmationInfo&); +bool operator!=(const ConfirmationInfo&, const ConfirmationInfo&); using ConfirmationList = std::vector; diff --git a/components/brave_ads/core/internal/account/confirmations/opted_in_info.h b/components/brave_ads/core/internal/account/confirmations/opted_in_info.h index 476c379e4228..5f7566ecfe9d 100644 --- a/components/brave_ads/core/internal/account/confirmations/opted_in_info.h +++ b/components/brave_ads/core/internal/account/confirmations/opted_in_info.h @@ -34,8 +34,8 @@ struct OptedInInfo final { absl::optional credential_base64url; }; -bool operator==(const OptedInInfo& lhs, const OptedInInfo& rhs); -bool operator!=(const OptedInInfo& lhs, const OptedInInfo& rhs); +bool operator==(const OptedInInfo&, const OptedInInfo&); +bool operator!=(const OptedInInfo&, const OptedInInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h b/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h index cac083d769dc..0dc92478b9c6 100644 --- a/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h +++ b/components/brave_ads/core/internal/account/confirmations/opted_in_user_data_info.h @@ -25,8 +25,8 @@ struct OptedInUserDataInfo final { base::Value::Dict fixed; }; -bool operator==(const OptedInUserDataInfo& lhs, const OptedInUserDataInfo& rhs); -bool operator!=(const OptedInUserDataInfo& lhs, const OptedInUserDataInfo& rhs); +bool operator==(const OptedInUserDataInfo&, const OptedInUserDataInfo&); +bool operator!=(const OptedInUserDataInfo&, const OptedInUserDataInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/catalog/campaign/catalog_daypart_info.h b/components/brave_ads/core/internal/catalog/campaign/catalog_daypart_info.h index 8982ce0c9689..d01759f226b8 100644 --- a/components/brave_ads/core/internal/catalog/campaign/catalog_daypart_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/catalog_daypart_info.h @@ -19,8 +19,8 @@ struct CatalogDaypartInfo final { int end_minute = (base::Time::kMinutesPerHour * base::Time::kHoursPerDay) - 1; }; -bool operator==(const CatalogDaypartInfo& lhs, const CatalogDaypartInfo& rhs); -bool operator!=(const CatalogDaypartInfo& lhs, const CatalogDaypartInfo& rhs); +bool operator==(const CatalogDaypartInfo&, const CatalogDaypartInfo&); +bool operator!=(const CatalogDaypartInfo&, const CatalogDaypartInfo&); using CatalogDaypartList = std::vector; diff --git a/components/brave_ads/core/internal/catalog/campaign/catalog_geo_target_info.h b/components/brave_ads/core/internal/catalog/campaign/catalog_geo_target_info.h index 729215a6e32c..121110249502 100644 --- a/components/brave_ads/core/internal/catalog/campaign/catalog_geo_target_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/catalog_geo_target_info.h @@ -16,10 +16,8 @@ struct CatalogGeoTargetInfo final { std::string name; }; -bool operator==(const CatalogGeoTargetInfo& lhs, - const CatalogGeoTargetInfo& rhs); -bool operator!=(const CatalogGeoTargetInfo& lhs, - const CatalogGeoTargetInfo& rhs); +bool operator==(const CatalogGeoTargetInfo&, const CatalogGeoTargetInfo&); +bool operator!=(const CatalogGeoTargetInfo&, const CatalogGeoTargetInfo&); using CatalogGeoTargetList = std::vector; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_os_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_os_info.h index 8386c04ca2e1..67fa26ca0982 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_os_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_os_info.h @@ -16,8 +16,8 @@ struct CatalogOsInfo final { std::string name; }; -bool operator==(const CatalogOsInfo& lhs, const CatalogOsInfo& rhs); -bool operator!=(const CatalogOsInfo& lhs, const CatalogOsInfo& rhs); +bool operator==(const CatalogOsInfo&, const CatalogOsInfo&); +bool operator!=(const CatalogOsInfo&, const CatalogOsInfo&); using CatalogOsList = std::vector; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_segment_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_segment_info.h index 89395f4fa7ae..d77005db6ca9 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_segment_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/catalog_segment_info.h @@ -16,8 +16,8 @@ struct CatalogSegmentInfo final { std::string name; }; -bool operator==(const CatalogSegmentInfo& lhs, const CatalogSegmentInfo& rhs); -bool operator!=(const CatalogSegmentInfo& lhs, const CatalogSegmentInfo& rhs); +bool operator==(const CatalogSegmentInfo&, const CatalogSegmentInfo&); +bool operator!=(const CatalogSegmentInfo&, const CatalogSegmentInfo&); using CatalogSegmentList = std::vector; diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_focal_point_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_focal_point_info.h index 803834b91f16..46025b5dc94a 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_focal_point_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/new_tab_page_ad/catalog_new_tab_page_ad_wallpaper_focal_point_info.h @@ -13,10 +13,10 @@ struct CatalogNewTabPageAdWallpaperFocalPointInfo final { int y = 0; }; -bool operator==(const CatalogNewTabPageAdWallpaperFocalPointInfo& lhs, - const CatalogNewTabPageAdWallpaperFocalPointInfo& rhs); -bool operator!=(const CatalogNewTabPageAdWallpaperFocalPointInfo& lhs, - const CatalogNewTabPageAdWallpaperFocalPointInfo& rhs); +bool operator==(const CatalogNewTabPageAdWallpaperFocalPointInfo&, + const CatalogNewTabPageAdWallpaperFocalPointInfo&); +bool operator!=(const CatalogNewTabPageAdWallpaperFocalPointInfo&, + const CatalogNewTabPageAdWallpaperFocalPointInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_promoted_content_ad_payload_info.h b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_promoted_content_ad_payload_info.h index 9d363d8ec663..f1964d94be2a 100644 --- a/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_promoted_content_ad_payload_info.h +++ b/components/brave_ads/core/internal/catalog/campaign/creative_set/creative/promoted_content_ad/catalog_promoted_content_ad_payload_info.h @@ -18,10 +18,10 @@ struct CatalogPromotedContentAdPayloadInfo final { GURL target_url; }; -bool operator==(const CatalogPromotedContentAdPayloadInfo& lhs, - const CatalogPromotedContentAdPayloadInfo& rhs); -bool operator!=(const CatalogPromotedContentAdPayloadInfo& lhs, - const CatalogPromotedContentAdPayloadInfo& rhs); +bool operator==(const CatalogPromotedContentAdPayloadInfo&, + const CatalogPromotedContentAdPayloadInfo&); +bool operator!=(const CatalogPromotedContentAdPayloadInfo&, + const CatalogPromotedContentAdPayloadInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/common/url/url_util.h b/components/brave_ads/core/internal/common/url/url_util.h index fbe35dcbd86f..38f5e54ca6d8 100644 --- a/components/brave_ads/core/internal/common/url/url_util.h +++ b/components/brave_ads/core/internal/common/url/url_util.h @@ -19,7 +19,7 @@ bool SchemeIsSupported(const GURL& url); bool MatchUrlPattern(const GURL& url, const std::string& pattern); -bool SameDomainOrHost(const GURL& lhs, const GURL& rhs); +bool SameDomainOrHost(const GURL&, const GURL&); bool DomainOrHostExists(const std::vector& urls, const GURL& url); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/creatives/creative_daypart_info.h b/components/brave_ads/core/internal/creatives/creative_daypart_info.h index a04c5737a401..b44328c5659b 100644 --- a/components/brave_ads/core/internal/creatives/creative_daypart_info.h +++ b/components/brave_ads/core/internal/creatives/creative_daypart_info.h @@ -19,8 +19,8 @@ struct CreativeDaypartInfo final { int end_minute = (base::Time::kMinutesPerHour * base::Time::kHoursPerDay) - 1; }; -bool operator==(const CreativeDaypartInfo& lhs, const CreativeDaypartInfo& rhs); -bool operator!=(const CreativeDaypartInfo& lhs, const CreativeDaypartInfo& rhs); +bool operator==(const CreativeDaypartInfo&, const CreativeDaypartInfo&); +bool operator!=(const CreativeDaypartInfo&, const CreativeDaypartInfo&); using CreativeDaypartList = std::vector; diff --git a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_focal_point_info.h b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_focal_point_info.h index d2a8c6844f82..1454cdb59fbc 100644 --- a/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_focal_point_info.h +++ b/components/brave_ads/core/internal/creatives/new_tab_page_ads/creative_new_tab_page_ad_wallpaper_focal_point_info.h @@ -13,10 +13,10 @@ struct CreativeNewTabPageAdWallpaperFocalPointInfo final { int y = 0; }; -bool operator==(const CreativeNewTabPageAdWallpaperFocalPointInfo& lhs, - const CreativeNewTabPageAdWallpaperFocalPointInfo& rhs); -bool operator!=(const CreativeNewTabPageAdWallpaperFocalPointInfo& lhs, - const CreativeNewTabPageAdWallpaperFocalPointInfo& rhs); +bool operator==(const CreativeNewTabPageAdWallpaperFocalPointInfo&, + const CreativeNewTabPageAdWallpaperFocalPointInfo&); +bool operator!=(const CreativeNewTabPageAdWallpaperFocalPointInfo&, + const CreativeNewTabPageAdWallpaperFocalPointInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/internal/ml/data/vector_data.h b/components/brave_ads/core/internal/ml/data/vector_data.h index fe95783f45ae..78d9a8724d2f 100644 --- a/components/brave_ads/core/internal/ml/data/vector_data.h +++ b/components/brave_ads/core/internal/ml/data/vector_data.h @@ -41,7 +41,7 @@ class VectorData final : public Data { ~VectorData() override; // Mathematical vector operations - friend float operator*(const VectorData& lhs, const VectorData& rhs); + friend float operator*(const VectorData&, const VectorData&); float ComputeSimilarity(const VectorData& other) const; void AddElementWise(const VectorData& other); diff --git a/components/brave_ads/core/internal/resources/behavioral/conversions/conversion_id_pattern_info.h b/components/brave_ads/core/internal/resources/behavioral/conversions/conversion_id_pattern_info.h index c2321844cb65..cbe65e745850 100644 --- a/components/brave_ads/core/internal/resources/behavioral/conversions/conversion_id_pattern_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/conversions/conversion_id_pattern_info.h @@ -17,10 +17,8 @@ struct ConversionIdPatternInfo final { std::string search_in; }; -bool operator==(const ConversionIdPatternInfo& lhs, - const ConversionIdPatternInfo& rhs); -bool operator!=(const ConversionIdPatternInfo& lhs, - const ConversionIdPatternInfo& rhs); +bool operator==(const ConversionIdPatternInfo&, const ConversionIdPatternInfo&); +bool operator!=(const ConversionIdPatternInfo&, const ConversionIdPatternInfo&); using ConversionIdPatternMap = std::map; diff --git a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_signal_history_info.h b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_signal_history_info.h index be303df8e032..6661209e1f7b 100644 --- a/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_signal_history_info.h +++ b/components/brave_ads/core/internal/resources/behavioral/purchase_intent/purchase_intent_signal_history_info.h @@ -22,10 +22,10 @@ struct PurchaseIntentSignalHistoryInfo final { uint16_t weight = 0; }; -bool operator==(const PurchaseIntentSignalHistoryInfo& lhs, - const PurchaseIntentSignalHistoryInfo& rhs); -bool operator!=(const PurchaseIntentSignalHistoryInfo& lhs, - const PurchaseIntentSignalHistoryInfo& rhs); +bool operator==(const PurchaseIntentSignalHistoryInfo&, + const PurchaseIntentSignalHistoryInfo&); +bool operator!=(const PurchaseIntentSignalHistoryInfo&, + const PurchaseIntentSignalHistoryInfo&); using PurchaseIntentSignalHistoryList = std::vector; diff --git a/components/brave_ads/core/internal/segments/segment_util.h b/components/brave_ads/core/internal/segments/segment_util.h index 689132e47c91..acb590842b2e 100644 --- a/components/brave_ads/core/internal/segments/segment_util.h +++ b/components/brave_ads/core/internal/segments/segment_util.h @@ -31,7 +31,7 @@ SegmentList GetSegments(const T& creative_ads) { std::string GetParentSegment(const std::string& segment); -bool MatchParentSegments(const std::string& lhs, const std::string& rhs); +bool MatchParentSegments(const std::string&, const std::string&); SegmentList GetParentSegments(const SegmentList& segments); bool HasChildSegment(const std::string& segment); diff --git a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_event_info.h b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_event_info.h index 1b5e8eb548fa..26dc07887d26 100644 --- a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_event_info.h +++ b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_event_info.h @@ -17,10 +17,8 @@ struct UserActivityEventInfo final { base::Time created_at; }; -bool operator==(const UserActivityEventInfo& lhs, - const UserActivityEventInfo& rhs); -bool operator!=(const UserActivityEventInfo& lhs, - const UserActivityEventInfo& rhs); +bool operator==(const UserActivityEventInfo&, const UserActivityEventInfo&); +bool operator!=(const UserActivityEventInfo&, const UserActivityEventInfo&); using UserActivityEventList = base::circular_deque; diff --git a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_trigger_info.h b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_trigger_info.h index 0105d737375b..6253a3d7d70a 100644 --- a/components/brave_ads/core/internal/user_attention/user_activity/user_activity_trigger_info.h +++ b/components/brave_ads/core/internal/user_attention/user_activity/user_activity_trigger_info.h @@ -16,10 +16,8 @@ struct UserActivityTriggerInfo final { double score = 0.0; }; -bool operator==(const UserActivityTriggerInfo& lhs, - const UserActivityTriggerInfo& rhs); -bool operator!=(const UserActivityTriggerInfo& lhs, - const UserActivityTriggerInfo& rhs); +bool operator==(const UserActivityTriggerInfo&, const UserActivityTriggerInfo&); +bool operator!=(const UserActivityTriggerInfo&, const UserActivityTriggerInfo&); using UserActivityTriggerList = std::vector; diff --git a/components/brave_ads/core/new_tab_page_ad_wallpaper_focal_point_info.h b/components/brave_ads/core/new_tab_page_ad_wallpaper_focal_point_info.h index 6225e741783f..c82dd23d9505 100644 --- a/components/brave_ads/core/new_tab_page_ad_wallpaper_focal_point_info.h +++ b/components/brave_ads/core/new_tab_page_ad_wallpaper_focal_point_info.h @@ -15,10 +15,10 @@ struct ADS_EXPORT NewTabPageAdWallpaperFocalPointInfo final { int y = 0; }; -bool operator==(const NewTabPageAdWallpaperFocalPointInfo& lhs, - const NewTabPageAdWallpaperFocalPointInfo& rhs); -bool operator!=(const NewTabPageAdWallpaperFocalPointInfo& lhs, - const NewTabPageAdWallpaperFocalPointInfo& rhs); +bool operator==(const NewTabPageAdWallpaperFocalPointInfo&, + const NewTabPageAdWallpaperFocalPointInfo&); +bool operator!=(const NewTabPageAdWallpaperFocalPointInfo&, + const NewTabPageAdWallpaperFocalPointInfo&); } // namespace brave_ads diff --git a/components/brave_ads/core/new_tab_page_ad_wallpaper_info.h b/components/brave_ads/core/new_tab_page_ad_wallpaper_info.h index 664e3dd80619..9cb7112d1f11 100644 --- a/components/brave_ads/core/new_tab_page_ad_wallpaper_info.h +++ b/components/brave_ads/core/new_tab_page_ad_wallpaper_info.h @@ -19,10 +19,10 @@ struct ADS_EXPORT NewTabPageAdWallpaperInfo final { NewTabPageAdWallpaperFocalPointInfo focal_point; }; -bool operator==(const NewTabPageAdWallpaperInfo& lhs, - const NewTabPageAdWallpaperInfo& rhs); -bool operator!=(const NewTabPageAdWallpaperInfo& lhs, - const NewTabPageAdWallpaperInfo& rhs); +bool operator==(const NewTabPageAdWallpaperInfo&, + const NewTabPageAdWallpaperInfo&); +bool operator!=(const NewTabPageAdWallpaperInfo&, + const NewTabPageAdWallpaperInfo&); using NewTabPageAdWallpaperList = std::vector;