Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: components/network_session_configurator/network_session_configurator_unittest.cc

Issue 1892123003: Add components/network_session_configurator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase on https://crrev.com/1945513002. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include "components/network_session_configurator/network_session_configurator.h "
6 6
7 #include "base/at_exit.h" 7 #include <map>
8 #include "base/command_line.h" 8 #include <memory>
9 #include "base/macros.h" 9
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
11 #include "base/run_loop.h"
12 #include "base/test/mock_entropy_provider.h" 11 #include "base/test/mock_entropy_provider.h"
13 #include "build/build_config.h" 12 #include "components/network_session_configurator/switches.h"
14 #include "chrome/browser/io_thread.h"
15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h"
17 #include "components/policy/core/common/mock_policy_service.h"
18 #include "components/prefs/pref_registry_simple.h"
19 #include "components/prefs/pref_service.h"
20 #include "components/prefs/testing_pref_service.h"
21 #include "components/proxy_config/pref_proxy_config_tracker_impl.h"
22 #include "components/proxy_config/proxy_config_pref_names.h"
23 #include "components/variations/variations_associated_data.h" 13 #include "components/variations/variations_associated_data.h"
24 #include "content/public/browser/browser_thread.h" 14 #include "net/http/http_stream_factory.h"
25 #include "content/public/test/test_browser_thread_bundle.h"
26 #include "net/cert_net/nss_ocsp.h"
27 #include "net/http/http_auth_preferences.h"
28 #include "net/http/http_auth_scheme.h"
29 #include "net/http/http_network_session.h"
30 #include "net/quic/quic_protocol.h" 15 #include "net/quic/quic_protocol.h"
31 #include "net/quic/quic_stream_factory.h"
32 #include "testing/gmock/include/gmock/gmock.h"
33 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
34 17
35 #if defined(ENABLE_EXTENSIONS)
36 #include "chrome/browser/extensions/event_router_forwarder.h"
37 #endif
38
39 #if defined(OS_CHROMEOS)
40 #include "chromeos/dbus/dbus_thread_manager.h"
41 #include "chromeos/network/network_handler.h"
42 #endif
43
44 namespace test { 18 namespace test {
45 19
46 using ::testing::ReturnRef;
47
48 // Class used for accessing IOThread methods (friend of IOThread).
49 class IOThreadPeer {
50 public:
51 static net::HttpAuthPreferences* GetAuthPreferences(IOThread* io_thread) {
52 return io_thread->globals()->http_auth_preferences.get();
53 }
54 };
55
56 class NetworkSessionConfiguratorTest : public testing::Test { 20 class NetworkSessionConfiguratorTest : public testing::Test {
57 public: 21 public:
58 NetworkSessionConfiguratorTest() 22 NetworkSessionConfiguratorTest()
59 : is_spdy_allowed_by_policy_(true), is_quic_allowed_by_policy_(true) { 23 : is_spdy_allowed_by_policy_(true),
24 is_quic_allowed_by_policy_(true),
25 quic_user_agent_id_("Chrome/52.0.2709.0 Linux x86_64") {
60 field_trial_list_.reset( 26 field_trial_list_.reset(
61 new base::FieldTrialList(new base::MockEntropyProvider())); 27 new base::FieldTrialList(new base::MockEntropyProvider()));
62 variations::testing::ClearAllVariationParams(); 28 variations::testing::ClearAllVariationParams();
63 } 29 }
64 30
65 void ParseFieldTrials() { 31 void ParseFieldTrials() {
66 network_session_configurator_.ParseFieldTrials( 32 network_session_configurator::ParseFieldTrials(
67 is_spdy_allowed_by_policy_, is_quic_allowed_by_policy_, &params_); 33 is_spdy_allowed_by_policy_, is_quic_allowed_by_policy_,
34 quic_user_agent_id_, &params_);
68 } 35 }
69 36
70 void ParseFieldTrialsAndCommandLine() { 37 void ParseFieldTrialsAndCommandLine() {
71 network_session_configurator_.ParseFieldTrialsAndCommandLine( 38 network_session_configurator::ParseFieldTrialsAndCommandLine(
72 is_spdy_allowed_by_policy_, is_quic_allowed_by_policy_, &params_); 39 is_spdy_allowed_by_policy_, is_quic_allowed_by_policy_,
40 quic_user_agent_id_, &params_);
73 } 41 }
74 42
75 bool is_spdy_allowed_by_policy_; 43 bool is_spdy_allowed_by_policy_;
76 bool is_quic_allowed_by_policy_; 44 bool is_quic_allowed_by_policy_;
45 std::string quic_user_agent_id_;
77 std::unique_ptr<base::FieldTrialList> field_trial_list_; 46 std::unique_ptr<base::FieldTrialList> field_trial_list_;
78 net::HttpNetworkSession::Params params_; 47 net::HttpNetworkSession::Params params_;
79
80 private:
81 IOThread::NetworkSessionConfigurator network_session_configurator_;
82 }; 48 };
83 49
84 TEST_F(NetworkSessionConfiguratorTest, Defaults) { 50 TEST_F(NetworkSessionConfiguratorTest, Defaults) {
85 ParseFieldTrialsAndCommandLine(); 51 ParseFieldTrialsAndCommandLine();
86 52
87 EXPECT_FALSE(params_.ignore_certificate_errors); 53 EXPECT_FALSE(params_.ignore_certificate_errors);
54 EXPECT_EQ("Chrome/52.0.2709.0 Linux x86_64", params_.quic_user_agent_id);
88 EXPECT_EQ(0u, params_.testing_fixed_http_port); 55 EXPECT_EQ(0u, params_.testing_fixed_http_port);
89 EXPECT_EQ(0u, params_.testing_fixed_https_port); 56 EXPECT_EQ(0u, params_.testing_fixed_https_port);
90 EXPECT_FALSE(params_.enable_spdy31); 57 EXPECT_FALSE(params_.enable_spdy31);
91 EXPECT_TRUE(params_.enable_http2); 58 EXPECT_TRUE(params_.enable_http2);
92 EXPECT_FALSE(params_.enable_tcp_fast_open_for_ssl); 59 EXPECT_FALSE(params_.enable_tcp_fast_open_for_ssl);
93 EXPECT_TRUE(params_.parse_alternative_services); 60 EXPECT_TRUE(params_.parse_alternative_services);
94 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); 61 EXPECT_FALSE(params_.enable_alternative_service_with_different_host);
95 EXPECT_FALSE(params_.enable_npn); 62 EXPECT_FALSE(params_.enable_npn);
96 EXPECT_TRUE(params_.enable_priority_dependencies); 63 EXPECT_TRUE(params_.enable_priority_dependencies);
97 EXPECT_FALSE(params_.enable_quic); 64 EXPECT_FALSE(params_.enable_quic);
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 EXPECT_FALSE(params_.quic_disable_connection_pooling); 211 EXPECT_FALSE(params_.quic_disable_connection_pooling);
245 EXPECT_EQ(0.25f, params_.quic_load_server_info_timeout_srtt_multiplier); 212 EXPECT_EQ(0.25f, params_.quic_load_server_info_timeout_srtt_multiplier);
246 EXPECT_FALSE(params_.quic_enable_connection_racing); 213 EXPECT_FALSE(params_.quic_enable_connection_racing);
247 EXPECT_FALSE(params_.quic_enable_non_blocking_io); 214 EXPECT_FALSE(params_.quic_enable_non_blocking_io);
248 EXPECT_FALSE(params_.quic_disable_disk_cache); 215 EXPECT_FALSE(params_.quic_disable_disk_cache);
249 EXPECT_FALSE(params_.quic_prefer_aes); 216 EXPECT_FALSE(params_.quic_prefer_aes);
250 EXPECT_TRUE(params_.parse_alternative_services); 217 EXPECT_TRUE(params_.parse_alternative_services);
251 EXPECT_FALSE(params_.enable_alternative_service_with_different_host); 218 EXPECT_FALSE(params_.enable_alternative_service_with_different_host);
252 EXPECT_EQ(0, params_.quic_max_number_of_lossy_connections); 219 EXPECT_EQ(0, params_.quic_max_number_of_lossy_connections);
253 EXPECT_EQ(1.0f, params_.quic_packet_loss_threshold); 220 EXPECT_EQ(1.0f, params_.quic_packet_loss_threshold);
254 EXPECT_FALSE(params_.quic_delay_tcp_race);
255 EXPECT_FALSE(params_.quic_close_sessions_on_ip_change); 221 EXPECT_FALSE(params_.quic_close_sessions_on_ip_change);
256 EXPECT_EQ(net::kIdleConnectionTimeoutSeconds, 222 EXPECT_EQ(net::kIdleConnectionTimeoutSeconds,
257 params_.quic_idle_connection_timeout_seconds); 223 params_.quic_idle_connection_timeout_seconds);
258 EXPECT_FALSE(params_.quic_disable_preconnect_if_0rtt); 224 EXPECT_FALSE(params_.quic_disable_preconnect_if_0rtt);
259 EXPECT_FALSE(params_.quic_migrate_sessions_on_network_change); 225 EXPECT_FALSE(params_.quic_migrate_sessions_on_network_change);
260 EXPECT_FALSE(params_.quic_migrate_sessions_early); 226 EXPECT_FALSE(params_.quic_migrate_sessions_early);
261 EXPECT_TRUE(params_.quic_host_whitelist.empty()); 227 EXPECT_TRUE(params_.quic_host_whitelist.empty());
262 228
263 net::HttpNetworkSession::Params default_params; 229 net::HttpNetworkSession::Params default_params;
264 EXPECT_EQ(default_params.quic_supported_versions, 230 EXPECT_EQ(default_params.quic_supported_versions,
265 params_.quic_supported_versions); 231 params_.quic_supported_versions);
266 } 232 }
267 233
234 TEST_F(NetworkSessionConfiguratorTest, DisableQuicFromCommandLine) {
235 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
236 base::CommandLine::ForCurrentProcess()->AppendSwitch("disable-quic");
237
238 ParseFieldTrialsAndCommandLine();
239
240 EXPECT_FALSE(params_.enable_quic);
241 }
242
243 TEST_F(NetworkSessionConfiguratorTest, EnableQuicForDataReductionProxy) {
244 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
245 base::FieldTrialList::CreateFieldTrial("DataReductionProxyUseQuic",
246 "Enabled");
247
248 ParseFieldTrialsAndCommandLine();
249
250 EXPECT_TRUE(params_.enable_quic);
251 }
252
268 TEST_F(NetworkSessionConfiguratorTest, 253 TEST_F(NetworkSessionConfiguratorTest,
269 DisableQuicWhenConnectionTimesOutWithOpenStreamsFromFieldTrialParams) { 254 DisableQuicWhenConnectionTimesOutWithOpenStreamsFromFieldTrialParams) {
270 std::map<std::string, std::string> field_trial_params; 255 std::map<std::string, std::string> field_trial_params;
271 field_trial_params["disable_quic_on_timeout_with_open_streams"] = "true"; 256 field_trial_params["disable_quic_on_timeout_with_open_streams"] = "true";
272 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); 257 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params);
273 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); 258 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
274 259
275 ParseFieldTrials(); 260 ParseFieldTrials();
276 261
277 EXPECT_TRUE(params_.disable_quic_on_timeout_with_open_streams); 262 EXPECT_TRUE(params_.disable_quic_on_timeout_with_open_streams);
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 std::map<std::string, std::string> field_trial_params; 555 std::map<std::string, std::string> field_trial_params;
571 field_trial_params["receive_buffer_size"] = "2097152"; 556 field_trial_params["receive_buffer_size"] = "2097152";
572 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params); 557 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params);
573 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); 558 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
574 559
575 ParseFieldTrials(); 560 ParseFieldTrials();
576 561
577 EXPECT_EQ(2097152, params_.quic_socket_receive_buffer_size); 562 EXPECT_EQ(2097152, params_.quic_socket_receive_buffer_size);
578 } 563 }
579 564
580 TEST_F(NetworkSessionConfiguratorTest, QuicDelayTcpConnection) {
581 std::map<std::string, std::string> field_trial_params;
582 field_trial_params["delay_tcp_race"] = "true";
583 variations::AssociateVariationParams("QUIC", "Enabled", field_trial_params);
584 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
585
586 ParseFieldTrials();
587
588 EXPECT_TRUE(params_.quic_delay_tcp_race);
589 }
590
591 TEST_F(NetworkSessionConfiguratorTest, QuicOriginsToForceQuicOn) { 565 TEST_F(NetworkSessionConfiguratorTest, QuicOriginsToForceQuicOn) {
592 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic"); 566 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic");
593 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 567 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
594 "origin-to-force-quic-on", "www.example.com:443, www.example.org:443"); 568 "origin-to-force-quic-on", "www.example.com:443, www.example.org:443");
595 569
596 ParseFieldTrialsAndCommandLine(); 570 ParseFieldTrialsAndCommandLine();
597 571
598 EXPECT_EQ(2u, params_.origins_to_force_quic_on.size()); 572 EXPECT_EQ(2u, params_.origins_to_force_quic_on.size());
599 EXPECT_TRUE( 573 EXPECT_TRUE(
600 ContainsKey(params_.origins_to_force_quic_on, 574 ContainsKey(params_.origins_to_force_quic_on,
(...skipping 23 matching lines...) Expand all
624 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled"); 598 base::FieldTrialList::CreateFieldTrial("QUIC", "Enabled");
625 599
626 ParseFieldTrials(); 600 ParseFieldTrials();
627 601
628 EXPECT_EQ(2u, params_.quic_host_whitelist.size()); 602 EXPECT_EQ(2u, params_.quic_host_whitelist.size());
629 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.org")); 603 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.org"));
630 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.com")); 604 EXPECT_TRUE(ContainsKey(params_.quic_host_whitelist, "www.example.com"));
631 } 605 }
632 606
633 TEST_F(NetworkSessionConfiguratorTest, QuicDisallowedByPolicy) { 607 TEST_F(NetworkSessionConfiguratorTest, QuicDisallowedByPolicy) {
634 base::CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableQuic); 608 base::CommandLine::ForCurrentProcess()->AppendSwitch("enable-quic");
635 is_quic_allowed_by_policy_ = false; 609 is_quic_allowed_by_policy_ = false;
636 610
637 ParseFieldTrialsAndCommandLine(); 611 ParseFieldTrialsAndCommandLine();
638 612
639 EXPECT_FALSE(params_.enable_quic); 613 EXPECT_FALSE(params_.enable_quic);
640 } 614 }
641 615
642 TEST_F(NetworkSessionConfiguratorTest, TCPFastOpenHttpsEnabled) { 616 TEST_F(NetworkSessionConfiguratorTest, TCPFastOpenHttpsEnabled) {
643 base::FieldTrialList::CreateFieldTrial("TCPFastOpen", "HttpsEnabled"); 617 base::FieldTrialList::CreateFieldTrial("TCPFastOpen", "HttpsEnabled");
644 618
645 ParseFieldTrials(); 619 ParseFieldTrials();
646 620
647 EXPECT_TRUE(params_.enable_tcp_fast_open_for_ssl); 621 EXPECT_TRUE(params_.enable_tcp_fast_open_for_ssl);
648 } 622 }
649 623
650 class IOThreadTestWithIOThreadObject : public testing::Test {
651 public:
652 // These functions need to be public, since it is difficult to bind to
653 // protected functions in a test (the code would need to explicitly contain
654 // the name of the actual test class).
655 void CheckCnameLookup(bool expected) {
656 auto http_auth_preferences =
657 IOThreadPeer::GetAuthPreferences(io_thread_.get());
658 ASSERT_NE(nullptr, http_auth_preferences);
659 EXPECT_EQ(expected, http_auth_preferences->NegotiateDisableCnameLookup());
660 }
661
662 void CheckNegotiateEnablePort(bool expected) {
663 auto http_auth_preferences =
664 IOThreadPeer::GetAuthPreferences(io_thread_.get());
665 ASSERT_NE(nullptr, http_auth_preferences);
666 EXPECT_EQ(expected, http_auth_preferences->NegotiateEnablePort());
667 }
668
669 #if defined(OS_ANDROID)
670 void CheckAuthAndroidNegoitateAccountType(std::string expected) {
671 auto http_auth_preferences =
672 IOThreadPeer::GetAuthPreferences(io_thread_.get());
673 ASSERT_NE(nullptr, http_auth_preferences);
674 EXPECT_EQ(expected,
675 http_auth_preferences->AuthAndroidNegotiateAccountType());
676 }
677 #endif
678
679 void CheckCanUseDefaultCredentials(bool expected, const GURL& url) {
680 auto http_auth_preferences =
681 IOThreadPeer::GetAuthPreferences(io_thread_.get());
682 EXPECT_EQ(expected, http_auth_preferences->CanUseDefaultCredentials(url));
683 }
684
685 void CheckCanDelegate(bool expected, const GURL& url) {
686 auto http_auth_preferences =
687 IOThreadPeer::GetAuthPreferences(io_thread_.get());
688 EXPECT_EQ(expected, http_auth_preferences->CanDelegate(url));
689 }
690
691 protected:
692 IOThreadTestWithIOThreadObject()
693 : thread_bundle_(content::TestBrowserThreadBundle::REAL_IO_THREAD |
694 content::TestBrowserThreadBundle::DONT_START_THREADS) {
695 #if defined(ENABLE_EXTENSIONS)
696 event_router_forwarder_ = new extensions::EventRouterForwarder;
697 #endif
698 PrefRegistrySimple* pref_registry = pref_service_.registry();
699 IOThread::RegisterPrefs(pref_registry);
700 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry);
701 ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry);
702
703 // Set up default function behaviour.
704 EXPECT_CALL(policy_service_,
705 GetPolicies(policy::PolicyNamespace(
706 policy::POLICY_DOMAIN_CHROME, std::string())))
707 .WillRepeatedly(ReturnRef(policy_map_));
708
709 #if defined(OS_CHROMEOS)
710 // Needed by IOThread constructor.
711 chromeos::DBusThreadManager::Initialize();
712 chromeos::NetworkHandler::Initialize();
713 #endif
714 // The IOThread constructor registers the IOThread object with as the
715 // BrowserThreadDelegate for the io thread.
716 io_thread_.reset(new IOThread(&pref_service_, &policy_service_, nullptr,
717 #if defined(ENABLE_EXTENSIONS)
718 event_router_forwarder_.get()
719 #else
720 nullptr
721 #endif
722 ));
723 // Now that IOThread object is registered starting the threads will
724 // call the IOThread::Init(). This sets up the environment needed for
725 // these tests.
726 thread_bundle_.Start();
727 }
728
729 ~IOThreadTestWithIOThreadObject() override {
730 #if defined(USE_NSS_CERTS)
731 // Reset OCSPIOLoop thread checks, so that the test runner can run
732 // futher tests in the same process.
733 RunOnIOThreadBlocking(base::Bind(&net::ResetNSSHttpIOForTesting));
734 #endif
735 #if defined(OS_CHROMEOS)
736 chromeos::NetworkHandler::Shutdown();
737 chromeos::DBusThreadManager::Shutdown();
738 #endif
739 }
740 TestingPrefServiceSimple* pref_service() { return &pref_service_; }
741
742 void RunOnIOThreadBlocking(const base::Closure& task) {
743 base::RunLoop run_loop;
744 content::BrowserThread::PostTaskAndReply(
745 content::BrowserThread::IO, FROM_HERE, task, run_loop.QuitClosure());
746 run_loop.Run();
747 }
748
749 private:
750 base::ShadowingAtExitManager at_exit_manager_;
751 TestingPrefServiceSimple pref_service_;
752 #if defined(ENABLE_EXTENSIONS)
753 scoped_refptr<extensions::EventRouterForwarder> event_router_forwarder_;
754 #endif
755 policy::PolicyMap policy_map_;
756 policy::MockPolicyService policy_service_;
757 // The ordering of the declarations of |io_thread_object_| and
758 // |thread_bundle_| matters. An IOThread cannot be deleted until all of
759 // the globals have been reset to their initial state via CleanUp. As
760 // TestBrowserThreadBundle's destructor is responsible for calling
761 // CleanUp(), the IOThread must be declared before the bundle, so that
762 // the bundle is deleted first.
763 std::unique_ptr<IOThread> io_thread_;
764 content::TestBrowserThreadBundle thread_bundle_;
765 };
766
767 TEST_F(IOThreadTestWithIOThreadObject, UpdateNegotiateDisableCnameLookup) {
768 // This test uses the kDisableAuthNegotiateCnameLookup to check that
769 // the HttpAuthPreferences are correctly initialized and running on the
770 // IO thread. The other preferences are tested by the HttpAuthPreferences
771 // unit tests.
772 pref_service()->SetBoolean(prefs::kDisableAuthNegotiateCnameLookup, false);
773 RunOnIOThreadBlocking(
774 base::Bind(&IOThreadTestWithIOThreadObject::CheckCnameLookup,
775 base::Unretained(this), false));
776 pref_service()->SetBoolean(prefs::kDisableAuthNegotiateCnameLookup, true);
777 RunOnIOThreadBlocking(
778 base::Bind(&IOThreadTestWithIOThreadObject::CheckCnameLookup,
779 base::Unretained(this), true));
780 }
781
782 TEST_F(IOThreadTestWithIOThreadObject, UpdateEnableAuthNegotiatePort) {
783 pref_service()->SetBoolean(prefs::kEnableAuthNegotiatePort, false);
784 RunOnIOThreadBlocking(
785 base::Bind(&IOThreadTestWithIOThreadObject::CheckNegotiateEnablePort,
786 base::Unretained(this), false));
787 pref_service()->SetBoolean(prefs::kEnableAuthNegotiatePort, true);
788 RunOnIOThreadBlocking(
789 base::Bind(&IOThreadTestWithIOThreadObject::CheckNegotiateEnablePort,
790 base::Unretained(this), true));
791 }
792
793 TEST_F(IOThreadTestWithIOThreadObject, UpdateServerWhitelist) {
794 GURL url("http://test.example.com");
795
796 pref_service()->SetString(prefs::kAuthServerWhitelist, "xxx");
797 RunOnIOThreadBlocking(
798 base::Bind(&IOThreadTestWithIOThreadObject::CheckCanUseDefaultCredentials,
799 base::Unretained(this), false, url));
800
801 pref_service()->SetString(prefs::kAuthServerWhitelist, "*");
802 RunOnIOThreadBlocking(
803 base::Bind(&IOThreadTestWithIOThreadObject::CheckCanUseDefaultCredentials,
804 base::Unretained(this), true, url));
805 }
806
807 TEST_F(IOThreadTestWithIOThreadObject, UpdateDelegateWhitelist) {
808 GURL url("http://test.example.com");
809
810 pref_service()->SetString(prefs::kAuthNegotiateDelegateWhitelist, "");
811 RunOnIOThreadBlocking(
812 base::Bind(&IOThreadTestWithIOThreadObject::CheckCanDelegate,
813 base::Unretained(this), false, url));
814
815 pref_service()->SetString(prefs::kAuthNegotiateDelegateWhitelist, "*");
816 RunOnIOThreadBlocking(
817 base::Bind(&IOThreadTestWithIOThreadObject::CheckCanDelegate,
818 base::Unretained(this), true, url));
819 }
820
821 #if defined(OS_ANDROID)
822 // AuthAndroidNegotiateAccountType is only used on Android.
823 TEST_F(IOThreadTestWithIOThreadObject, UpdateAuthAndroidNegotiateAccountType) {
824 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc1");
825 RunOnIOThreadBlocking(base::Bind(
826 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType,
827 base::Unretained(this), "acc1"));
828 pref_service()->SetString(prefs::kAuthAndroidNegotiateAccountType, "acc2");
829 RunOnIOThreadBlocking(base::Bind(
830 &IOThreadTestWithIOThreadObject::CheckAuthAndroidNegoitateAccountType,
831 base::Unretained(this), "acc2"));
832 }
833 #endif
834
835 } // namespace test 624 } // namespace test
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698