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: chrome/browser/sync/profile_sync_service_unittest.cc

Issue 6375007: [Sync] Refactored ProfileSyncService and remove its backend() function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add comment Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <stack> 5 #include <stack>
6 #include <vector> 6 #include <vector>
7 7
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 using browser_sync::DataTypeController; 45 using browser_sync::DataTypeController;
46 using browser_sync::ModelAssociator; 46 using browser_sync::ModelAssociator;
47 using browser_sync::SyncBackendHost; 47 using browser_sync::SyncBackendHost;
48 using browser_sync::SyncBackendHostMock; 48 using browser_sync::SyncBackendHostMock;
49 using browser_sync::UnrecoverableErrorHandler; 49 using browser_sync::UnrecoverableErrorHandler;
50 using testing::_; 50 using testing::_;
51 using testing::Return; 51 using testing::Return;
52 using testing::WithArg; 52 using testing::WithArg;
53 using testing::Invoke; 53 using testing::Invoke;
54 54
55 // TODO(akalin): Bookmark-specific tests should be moved into their
56 // own file.
55 class TestBookmarkModelAssociator : public BookmarkModelAssociator { 57 class TestBookmarkModelAssociator : public BookmarkModelAssociator {
56 public: 58 public:
57 TestBookmarkModelAssociator(TestProfileSyncService* service, 59 TestBookmarkModelAssociator(
60 TestProfileSyncService* service,
58 UnrecoverableErrorHandler* persist_ids_error_handler) 61 UnrecoverableErrorHandler* persist_ids_error_handler)
59 : BookmarkModelAssociator(service, persist_ids_error_handler), 62 : BookmarkModelAssociator(service, persist_ids_error_handler),
60 helper_(new TestModelAssociatorHelper(service->id_factory())) { 63 id_factory_(service->id_factory()) {}
64
65 // TODO(akalin): This logic lazily creates any tagged node that is
66 // requested. A better way would be to have utility functions to
67 // create sync nodes from some bookmark structure and to use that.
68 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) {
69 std::wstring tag_wide;
70 if (!UTF8ToWide(tag.c_str(), tag.length(), &tag_wide)) {
71 NOTREACHED() << "Unable to convert UTF8 to wide for string: " << tag;
72 return false;
73 }
74
75 bool root_exists = false;
76 syncable::ModelType type = model_type();
77 {
78 sync_api::WriteTransaction trans(sync_service()->GetUserShare());
79 sync_api::ReadNode uber_root(&trans);
80 uber_root.InitByRootLookup();
81
82 sync_api::ReadNode root(&trans);
83 root_exists = root.InitByTagLookup(
84 ProfileSyncServiceTestHelper::GetTagForType(type));
85 }
86
87 if (!root_exists) {
88 bool created = ProfileSyncServiceTestHelper::CreateRoot(
89 type,
90 sync_service()->GetUserShare(),
91 id_factory_);
92 if (!created)
93 return false;
94 }
95
96 sync_api::WriteTransaction trans(sync_service()->GetUserShare());
97 sync_api::ReadNode root(&trans);
98 EXPECT_TRUE(root.InitByTagLookup(
99 ProfileSyncServiceTestHelper::GetTagForType(type)));
100
101 // First, try to find a node with the title among the root's children.
102 // This will be the case if we are testing model persistence, and
103 // are reloading a sync repository created earlier in the test.
104 int64 last_child_id = sync_api::kInvalidId;
105 for (int64 id = root.GetFirstChildId(); id != sync_api::kInvalidId; /***/) {
106 sync_api::ReadNode child(&trans);
107 child.InitByIdLookup(id);
108 last_child_id = id;
109 if (tag_wide == child.GetTitle()) {
110 *sync_id = id;
111 return true;
112 }
113 id = child.GetSuccessorId();
114 }
115
116 sync_api::ReadNode predecessor_node(&trans);
117 sync_api::ReadNode* predecessor = NULL;
118 if (last_child_id != sync_api::kInvalidId) {
119 predecessor_node.InitByIdLookup(last_child_id);
120 predecessor = &predecessor_node;
121 }
122 sync_api::WriteNode node(&trans);
123 // Create new fake tagged nodes at the end of the ordering.
124 node.InitByCreation(type, root, predecessor);
125 node.SetIsFolder(true);
126 node.SetTitle(tag_wide);
127 node.SetExternalId(0);
128 *sync_id = node.GetId();
129 return true;
61 } 130 }
62 virtual bool GetSyncIdForTaggedNode(const std::string& tag, int64* sync_id) { 131
63 return helper_->GetSyncIdForTaggedNode(this, tag, sync_id);
64 }
65 private: 132 private:
66 scoped_ptr<TestModelAssociatorHelper> helper_; 133 browser_sync::TestIdFactory* id_factory_;
67 }; 134 };
68 135
69 // FakeServerChange constructs a list of sync_api::ChangeRecords while modifying 136 // FakeServerChange constructs a list of sync_api::ChangeRecords while modifying
70 // the sync model, and can pass the ChangeRecord list to a 137 // the sync model, and can pass the ChangeRecord list to a
71 // sync_api::SyncObserver (i.e., the ProfileSyncService) to test the client 138 // sync_api::SyncObserver (i.e., the ProfileSyncService) to test the client
72 // change-application behavior. 139 // change-application behavior.
73 // Tests using FakeServerChange should be careful to avoid back-references, 140 // Tests using FakeServerChange should be careful to avoid back-references,
74 // since FakeServerChange will send the edits in the order specified. 141 // since FakeServerChange will send the edits in the order specified.
75 class FakeServerChange { 142 class FakeServerChange {
76 public: 143 public:
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 &gnext)); 402 &gnext));
336 EXPECT_EQ(gnode.GetSuccessorId(), gnext.GetId()); 403 EXPECT_EQ(gnode.GetSuccessorId(), gnext.GetId());
337 EXPECT_EQ(gnode.GetParentId(), gnext.GetParentId()); 404 EXPECT_EQ(gnode.GetParentId(), gnext.GetParentId());
338 } 405 }
339 if (bnode->GetChildCount()) { 406 if (bnode->GetChildCount()) {
340 EXPECT_TRUE(gnode.GetFirstChildId()); 407 EXPECT_TRUE(gnode.GetFirstChildId());
341 } 408 }
342 } 409 }
343 410
344 void ExpectSyncerNodeMatching(const BookmarkNode* bnode) { 411 void ExpectSyncerNodeMatching(const BookmarkNode* bnode) {
345 sync_api::ReadTransaction trans(service_->backend_->GetUserShareHandle()); 412 sync_api::ReadTransaction trans(service_->GetUserShare());
346 ExpectSyncerNodeMatching(&trans, bnode); 413 ExpectSyncerNodeMatching(&trans, bnode);
347 } 414 }
348 415
349 void ExpectBrowserNodeMatching(sync_api::BaseTransaction* trans, 416 void ExpectBrowserNodeMatching(sync_api::BaseTransaction* trans,
350 int64 sync_id) { 417 int64 sync_id) {
351 EXPECT_TRUE(sync_id); 418 EXPECT_TRUE(sync_id);
352 const BookmarkNode* bnode = 419 const BookmarkNode* bnode =
353 associator()->GetChromeNodeFromSyncId(sync_id); 420 associator()->GetChromeNodeFromSyncId(sync_id);
354 ASSERT_TRUE(bnode); 421 ASSERT_TRUE(bnode);
355 int64 id = associator()->GetSyncIdFromChromeId(bnode->id()); 422 int64 id = associator()->GetSyncIdFromChromeId(bnode->id());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 ExpectBrowserNodeMatching(trans, id); 480 ExpectBrowserNodeMatching(trans, id);
414 481
415 sync_api::ReadNode gnode(trans); 482 sync_api::ReadNode gnode(trans);
416 ASSERT_TRUE(gnode.InitByIdLookup(id)); 483 ASSERT_TRUE(gnode.InitByIdLookup(id));
417 stack.push(gnode.GetFirstChildId()); 484 stack.push(gnode.GetFirstChildId());
418 stack.push(gnode.GetSuccessorId()); 485 stack.push(gnode.GetSuccessorId());
419 } 486 }
420 } 487 }
421 488
422 void ExpectModelMatch() { 489 void ExpectModelMatch() {
423 sync_api::ReadTransaction trans(service_->backend_->GetUserShareHandle()); 490 sync_api::ReadTransaction trans(service_->GetUserShare());
424 ExpectModelMatch(&trans); 491 ExpectModelMatch(&trans);
425 } 492 }
426 493
427 int64 other_bookmarks_id() { 494 int64 other_bookmarks_id() {
428 return associator()->GetSyncIdFromChromeId(model_->other_node()->id()); 495 return associator()->GetSyncIdFromChromeId(model_->other_node()->id());
429 } 496 }
430 497
431 int64 bookmark_bar_id() { 498 int64 bookmark_bar_id() {
432 return associator()->GetSyncIdFromChromeId( 499 return associator()->GetSyncIdFromChromeId(
433 model_->GetBookmarkBarNode()->id()); 500 model_->GetBookmarkBarNode()->id());
434 } 501 }
435 502
436 SyncBackendHost* backend() { return service_->backend_.get(); }
437
438 // This serves as the "UI loop" on which the ProfileSyncService lives and 503 // This serves as the "UI loop" on which the ProfileSyncService lives and
439 // operates. It is needed because the SyncBackend can post tasks back to 504 // operates. It is needed because the SyncBackend can post tasks back to
440 // the service, meaning it can't be null. It doesn't have to be running, 505 // the service, meaning it can't be null. It doesn't have to be running,
441 // though -- OnInitializationCompleted is the only example (so far) in this 506 // though -- OnInitializationCompleted is the only example (so far) in this
442 // test where we need to Run the loop to swallow a task and then quit, to 507 // test where we need to Run the loop to swallow a task and then quit, to
443 // avoid leaking the ProfileSyncService (the PostTask will retain the callee 508 // avoid leaking the ProfileSyncService (the PostTask will retain the callee
444 // and caller until the task is run). 509 // and caller until the task is run).
445 MessageLoop message_loop_; 510 MessageLoop message_loop_;
446 BrowserThread ui_thread_; 511 BrowserThread ui_thread_;
447 BrowserThread file_thread_; 512 BrowserThread file_thread_;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 // Delete an item with several children. 606 // Delete an item with several children.
542 model_->Remove(folder2->GetParent(), 607 model_->Remove(folder2->GetParent(),
543 folder2->GetParent()->IndexOfChild(folder2)); 608 folder2->GetParent()->IndexOfChild(folder2));
544 ExpectModelMatch(); 609 ExpectModelMatch();
545 } 610 }
546 611
547 TEST_F(ProfileSyncServiceTest, ServerChangeProcessing) { 612 TEST_F(ProfileSyncServiceTest, ServerChangeProcessing) {
548 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 613 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
549 StartSyncService(); 614 StartSyncService();
550 615
551 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); 616 sync_api::WriteTransaction trans(service_->GetUserShare());
552 617
553 FakeServerChange adds(&trans); 618 FakeServerChange adds(&trans);
554 int64 f1 = adds.AddFolder(L"Server Folder B", bookmark_bar_id(), 0); 619 int64 f1 = adds.AddFolder(L"Server Folder B", bookmark_bar_id(), 0);
555 int64 f2 = adds.AddFolder(L"Server Folder A", bookmark_bar_id(), f1); 620 int64 f2 = adds.AddFolder(L"Server Folder A", bookmark_bar_id(), f1);
556 int64 u1 = adds.AddURL(L"Some old site", "ftp://nifty.andrew.cmu.edu/", 621 int64 u1 = adds.AddURL(L"Some old site", "ftp://nifty.andrew.cmu.edu/",
557 bookmark_bar_id(), f2); 622 bookmark_bar_id(), f2);
558 int64 u2 = adds.AddURL(L"Nifty", "ftp://nifty.andrew.cmu.edu/", f1, 0); 623 int64 u2 = adds.AddURL(L"Nifty", "ftp://nifty.andrew.cmu.edu/", f1, 0);
559 // u3 is a duplicate URL 624 // u3 is a duplicate URL
560 int64 u3 = adds.AddURL(L"Nifty2", "ftp://nifty.andrew.cmu.edu/", f1, u2); 625 int64 u3 = adds.AddURL(L"Nifty2", "ftp://nifty.andrew.cmu.edu/", f1, u2);
561 // u4 is a duplicate title, different URL. 626 // u4 is a duplicate title, different URL.
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 } 695 }
631 696
632 // Tests a specific case in ApplyModelChanges where we move the 697 // Tests a specific case in ApplyModelChanges where we move the
633 // children out from under a parent, and then delete the parent 698 // children out from under a parent, and then delete the parent
634 // in the same changelist. The delete shows up first in the changelist, 699 // in the same changelist. The delete shows up first in the changelist,
635 // requiring the children to be moved to a temporary location. 700 // requiring the children to be moved to a temporary location.
636 TEST_F(ProfileSyncServiceTest, ServerChangeRequiringFosterParent) { 701 TEST_F(ProfileSyncServiceTest, ServerChangeRequiringFosterParent) {
637 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE); 702 LoadBookmarkModel(DELETE_EXISTING_STORAGE, DONT_SAVE_TO_STORAGE);
638 StartSyncService(); 703 StartSyncService();
639 704
640 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); 705 sync_api::WriteTransaction trans(service_->GetUserShare());
641 706
642 // Stress the immediate children of other_node because that's where 707 // Stress the immediate children of other_node because that's where
643 // ApplyModelChanges puts a temporary foster parent node. 708 // ApplyModelChanges puts a temporary foster parent node.
644 std::string url("http://dev.chromium.org/"); 709 std::string url("http://dev.chromium.org/");
645 FakeServerChange adds(&trans); 710 FakeServerChange adds(&trans);
646 int64 f0 = other_bookmarks_id(); // + other_node 711 int64 f0 = other_bookmarks_id(); // + other_node
647 int64 f1 = adds.AddFolder(L"f1", f0, 0); // + f1 712 int64 f1 = adds.AddFolder(L"f1", f0, 0); // + f1
648 int64 f2 = adds.AddFolder(L"f2", f1, 0); // + f2 713 int64 f2 = adds.AddFolder(L"f2", f1, 0); // + f2
649 int64 u3 = adds.AddURL( L"u3", url, f2, 0); // + u3 NOLINT 714 int64 u3 = adds.AddURL( L"u3", url, f2, 0); // + u3 NOLINT
650 int64 u4 = adds.AddURL( L"u4", url, f2, u3); // + u4 NOLINT 715 int64 u4 = adds.AddURL( L"u4", url, f2, u3); // + u4 NOLINT
(...skipping 28 matching lines...) Expand all
679 744
680 ExpectModelMatch(&trans); 745 ExpectModelMatch(&trans);
681 } 746 }
682 747
683 // Simulate a server change record containing a valid but non-canonical URL. 748 // Simulate a server change record containing a valid but non-canonical URL.
684 TEST_F(ProfileSyncServiceTest, ServerChangeWithNonCanonicalURL) { 749 TEST_F(ProfileSyncServiceTest, ServerChangeWithNonCanonicalURL) {
685 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE); 750 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE);
686 StartSyncService(); 751 StartSyncService();
687 752
688 { 753 {
689 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); 754 sync_api::WriteTransaction trans(service_->GetUserShare());
690 755
691 FakeServerChange adds(&trans); 756 FakeServerChange adds(&trans);
692 std::string url("http://dev.chromium.org"); 757 std::string url("http://dev.chromium.org");
693 EXPECT_NE(GURL(url).spec(), url); 758 EXPECT_NE(GURL(url).spec(), url);
694 adds.AddURL(L"u1", url, other_bookmarks_id(), 0); 759 adds.AddURL(L"u1", url, other_bookmarks_id(), 0);
695 760
696 adds.ApplyPendingChanges(change_processor()); 761 adds.ApplyPendingChanges(change_processor());
697 762
698 EXPECT_TRUE(model_->other_node()->GetChildCount() == 1); 763 EXPECT_TRUE(model_->other_node()->GetChildCount() == 1);
699 ExpectModelMatch(&trans); 764 ExpectModelMatch(&trans);
(...skipping 10 matching lines...) Expand all
710 } 775 }
711 776
712 // Simulate a server change record containing an invalid URL (per GURL). 777 // Simulate a server change record containing an invalid URL (per GURL).
713 // TODO(ncarter): Disabled due to crashes. Fix bug 1677563. 778 // TODO(ncarter): Disabled due to crashes. Fix bug 1677563.
714 TEST_F(ProfileSyncServiceTest, DISABLED_ServerChangeWithInvalidURL) { 779 TEST_F(ProfileSyncServiceTest, DISABLED_ServerChangeWithInvalidURL) {
715 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE); 780 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE);
716 StartSyncService(); 781 StartSyncService();
717 782
718 int child_count = 0; 783 int child_count = 0;
719 { 784 {
720 sync_api::WriteTransaction trans(backend()->GetUserShareHandle()); 785 sync_api::WriteTransaction trans(service_->GetUserShare());
721 786
722 FakeServerChange adds(&trans); 787 FakeServerChange adds(&trans);
723 std::string url("x"); 788 std::string url("x");
724 EXPECT_FALSE(GURL(url).is_valid()); 789 EXPECT_FALSE(GURL(url).is_valid());
725 adds.AddURL(L"u1", url, other_bookmarks_id(), 0); 790 adds.AddURL(L"u1", url, other_bookmarks_id(), 0);
726 791
727 adds.ApplyPendingChanges(change_processor()); 792 adds.ApplyPendingChanges(change_processor());
728 793
729 // We're lenient about what should happen -- the model could wind up with 794 // We're lenient about what should happen -- the model could wind up with
730 // the node or without it; but things should be consistent, and we 795 // the node or without it; but things should be consistent, and we
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 892
828 // Add a node which will be the target of the consistency violation. 893 // Add a node which will be the target of the consistency violation.
829 const BookmarkNode* node = 894 const BookmarkNode* node =
830 model_->AddGroup(model_->other_node(), 0, ASCIIToUTF16("node")); 895 model_->AddGroup(model_->other_node(), 0, ASCIIToUTF16("node"));
831 ExpectSyncerNodeMatching(node); 896 ExpectSyncerNodeMatching(node);
832 897
833 // Now destroy the syncer node as if we were the ProfileSyncService without 898 // Now destroy the syncer node as if we were the ProfileSyncService without
834 // updating the ProfileSyncService state. This should introduce 899 // updating the ProfileSyncService state. This should introduce
835 // inconsistency between the two models. 900 // inconsistency between the two models.
836 { 901 {
837 sync_api::WriteTransaction trans(service_->backend_->GetUserShareHandle()); 902 sync_api::WriteTransaction trans(service_->GetUserShare());
838 sync_api::WriteNode sync_node(&trans); 903 sync_api::WriteNode sync_node(&trans);
839 EXPECT_TRUE(associator()->InitSyncNodeFromChromeId(node->id(), 904 EXPECT_TRUE(associator()->InitSyncNodeFromChromeId(node->id(),
840 &sync_node)); 905 &sync_node));
841 sync_node.Remove(); 906 sync_node.Remove();
842 } 907 }
843 // The models don't match at this point, but the ProfileSyncService 908 // The models don't match at this point, but the ProfileSyncService
844 // doesn't know it yet. 909 // doesn't know it yet.
845 ExpectSyncerNodeKnown(node); 910 ExpectSyncerNodeKnown(node);
846 EXPECT_TRUE(service_->ShouldPushChanges()); 911 EXPECT_TRUE(service_->ShouldPushChanges());
847 912
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 1381
1317 // See what happens if we enable sync but then delete the "Sync Data" 1382 // See what happens if we enable sync but then delete the "Sync Data"
1318 // folder. 1383 // folder.
1319 TEST_F(ProfileSyncServiceTestWithData, RecoverAfterDeletingSyncDataDirectory) { 1384 TEST_F(ProfileSyncServiceTestWithData, RecoverAfterDeletingSyncDataDirectory) {
1320 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE); 1385 LoadBookmarkModel(DELETE_EXISTING_STORAGE, SAVE_TO_STORAGE);
1321 StartSyncService(); 1386 StartSyncService();
1322 1387
1323 WriteTestDataToBookmarkModel(); 1388 WriteTestDataToBookmarkModel();
1324 1389
1325 // While the service is running. 1390 // While the service is running.
1326 FilePath sync_data_directory = backend()->sync_data_folder_path(); 1391 FilePath sync_data_directory =
1392 service_->GetBackendForTest()->sync_data_folder_path();
1327 1393
1328 // Simulate a normal shutdown for the sync service (don't disable it for 1394 // Simulate a normal shutdown for the sync service (don't disable it for
1329 // the user, which would reset the preferences and delete the sync data 1395 // the user, which would reset the preferences and delete the sync data
1330 // directory). 1396 // directory).
1331 StopSyncService(SAVE_TO_STORAGE); 1397 StopSyncService(SAVE_TO_STORAGE);
1332 1398
1333 // Now pretend that the user has deleted this directory from the disk. 1399 // Now pretend that the user has deleted this directory from the disk.
1334 file_util::Delete(sync_data_directory, true); 1400 file_util::Delete(sync_data_directory, true);
1335 1401
1336 // Restart the sync service. Don't fake out setting initial sync ended; lets 1402 // Restart the sync service. Don't fake out setting initial sync ended; lets
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 1447
1382 service_->RegisterDataTypeController( 1448 service_->RegisterDataTypeController(
1383 new browser_sync::BookmarkDataTypeController(&factory_, 1449 new browser_sync::BookmarkDataTypeController(&factory_,
1384 profile_.get(), 1450 profile_.get(),
1385 service_.get())); 1451 service_.get()));
1386 1452
1387 service_->Initialize(); // will call disableForUser because sync setup 1453 service_->Initialize(); // will call disableForUser because sync setup
1388 // hasn't been completed. 1454 // hasn't been completed.
1389 } 1455 }
1390 1456
1391 ASSERT_FALSE(service_->backend());
1392 ASSERT_FALSE(service_->HasSyncSetupCompleted()); 1457 ASSERT_FALSE(service_->HasSyncSetupCompleted());
1393 1458
1394 // Create some tokens in the token service; the service will startup when 1459 // Create some tokens in the token service; the service will startup when
1395 // it is notified that tokens are available. 1460 // it is notified that tokens are available.
1396 profile_->GetTokenService()->IssueAuthTokenForTest( 1461 profile_->GetTokenService()->IssueAuthTokenForTest(
1397 GaiaConstants::kSyncService, "sync_token"); 1462 GaiaConstants::kSyncService, "sync_token");
1398 1463
1399 syncable::ModelTypeSet set; 1464 syncable::ModelTypeSet set;
1400 set.insert(syncable::BOOKMARKS); 1465 set.insert(syncable::BOOKMARKS);
1401 service_->OnUserChoseDatatypes(false, set); 1466 service_->OnUserChoseDatatypes(false, set);
1402 1467
1403 MessageLoop::current()->RunAllPending(); 1468 MessageLoop::current()->RunAllPending();
1404 1469
1405 // Stop the service so we can read the new Sync Data files that were created. 1470 // Stop the service so we can read the new Sync Data files that were created.
1406 service_.reset(); 1471 service_.reset();
1407 1472
1408 // This file should have been deleted when the whole directory was nuked. 1473 // This file should have been deleted when the whole directory was nuked.
1409 ASSERT_FALSE(file_util::PathExists(sync_file3)); 1474 ASSERT_FALSE(file_util::PathExists(sync_file3));
1410 ASSERT_FALSE(file_util::PathExists(sync_file1)); 1475 ASSERT_FALSE(file_util::PathExists(sync_file1));
1411 1476
1412 // This will still exist, but the text should have changed. 1477 // This will still exist, but the text should have changed.
1413 ASSERT_TRUE(file_util::PathExists(sync_file2)); 1478 ASSERT_TRUE(file_util::PathExists(sync_file2));
1414 std::string file2text; 1479 std::string file2text;
1415 file_util::ReadFileToString(sync_file2, &file2text); 1480 file_util::ReadFileToString(sync_file2, &file2text);
1416 ASSERT_FALSE(file2text.compare(nonsense2) == 0); 1481 ASSERT_FALSE(file2text.compare(nonsense2) == 0);
1417 } 1482 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_typed_url_unittest.cc ('k') | chrome/browser/sync/profile_sync_test_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698