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

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 642613002: Use Sync FakeServer in exponential backoff tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.h ('k') | sync/test/fake_server/fake_server.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/sync/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 #include "components/os_crypt/os_crypt.h" 59 #include "components/os_crypt/os_crypt.h"
60 #include "components/search_engines/template_url_service.h" 60 #include "components/search_engines/template_url_service.h"
61 #include "components/signin/core/browser/signin_manager.h" 61 #include "components/signin/core/browser/signin_manager.h"
62 #include "content/public/browser/web_contents.h" 62 #include "content/public/browser/web_contents.h"
63 #include "content/public/test/test_browser_thread.h" 63 #include "content/public/test/test_browser_thread.h"
64 #include "google_apis/gaia/gaia_urls.h" 64 #include "google_apis/gaia/gaia_urls.h"
65 #include "net/base/escape.h" 65 #include "net/base/escape.h"
66 #include "net/base/load_flags.h" 66 #include "net/base/load_flags.h"
67 #include "net/base/network_change_notifier.h" 67 #include "net/base/network_change_notifier.h"
68 #include "net/cookies/cookie_monster.h" 68 #include "net/cookies/cookie_monster.h"
69 #include "net/proxy/proxy_config.h"
70 #include "net/proxy/proxy_config_service_fixed.h"
71 #include "net/proxy/proxy_service.h"
72 #include "net/test/spawned_test_server/spawned_test_server.h" 69 #include "net/test/spawned_test_server/spawned_test_server.h"
73 #include "net/url_request/test_url_fetcher_factory.h" 70 #include "net/url_request/test_url_fetcher_factory.h"
74 #include "net/url_request/url_fetcher.h" 71 #include "net/url_request/url_fetcher.h"
75 #include "net/url_request/url_fetcher_delegate.h" 72 #include "net/url_request/url_fetcher_delegate.h"
76 #include "net/url_request/url_request_context.h" 73 #include "net/url_request/url_request_context.h"
77 #include "net/url_request/url_request_context_getter.h" 74 #include "net/url_request/url_request_context_getter.h"
78 #include "sync/engine/sync_scheduler_impl.h" 75 #include "sync/engine/sync_scheduler_impl.h"
79 #include "sync/protocol/sync.pb.h" 76 #include "sync/protocol/sync.pb.h"
80 #include "sync/test/fake_server/fake_server.h" 77 #include "sync/test/fake_server/fake_server.h"
81 #include "sync/test/fake_server/fake_server_network_resources.h" 78 #include "sync/test/fake_server/fake_server_network_resources.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 }; 133 };
137 134
138 void SetupNetworkCallback( 135 void SetupNetworkCallback(
139 base::WaitableEvent* done, 136 base::WaitableEvent* done,
140 net::URLRequestContextGetter* url_request_context_getter) { 137 net::URLRequestContextGetter* url_request_context_getter) {
141 url_request_context_getter->GetURLRequestContext()-> 138 url_request_context_getter->GetURLRequestContext()->
142 set_cookie_store(new net::CookieMonster(NULL, NULL)); 139 set_cookie_store(new net::CookieMonster(NULL, NULL));
143 done->Signal(); 140 done->Signal();
144 } 141 }
145 142
146 void SetProxyConfigCallback(
147 base::WaitableEvent* done,
148 net::URLRequestContextGetter* url_request_context_getter,
149 const net::ProxyConfig& proxy_config) {
150 net::ProxyService* proxy_service =
151 url_request_context_getter->GetURLRequestContext()->proxy_service();
152 proxy_service->ResetConfigService(
153 new net::ProxyConfigServiceFixed(proxy_config));
154 done->Signal();
155 }
156
157 KeyedService* BuildFakeServerProfileInvalidationProvider( 143 KeyedService* BuildFakeServerProfileInvalidationProvider(
158 content::BrowserContext* context) { 144 content::BrowserContext* context) {
159 return new invalidation::ProfileInvalidationProvider( 145 return new invalidation::ProfileInvalidationProvider(
160 scoped_ptr<invalidation::InvalidationService>( 146 scoped_ptr<invalidation::InvalidationService>(
161 new fake_server::FakeServerInvalidationService)); 147 new fake_server::FakeServerInvalidationService));
162 } 148 }
163 149
164 KeyedService* BuildP2PProfileInvalidationProvider( 150 KeyedService* BuildP2PProfileInvalidationProvider(
165 content::BrowserContext* context, 151 content::BrowserContext* context,
166 syncer::P2PNotificationTarget notification_target) { 152 syncer::P2PNotificationTarget notification_target) {
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 sync_url_status, net::URLFetcher::GET, &delegate)); 778 sync_url_status, net::URLFetcher::GET, &delegate));
793 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | 779 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE |
794 net::LOAD_DO_NOT_SEND_COOKIES | 780 net::LOAD_DO_NOT_SEND_COOKIES |
795 net::LOAD_DO_NOT_SAVE_COOKIES); 781 net::LOAD_DO_NOT_SAVE_COOKIES);
796 fetcher->SetRequestContext(g_browser_process->system_request_context()); 782 fetcher->SetRequestContext(g_browser_process->system_request_context());
797 fetcher->Start(); 783 fetcher->Start();
798 content::RunMessageLoop(); 784 content::RunMessageLoop();
799 return delegate.running(); 785 return delegate.running();
800 } 786 }
801 787
802 void SyncTest::EnableNetwork(Profile* profile) {
803 // TODO(pvalenzuela): Remove this restriction when FakeServer's observers
804 // (namely FakeServerInvaldationService) are aware of a network disconnect.
805 ASSERT_NE(IN_PROCESS_FAKE_SERVER, server_type_)
806 << "FakeServer does not support EnableNetwork.";
807 SetProxyConfig(profile->GetRequestContext(),
808 net::ProxyConfig::CreateDirect());
809 if (notifications_enabled_) {
810 EnableNotificationsImpl();
811 }
812 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed.
813 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
814 }
815
816 void SyncTest::DisableNetwork(Profile* profile) {
817 // TODO(pvalenzuela): Remove this restriction when FakeServer's observers
818 // (namely FakeServerInvaldationService) are aware of a network disconnect.
819 ASSERT_NE(IN_PROCESS_FAKE_SERVER, server_type_)
820 << "FakeServer does not support DisableNetwork.";
821 DisableNotificationsImpl();
822 // Set the current proxy configuration to a nonexistent proxy to effectively
823 // disable networking.
824 net::ProxyConfig config;
825 config.proxy_rules().ParseFromString("http=127.0.0.1:0");
826 SetProxyConfig(profile->GetRequestContext(), config);
827 // TODO(rsimha): Remove this line once http://crbug.com/53857 is fixed.
828 net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
829 }
830
831 bool SyncTest::TestUsesSelfNotifications() { 788 bool SyncTest::TestUsesSelfNotifications() {
832 return true; 789 return true;
833 } 790 }
834 791
835 bool SyncTest::EnableEncryption(int index) { 792 bool SyncTest::EnableEncryption(int index) {
836 ProfileSyncService* service = GetClient(index)->service(); 793 ProfileSyncService* service = GetClient(index)->service();
837 794
838 if (::IsEncryptionComplete(service)) 795 if (::IsEncryptionComplete(service))
839 return true; 796 return true;
840 797
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 syncer::GetSpecificsFieldNumberFromModelType(it.Get()))); 896 syncer::GetSpecificsFieldNumberFromModelType(it.Get())));
940 joiner = '&'; 897 joiner = '&';
941 } 898 }
942 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 899 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
943 ASSERT_EQ("Migration: 200", 900 ASSERT_EQ("Migration: 200",
944 base::UTF16ToASCII( 901 base::UTF16ToASCII(
945 browser()->tab_strip_model()->GetActiveWebContents()-> 902 browser()->tab_strip_model()->GetActiveWebContents()->
946 GetTitle())); 903 GetTitle()));
947 } 904 }
948 905
949 void SyncTest::TriggerTransientError() {
950 ASSERT_TRUE(ServerSupportsErrorTriggering());
951 std::string path = "chromiumsync/transienterror";
952 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
953 ASSERT_EQ("Transient error",
954 base::UTF16ToASCII(
955 browser()->tab_strip_model()->GetActiveWebContents()->
956 GetTitle()));
957 }
958
959 void SyncTest::TriggerXmppAuthError() { 906 void SyncTest::TriggerXmppAuthError() {
960 ASSERT_TRUE(ServerSupportsErrorTriggering()); 907 ASSERT_TRUE(ServerSupportsErrorTriggering());
961 std::string path = "chromiumsync/xmppcred"; 908 std::string path = "chromiumsync/xmppcred";
962 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); 909 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path));
963 } 910 }
964 911
965 namespace { 912 namespace {
966 913
967 sync_pb::SyncEnums::ErrorType 914 sync_pb::SyncEnums::ErrorType
968 GetClientToServerResponseErrorType( 915 GetClientToServerResponseErrorType(
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 1006
1060 void SyncTest::SetupNetwork(net::URLRequestContextGetter* context_getter) { 1007 void SyncTest::SetupNetwork(net::URLRequestContextGetter* context_getter) {
1061 base::WaitableEvent done(false, false); 1008 base::WaitableEvent done(false, false);
1062 BrowserThread::PostTask( 1009 BrowserThread::PostTask(
1063 BrowserThread::IO, FROM_HERE, 1010 BrowserThread::IO, FROM_HERE,
1064 base::Bind(&SetupNetworkCallback, &done, 1011 base::Bind(&SetupNetworkCallback, &done,
1065 make_scoped_refptr(context_getter))); 1012 make_scoped_refptr(context_getter)));
1066 done.Wait(); 1013 done.Wait();
1067 } 1014 }
1068 1015
1069 void SyncTest::SetProxyConfig(net::URLRequestContextGetter* context_getter,
1070 const net::ProxyConfig& proxy_config) {
1071 base::WaitableEvent done(false, false);
1072 BrowserThread::PostTask(
1073 BrowserThread::IO, FROM_HERE,
1074 base::Bind(&SetProxyConfigCallback, &done,
1075 make_scoped_refptr(context_getter), proxy_config));
1076 done.Wait();
1077 }
1078
1079 fake_server::FakeServer* SyncTest::GetFakeServer() const { 1016 fake_server::FakeServer* SyncTest::GetFakeServer() const {
1080 return fake_server_.get(); 1017 return fake_server_.get();
1081 } 1018 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.h ('k') | sync/test/fake_server/fake_server.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698