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 <map> | 5 #include <map> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 profile()->ResetRequestContext(); | 242 profile()->ResetRequestContext(); |
243 | 243 |
244 // We need to destroy the profile before shutting down the threads, because | 244 // We need to destroy the profile before shutting down the threads, because |
245 // some of the ref counted objects in the profile depend on their | 245 // some of the ref counted objects in the profile depend on their |
246 // destruction on the io thread. | 246 // destruction on the io thread. |
247 DestroyBrowserAndProfile(); | 247 DestroyBrowserAndProfile(); |
248 ASSERT_FALSE(profile()); | 248 ASSERT_FALSE(profile()); |
249 | 249 |
250 // Pump messages posted by the sync core thread (which may end up | 250 // Pump messages posted by the sync core thread (which may end up |
251 // posting on the IO thread). | 251 // posting on the IO thread). |
252 MessageLoop::current()->RunUntilIdle(); | 252 base::MessageLoop::current()->RunUntilIdle(); |
253 io_thread_.Stop(); | 253 io_thread_.Stop(); |
254 MessageLoop::current()->RunUntilIdle(); | 254 base::MessageLoop::current()->RunUntilIdle(); |
255 BrowserWithTestWindowTest::TearDown(); | 255 BrowserWithTestWindowTest::TearDown(); |
256 } | 256 } |
257 | 257 |
258 bool StartSyncService(const base::Closure& callback, | 258 bool StartSyncService(const base::Closure& callback, |
259 bool will_fail_association) { | 259 bool will_fail_association) { |
260 if (sync_service_) | 260 if (sync_service_) |
261 return false; | 261 return false; |
262 SigninManagerBase* signin = | 262 SigninManagerBase* signin = |
263 SigninManagerFactory::GetForProfile(profile()); | 263 SigninManagerFactory::GetForProfile(profile()); |
264 signin->SetAuthenticatedUsername("test_user"); | 264 signin->SetAuthenticatedUsername("test_user"); |
(...skipping 21 matching lines...) Expand all Loading... |
286 true /* setup_for_test */); | 286 true /* setup_for_test */); |
287 EXPECT_CALL(*factory, CreateSessionSyncComponents(_, _)). | 287 EXPECT_CALL(*factory, CreateSessionSyncComponents(_, _)). |
288 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents( | 288 WillOnce(Return(ProfileSyncComponentsFactory::SyncComponents( |
289 model_associator_, change_processor_))); | 289 model_associator_, change_processor_))); |
290 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _)). | 290 EXPECT_CALL(*factory, CreateDataTypeManager(_, _, _, _, _)). |
291 WillOnce(ReturnNewDataTypeManager()); | 291 WillOnce(ReturnNewDataTypeManager()); |
292 | 292 |
293 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest( | 293 TokenServiceFactory::GetForProfile(profile())->IssueAuthTokenForTest( |
294 GaiaConstants::kSyncService, "token"); | 294 GaiaConstants::kSyncService, "token"); |
295 sync_service_->Initialize(); | 295 sync_service_->Initialize(); |
296 MessageLoop::current()->Run(); | 296 base::MessageLoop::current()->Run(); |
297 return true; | 297 return true; |
298 } | 298 } |
299 | 299 |
300 content::TestBrowserThread io_thread_; | 300 content::TestBrowserThread io_thread_; |
301 // Path used in testing. | 301 // Path used in testing. |
302 base::ScopedTempDir temp_dir_; | 302 base::ScopedTempDir temp_dir_; |
303 SessionModelAssociator* model_associator_; | 303 SessionModelAssociator* model_associator_; |
304 SessionChangeProcessor* change_processor_; | 304 SessionChangeProcessor* change_processor_; |
305 SessionID window_id_; | 305 SessionID window_id_; |
306 scoped_ptr<TestProfileSyncService> sync_service_; | 306 scoped_ptr<TestProfileSyncService> sync_service_; |
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 tab_list.push_back(5); | 1193 tab_list.push_back(5); |
1194 AddWindowSpecifics(0, tab_list, &meta); | 1194 AddWindowSpecifics(0, tab_list, &meta); |
1195 sync_pb::SessionSpecifics tab; | 1195 sync_pb::SessionSpecifics tab; |
1196 BuildTabSpecifics(tag, 0, tab_list[0], &tab); | 1196 BuildTabSpecifics(tag, 0, tab_list[0], &tab); |
1197 std::string url = tab.tab().navigation(0).virtual_url(); | 1197 std::string url = tab.tab().navigation(0).virtual_url(); |
1198 scoped_refptr<base::RefCountedMemory> favicon; | 1198 scoped_refptr<base::RefCountedMemory> favicon; |
1199 | 1199 |
1200 // Update associator. | 1200 // Update associator. |
1201 model_associator_->AssociateForeignSpecifics(meta, base::Time()); | 1201 model_associator_->AssociateForeignSpecifics(meta, base::Time()); |
1202 model_associator_->AssociateForeignSpecifics(tab, base::Time()); | 1202 model_associator_->AssociateForeignSpecifics(tab, base::Time()); |
1203 MessageLoop::current()->RunUntilIdle(); | 1203 base::MessageLoop::current()->RunUntilIdle(); |
1204 ASSERT_FALSE(model_associator_->GetSyncedFaviconForPageURL(url, &favicon)); | 1204 ASSERT_FALSE(model_associator_->GetSyncedFaviconForPageURL(url, &favicon)); |
1205 | 1205 |
1206 // Now add a favicon. | 1206 // Now add a favicon. |
1207 tab.mutable_tab()->set_favicon_source("http://favicon_source.com/png.ico"); | 1207 tab.mutable_tab()->set_favicon_source("http://favicon_source.com/png.ico"); |
1208 tab.mutable_tab()->set_favicon_type(sync_pb::SessionTab::TYPE_WEB_FAVICON); | 1208 tab.mutable_tab()->set_favicon_type(sync_pb::SessionTab::TYPE_WEB_FAVICON); |
1209 tab.mutable_tab()->set_favicon("data"); | 1209 tab.mutable_tab()->set_favicon("data"); |
1210 model_associator_->AssociateForeignSpecifics(tab, base::Time()); | 1210 model_associator_->AssociateForeignSpecifics(tab, base::Time()); |
1211 MessageLoop::current()->RunUntilIdle(); | 1211 base::MessageLoop::current()->RunUntilIdle(); |
1212 ASSERT_TRUE(model_associator_->GetSyncedFaviconForPageURL(url, &favicon)); | 1212 ASSERT_TRUE(model_associator_->GetSyncedFaviconForPageURL(url, &favicon)); |
1213 ASSERT_TRUE(CompareMemoryToString("data", favicon)); | 1213 ASSERT_TRUE(CompareMemoryToString("data", favicon)); |
1214 | 1214 |
1215 // Simulate navigating away. The associator should not delete the favicon. | 1215 // Simulate navigating away. The associator should not delete the favicon. |
1216 tab.mutable_tab()->clear_navigation(); | 1216 tab.mutable_tab()->clear_navigation(); |
1217 tab.mutable_tab()->add_navigation()->set_virtual_url("http://new_url.com"); | 1217 tab.mutable_tab()->add_navigation()->set_virtual_url("http://new_url.com"); |
1218 tab.mutable_tab()->clear_favicon_source(); | 1218 tab.mutable_tab()->clear_favicon_source(); |
1219 tab.mutable_tab()->clear_favicon_type(); | 1219 tab.mutable_tab()->clear_favicon_type(); |
1220 tab.mutable_tab()->clear_favicon(); | 1220 tab.mutable_tab()->clear_favicon(); |
1221 model_associator_->AssociateForeignSpecifics(tab, base::Time()); | 1221 model_associator_->AssociateForeignSpecifics(tab, base::Time()); |
1222 MessageLoop::current()->RunUntilIdle(); | 1222 base::MessageLoop::current()->RunUntilIdle(); |
1223 ASSERT_TRUE(model_associator_->GetSyncedFaviconForPageURL(url, &favicon)); | 1223 ASSERT_TRUE(model_associator_->GetSyncedFaviconForPageURL(url, &favicon)); |
1224 } | 1224 } |
1225 | 1225 |
1226 TEST_F(ProfileSyncServiceSessionTest, CorruptedLocalHeader) { | 1226 TEST_F(ProfileSyncServiceSessionTest, CorruptedLocalHeader) { |
1227 AddTab(browser(), GURL("http://foo1")); | 1227 AddTab(browser(), GURL("http://foo1")); |
1228 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1228 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1229 AddTab(browser(), GURL("http://bar1")); | 1229 AddTab(browser(), GURL("http://bar1")); |
1230 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1230 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1231 CreateRootHelper create_root(this); | 1231 CreateRootHelper create_root(this); |
1232 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1232 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
(...skipping 11 matching lines...) Expand all Loading... |
1244 sync_pb::SessionSpecifics specifics; | 1244 sync_pb::SessionSpecifics specifics; |
1245 header.SetSessionSpecifics(specifics); | 1245 header.SetSessionSpecifics(specifics); |
1246 } | 1246 } |
1247 // Ensure we associate properly despite the pre-existing node with our local | 1247 // Ensure we associate properly despite the pre-existing node with our local |
1248 // tag. | 1248 // tag. |
1249 error = model_associator_->AssociateModels(NULL, NULL); | 1249 error = model_associator_->AssociateModels(NULL, NULL); |
1250 ASSERT_FALSE(error.IsSet()); | 1250 ASSERT_FALSE(error.IsSet()); |
1251 } | 1251 } |
1252 | 1252 |
1253 } // namespace browser_sync | 1253 } // namespace browser_sync |
OLD | NEW |