[Android] Fix BraveAdsAdsServiceImplTest on is_official_build x86 (#35792)
brave_rewards::features::kBraveRewards is DISABLED_BY_DEFAULT on x86/x86_64 Android official builds, so brave_rewards::IsSupported returned false via IsDisabledByFeature. After https://github.com/brave/brave-core/pull/35698 moved the IsSupported gate into AdsServiceImpl::CanStartBatAdsService, that path now suppresses the service in unit tests too and launch_count stays 0. Force-enable the feature in the fixture so Android tests match the non-Android path they were written against. Resolves: https://github.com/brave/brave-browser/issues/54831
This commit is contained in:
@@ -144,6 +144,7 @@ source_set("unit_tests") {
|
||||
"//brave/components/brave_ads/core/public:headers",
|
||||
"//brave/components/brave_component_updater/browser",
|
||||
"//brave/components/brave_rewards/core",
|
||||
"//brave/components/brave_rewards/core:features",
|
||||
"//brave/components/brave_rewards/core/buildflags",
|
||||
"//brave/components/ntp_background_images/common",
|
||||
"//components/content_settings/core/browser",
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "base/files/scoped_temp_dir.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/test/run_until.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "base/test/task_environment.h"
|
||||
#include "base/values.h"
|
||||
#include "brave/components/brave_ads/browser/test/fake_ads_service_delegate.h"
|
||||
@@ -21,6 +22,7 @@
|
||||
#include "brave/components/brave_ads/core/public/prefs/pref_names.h"
|
||||
#include "brave/components/brave_ads/core/public/prefs/pref_registry.h"
|
||||
#include "brave/components/brave_rewards/core/buildflags/buildflags.h"
|
||||
#include "brave/components/brave_rewards/core/features.h"
|
||||
#include "brave/components/brave_rewards/core/pref_names.h"
|
||||
#include "brave/components/brave_rewards/core/pref_registry.h"
|
||||
#include "brave/components/ntp_background_images/common/pref_names.h"
|
||||
@@ -41,6 +43,16 @@ namespace brave_ads {
|
||||
class BraveAdsAdsServiceImplTest : public testing::Test {
|
||||
public:
|
||||
void SetUp() override {
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
// `brave_rewards::features::kBraveRewards` is `DISABLED_BY_DEFAULT` on
|
||||
// `is_official_build=true` x86/x86_64 Android, which routes
|
||||
// `brave_rewards::IsSupported` through `IsDisabledByFeature` and prevents
|
||||
// the service from starting. Force-enable so Android matches the
|
||||
// non-Android path these tests were written against.
|
||||
scoped_feature_list_.InitAndEnableFeature(
|
||||
brave_rewards::features::kBraveRewards);
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
ASSERT_TRUE(profile_dir_.CreateUniqueTempDir());
|
||||
|
||||
RegisterProfilePrefs(prefs_.registry());
|
||||
@@ -95,6 +107,10 @@ class BraveAdsAdsServiceImplTest : public testing::Test {
|
||||
|
||||
void Shutdown() { ads_service_->Shutdown(); }
|
||||
|
||||
#if BUILDFLAG(IS_ANDROID)
|
||||
base::test::ScopedFeatureList scoped_feature_list_;
|
||||
#endif // BUILDFLAG(IS_ANDROID)
|
||||
|
||||
base::test::TaskEnvironment task_environment_;
|
||||
|
||||
base::ScopedTempDir profile_dir_;
|
||||
|
||||
Reference in New Issue
Block a user