Commit 3674f5a4 authored by Sophie Chang's avatar Sophie Chang Committed by Commit Bot

Remove drp checks in hints manager test

Change-Id: I6b311605c30c150a47b8dac52e444d9ddf1a28a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2019412Reviewed-by: default avatarMichael Crouse <mcrouse@chromium.org>
Commit-Queue: Sophie Chang <sophiechang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735135}
parent f56fc9fc
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
#include "chrome/browser/previews/previews_service.h" #include "chrome/browser/previews/previews_service.h"
#include "chrome/browser/previews/previews_service_factory.h" #include "chrome/browser/previews/previews_service_factory.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
#include "components/optimization_guide/bloom_filter.h" #include "components/optimization_guide/bloom_filter.h"
#include "components/optimization_guide/hints_component_util.h" #include "components/optimization_guide/hints_component_util.h"
#include "components/optimization_guide/hints_fetcher.h" #include "components/optimization_guide/hints_fetcher.h"
...@@ -34,7 +32,6 @@ ...@@ -34,7 +32,6 @@
#include "components/optimization_guide/proto_database_provider_test_base.h" #include "components/optimization_guide/proto_database_provider_test_base.h"
#include "components/optimization_guide/top_host_provider.h" #include "components/optimization_guide/top_host_provider.h"
#include "components/prefs/testing_pref_service.h" #include "components/prefs/testing_pref_service.h"
#include "components/previews/core/previews_switches.h"
#include "content/public/test/browser_task_environment.h" #include "content/public/test/browser_task_environment.h"
#include "content/public/test/mock_navigation_handle.h" #include "content/public/test/mock_navigation_handle.h"
#include "content/public/test/test_web_contents_factory.h" #include "content/public/test/test_web_contents_factory.h"
...@@ -234,20 +231,13 @@ class OptimizationGuideHintsManagerTest ...@@ -234,20 +231,13 @@ class OptimizationGuideHintsManagerTest
void SetUp() override { void SetUp() override {
optimization_guide::ProtoDatabaseProviderTestBase::SetUp(); optimization_guide::ProtoDatabaseProviderTestBase::SetUp();
web_contents_factory_.reset(new content::TestWebContentsFactory); web_contents_factory_.reset(new content::TestWebContentsFactory);
drp_test_context_ =
data_reduction_proxy::DataReductionProxyTestContext::Builder()
.WithMockConfig()
.Build();
CreateServiceAndHintsManager( CreateServiceAndHintsManager(
/*optimization_types_at_initialization=*/{}, /*optimization_types_at_initialization=*/{},
/*top_host_provider=*/nullptr); /*top_host_provider=*/nullptr);
base::CommandLine::ForCurrentProcess()->AppendSwitch(
data_reduction_proxy::switches::kEnableDataReductionProxy);
} }
void TearDown() override { void TearDown() override {
optimization_guide::ProtoDatabaseProviderTestBase::TearDown(); optimization_guide::ProtoDatabaseProviderTestBase::TearDown();
drp_test_context_->DestroySettings();
ResetHintsManager(); ResetHintsManager();
} }
...@@ -353,23 +343,6 @@ class OptimizationGuideHintsManagerTest ...@@ -353,23 +343,6 @@ class OptimizationGuideHintsManagerTest
RunUntilIdle(); RunUntilIdle();
} }
void SetUserPermissions(bool data_saver_enabled, bool has_seen_infobar) {
drp_test_context_->SetDataReductionProxyEnabled(data_saver_enabled);
// Make sure infobar not shown.
PreviewsService* previews_service =
PreviewsServiceFactory::GetForProfile(&testing_profile_);
PreviewsLitePageRedirectDecider* decider =
previews_service->previews_lite_page_redirect_decider();
// Initialize settings here so Lite Pages Decider checks for the Data Saver
// bit.
decider->OnSettingsInitialized();
if (has_seen_infobar) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
previews::switches::kDoNotRequireLitePageRedirectInfoBar);
}
}
// Creates a navigation handle with the OptimizationGuideWebContentsObserver // Creates a navigation handle with the OptimizationGuideWebContentsObserver
// attached. // attached.
std::unique_ptr<content::MockNavigationHandle> std::unique_ptr<content::MockNavigationHandle>
...@@ -427,8 +400,6 @@ class OptimizationGuideHintsManagerTest ...@@ -427,8 +400,6 @@ class OptimizationGuideHintsManagerTest
base::test::TaskEnvironment::MainThreadType::UI, base::test::TaskEnvironment::MainThreadType::UI,
base::test::TaskEnvironment::TimeSource::MOCK_TIME}; base::test::TaskEnvironment::TimeSource::MOCK_TIME};
TestingProfile testing_profile_; TestingProfile testing_profile_;
std::unique_ptr<data_reduction_proxy::DataReductionProxyTestContext>
drp_test_context_;
std::unique_ptr<content::TestWebContentsFactory> web_contents_factory_; std::unique_ptr<content::TestWebContentsFactory> web_contents_factory_;
std::unique_ptr<OptimizationGuideHintsManager> hints_manager_; std::unique_ptr<OptimizationGuideHintsManager> hints_manager_;
std::unique_ptr<TestOptimizationGuideService> optimization_guide_service_; std::unique_ptr<TestOptimizationGuideService> optimization_guide_service_;
...@@ -1840,7 +1811,9 @@ class OptimizationGuideHintsManagerFetchingDisabledTest ...@@ -1840,7 +1811,9 @@ class OptimizationGuideHintsManagerFetchingDisabledTest
TEST_F(OptimizationGuideHintsManagerFetchingDisabledTest, TEST_F(OptimizationGuideHintsManagerFetchingDisabledTest,
HintsFetchNotAllowedIfFeatureIsNotEnabled) { HintsFetchNotAllowedIfFeatureIsNotEnabled) {
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>( std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"})); std::vector<std::string>({"example1.com", "example2.com"}));
...@@ -1867,27 +1840,14 @@ class OptimizationGuideHintsManagerFetchingTest ...@@ -1867,27 +1840,14 @@ class OptimizationGuideHintsManagerFetchingTest
}; };
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetchNotAllowedIfFeatureIsEnabledButTopHostProviderIsNotProvided) { HintsFetchNotAllowedIfFeatureIsEnabledButUserNotAllowed) {
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->RemoveSwitch(
CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{}, optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
/*top_host_provider=*/nullptr);
hints_manager()->SetHintsFetcherForTesting(
BuildTestHintsFetcher(HintsFetcherEndState::kFetchSuccessWithHostHints));
InitializeWithDefaultConfig("1.0.0");
// Force timer to expire and schedule a hints fetch.
MoveClockForwardBy(base::TimeDelta::FromSeconds(kTestFetchRetryDelaySecs));
EXPECT_FALSE(hints_fetcher()->hints_fetched());
}
TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetchNotAllowedIfFeatureIsEnabledButDataSaverIsNotEnabled) {
SetUserPermissions(/*data_saver_enabled=*/false, /*has_seen_infobar=*/true);
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>( std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"})); std::vector<std::string>({"example1.com", "example2.com"}));
CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{}, CreateServiceAndHintsManager({optimization_guide::proto::DEFER_ALL_SCRIPT},
top_host_provider.get()); top_host_provider.get());
hints_manager()->SetHintsFetcherForTesting( hints_manager()->SetHintsFetcherForTesting(
BuildTestHintsFetcher(HintsFetcherEndState::kFetchSuccessWithHostHints)); BuildTestHintsFetcher(HintsFetcherEndState::kFetchSuccessWithHostHints));
...@@ -1895,62 +1855,32 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -1895,62 +1855,32 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
// Force timer to expire and schedule a hints fetch. // Force timer to expire and schedule a hints fetch.
MoveClockForwardBy(base::TimeDelta::FromSeconds(kTestFetchRetryDelaySecs)); MoveClockForwardBy(base::TimeDelta::FromSeconds(kTestFetchRetryDelaySecs));
EXPECT_EQ(0, top_host_provider->get_num_top_hosts_called());
EXPECT_FALSE(hints_fetcher()->hints_fetched()); EXPECT_FALSE(hints_fetcher()->hints_fetched());
} }
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetchAllowedIfFeatureIsEnabledAndDataSaverUserHasNotSeenInfobar) { HintsFetchNotAllowedIfFeatureIsEnabledButTopHostProviderIsNotProvided) {
std::unique_ptr<FakeTopHostProvider> top_host_provider = base::CommandLine::ForCurrentProcess()->AppendSwitch(
std::make_unique<FakeTopHostProvider>( optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
std::vector<std::string>({"example1.com", "example2.com"})); CreateServiceAndHintsManager({optimization_guide::proto::DEFER_ALL_SCRIPT},
/*top_host_provider=*/nullptr);
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/false);
CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{},
top_host_provider.get());
hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT});
hints_manager()->SetHintsFetcherForTesting( hints_manager()->SetHintsFetcherForTesting(
BuildTestHintsFetcher(HintsFetcherEndState::kFetchSuccessWithHostHints)); BuildTestHintsFetcher(HintsFetcherEndState::kFetchSuccessWithHostHints));
InitializeWithDefaultConfig("1.0.0"); InitializeWithDefaultConfig("1.0.0");
// Force timer to expire and schedule a hints fetch. // Force timer to expire and schedule a hints fetch.
MoveClockForwardBy(base::TimeDelta::FromSeconds(kTestFetchRetryDelaySecs)); MoveClockForwardBy(base::TimeDelta::FromSeconds(kTestFetchRetryDelaySecs));
EXPECT_EQ(0, top_host_provider->get_num_top_hosts_called());
EXPECT_FALSE(hints_fetcher()->hints_fetched()); EXPECT_FALSE(hints_fetcher()->hints_fetched());
} }
TEST_F(
OptimizationGuideHintsManagerFetchingTest,
HintsFetchAllowedIfFeatureIsEnabledAndUserMeetsAllDataSaverUserCriteria) {
std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"}));
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true);
CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{},
top_host_provider.get());
hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT});
hints_manager()->SetHintsFetcherForTesting(
BuildTestHintsFetcher(HintsFetcherEndState::kFetchSuccessWithHostHints));
InitializeWithDefaultConfig("1.0.0");
// Force timer to expire and schedule a hints fetch.
MoveClockForwardBy(base::TimeDelta::FromSeconds(kTestFetchRetryDelaySecs));
EXPECT_EQ(1, top_host_provider->get_num_top_hosts_called());
EXPECT_TRUE(hints_fetcher()->hints_fetched());
}
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
NoRegisteredOptimizationTypesAndHintsFetchNotAttempted) { NoRegisteredOptimizationTypesAndHintsFetchNotAttempted) {
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>( std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"})); std::vector<std::string>({"example1.com", "example2.com"}));
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{}, CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{},
top_host_provider.get()); top_host_provider.get());
...@@ -1966,7 +1896,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -1966,7 +1896,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetcherEnabledNoHostsToFetch) { HintsFetcherEnabledNoHostsToFetch) {
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>(std::vector<std::string>({})); std::make_unique<FakeTopHostProvider>(std::vector<std::string>({}));
CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{}, CreateServiceAndHintsManager(/*optimization_types_at_initialization=*/{},
...@@ -1986,7 +1917,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -1986,7 +1917,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetcherEnabledWithHostsNoHintsInResponse) { HintsFetcherEnabledWithHostsNoHintsInResponse) {
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>( std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"})); std::vector<std::string>({"example1.com", "example2.com"}));
...@@ -2012,7 +1944,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2012,7 +1944,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
} }
TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetcherTimerRetryDelay) { TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetcherTimerRetryDelay) {
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>( std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"})); std::vector<std::string>({"example1.com", "example2.com"}));
...@@ -2041,7 +1974,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetcherTimerRetryDelay) { ...@@ -2041,7 +1974,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetcherTimerRetryDelay) {
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetcherTimerFetchSucceeds) { HintsFetcherTimerFetchSucceeds) {
SetUserPermissions(/*data_saver_enabled=*/true, /*has_seen_infobar=*/true); base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
std::unique_ptr<FakeTopHostProvider> top_host_provider = std::unique_ptr<FakeTopHostProvider> top_host_provider =
std::make_unique<FakeTopHostProvider>( std::make_unique<FakeTopHostProvider>(
std::vector<std::string>({"example1.com", "example2.com"})); std::vector<std::string>({"example1.com", "example2.com"}));
...@@ -2073,6 +2007,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2073,6 +2007,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetched_AtSRP_ECT_SLOW_2G) { HintsFetched_AtSRP_ECT_SLOW_2G) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2096,6 +2032,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2096,6 +2032,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetched_AtSRP_NoRegisteredOptimizationTypes) { HintsFetched_AtSRP_NoRegisteredOptimizationTypes) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
// Set ECT estimate so hint is activated. // Set ECT estimate so hint is activated.
...@@ -2117,6 +2055,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2117,6 +2055,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetched_AtSRP_ECT_SLOW_2G_DuplicatesRemoved) { HintsFetched_AtSRP_ECT_SLOW_2G_DuplicatesRemoved) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2146,6 +2086,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2146,6 +2086,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetched_AtSRP_ECT_SLOW_2G_NonHTTPOrHTTPSHostsRemoved) { HintsFetched_AtSRP_ECT_SLOW_2G_NonHTTPOrHTTPSHostsRemoved) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2173,6 +2115,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2173,6 +2115,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
} }
TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetched_AtSRP_ECT_4G) { TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetched_AtSRP_ECT_4G) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2196,6 +2140,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetched_AtSRP_ECT_4G) { ...@@ -2196,6 +2140,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, HintsFetched_AtSRP_ECT_4G) {
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetched_AtNonSRP_ECT_SLOW_2G) { HintsFetched_AtNonSRP_ECT_SLOW_2G) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2219,6 +2165,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2219,6 +2165,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetchedAtNavigationTime_ECT_SLOW_2G) { HintsFetchedAtNavigationTime_ECT_SLOW_2G) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2254,6 +2202,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2254,6 +2202,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsFetchedAtNavigationTime_HasComponentHintButNotFetched) { HintsFetchedAtNavigationTime_HasComponentHintButNotFetched) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2290,6 +2240,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2290,6 +2240,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
URLHintsNotFetchedAtNavigationTime) { URLHintsNotFetchedAtNavigationTime) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2350,6 +2302,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2350,6 +2302,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
HintsNotFetchedAtNavigationTime_ECT_4G) { HintsNotFetchedAtNavigationTime_ECT_4G) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2380,6 +2334,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2380,6 +2334,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationCalledMidFetch) { CanApplyOptimizationCalledMidFetch) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2404,6 +2360,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2404,6 +2360,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationCalledPostFetchButNoHintsCameBack) { CanApplyOptimizationCalledPostFetchButNoHintsCameBack) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2432,6 +2390,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2432,6 +2390,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationCalledPostFetchButFetchFailed) { CanApplyOptimizationCalledPostFetchButFetchFailed) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::DEFER_ALL_SCRIPT}); {optimization_guide::proto::DEFER_ALL_SCRIPT});
InitializeWithDefaultConfig("1.0.0.0"); InitializeWithDefaultConfig("1.0.0.0");
...@@ -2460,6 +2420,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2460,6 +2420,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationWithURLKeyedHintApplicableForOptimizationType) { CanApplyOptimizationWithURLKeyedHintApplicableForOptimizationType) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::COMPRESS_PUBLIC_IMAGES}); {optimization_guide::proto::COMPRESS_PUBLIC_IMAGES});
InitializeWithDefaultConfig("1.0.0"); InitializeWithDefaultConfig("1.0.0");
...@@ -2494,6 +2456,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2494,6 +2456,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationNotAllowedByURLButAllowedByHostKeyedHint) { CanApplyOptimizationNotAllowedByURLButAllowedByHostKeyedHint) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::NOSCRIPT}); {optimization_guide::proto::NOSCRIPT});
...@@ -2526,6 +2490,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2526,6 +2490,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationNotAllowedByURLOrHostKeyedHint) { CanApplyOptimizationNotAllowedByURLOrHostKeyedHint) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::RESOURCE_LOADING}); {optimization_guide::proto::RESOURCE_LOADING});
...@@ -2558,6 +2524,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2558,6 +2524,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationNoURLKeyedHintOrHostKeyedHint) { CanApplyOptimizationNoURLKeyedHintOrHostKeyedHint) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::COMPRESS_PUBLIC_IMAGES}); {optimization_guide::proto::COMPRESS_PUBLIC_IMAGES});
...@@ -2592,6 +2560,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest, ...@@ -2592,6 +2560,8 @@ TEST_F(OptimizationGuideHintsManagerFetchingTest,
TEST_F(OptimizationGuideHintsManagerFetchingTest, TEST_F(OptimizationGuideHintsManagerFetchingTest,
CanApplyOptimizationCalledMidFetchForURLKeyedOptimization) { CanApplyOptimizationCalledMidFetchForURLKeyedOptimization) {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
optimization_guide::switches::kDisableCheckingUserPermissionsForTesting);
hints_manager()->RegisterOptimizationTypes( hints_manager()->RegisterOptimizationTypes(
{optimization_guide::proto::COMPRESS_PUBLIC_IMAGES}); {optimization_guide::proto::COMPRESS_PUBLIC_IMAGES});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment