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 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingHeaderAndTab) { | 1012 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingHeaderAndTab) { |
1013 AddTab(browser(), GURL("http://foo1")); | 1013 AddTab(browser(), GURL("http://foo1")); |
1014 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1014 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1015 AddTab(browser(), GURL("http://bar1")); | 1015 AddTab(browser(), GURL("http://bar1")); |
1016 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1016 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1017 CreateRootHelper create_root(this); | 1017 CreateRootHelper create_root(this); |
1018 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1018 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1019 SyncError error; | 1019 SyncError error; |
1020 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1020 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
1021 | 1021 |
1022 ASSERT_TRUE(model_associator_->DisassociateModels(&error)); | 1022 error = model_associator_->DisassociateModels(); |
| 1023 ASSERT_FALSE(error.IsSet()); |
1023 { | 1024 { |
1024 // Create a sync node with the local tag but neither header nor tab field. | 1025 // Create a sync node with the local tag but neither header nor tab field. |
1025 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1026 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1026 sync_api::ReadNode root(&trans); | 1027 sync_api::ReadNode root(&trans); |
1027 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1028 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1028 sync_api::WriteNode extra_header(&trans); | 1029 sync_api::WriteNode extra_header(&trans); |
1029 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1030 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, |
1030 root, "new_tag")); | 1031 root, "new_tag")); |
1031 sync_pb::SessionSpecifics specifics; | 1032 sync_pb::SessionSpecifics specifics; |
1032 specifics.set_session_tag(local_tag); | 1033 specifics.set_session_tag(local_tag); |
1033 extra_header.SetSessionSpecifics(specifics); | 1034 extra_header.SetSessionSpecifics(specifics); |
1034 } | 1035 } |
1035 ASSERT_TRUE(model_associator_->AssociateModels(&error)); | 1036 |
| 1037 error = model_associator_->AssociateModels(); |
1036 ASSERT_FALSE(error.IsSet()); | 1038 ASSERT_FALSE(error.IsSet()); |
1037 } | 1039 } |
1038 | 1040 |
1039 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1041 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
1040 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MultipleHeaders) { | 1042 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MultipleHeaders) { |
1041 AddTab(browser(), GURL("http://foo1")); | 1043 AddTab(browser(), GURL("http://foo1")); |
1042 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1044 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1043 AddTab(browser(), GURL("http://bar1")); | 1045 AddTab(browser(), GURL("http://bar1")); |
1044 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1046 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1045 CreateRootHelper create_root(this); | 1047 CreateRootHelper create_root(this); |
1046 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1048 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1047 SyncError error; | 1049 SyncError error; |
1048 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1050 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
1049 | 1051 |
1050 ASSERT_TRUE(model_associator_->DisassociateModels(&error)); | 1052 error = model_associator_->DisassociateModels(); |
| 1053 ASSERT_FALSE(error.IsSet()); |
1051 { | 1054 { |
1052 // Create another sync node with a header field and the local tag. | 1055 // Create another sync node with a header field and the local tag. |
1053 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1056 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1054 sync_api::ReadNode root(&trans); | 1057 sync_api::ReadNode root(&trans); |
1055 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1058 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1056 sync_api::WriteNode extra_header(&trans); | 1059 sync_api::WriteNode extra_header(&trans); |
1057 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1060 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, |
1058 root, local_tag + "_")); | 1061 root, local_tag + "_")); |
1059 sync_pb::SessionSpecifics specifics; | 1062 sync_pb::SessionSpecifics specifics; |
1060 specifics.set_session_tag(local_tag); | 1063 specifics.set_session_tag(local_tag); |
1061 specifics.mutable_header(); | 1064 specifics.mutable_header(); |
1062 extra_header.SetSessionSpecifics(specifics); | 1065 extra_header.SetSessionSpecifics(specifics); |
1063 } | 1066 } |
1064 ASSERT_TRUE(model_associator_->AssociateModels(&error)); | 1067 error = model_associator_->AssociateModels(); |
1065 ASSERT_FALSE(error.IsSet()); | 1068 ASSERT_FALSE(error.IsSet()); |
1066 } | 1069 } |
1067 | 1070 |
1068 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1071 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
1069 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedForeign) { | 1072 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedForeign) { |
1070 AddTab(browser(), GURL("http://foo1")); | 1073 AddTab(browser(), GURL("http://foo1")); |
1071 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1074 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1072 AddTab(browser(), GURL("http://bar1")); | 1075 AddTab(browser(), GURL("http://bar1")); |
1073 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1076 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1074 CreateRootHelper create_root(this); | 1077 CreateRootHelper create_root(this); |
1075 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1078 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1076 SyncError error; | 1079 SyncError error; |
1077 | 1080 |
1078 ASSERT_TRUE(model_associator_->DisassociateModels(&error)); | 1081 error = model_associator_->DisassociateModels(); |
| 1082 ASSERT_FALSE(error.IsSet()); |
1079 { | 1083 { |
1080 // 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 |
1081 // tag. | 1085 // tag. |
1082 std::string foreign_tag = "foreign_tag"; | 1086 std::string foreign_tag = "foreign_tag"; |
1083 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1087 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1084 sync_api::ReadNode root(&trans); | 1088 sync_api::ReadNode root(&trans); |
1085 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1089 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1086 sync_api::WriteNode extra_header(&trans); | 1090 sync_api::WriteNode extra_header(&trans); |
1087 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1091 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, |
1088 root, foreign_tag)); | 1092 root, foreign_tag)); |
1089 sync_pb::SessionSpecifics specifics; | 1093 sync_pb::SessionSpecifics specifics; |
1090 specifics.set_session_tag(foreign_tag); | 1094 specifics.set_session_tag(foreign_tag); |
1091 extra_header.SetSessionSpecifics(specifics); | 1095 extra_header.SetSessionSpecifics(specifics); |
1092 } | 1096 } |
1093 ASSERT_TRUE(model_associator_->AssociateModels(&error)); | 1097 error = model_associator_->AssociateModels(); |
1094 ASSERT_FALSE(error.IsSet()); | 1098 ASSERT_FALSE(error.IsSet()); |
1095 } | 1099 } |
1096 | 1100 |
1097 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1101 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
1098 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingLocalTabNode) { | 1102 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingLocalTabNode) { |
1099 AddTab(browser(), GURL("http://foo1")); | 1103 AddTab(browser(), GURL("http://foo1")); |
1100 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1104 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1101 AddTab(browser(), GURL("http://bar1")); | 1105 AddTab(browser(), GURL("http://bar1")); |
1102 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1106 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1103 CreateRootHelper create_root(this); | 1107 CreateRootHelper create_root(this); |
1104 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1108 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1105 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1109 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
1106 SyncError error; | 1110 SyncError error; |
1107 | 1111 |
1108 ASSERT_TRUE(model_associator_->DisassociateModels(&error)); | 1112 error = model_associator_->DisassociateModels(); |
| 1113 ASSERT_FALSE(error.IsSet()); |
1109 { | 1114 { |
1110 // Delete the first sync tab node. | 1115 // Delete the first sync tab node. |
1111 std::string tab_tag = SessionModelAssociator::TabIdToTag(local_tag, 0); | 1116 std::string tab_tag = SessionModelAssociator::TabIdToTag(local_tag, 0); |
1112 | 1117 |
1113 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1118 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1114 sync_api::ReadNode root(&trans); | 1119 sync_api::ReadNode root(&trans); |
1115 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1120 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1116 sync_api::WriteNode tab_node(&trans); | 1121 sync_api::WriteNode tab_node(&trans); |
1117 ASSERT_TRUE(tab_node.InitByClientTagLookup(syncable::SESSIONS, tab_tag)); | 1122 ASSERT_TRUE(tab_node.InitByClientTagLookup(syncable::SESSIONS, tab_tag)); |
1118 tab_node.Remove(); | 1123 tab_node.Remove(); |
1119 } | 1124 } |
1120 ASSERT_TRUE(model_associator_->AssociateModels(&error)); | 1125 error = model_associator_->AssociateModels(); |
1121 ASSERT_FALSE(error.IsSet()); | 1126 ASSERT_FALSE(error.IsSet()); |
1122 | 1127 |
1123 // Add some more tabs to ensure we don't conflict with the pre-existing tab | 1128 // Add some more tabs to ensure we don't conflict with the pre-existing tab |
1124 // node. | 1129 // node. |
1125 AddTab(browser(), GURL("http://baz1")); | 1130 AddTab(browser(), GURL("http://baz1")); |
1126 AddTab(browser(), GURL("http://baz2")); | 1131 AddTab(browser(), GURL("http://baz2")); |
1127 } | 1132 } |
1128 | 1133 |
1129 } // namespace browser_sync | 1134 } // namespace browser_sync |
OLD | NEW |