| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "sync/test/engine/test_id_factory.h" | 48 #include "sync/test/engine/test_id_factory.h" |
| 49 #include "testing/gmock/include/gmock/gmock.h" | 49 #include "testing/gmock/include/gmock/gmock.h" |
| 50 #include "testing/gtest/include/gtest/gtest.h" | 50 #include "testing/gtest/include/gtest/gtest.h" |
| 51 #include "ui/base/ui_base_types.h" | 51 #include "ui/base/ui_base_types.h" |
| 52 | 52 |
| 53 using browser_sync::SessionChangeProcessor; | 53 using browser_sync::SessionChangeProcessor; |
| 54 using browser_sync::SessionDataTypeController; | 54 using browser_sync::SessionDataTypeController; |
| 55 using browser_sync::SessionModelAssociator; | 55 using browser_sync::SessionModelAssociator; |
| 56 using browser_sync::SyncBackendHost; | 56 using browser_sync::SyncBackendHost; |
| 57 using content::BrowserThread; | 57 using content::BrowserThread; |
| 58 using csync::ChangeRecord; | 58 using syncer::ChangeRecord; |
| 59 using testing::_; | 59 using testing::_; |
| 60 using testing::Return; | 60 using testing::Return; |
| 61 using csync::TestIdFactory; | 61 using syncer::TestIdFactory; |
| 62 | 62 |
| 63 namespace browser_sync { | 63 namespace browser_sync { |
| 64 | 64 |
| 65 namespace { | 65 namespace { |
| 66 | 66 |
| 67 void BuildSessionSpecifics(const std::string& tag, | 67 void BuildSessionSpecifics(const std::string& tag, |
| 68 sync_pb::SessionSpecifics* meta) { | 68 sync_pb::SessionSpecifics* meta) { |
| 69 meta->set_session_tag(tag); | 69 meta->set_session_tag(tag); |
| 70 sync_pb::SessionHeader* header = meta->mutable_header(); | 70 sync_pb::SessionHeader* header = meta->mutable_header(); |
| 71 header->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_LINUX); | 71 header->set_device_type(sync_pb::SessionHeader_DeviceType_TYPE_LINUX); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 CreateRootHelper create_root(this); | 300 CreateRootHelper create_root(this); |
| 301 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 301 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 302 ASSERT_TRUE(create_root.success()); | 302 ASSERT_TRUE(create_root.success()); |
| 303 | 303 |
| 304 // Check that the DataTypeController associated the models. | 304 // Check that the DataTypeController associated the models. |
| 305 bool has_nodes; | 305 bool has_nodes; |
| 306 ASSERT_TRUE(model_associator_->SyncModelHasUserCreatedNodes(&has_nodes)); | 306 ASSERT_TRUE(model_associator_->SyncModelHasUserCreatedNodes(&has_nodes)); |
| 307 ASSERT_TRUE(has_nodes); | 307 ASSERT_TRUE(has_nodes); |
| 308 std::string machine_tag = model_associator_->GetCurrentMachineTag(); | 308 std::string machine_tag = model_associator_->GetCurrentMachineTag(); |
| 309 int64 sync_id = model_associator_->GetSyncIdFromSessionTag(machine_tag); | 309 int64 sync_id = model_associator_->GetSyncIdFromSessionTag(machine_tag); |
| 310 ASSERT_NE(csync::kInvalidId, sync_id); | 310 ASSERT_NE(syncer::kInvalidId, sync_id); |
| 311 | 311 |
| 312 // Check that we can get the correct session specifics back from the node. | 312 // Check that we can get the correct session specifics back from the node. |
| 313 csync::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 313 syncer::ReadTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 314 csync::ReadNode node(&trans); | 314 syncer::ReadNode node(&trans); |
| 315 ASSERT_EQ(csync::BaseNode::INIT_OK, | 315 ASSERT_EQ(syncer::BaseNode::INIT_OK, |
| 316 node.InitByClientTagLookup(syncable::SESSIONS, machine_tag)); | 316 node.InitByClientTagLookup(syncable::SESSIONS, machine_tag)); |
| 317 const sync_pb::SessionSpecifics& specifics(node.GetSessionSpecifics()); | 317 const sync_pb::SessionSpecifics& specifics(node.GetSessionSpecifics()); |
| 318 ASSERT_EQ(machine_tag, specifics.session_tag()); | 318 ASSERT_EQ(machine_tag, specifics.session_tag()); |
| 319 ASSERT_TRUE(specifics.has_header()); | 319 ASSERT_TRUE(specifics.has_header()); |
| 320 const sync_pb::SessionHeader& header_s = specifics.header(); | 320 const sync_pb::SessionHeader& header_s = specifics.header(); |
| 321 ASSERT_TRUE(header_s.has_device_type()); | 321 ASSERT_TRUE(header_s.has_device_type()); |
| 322 ASSERT_EQ("TestSessionName", header_s.client_name()); | 322 ASSERT_EQ("TestSessionName", header_s.client_name()); |
| 323 ASSERT_EQ(0, header_s.window_size()); | 323 ASSERT_EQ(0, header_s.window_size()); |
| 324 } | 324 } |
| 325 | 325 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 337 ASSERT_TRUE(has_nodes); | 337 ASSERT_TRUE(has_nodes); |
| 338 AddTab(browser(), GURL("http://foo/1")); | 338 AddTab(browser(), GURL("http://foo/1")); |
| 339 NavigateAndCommitActiveTab(GURL("http://foo/2")); | 339 NavigateAndCommitActiveTab(GURL("http://foo/2")); |
| 340 AddTab(browser(), GURL("http://bar/1")); | 340 AddTab(browser(), GURL("http://bar/1")); |
| 341 NavigateAndCommitActiveTab(GURL("http://bar/2")); | 341 NavigateAndCommitActiveTab(GURL("http://bar/2")); |
| 342 | 342 |
| 343 ASSERT_TRUE(model_associator_->SyncModelHasUserCreatedNodes(&has_nodes)); | 343 ASSERT_TRUE(model_associator_->SyncModelHasUserCreatedNodes(&has_nodes)); |
| 344 ASSERT_TRUE(has_nodes); | 344 ASSERT_TRUE(has_nodes); |
| 345 std::string machine_tag = model_associator_->GetCurrentMachineTag(); | 345 std::string machine_tag = model_associator_->GetCurrentMachineTag(); |
| 346 int64 sync_id = model_associator_->GetSyncIdFromSessionTag(machine_tag); | 346 int64 sync_id = model_associator_->GetSyncIdFromSessionTag(machine_tag); |
| 347 ASSERT_NE(csync::kInvalidId, sync_id); | 347 ASSERT_NE(syncer::kInvalidId, sync_id); |
| 348 | 348 |
| 349 // Check that this machine's data is not included in the foreign windows. | 349 // Check that this machine's data is not included in the foreign windows. |
| 350 std::vector<const SyncedSession*> foreign_sessions; | 350 std::vector<const SyncedSession*> foreign_sessions; |
| 351 ASSERT_FALSE(model_associator_->GetAllForeignSessions(&foreign_sessions)); | 351 ASSERT_FALSE(model_associator_->GetAllForeignSessions(&foreign_sessions)); |
| 352 ASSERT_EQ(foreign_sessions.size(), 0U); | 352 ASSERT_EQ(foreign_sessions.size(), 0U); |
| 353 | 353 |
| 354 // Get the tabs for this machine from the node and check that they were | 354 // Get the tabs for this machine from the node and check that they were |
| 355 // filled. | 355 // filled. |
| 356 SessionModelAssociator::TabLinksMap tab_map = model_associator_->tab_map_; | 356 SessionModelAssociator::TabLinksMap tab_map = model_associator_->tab_map_; |
| 357 ASSERT_EQ(2U, tab_map.size()); | 357 ASSERT_EQ(2U, tab_map.size()); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 641 | 641 |
| 642 // Test the DataTypeController on update. | 642 // Test the DataTypeController on update. |
| 643 TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionUpdate) { | 643 TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionUpdate) { |
| 644 CreateRootHelper create_root(this); | 644 CreateRootHelper create_root(this); |
| 645 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 645 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 646 ASSERT_TRUE(create_root.success()); | 646 ASSERT_TRUE(create_root.success()); |
| 647 int64 node_id = model_associator_->GetSyncIdFromSessionTag( | 647 int64 node_id = model_associator_->GetSyncIdFromSessionTag( |
| 648 model_associator_->GetCurrentMachineTag()); | 648 model_associator_->GetCurrentMachineTag()); |
| 649 ASSERT_FALSE(notified_of_update_); | 649 ASSERT_FALSE(notified_of_update_); |
| 650 { | 650 { |
| 651 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 651 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 652 change_processor_->ApplyChangesFromSyncModel( | 652 change_processor_->ApplyChangesFromSyncModel( |
| 653 &trans, | 653 &trans, |
| 654 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList( | 654 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList( |
| 655 node_id, ChangeRecord::ACTION_UPDATE)); | 655 node_id, ChangeRecord::ACTION_UPDATE)); |
| 656 } | 656 } |
| 657 ASSERT_TRUE(notified_of_update_); | 657 ASSERT_TRUE(notified_of_update_); |
| 658 } | 658 } |
| 659 | 659 |
| 660 // Test the DataTypeController on add. | 660 // Test the DataTypeController on add. |
| 661 TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionAdd) { | 661 TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionAdd) { |
| 662 CreateRootHelper create_root(this); | 662 CreateRootHelper create_root(this); |
| 663 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 663 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 664 ASSERT_TRUE(create_root.success()); | 664 ASSERT_TRUE(create_root.success()); |
| 665 | 665 |
| 666 int64 node_id = model_associator_->GetSyncIdFromSessionTag( | 666 int64 node_id = model_associator_->GetSyncIdFromSessionTag( |
| 667 model_associator_->GetCurrentMachineTag()); | 667 model_associator_->GetCurrentMachineTag()); |
| 668 ASSERT_FALSE(notified_of_update_); | 668 ASSERT_FALSE(notified_of_update_); |
| 669 { | 669 { |
| 670 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 670 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 671 change_processor_->ApplyChangesFromSyncModel( | 671 change_processor_->ApplyChangesFromSyncModel( |
| 672 &trans, | 672 &trans, |
| 673 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList( | 673 ProfileSyncServiceTestHelper::MakeSingletonChangeRecordList( |
| 674 node_id, ChangeRecord::ACTION_ADD)); | 674 node_id, ChangeRecord::ACTION_ADD)); |
| 675 } | 675 } |
| 676 ASSERT_TRUE(notified_of_update_); | 676 ASSERT_TRUE(notified_of_update_); |
| 677 } | 677 } |
| 678 | 678 |
| 679 // Test the DataTypeController on delete. | 679 // Test the DataTypeController on delete. |
| 680 TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionDelete) { | 680 TEST_F(ProfileSyncServiceSessionTest, UpdatedSyncNodeActionDelete) { |
| 681 CreateRootHelper create_root(this); | 681 CreateRootHelper create_root(this); |
| 682 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 682 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 683 ASSERT_TRUE(create_root.success()); | 683 ASSERT_TRUE(create_root.success()); |
| 684 | 684 |
| 685 int64 node_id = model_associator_->GetSyncIdFromSessionTag( | 685 int64 node_id = model_associator_->GetSyncIdFromSessionTag( |
| 686 model_associator_->GetCurrentMachineTag()); | 686 model_associator_->GetCurrentMachineTag()); |
| 687 sync_pb::EntitySpecifics deleted_specifics; | 687 sync_pb::EntitySpecifics deleted_specifics; |
| 688 deleted_specifics.mutable_session()->set_session_tag("tag"); | 688 deleted_specifics.mutable_session()->set_session_tag("tag"); |
| 689 ASSERT_FALSE(notified_of_update_); | 689 ASSERT_FALSE(notified_of_update_); |
| 690 { | 690 { |
| 691 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 691 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 692 change_processor_->ApplyChangesFromSyncModel( | 692 change_processor_->ApplyChangesFromSyncModel( |
| 693 &trans, | 693 &trans, |
| 694 ProfileSyncServiceTestHelper::MakeSingletonDeletionChangeRecordList( | 694 ProfileSyncServiceTestHelper::MakeSingletonDeletionChangeRecordList( |
| 695 node_id, deleted_specifics)); | 695 node_id, deleted_specifics)); |
| 696 } | 696 } |
| 697 ASSERT_TRUE(notified_of_update_); | 697 ASSERT_TRUE(notified_of_update_); |
| 698 } | 698 } |
| 699 // Test the TabNodePool when it starts off empty. | 699 // Test the TabNodePool when it starts off empty. |
| 700 TEST_F(ProfileSyncServiceSessionTest, TabNodePoolEmpty) { | 700 TEST_F(ProfileSyncServiceSessionTest, TabNodePoolEmpty) { |
| 701 CreateRootHelper create_root(this); | 701 CreateRootHelper create_root(this); |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 | 971 |
| 972 CreateRootHelper create_root(this); | 972 CreateRootHelper create_root(this); |
| 973 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 973 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 974 ASSERT_TRUE(create_root.success()); | 974 ASSERT_TRUE(create_root.success()); |
| 975 bool has_nodes; | 975 bool has_nodes; |
| 976 ASSERT_TRUE(model_associator_->SyncModelHasUserCreatedNodes(&has_nodes)); | 976 ASSERT_TRUE(model_associator_->SyncModelHasUserCreatedNodes(&has_nodes)); |
| 977 ASSERT_TRUE(has_nodes); | 977 ASSERT_TRUE(has_nodes); |
| 978 | 978 |
| 979 std::string machine_tag = model_associator_->GetCurrentMachineTag(); | 979 std::string machine_tag = model_associator_->GetCurrentMachineTag(); |
| 980 int64 sync_id = model_associator_->GetSyncIdFromSessionTag(machine_tag); | 980 int64 sync_id = model_associator_->GetSyncIdFromSessionTag(machine_tag); |
| 981 ASSERT_NE(csync::kInvalidId, sync_id); | 981 ASSERT_NE(syncer::kInvalidId, sync_id); |
| 982 | 982 |
| 983 // Check that this machine's data is not included in the foreign windows. | 983 // Check that this machine's data is not included in the foreign windows. |
| 984 std::vector<const SyncedSession*> foreign_sessions; | 984 std::vector<const SyncedSession*> foreign_sessions; |
| 985 ASSERT_FALSE(model_associator_->GetAllForeignSessions(&foreign_sessions)); | 985 ASSERT_FALSE(model_associator_->GetAllForeignSessions(&foreign_sessions)); |
| 986 ASSERT_EQ(foreign_sessions.size(), 0U); | 986 ASSERT_EQ(foreign_sessions.size(), 0U); |
| 987 | 987 |
| 988 // Get the tabs for this machine from the node and check that they were | 988 // Get the tabs for this machine from the node and check that they were |
| 989 // filled. | 989 // filled. |
| 990 SessionModelAssociator::TabLinksMap tab_map = model_associator_->tab_map_; | 990 SessionModelAssociator::TabLinksMap tab_map = model_associator_->tab_map_; |
| 991 ASSERT_EQ(2U, tab_map.size()); | 991 ASSERT_EQ(2U, tab_map.size()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1006 } | 1006 } |
| 1007 | 1007 |
| 1008 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1008 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
| 1009 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingHeaderAndTab) { | 1009 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingHeaderAndTab) { |
| 1010 AddTab(browser(), GURL("http://foo1")); | 1010 AddTab(browser(), GURL("http://foo1")); |
| 1011 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1011 NavigateAndCommitActiveTab(GURL("http://foo2")); |
| 1012 AddTab(browser(), GURL("http://bar1")); | 1012 AddTab(browser(), GURL("http://bar1")); |
| 1013 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1013 NavigateAndCommitActiveTab(GURL("http://bar2")); |
| 1014 CreateRootHelper create_root(this); | 1014 CreateRootHelper create_root(this); |
| 1015 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1015 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 1016 csync::SyncError error; | 1016 syncer::SyncError error; |
| 1017 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1017 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
| 1018 | 1018 |
| 1019 error = model_associator_->DisassociateModels(); | 1019 error = model_associator_->DisassociateModels(); |
| 1020 ASSERT_FALSE(error.IsSet()); | 1020 ASSERT_FALSE(error.IsSet()); |
| 1021 { | 1021 { |
| 1022 // Create a sync node with the local tag but neither header nor tab field. | 1022 // Create a sync node with the local tag but neither header nor tab field. |
| 1023 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1023 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 1024 csync::ReadNode root(&trans); | 1024 syncer::ReadNode root(&trans); |
| 1025 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1025 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
| 1026 csync::WriteNode extra_header(&trans); | 1026 syncer::WriteNode extra_header(&trans); |
| 1027 csync::WriteNode::InitUniqueByCreationResult result = | 1027 syncer::WriteNode::InitUniqueByCreationResult result = |
| 1028 extra_header.InitUniqueByCreation(syncable::SESSIONS, root, "new_tag"); | 1028 extra_header.InitUniqueByCreation(syncable::SESSIONS, root, "new_tag"); |
| 1029 ASSERT_EQ(csync::WriteNode::INIT_SUCCESS, result); | 1029 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); |
| 1030 sync_pb::SessionSpecifics specifics; | 1030 sync_pb::SessionSpecifics specifics; |
| 1031 specifics.set_session_tag(local_tag); | 1031 specifics.set_session_tag(local_tag); |
| 1032 extra_header.SetSessionSpecifics(specifics); | 1032 extra_header.SetSessionSpecifics(specifics); |
| 1033 } | 1033 } |
| 1034 | 1034 |
| 1035 error = model_associator_->AssociateModels(); | 1035 error = model_associator_->AssociateModels(); |
| 1036 ASSERT_FALSE(error.IsSet()); | 1036 ASSERT_FALSE(error.IsSet()); |
| 1037 } | 1037 } |
| 1038 | 1038 |
| 1039 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1039 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
| 1040 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MultipleHeaders) { | 1040 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MultipleHeaders) { |
| 1041 AddTab(browser(), GURL("http://foo1")); | 1041 AddTab(browser(), GURL("http://foo1")); |
| 1042 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1042 NavigateAndCommitActiveTab(GURL("http://foo2")); |
| 1043 AddTab(browser(), GURL("http://bar1")); | 1043 AddTab(browser(), GURL("http://bar1")); |
| 1044 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1044 NavigateAndCommitActiveTab(GURL("http://bar2")); |
| 1045 CreateRootHelper create_root(this); | 1045 CreateRootHelper create_root(this); |
| 1046 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1046 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 1047 csync::SyncError error; | 1047 syncer::SyncError error; |
| 1048 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1048 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
| 1049 | 1049 |
| 1050 error = model_associator_->DisassociateModels(); | 1050 error = model_associator_->DisassociateModels(); |
| 1051 ASSERT_FALSE(error.IsSet()); | 1051 ASSERT_FALSE(error.IsSet()); |
| 1052 { | 1052 { |
| 1053 // Create another sync node with a header field and the local tag. | 1053 // Create another sync node with a header field and the local tag. |
| 1054 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1054 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 1055 csync::ReadNode root(&trans); | 1055 syncer::ReadNode root(&trans); |
| 1056 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1056 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
| 1057 csync::WriteNode extra_header(&trans); | 1057 syncer::WriteNode extra_header(&trans); |
| 1058 csync::WriteNode::InitUniqueByCreationResult result = | 1058 syncer::WriteNode::InitUniqueByCreationResult result = |
| 1059 extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1059 extra_header.InitUniqueByCreation(syncable::SESSIONS, |
| 1060 root, local_tag + "_"); | 1060 root, local_tag + "_"); |
| 1061 ASSERT_EQ(csync::WriteNode::INIT_SUCCESS, result); | 1061 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); |
| 1062 sync_pb::SessionSpecifics specifics; | 1062 sync_pb::SessionSpecifics specifics; |
| 1063 specifics.set_session_tag(local_tag); | 1063 specifics.set_session_tag(local_tag); |
| 1064 specifics.mutable_header(); | 1064 specifics.mutable_header(); |
| 1065 extra_header.SetSessionSpecifics(specifics); | 1065 extra_header.SetSessionSpecifics(specifics); |
| 1066 } | 1066 } |
| 1067 error = model_associator_->AssociateModels(); | 1067 error = model_associator_->AssociateModels(); |
| 1068 ASSERT_FALSE(error.IsSet()); | 1068 ASSERT_FALSE(error.IsSet()); |
| 1069 } | 1069 } |
| 1070 | 1070 |
| 1071 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1071 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
| 1072 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedForeign) { | 1072 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedForeign) { |
| 1073 AddTab(browser(), GURL("http://foo1")); | 1073 AddTab(browser(), GURL("http://foo1")); |
| 1074 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1074 NavigateAndCommitActiveTab(GURL("http://foo2")); |
| 1075 AddTab(browser(), GURL("http://bar1")); | 1075 AddTab(browser(), GURL("http://bar1")); |
| 1076 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1076 NavigateAndCommitActiveTab(GURL("http://bar2")); |
| 1077 CreateRootHelper create_root(this); | 1077 CreateRootHelper create_root(this); |
| 1078 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1078 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 1079 csync::SyncError error; | 1079 syncer::SyncError error; |
| 1080 | 1080 |
| 1081 error = model_associator_->DisassociateModels(); | 1081 error = model_associator_->DisassociateModels(); |
| 1082 ASSERT_FALSE(error.IsSet()); | 1082 ASSERT_FALSE(error.IsSet()); |
| 1083 { | 1083 { |
| 1084 // Create another sync node with neither header nor tab field and a foreign | 1084 // Create another sync node with neither header nor tab field and a foreign |
| 1085 // tag. | 1085 // tag. |
| 1086 std::string foreign_tag = "foreign_tag"; | 1086 std::string foreign_tag = "foreign_tag"; |
| 1087 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1087 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 1088 csync::ReadNode root(&trans); | 1088 syncer::ReadNode root(&trans); |
| 1089 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1089 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
| 1090 csync::WriteNode extra_header(&trans); | 1090 syncer::WriteNode extra_header(&trans); |
| 1091 csync::WriteNode::InitUniqueByCreationResult result = | 1091 syncer::WriteNode::InitUniqueByCreationResult result = |
| 1092 extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1092 extra_header.InitUniqueByCreation(syncable::SESSIONS, |
| 1093 root, foreign_tag); | 1093 root, foreign_tag); |
| 1094 ASSERT_EQ(csync::WriteNode::INIT_SUCCESS, result); | 1094 ASSERT_EQ(syncer::WriteNode::INIT_SUCCESS, result); |
| 1095 sync_pb::SessionSpecifics specifics; | 1095 sync_pb::SessionSpecifics specifics; |
| 1096 specifics.set_session_tag(foreign_tag); | 1096 specifics.set_session_tag(foreign_tag); |
| 1097 extra_header.SetSessionSpecifics(specifics); | 1097 extra_header.SetSessionSpecifics(specifics); |
| 1098 } | 1098 } |
| 1099 error = model_associator_->AssociateModels(); | 1099 error = model_associator_->AssociateModels(); |
| 1100 ASSERT_FALSE(error.IsSet()); | 1100 ASSERT_FALSE(error.IsSet()); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1103 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
| 1104 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingLocalTabNode) { | 1104 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingLocalTabNode) { |
| 1105 AddTab(browser(), GURL("http://foo1")); | 1105 AddTab(browser(), GURL("http://foo1")); |
| 1106 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1106 NavigateAndCommitActiveTab(GURL("http://foo2")); |
| 1107 AddTab(browser(), GURL("http://bar1")); | 1107 AddTab(browser(), GURL("http://bar1")); |
| 1108 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1108 NavigateAndCommitActiveTab(GURL("http://bar2")); |
| 1109 CreateRootHelper create_root(this); | 1109 CreateRootHelper create_root(this); |
| 1110 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1110 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 1111 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1111 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
| 1112 csync::SyncError error; | 1112 syncer::SyncError error; |
| 1113 | 1113 |
| 1114 error = model_associator_->DisassociateModels(); | 1114 error = model_associator_->DisassociateModels(); |
| 1115 ASSERT_FALSE(error.IsSet()); | 1115 ASSERT_FALSE(error.IsSet()); |
| 1116 { | 1116 { |
| 1117 // Delete the first sync tab node. | 1117 // Delete the first sync tab node. |
| 1118 std::string tab_tag = SessionModelAssociator::TabIdToTag(local_tag, 0); | 1118 std::string tab_tag = SessionModelAssociator::TabIdToTag(local_tag, 0); |
| 1119 | 1119 |
| 1120 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1120 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 1121 csync::ReadNode root(&trans); | 1121 syncer::ReadNode root(&trans); |
| 1122 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1122 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
| 1123 csync::WriteNode tab_node(&trans); | 1123 syncer::WriteNode tab_node(&trans); |
| 1124 ASSERT_TRUE(tab_node.InitByClientTagLookup(syncable::SESSIONS, tab_tag)); | 1124 ASSERT_TRUE(tab_node.InitByClientTagLookup(syncable::SESSIONS, tab_tag)); |
| 1125 tab_node.Remove(); | 1125 tab_node.Remove(); |
| 1126 } | 1126 } |
| 1127 error = model_associator_->AssociateModels(); | 1127 error = model_associator_->AssociateModels(); |
| 1128 ASSERT_FALSE(error.IsSet()); | 1128 ASSERT_FALSE(error.IsSet()); |
| 1129 | 1129 |
| 1130 // Add some more tabs to ensure we don't conflict with the pre-existing tab | 1130 // Add some more tabs to ensure we don't conflict with the pre-existing tab |
| 1131 // node. | 1131 // node. |
| 1132 AddTab(browser(), GURL("http://baz1")); | 1132 AddTab(browser(), GURL("http://baz1")); |
| 1133 AddTab(browser(), GURL("http://baz2")); | 1133 AddTab(browser(), GURL("http://baz2")); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 | 1175 |
| 1176 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1176 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
| 1177 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedLocalHeader) { | 1177 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedLocalHeader) { |
| 1178 AddTab(browser(), GURL("http://foo1")); | 1178 AddTab(browser(), GURL("http://foo1")); |
| 1179 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1179 NavigateAndCommitActiveTab(GURL("http://foo2")); |
| 1180 AddTab(browser(), GURL("http://bar1")); | 1180 AddTab(browser(), GURL("http://bar1")); |
| 1181 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1181 NavigateAndCommitActiveTab(GURL("http://bar2")); |
| 1182 CreateRootHelper create_root(this); | 1182 CreateRootHelper create_root(this); |
| 1183 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1183 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
| 1184 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1184 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
| 1185 csync::SyncError error; | 1185 syncer::SyncError error; |
| 1186 | 1186 |
| 1187 error = model_associator_->DisassociateModels(); | 1187 error = model_associator_->DisassociateModels(); |
| 1188 ASSERT_FALSE(error.IsSet()); | 1188 ASSERT_FALSE(error.IsSet()); |
| 1189 { | 1189 { |
| 1190 // Load the header node and clear it. | 1190 // Load the header node and clear it. |
| 1191 csync::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1191 syncer::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
| 1192 csync::WriteNode header(&trans); | 1192 syncer::WriteNode header(&trans); |
| 1193 ASSERT_EQ(csync::BaseNode::INIT_OK, | 1193 ASSERT_EQ(syncer::BaseNode::INIT_OK, |
| 1194 header.InitByClientTagLookup(syncable::SESSIONS, local_tag)); | 1194 header.InitByClientTagLookup(syncable::SESSIONS, local_tag)); |
| 1195 sync_pb::SessionSpecifics specifics; | 1195 sync_pb::SessionSpecifics specifics; |
| 1196 header.SetSessionSpecifics(specifics); | 1196 header.SetSessionSpecifics(specifics); |
| 1197 } | 1197 } |
| 1198 // Ensure we associate properly despite the pre-existing node with our local | 1198 // Ensure we associate properly despite the pre-existing node with our local |
| 1199 // tag. | 1199 // tag. |
| 1200 error = model_associator_->AssociateModels(); | 1200 error = model_associator_->AssociateModels(); |
| 1201 ASSERT_FALSE(error.IsSet()); | 1201 ASSERT_FALSE(error.IsSet()); |
| 1202 } | 1202 } |
| 1203 | 1203 |
| 1204 } // namespace browser_sync | 1204 } // namespace browser_sync |
| OLD | NEW |