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 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1018 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1018 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
1019 | 1019 |
1020 error = model_associator_->DisassociateModels(); | 1020 error = model_associator_->DisassociateModels(); |
1021 ASSERT_FALSE(error.IsSet()); | 1021 ASSERT_FALSE(error.IsSet()); |
1022 { | 1022 { |
1023 // Create a sync node with the local tag but neither header nor tab field. | 1023 // Create a sync node with the local tag but neither header nor tab field. |
1024 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1024 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1025 sync_api::ReadNode root(&trans); | 1025 sync_api::ReadNode root(&trans); |
1026 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1026 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1027 sync_api::WriteNode extra_header(&trans); | 1027 sync_api::WriteNode extra_header(&trans); |
1028 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1028 sync_api::WriteNode::InitUniqueByCreationResult result = |
1029 root, "new_tag")); | 1029 extra_header.InitUniqueByCreation(syncable::SESSIONS, root, "new_tag"); |
| 1030 ASSERT_EQ(sync_api::WriteNode::INIT_SUCCESS, result); |
1030 sync_pb::SessionSpecifics specifics; | 1031 sync_pb::SessionSpecifics specifics; |
1031 specifics.set_session_tag(local_tag); | 1032 specifics.set_session_tag(local_tag); |
1032 extra_header.SetSessionSpecifics(specifics); | 1033 extra_header.SetSessionSpecifics(specifics); |
1033 } | 1034 } |
1034 | 1035 |
1035 error = model_associator_->AssociateModels(); | 1036 error = model_associator_->AssociateModels(); |
1036 ASSERT_FALSE(error.IsSet()); | 1037 ASSERT_FALSE(error.IsSet()); |
1037 } | 1038 } |
1038 | 1039 |
1039 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1040 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
1040 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MultipleHeaders) { | 1041 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MultipleHeaders) { |
1041 AddTab(browser(), GURL("http://foo1")); | 1042 AddTab(browser(), GURL("http://foo1")); |
1042 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1043 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1043 AddTab(browser(), GURL("http://bar1")); | 1044 AddTab(browser(), GURL("http://bar1")); |
1044 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1045 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1045 CreateRootHelper create_root(this); | 1046 CreateRootHelper create_root(this); |
1046 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1047 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1047 SyncError error; | 1048 SyncError error; |
1048 std::string local_tag = model_associator_->GetCurrentMachineTag(); | 1049 std::string local_tag = model_associator_->GetCurrentMachineTag(); |
1049 | 1050 |
1050 error = model_associator_->DisassociateModels(); | 1051 error = model_associator_->DisassociateModels(); |
1051 ASSERT_FALSE(error.IsSet()); | 1052 ASSERT_FALSE(error.IsSet()); |
1052 { | 1053 { |
1053 // Create another sync node with a header field and the local tag. | 1054 // Create another sync node with a header field and the local tag. |
1054 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1055 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1055 sync_api::ReadNode root(&trans); | 1056 sync_api::ReadNode root(&trans); |
1056 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1057 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1057 sync_api::WriteNode extra_header(&trans); | 1058 sync_api::WriteNode extra_header(&trans); |
1058 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1059 sync_api::WriteNode::InitUniqueByCreationResult result = |
1059 root, local_tag + "_")); | 1060 extra_header.InitUniqueByCreation(syncable::SESSIONS, |
| 1061 root, local_tag + "_"); |
| 1062 ASSERT_EQ(sync_api::WriteNode::INIT_SUCCESS, result); |
1060 sync_pb::SessionSpecifics specifics; | 1063 sync_pb::SessionSpecifics specifics; |
1061 specifics.set_session_tag(local_tag); | 1064 specifics.set_session_tag(local_tag); |
1062 specifics.mutable_header(); | 1065 specifics.mutable_header(); |
1063 extra_header.SetSessionSpecifics(specifics); | 1066 extra_header.SetSessionSpecifics(specifics); |
1064 } | 1067 } |
1065 error = model_associator_->AssociateModels(); | 1068 error = model_associator_->AssociateModels(); |
1066 ASSERT_FALSE(error.IsSet()); | 1069 ASSERT_FALSE(error.IsSet()); |
1067 } | 1070 } |
1068 | 1071 |
1069 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1072 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
1070 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedForeign) { | 1073 TEST_F(ProfileSyncServiceSessionTest, DISABLED_CorruptedForeign) { |
1071 AddTab(browser(), GURL("http://foo1")); | 1074 AddTab(browser(), GURL("http://foo1")); |
1072 NavigateAndCommitActiveTab(GURL("http://foo2")); | 1075 NavigateAndCommitActiveTab(GURL("http://foo2")); |
1073 AddTab(browser(), GURL("http://bar1")); | 1076 AddTab(browser(), GURL("http://bar1")); |
1074 NavigateAndCommitActiveTab(GURL("http://bar2")); | 1077 NavigateAndCommitActiveTab(GURL("http://bar2")); |
1075 CreateRootHelper create_root(this); | 1078 CreateRootHelper create_root(this); |
1076 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); | 1079 ASSERT_TRUE(StartSyncService(create_root.callback(), false)); |
1077 SyncError error; | 1080 SyncError error; |
1078 | 1081 |
1079 error = model_associator_->DisassociateModels(); | 1082 error = model_associator_->DisassociateModels(); |
1080 ASSERT_FALSE(error.IsSet()); | 1083 ASSERT_FALSE(error.IsSet()); |
1081 { | 1084 { |
1082 // Create another sync node with neither header nor tab field and a foreign | 1085 // Create another sync node with neither header nor tab field and a foreign |
1083 // tag. | 1086 // tag. |
1084 std::string foreign_tag = "foreign_tag"; | 1087 std::string foreign_tag = "foreign_tag"; |
1085 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); | 1088 sync_api::WriteTransaction trans(FROM_HERE, sync_service_->GetUserShare()); |
1086 sync_api::ReadNode root(&trans); | 1089 sync_api::ReadNode root(&trans); |
1087 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); | 1090 root.InitByTagLookup(syncable::ModelTypeToRootTag(syncable::SESSIONS)); |
1088 sync_api::WriteNode extra_header(&trans); | 1091 sync_api::WriteNode extra_header(&trans); |
1089 ASSERT_TRUE(extra_header.InitUniqueByCreation(syncable::SESSIONS, | 1092 sync_api::WriteNode::InitUniqueByCreationResult result = |
1090 root, foreign_tag)); | 1093 extra_header.InitUniqueByCreation(syncable::SESSIONS, |
| 1094 root, foreign_tag); |
| 1095 ASSERT_EQ(sync_api::WriteNode::INIT_SUCCESS, result); |
1091 sync_pb::SessionSpecifics specifics; | 1096 sync_pb::SessionSpecifics specifics; |
1092 specifics.set_session_tag(foreign_tag); | 1097 specifics.set_session_tag(foreign_tag); |
1093 extra_header.SetSessionSpecifics(specifics); | 1098 extra_header.SetSessionSpecifics(specifics); |
1094 } | 1099 } |
1095 error = model_associator_->AssociateModels(); | 1100 error = model_associator_->AssociateModels(); |
1096 ASSERT_FALSE(error.IsSet()); | 1101 ASSERT_FALSE(error.IsSet()); |
1097 } | 1102 } |
1098 | 1103 |
1099 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed | 1104 // TODO(jhorwich): Re-enable when crbug.com/121487 addressed |
1100 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingLocalTabNode) { | 1105 TEST_F(ProfileSyncServiceSessionTest, DISABLED_MissingLocalTabNode) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 sync_pb::SessionSpecifics specifics; | 1196 sync_pb::SessionSpecifics specifics; |
1192 header.SetSessionSpecifics(specifics); | 1197 header.SetSessionSpecifics(specifics); |
1193 } | 1198 } |
1194 // Ensure we associate properly despite the pre-existing node with our local | 1199 // Ensure we associate properly despite the pre-existing node with our local |
1195 // tag. | 1200 // tag. |
1196 error = model_associator_->AssociateModels(); | 1201 error = model_associator_->AssociateModels(); |
1197 ASSERT_FALSE(error.IsSet()); | 1202 ASSERT_FALSE(error.IsSet()); |
1198 } | 1203 } |
1199 | 1204 |
1200 } // namespace browser_sync | 1205 } // namespace browser_sync |
OLD | NEW |