OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <limits> | 10 #include <limits> |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #include "components/sync_driver/sync_driver_switches.h" | 74 #include "components/sync_driver/sync_driver_switches.h" |
75 #include "content/public/browser/navigation_entry.h" | 75 #include "content/public/browser/navigation_entry.h" |
76 #include "content/public/browser/notification_service.h" | 76 #include "content/public/browser/notification_service.h" |
77 #include "content/public/browser/web_contents.h" | 77 #include "content/public/browser/web_contents.h" |
78 #include "content/public/test/test_browser_thread.h" | 78 #include "content/public/test/test_browser_thread.h" |
79 #include "google_apis/gaia/gaia_urls.h" | 79 #include "google_apis/gaia/gaia_urls.h" |
80 #include "net/base/escape.h" | 80 #include "net/base/escape.h" |
81 #include "net/base/load_flags.h" | 81 #include "net/base/load_flags.h" |
82 #include "net/base/network_change_notifier.h" | 82 #include "net/base/network_change_notifier.h" |
83 #include "net/base/port_util.h" | 83 #include "net/base/port_util.h" |
84 #include "net/cookies/cookie_monster.h" | |
85 #include "net/url_request/test_url_fetcher_factory.h" | 84 #include "net/url_request/test_url_fetcher_factory.h" |
86 #include "net/url_request/url_fetcher.h" | 85 #include "net/url_request/url_fetcher.h" |
87 #include "net/url_request/url_fetcher_delegate.h" | 86 #include "net/url_request/url_fetcher_delegate.h" |
88 #include "net/url_request/url_request_context.h" | |
89 #include "net/url_request/url_request_context_getter.h" | |
90 #include "sync/engine/sync_scheduler_impl.h" | 87 #include "sync/engine/sync_scheduler_impl.h" |
91 #include "sync/protocol/sync.pb.h" | 88 #include "sync/protocol/sync.pb.h" |
92 #include "sync/test/fake_server/fake_server.h" | 89 #include "sync/test/fake_server/fake_server.h" |
93 #include "sync/test/fake_server/fake_server_network_resources.h" | 90 #include "sync/test/fake_server/fake_server_network_resources.h" |
94 #include "url/gurl.h" | 91 #include "url/gurl.h" |
95 | 92 |
96 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
97 #include "chromeos/chromeos_switches.h" | 94 #include "chromeos/chromeos_switches.h" |
98 #endif | 95 #endif |
99 | 96 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 explicit EncryptionChecker(ProfileSyncService* service) | 166 explicit EncryptionChecker(ProfileSyncService* service) |
170 : SingleClientStatusChangeChecker(service) {} | 167 : SingleClientStatusChangeChecker(service) {} |
171 | 168 |
172 bool IsExitConditionSatisfied() override { | 169 bool IsExitConditionSatisfied() override { |
173 return IsEncryptionComplete(service()); | 170 return IsEncryptionComplete(service()); |
174 } | 171 } |
175 | 172 |
176 std::string GetDebugMessage() const override { return "Encryption"; } | 173 std::string GetDebugMessage() const override { return "Encryption"; } |
177 }; | 174 }; |
178 | 175 |
179 void SetupNetworkCallback( | |
180 base::WaitableEvent* done, | |
181 net::URLRequestContextGetter* url_request_context_getter) { | |
182 url_request_context_getter->GetURLRequestContext()-> | |
183 set_cookie_store(new net::CookieMonster(NULL, NULL)); | |
184 done->Signal(); | |
185 } | |
186 | |
187 scoped_ptr<KeyedService> BuildFakeServerProfileInvalidationProvider( | 176 scoped_ptr<KeyedService> BuildFakeServerProfileInvalidationProvider( |
188 content::BrowserContext* context) { | 177 content::BrowserContext* context) { |
189 return make_scoped_ptr(new invalidation::ProfileInvalidationProvider( | 178 return make_scoped_ptr(new invalidation::ProfileInvalidationProvider( |
190 scoped_ptr<invalidation::InvalidationService>( | 179 scoped_ptr<invalidation::InvalidationService>( |
191 new fake_server::FakeServerInvalidationService))); | 180 new fake_server::FakeServerInvalidationService))); |
192 } | 181 } |
193 | 182 |
194 scoped_ptr<KeyedService> BuildP2PProfileInvalidationProvider( | 183 scoped_ptr<KeyedService> BuildP2PProfileInvalidationProvider( |
195 content::BrowserContext* context, | 184 content::BrowserContext* context, |
196 syncer::P2PNotificationTarget notification_target) { | 185 syncer::P2PNotificationTarget notification_target) { |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 | 517 |
529 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser " | 518 EXPECT_FALSE(GetBrowser(index) == NULL) << "Could not create Browser " |
530 << index << "."; | 519 << index << "."; |
531 | 520 |
532 // Make sure the ProfileSyncService has been created before creating the | 521 // Make sure the ProfileSyncService has been created before creating the |
533 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to | 522 // ProfileSyncServiceHarness - some tests expect the ProfileSyncService to |
534 // already exist. | 523 // already exist. |
535 ProfileSyncService* profile_sync_service = | 524 ProfileSyncService* profile_sync_service = |
536 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); | 525 ProfileSyncServiceFactory::GetForProfile(GetProfile(index)); |
537 | 526 |
538 SetupNetwork(GetProfile(index)->GetRequestContext()); | |
539 | |
540 if (server_type_ == IN_PROCESS_FAKE_SERVER) { | 527 if (server_type_ == IN_PROCESS_FAKE_SERVER) { |
541 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. | 528 // TODO(pvalenzuela): Run the fake server via EmbeddedTestServer. |
542 profile_sync_service->OverrideNetworkResourcesForTest( | 529 profile_sync_service->OverrideNetworkResourcesForTest( |
543 make_scoped_ptr<syncer::NetworkResources>( | 530 make_scoped_ptr<syncer::NetworkResources>( |
544 new fake_server::FakeServerNetworkResources( | 531 new fake_server::FakeServerNetworkResources( |
545 fake_server_->AsWeakPtr()))); | 532 fake_server_->AsWeakPtr()))); |
546 } | 533 } |
547 | 534 |
548 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers() | 535 ProfileSyncServiceHarness::SigninType singin_type = UsingExternalServers() |
549 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN | 536 ? ProfileSyncServiceHarness::SigninType::UI_SIGNIN |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 void SyncTest::TriggerCreateSyncedBookmarks() { | 1098 void SyncTest::TriggerCreateSyncedBookmarks() { |
1112 ASSERT_TRUE(ServerSupportsErrorTriggering()); | 1099 ASSERT_TRUE(ServerSupportsErrorTriggering()); |
1113 std::string path = "chromiumsync/createsyncedbookmarks"; | 1100 std::string path = "chromiumsync/createsyncedbookmarks"; |
1114 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); | 1101 ui_test_utils::NavigateToURL(browser(), sync_server_.GetURL(path)); |
1115 ASSERT_EQ("Synced Bookmarks", | 1102 ASSERT_EQ("Synced Bookmarks", |
1116 base::UTF16ToASCII( | 1103 base::UTF16ToASCII( |
1117 browser()->tab_strip_model()->GetActiveWebContents()-> | 1104 browser()->tab_strip_model()->GetActiveWebContents()-> |
1118 GetTitle())); | 1105 GetTitle())); |
1119 } | 1106 } |
1120 | 1107 |
1121 void SyncTest::SetupNetwork(net::URLRequestContextGetter* context_getter) { | |
1122 base::WaitableEvent done(false, false); | |
1123 BrowserThread::PostTask( | |
1124 BrowserThread::IO, FROM_HERE, | |
1125 base::Bind(&SetupNetworkCallback, &done, | |
1126 make_scoped_refptr(context_getter))); | |
1127 done.Wait(); | |
1128 } | |
1129 | |
1130 fake_server::FakeServer* SyncTest::GetFakeServer() const { | 1108 fake_server::FakeServer* SyncTest::GetFakeServer() const { |
1131 return fake_server_.get(); | 1109 return fake_server_.get(); |
1132 } | 1110 } |
1133 | 1111 |
1134 void SyncTest::TriggerSyncForModelTypes(int index, | 1112 void SyncTest::TriggerSyncForModelTypes(int index, |
1135 syncer::ModelTypeSet model_types) { | 1113 syncer::ModelTypeSet model_types) { |
1136 GetSyncService(index)->TriggerRefresh(model_types); | 1114 GetSyncService(index)->TriggerRefresh(model_types); |
1137 } | 1115 } |
1138 | 1116 |
1139 void SyncTest::SetPreexistingPreferencesFileContents( | 1117 void SyncTest::SetPreexistingPreferencesFileContents( |
1140 const std::string& contents) { | 1118 const std::string& contents) { |
1141 preexisting_preferences_file_contents_ = contents; | 1119 preexisting_preferences_file_contents_ = contents; |
1142 } | 1120 } |
OLD | NEW |