-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20395 from brave/issues/31564
Add additional Brave Ads Griffin support
- Loading branch information
Showing
73 changed files
with
1,169 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
components/brave_ads/core/internal/account/confirmations/confirmations_feature.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* 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/account/confirmations/confirmations_feature.h" // IWYU pragma: keep | ||
|
||
namespace brave_ads { | ||
|
||
BASE_FEATURE(kConfirmationsFeature, | ||
"Confirmations", | ||
base::FEATURE_ENABLED_BY_DEFAULT); | ||
|
||
} // namespace brave_ads |
25 changes: 25 additions & 0 deletions
25
components/brave_ads/core/internal/account/confirmations/confirmations_feature.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ACCOUNT_CONFIRMATIONS_CONFIRMATIONS_FEATURE_H_ | ||
#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_CONFIRMATIONS_CONFIRMATIONS_FEATURE_H_ | ||
|
||
#include "base/feature_list.h" | ||
#include "base/metrics/field_trial_params.h" | ||
|
||
namespace base { | ||
class TimeDelta; | ||
} // namespace base | ||
|
||
namespace brave_ads { | ||
|
||
BASE_DECLARE_FEATURE(kConfirmationsFeature); | ||
|
||
constexpr base::FeatureParam<base::TimeDelta> kProcessConfirmationAfter{ | ||
&kConfirmationsFeature, "process_after", base::Seconds(15)}; | ||
|
||
} // namespace brave_ads | ||
|
||
#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_CONFIRMATIONS_CONFIRMATIONS_FEATURE_H_ |
66 changes: 66 additions & 0 deletions
66
components/brave_ads/core/internal/account/confirmations/confirmations_feature_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* 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/account/confirmations/confirmations_feature.h" | ||
|
||
#include "base/test/scoped_feature_list.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
// npm run test -- brave_unit_tests --filter=BraveAds* | ||
|
||
namespace brave_ads { | ||
|
||
TEST(BraveAdsConfirmationsFeatureTest, IsEnabled) { | ||
// Arrange | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_TRUE(base::FeatureList::IsEnabled(kConfirmationsFeature)); | ||
} | ||
|
||
TEST(BraveAdsConfirmationsFeatureTest, IsDisabled) { | ||
// Arrange | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
scoped_feature_list.InitAndDisableFeature(kConfirmationsFeature); | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_FALSE(base::FeatureList::IsEnabled(kConfirmationsFeature)); | ||
} | ||
|
||
TEST(BraveAdsConfirmationsFeatureTest, ProcessConfirmationAfter) { | ||
// Arrange | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
scoped_feature_list.InitAndEnableFeatureWithParameters( | ||
kConfirmationsFeature, {{"process_after", "3h"}}); | ||
// Act | ||
|
||
// Assert | ||
EXPECT_EQ(base::Hours(3), kProcessConfirmationAfter.Get()); | ||
} | ||
|
||
TEST(BraveAdsConfirmationsFeatureTest, DefaultProcessConfirmationAfter) { | ||
// Arrange | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_EQ(base::Seconds(15), kProcessConfirmationAfter.Get()); | ||
} | ||
|
||
TEST(BraveAdsConfirmationsFeatureTest, | ||
DefaultProcessConfirmationAfterWhenDisabled) { | ||
// Arrange | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_EQ(base::Seconds(15), kProcessConfirmationAfter.Get()); | ||
} | ||
|
||
} // namespace brave_ads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
components/brave_ads/core/internal/account/issuers/issuers_feature.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* 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/account/issuers/issuers_feature.h" // IWYU pragma: keep | ||
|
||
namespace brave_ads { | ||
|
||
BASE_FEATURE(kIssuersFeature, "Issuers", base::FEATURE_ENABLED_BY_DEFAULT); | ||
|
||
} // namespace brave_ads |
21 changes: 21 additions & 0 deletions
21
components/brave_ads/core/internal/account/issuers/issuers_feature.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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_ACCOUNT_ISSUERS_ISSUERS_FEATURE_H_ | ||
#define BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_ISSUERS_ISSUERS_FEATURE_H_ | ||
|
||
#include "base/feature_list.h" | ||
#include "base/metrics/field_trial_params.h" | ||
|
||
namespace brave_ads { | ||
|
||
BASE_DECLARE_FEATURE(kIssuersFeature); | ||
|
||
constexpr base::FeatureParam<int> kMaximumIssuerPublicKeys{ | ||
&kIssuersFeature, "maximum_public_keys", 6}; | ||
|
||
} // namespace brave_ads | ||
|
||
#endif // BRAVE_COMPONENTS_BRAVE_ADS_CORE_INTERNAL_ACCOUNT_ISSUERS_ISSUERS_FEATURE_H_ |
67 changes: 67 additions & 0 deletions
67
components/brave_ads/core/internal/account/issuers/issuers_feature_unittest.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* 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/account/issuers/issuers_feature.h" | ||
|
||
#include "base/test/scoped_feature_list.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
// npm run test -- brave_unit_tests --filter=BraveAds* | ||
|
||
namespace brave_ads { | ||
|
||
TEST(BraveAdsIssuersFeatureTest, IsEnabled) { | ||
// Arrange | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_TRUE(base::FeatureList::IsEnabled(kIssuersFeature)); | ||
} | ||
|
||
TEST(BraveAdsIssuersFeatureTest, IsDisabled) { | ||
// Arrange | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
scoped_feature_list.InitAndDisableFeature(kIssuersFeature); | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_FALSE(base::FeatureList::IsEnabled(kIssuersFeature)); | ||
} | ||
|
||
TEST(BraveAdsIssuersFeatureTest, MaximumIssuerPublicKeys) { | ||
// Arrange | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
scoped_feature_list.InitAndEnableFeatureWithParameters( | ||
kIssuersFeature, {{"maximum_public_keys", "1"}}); | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_EQ(1, kMaximumIssuerPublicKeys.Get()); | ||
} | ||
|
||
TEST(BraveAdsIssuersFeatureTest, DefaultMaximumIssuerPublicKeys) { | ||
// Arrange | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_EQ(6, kMaximumIssuerPublicKeys.Get()); | ||
} | ||
|
||
TEST(BraveAdsIssuersFeatureTest, DefaultMaximumIssuerPublicKeysWhenDisabled) { | ||
// Arrange | ||
base::test::ScopedFeatureList scoped_feature_list; | ||
scoped_feature_list.InitAndDisableFeature(kIssuersFeature); | ||
|
||
// Act | ||
|
||
// Assert | ||
EXPECT_EQ(6, kMaximumIssuerPublicKeys.Get()); | ||
} | ||
|
||
} // namespace brave_ads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.