OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/callback.h" | 14 #include "base/callback.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/location.h" | 16 #include "base/location.h" |
17 #include "base/memory/ref_counted.h" | 17 #include "base/memory/ref_counted.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/message_loop/message_loop.h" | 19 #include "base/run_loop.h" |
20 #include "base/strings/string16.h" | 20 #include "base/strings/string16.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "base/synchronization/waitable_event.h" | 22 #include "base/synchronization/waitable_event.h" |
23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
24 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 24 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
25 #include "chrome/browser/signin/account_tracker_service_factory.h" | 25 #include "chrome/browser/signin/account_tracker_service_factory.h" |
26 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" | 26 #include "chrome/browser/signin/fake_profile_oauth2_token_service_builder.h" |
27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
28 #include "chrome/browser/signin/signin_manager_factory.h" | 28 #include "chrome/browser/signin/signin_manager_factory.h" |
29 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" | 29 #include "chrome/browser/sync/abstract_profile_sync_service_test.h" |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). | 522 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). |
523 WillRepeatedly(Return(true)); | 523 WillRepeatedly(Return(true)); |
524 | 524 |
525 // We need tokens to get the tests going | 525 // We need tokens to get the tests going |
526 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) | 526 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) |
527 ->UpdateCredentials(signin->GetAuthenticatedAccountId(), | 527 ->UpdateCredentials(signin->GetAuthenticatedAccountId(), |
528 "oauth2_login_token"); | 528 "oauth2_login_token"); |
529 | 529 |
530 sync_service_->RegisterDataTypeController(CreateDataTypeController(type)); | 530 sync_service_->RegisterDataTypeController(CreateDataTypeController(type)); |
531 sync_service_->Initialize(); | 531 sync_service_->Initialize(); |
532 base::MessageLoop::current()->Run(); | 532 |
| 533 base::RunLoop run_loop; |
| 534 run_loop.Run(); |
533 | 535 |
534 // It's possible this test triggered an unrecoverable error, in which case | 536 // It's possible this test triggered an unrecoverable error, in which case |
535 // we can't get the sync count. | 537 // we can't get the sync count. |
536 if (sync_service_->IsSyncActive()) { | 538 if (sync_service_->IsSyncActive()) { |
537 EXPECT_EQ(GetSyncCount(type), | 539 EXPECT_EQ(GetSyncCount(type), |
538 association_stats_.num_sync_items_after_association); | 540 association_stats_.num_sync_items_after_association); |
539 } | 541 } |
540 EXPECT_EQ(association_stats_.num_sync_items_after_association, | 542 EXPECT_EQ(association_stats_.num_sync_items_after_association, |
541 association_stats_.num_sync_items_before_association + | 543 association_stats_.num_sync_items_before_association + |
542 association_stats_.num_sync_items_added - | 544 association_stats_.num_sync_items_added - |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 AutofillProfileChange change( | 1264 AutofillProfileChange change( |
1263 AutofillProfileChange::REMOVE, sync_profile.guid(), NULL); | 1265 AutofillProfileChange::REMOVE, sync_profile.guid(), NULL); |
1264 web_data_service_->OnAutofillProfileChanged(change); | 1266 web_data_service_->OnAutofillProfileChanged(change); |
1265 | 1267 |
1266 std::vector<AutofillProfile> new_sync_profiles; | 1268 std::vector<AutofillProfile> new_sync_profiles; |
1267 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 1269 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( |
1268 &new_sync_profiles)); | 1270 &new_sync_profiles)); |
1269 ASSERT_EQ(0U, new_sync_profiles.size()); | 1271 ASSERT_EQ(0U, new_sync_profiles.size()); |
1270 } | 1272 } |
1271 | 1273 |
1272 // http://crbug.com/57884 | 1274 TEST_F(ProfileSyncServiceAutofillTest, ServerChangeRace) { |
1273 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { | |
1274 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via | 1275 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via |
1275 // LoadAutofillData(). | 1276 // LoadAutofillData(). |
1276 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | 1277 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). |
1277 Times(3).WillRepeatedly(Return(true)); | 1278 Times(3).WillRepeatedly(Return(true)); |
1278 // On the other hand Autofill and Autocomplete are separated now, so | 1279 // On the other hand Autofill and Autocomplete are separated now, so |
1279 // GetAutofillProfiles() should not be called. | 1280 // GetAutofillProfiles() should not be called. |
1280 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).Times(0); | 1281 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).Times(0); |
1281 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). | 1282 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). |
1282 WillRepeatedly(Return(true)); | 1283 WillRepeatedly(Return(true)); |
1283 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); | 1284 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); |
(...skipping 16 matching lines...) Expand all Loading... |
1300 DVLOG(1) << "Syncapi update finished."; | 1301 DVLOG(1) << "Syncapi update finished."; |
1301 | 1302 |
1302 // If we reach here, it means syncapi succeeded and we didn't deadlock. Yay! | 1303 // If we reach here, it means syncapi succeeded and we didn't deadlock. Yay! |
1303 // Signal FakeServerUpdater that it can complete. | 1304 // Signal FakeServerUpdater that it can complete. |
1304 wait_for_syncapi->Signal(); | 1305 wait_for_syncapi->Signal(); |
1305 | 1306 |
1306 // Make another entry to ensure nothing broke afterwards and wait for finish | 1307 // Make another entry to ensure nothing broke afterwards and wait for finish |
1307 // to clean up. | 1308 // to clean up. |
1308 updater->CreateNewEntryAndWait(MakeAutofillEntry("server2", "entry2", 3)); | 1309 updater->CreateNewEntryAndWait(MakeAutofillEntry("server2", "entry2", 3)); |
1309 | 1310 |
| 1311 // Let callbacks posted on UI thread execute. |
| 1312 base::RunLoop run_loop; |
| 1313 run_loop.RunUntilIdle(); |
| 1314 |
1310 std::vector<AutofillEntry> sync_entries; | 1315 std::vector<AutofillEntry> sync_entries; |
1311 std::vector<AutofillProfile> sync_profiles; | 1316 std::vector<AutofillProfile> sync_profiles; |
1312 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1317 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1313 EXPECT_EQ(3U, sync_entries.size()); | 1318 EXPECT_EQ(3U, sync_entries.size()); |
1314 EXPECT_EQ(0U, sync_profiles.size()); | 1319 EXPECT_EQ(0U, sync_profiles.size()); |
1315 for (size_t i = 0; i < sync_entries.size(); i++) { | 1320 for (size_t i = 0; i < sync_entries.size(); i++) { |
1316 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1321 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1317 << ", " << sync_entries[i].key().value(); | 1322 << ", " << sync_entries[i].key().value(); |
1318 } | 1323 } |
1319 } | 1324 } |
OLD | NEW |