| Index: chrome/browser/policy/policy_network_browsertest.cc
|
| diff --git a/chrome/browser/policy/policy_network_browsertest.cc b/chrome/browser/policy/policy_network_browsertest.cc
|
| index 7aed8c46b6de0cf7310f1f0a67757166036fcf0c..aed2993d934f05ca28b123e8e879c96a9d734c87 100644
|
| --- a/chrome/browser/policy/policy_network_browsertest.cc
|
| +++ b/chrome/browser/policy/policy_network_browsertest.cc
|
| @@ -9,6 +9,9 @@
|
| #include "base/memory/ref_counted.h"
|
| #include "base/run_loop.h"
|
| #include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/safe_browsing/safe_browsing_service.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| #include "chrome/common/chrome_switches.h"
|
| #include "chrome/test/base/in_process_browser_test.h"
|
| #include "components/policy/core/browser/browser_policy_connector.h"
|
| @@ -24,25 +27,47 @@
|
|
|
| namespace {
|
|
|
| -void VerifyQuicEnabledStatus(net::URLRequestContextGetter* getter,
|
| - bool quic_enabled_expected,
|
| - const base::Closure& done_callback) {
|
| - net::URLRequestContext* context = getter->GetURLRequestContext();
|
| - bool quic_enabled = context->http_transaction_factory()->GetSession()->
|
| - params().enable_quic;
|
| - EXPECT_EQ(quic_enabled_expected, quic_enabled);
|
| +bool IsQuicEnabled(net::URLRequestContextGetter* context) {
|
| + return context->GetURLRequestContext()
|
| + ->http_transaction_factory()
|
| + ->GetSession()
|
| + ->IsQuicEnabled();
|
| +}
|
| +
|
| +void VerifyQuicEnabledStatus(
|
| + net::URLRequestContextGetter* system_context,
|
| + scoped_refptr<net::URLRequestContextGetter> safe_browsing_context,
|
| + net::URLRequestContextGetter* profile_context,
|
| + bool quic_enabled_expected,
|
| + const base::Closure& done_callback) {
|
| + bool quic_enabled_system = IsQuicEnabled(system_context);
|
| + EXPECT_EQ(quic_enabled_expected, quic_enabled_system);
|
| +
|
| + bool quic_enabled_safe_browsing = IsQuicEnabled(safe_browsing_context.get());
|
| + EXPECT_EQ(quic_enabled_expected, quic_enabled_safe_browsing);
|
| +
|
| + bool quic_enabled_profile = IsQuicEnabled(profile_context);
|
| + EXPECT_EQ(quic_enabled_expected, quic_enabled_profile);
|
|
|
| content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
|
| done_callback);
|
| }
|
|
|
| -void VerifyQuicEnabledStatusInIOThread(bool quic_enabled_expected) {
|
| +void VerifyQuicEnabledStatusInIOThread(Profile* profile,
|
| + bool quic_enabled_expected) {
|
| base::RunLoop run_loop;
|
| + net::URLRequestContextGetter* system_context =
|
| + g_browser_process->system_request_context();
|
| + scoped_refptr<net::URLRequestContextGetter> safe_browsing_context =
|
| + g_browser_process->safe_browsing_service()->url_request_context();
|
| + net::URLRequestContextGetter* profile_context = profile->GetRequestContext();
|
| +
|
| content::BrowserThread::PostTask(
|
| content::BrowserThread::IO, FROM_HERE,
|
| - base::Bind(VerifyQuicEnabledStatus,
|
| - base::RetainedRef(g_browser_process->system_request_context()),
|
| - quic_enabled_expected, run_loop.QuitClosure()));
|
| + base::Bind(VerifyQuicEnabledStatus, base::RetainedRef(system_context),
|
| + safe_browsing_context,
|
| + base::RetainedRef(profile_context), quic_enabled_expected,
|
| + run_loop.QuitClosure()));
|
| run_loop.Run();
|
| }
|
|
|
| @@ -55,7 +80,7 @@ namespace policy {
|
| // when these are being written.
|
| class QuicAllowedPolicyTestBase: public InProcessBrowserTest {
|
| public:
|
| - QuicAllowedPolicyTestBase() : InProcessBrowserTest(){}
|
| + QuicAllowedPolicyTestBase() : InProcessBrowserTest() {}
|
|
|
| protected:
|
| void SetUpInProcessBrowserTestFixture() override {
|
| @@ -71,15 +96,16 @@ class QuicAllowedPolicyTestBase: public InProcessBrowserTest {
|
|
|
| virtual void GetQuicAllowedPolicy(PolicyMap* values) = 0;
|
|
|
| - private:
|
| MockConfigurationPolicyProvider provider_;
|
| +
|
| + private:
|
| DISALLOW_COPY_AND_ASSIGN(QuicAllowedPolicyTestBase);
|
| };
|
|
|
| // Policy QuicAllowed set to false.
|
| class QuicAllowedPolicyIsFalse: public QuicAllowedPolicyTestBase {
|
| public:
|
| - QuicAllowedPolicyIsFalse() : QuicAllowedPolicyTestBase(){}
|
| + QuicAllowedPolicyIsFalse() : QuicAllowedPolicyTestBase() {}
|
|
|
| protected:
|
| void GetQuicAllowedPolicy(PolicyMap* values) override {
|
| @@ -93,13 +119,13 @@ class QuicAllowedPolicyIsFalse: public QuicAllowedPolicyTestBase {
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(QuicAllowedPolicyIsFalse, QuicDisallowed) {
|
| - VerifyQuicEnabledStatusInIOThread(false);
|
| + VerifyQuicEnabledStatusInIOThread(browser()->profile(), false);
|
| }
|
|
|
| // Policy QuicAllowed set to true.
|
| class QuicAllowedPolicyIsTrue: public QuicAllowedPolicyTestBase {
|
| public:
|
| - QuicAllowedPolicyIsTrue() : QuicAllowedPolicyTestBase(){}
|
| + QuicAllowedPolicyIsTrue() : QuicAllowedPolicyTestBase() {}
|
|
|
| protected:
|
| void GetQuicAllowedPolicy(PolicyMap* values) override {
|
| @@ -113,13 +139,13 @@ class QuicAllowedPolicyIsTrue: public QuicAllowedPolicyTestBase {
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(QuicAllowedPolicyIsTrue, QuicAllowed) {
|
| - VerifyQuicEnabledStatusInIOThread(true);
|
| + VerifyQuicEnabledStatusInIOThread(browser()->profile(), true);
|
| }
|
|
|
| // Policy QuicAllowed is not set.
|
| class QuicAllowedPolicyIsNotSet: public QuicAllowedPolicyTestBase {
|
| public:
|
| - QuicAllowedPolicyIsNotSet() : QuicAllowedPolicyTestBase(){}
|
| + QuicAllowedPolicyIsNotSet() : QuicAllowedPolicyTestBase() {}
|
|
|
| protected:
|
| void GetQuicAllowedPolicy(PolicyMap* values) override {
|
| @@ -130,7 +156,30 @@ class QuicAllowedPolicyIsNotSet: public QuicAllowedPolicyTestBase {
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(QuicAllowedPolicyIsNotSet, NoQuicRegulations) {
|
| - VerifyQuicEnabledStatusInIOThread(true);
|
| + VerifyQuicEnabledStatusInIOThread(browser()->profile(), true);
|
| }
|
|
|
| +// Policy QuicAllowed is set after IOThread initialization.
|
| +class QuicAllowedPolicyIsSetToFalseAfterInit
|
| + : public QuicAllowedPolicyTestBase {
|
| + public:
|
| + QuicAllowedPolicyIsSetToFalseAfterInit() : QuicAllowedPolicyTestBase() {}
|
| +
|
| + protected:
|
| + void GetQuicAllowedPolicy(PolicyMap* values) override {}
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(QuicAllowedPolicyIsSetToFalseAfterInit);
|
| +};
|
| +
|
| +IN_PROC_BROWSER_TEST_F(QuicAllowedPolicyIsSetToFalseAfterInit, QuicDisallowed) {
|
| + PolicyMap values;
|
| + values.Set(key::kQuicAllowed, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
|
| + POLICY_SOURCE_CLOUD,
|
| + base::MakeUnique<base::FundamentalValue>(false), nullptr);
|
| + provider_.UpdateChromePolicy(values);
|
| + base::RunLoop().RunUntilIdle();
|
| +
|
| + VerifyQuicEnabledStatusInIOThread(browser()->profile(), false);
|
| +}
|
| } // namespace policy
|
|
|