OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/memory/ref_counted.h" | 16 #include "base/memory/ref_counted.h" |
17 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
18 #include "base/message_loop.h" | 18 #include "base/message_loop.h" |
19 #include "base/string16.h" | 19 #include "base/string16.h" |
20 #include "base/synchronization/waitable_event.h" | 20 #include "base/synchronization/waitable_event.h" |
21 #include "base/task.h" | 21 #include "base/task.h" |
22 #include "base/time.h" | 22 #include "base/time.h" |
23 #include "base/utf_string_conversions.h" | 23 #include "base/utf_string_conversions.h" |
24 #include "chrome/browser/autofill/autofill_common_test.h" | 24 #include "chrome/browser/autofill/autofill_common_test.h" |
25 #include "chrome/browser/autofill/personal_data_manager.h" | 25 #include "chrome/browser/autofill/personal_data_manager.h" |
26 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 26 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
27 #include "chrome/browser/history/history.h" | |
Nicolas Zea
2011/12/07 00:46:43
can you just forward declare the history service i
GeorgeY
2011/12/07 00:55:08
Is it enough for static_cast<>? Trying...
Yes, co
| |
27 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 28 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
28 #include "chrome/browser/sync/engine/model_changing_syncer_command.h" | 29 #include "chrome/browser/sync/engine/model_changing_syncer_command.h" |
29 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" | 30 #include "chrome/browser/sync/glue/autofill_data_type_controller.h" |
30 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" | 31 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h" |
31 #include "chrome/browser/sync/glue/data_type_controller.h" | 32 #include "chrome/browser/sync/glue/data_type_controller.h" |
32 #include "chrome/browser/sync/glue/generic_change_processor.h" | 33 #include "chrome/browser/sync/glue/generic_change_processor.h" |
33 #include "chrome/browser/sync/glue/shared_change_processor.h" | 34 #include "chrome/browser/sync/glue/shared_change_processor.h" |
34 #include "chrome/browser/sync/glue/syncable_service_adapter.h" | 35 #include "chrome/browser/sync/glue/syncable_service_adapter.h" |
35 #include "chrome/browser/sync/internal_api/read_node.h" | 36 #include "chrome/browser/sync/internal_api/read_node.h" |
36 #include "chrome/browser/sync/internal_api/read_transaction.h" | 37 #include "chrome/browser/sync/internal_api/read_transaction.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
126 : autofill_table_(autofill_table) {} | 127 : autofill_table_(autofill_table) {} |
127 | 128 |
128 virtual AutofillTable* GetAutofillTable() OVERRIDE { | 129 virtual AutofillTable* GetAutofillTable() OVERRIDE { |
129 return autofill_table_; | 130 return autofill_table_; |
130 } | 131 } |
131 | 132 |
132 private: | 133 private: |
133 AutofillTable* autofill_table_; | 134 AutofillTable* autofill_table_; |
134 }; | 135 }; |
135 | 136 |
136 | |
137 class ProfileSyncServiceAutofillTest; | 137 class ProfileSyncServiceAutofillTest; |
138 | 138 |
139 template<class AutofillProfile> | 139 template<class AutofillProfile> |
140 syncable::ModelType GetModelType() { | 140 syncable::ModelType GetModelType() { |
141 return syncable::UNSPECIFIED; | 141 return syncable::UNSPECIFIED; |
142 } | 142 } |
143 | 143 |
144 template<> | 144 template<> |
145 syncable::ModelType GetModelType<AutofillEntry>() { | 145 syncable::ModelType GetModelType<AutofillEntry>() { |
146 return syncable::AUTOFILL; | 146 return syncable::AUTOFILL; |
(...skipping 939 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1086 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, | 1086 notifier->Notify(chrome::NOTIFICATION_AUTOFILL_PROFILE_CHANGED, |
1087 content::Source<WebDataService>(web_data_service_.get()), | 1087 content::Source<WebDataService>(web_data_service_.get()), |
1088 content::Details<AutofillProfileChange>(&change)); | 1088 content::Details<AutofillProfileChange>(&change)); |
1089 | 1089 |
1090 std::vector<AutofillProfile> new_sync_profiles; | 1090 std::vector<AutofillProfile> new_sync_profiles; |
1091 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 1091 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( |
1092 &new_sync_profiles)); | 1092 &new_sync_profiles)); |
1093 ASSERT_EQ(0U, new_sync_profiles.size()); | 1093 ASSERT_EQ(0U, new_sync_profiles.size()); |
1094 } | 1094 } |
1095 | 1095 |
1096 // Crashy, http://crbug.com/57884 | 1096 TEST_F(ProfileSyncServiceAutofillTest, ServerChangeRace) { |
1097 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { | 1097 // GetHistoryService() gets called indirectly, but the result is ignored, so |
1098 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)).WillOnce(Return(true)); | 1098 // it is safe to return NULL. |
1099 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).WillOnce(Return(true)); | 1099 EXPECT_CALL(profile_, GetHistoryService(_)). |
1100 WillRepeatedly(Return(static_cast<HistoryService*>(NULL))); | |
1101 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via | |
1102 // LoadAutofillData(). | |
1103 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | |
1104 Times(3).WillRepeatedly(Return(true)); | |
1105 // On the other hand Autofill and Autocomplete are separated now, so | |
1106 // GetAutofillProfiles() should not be called. | |
1107 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).Times(0); | |
1100 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). | 1108 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). |
1101 WillRepeatedly(Return(true)); | 1109 WillRepeatedly(Return(true)); |
1102 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); | 1110 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); |
1103 CreateRootHelper create_root(this, syncable::AUTOFILL); | 1111 CreateRootHelper create_root(this, syncable::AUTOFILL); |
1104 StartSyncService(create_root.callback(), false, syncable::AUTOFILL); | 1112 StartSyncService(create_root.callback(), false, syncable::AUTOFILL); |
1105 ASSERT_TRUE(create_root.success()); | 1113 ASSERT_TRUE(create_root.success()); |
1106 | 1114 |
1107 // (true, false) means we have to reset after |Signal|, init to unsignaled. | 1115 // (true, false) means we have to reset after |Signal|, init to unsignaled. |
1108 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false)); | 1116 scoped_ptr<WaitableEvent> wait_for_start(new WaitableEvent(true, false)); |
1109 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false)); | 1117 scoped_ptr<WaitableEvent> wait_for_syncapi(new WaitableEvent(true, false)); |
(...skipping 19 matching lines...) Expand all Loading... | |
1129 std::vector<AutofillEntry> sync_entries; | 1137 std::vector<AutofillEntry> sync_entries; |
1130 std::vector<AutofillProfile> sync_profiles; | 1138 std::vector<AutofillProfile> sync_profiles; |
1131 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1139 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1132 EXPECT_EQ(3U, sync_entries.size()); | 1140 EXPECT_EQ(3U, sync_entries.size()); |
1133 EXPECT_EQ(0U, sync_profiles.size()); | 1141 EXPECT_EQ(0U, sync_profiles.size()); |
1134 for (size_t i = 0; i < sync_entries.size(); i++) { | 1142 for (size_t i = 0; i < sync_entries.size(); i++) { |
1135 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1143 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1136 << ", " << sync_entries[i].key().value(); | 1144 << ", " << sync_entries[i].key().value(); |
1137 } | 1145 } |
1138 } | 1146 } |
OLD | NEW |