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/run_loop.h" | 19 #include "base/message_loop/message_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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). | 519 EXPECT_CALL(*personal_data_manager_, IsDataLoaded()). |
520 WillRepeatedly(Return(true)); | 520 WillRepeatedly(Return(true)); |
521 | 521 |
522 // We need tokens to get the tests going | 522 // We need tokens to get the tests going |
523 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) | 523 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) |
524 ->UpdateCredentials(signin->GetAuthenticatedAccountId(), | 524 ->UpdateCredentials(signin->GetAuthenticatedAccountId(), |
525 "oauth2_login_token"); | 525 "oauth2_login_token"); |
526 | 526 |
527 sync_service_->RegisterDataTypeController(CreateDataTypeController(type)); | 527 sync_service_->RegisterDataTypeController(CreateDataTypeController(type)); |
528 sync_service_->Initialize(); | 528 sync_service_->Initialize(); |
529 | 529 base::MessageLoop::current()->Run(); |
530 base::RunLoop run_loop; | |
531 run_loop.Run(); | |
532 | 530 |
533 // It's possible this test triggered an unrecoverable error, in which case | 531 // It's possible this test triggered an unrecoverable error, in which case |
534 // we can't get the sync count. | 532 // we can't get the sync count. |
535 if (sync_service_->IsSyncActive()) { | 533 if (sync_service_->IsSyncActive()) { |
536 EXPECT_EQ(GetSyncCount(type), | 534 EXPECT_EQ(GetSyncCount(type), |
537 association_stats_.num_sync_items_after_association); | 535 association_stats_.num_sync_items_after_association); |
538 } | 536 } |
539 EXPECT_EQ(association_stats_.num_sync_items_after_association, | 537 EXPECT_EQ(association_stats_.num_sync_items_after_association, |
540 association_stats_.num_sync_items_before_association + | 538 association_stats_.num_sync_items_before_association + |
541 association_stats_.num_sync_items_added - | 539 association_stats_.num_sync_items_added - |
(...skipping 719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 AutofillProfileChange change( | 1259 AutofillProfileChange change( |
1262 AutofillProfileChange::REMOVE, sync_profile.guid(), NULL); | 1260 AutofillProfileChange::REMOVE, sync_profile.guid(), NULL); |
1263 web_data_service_->OnAutofillProfileChanged(change); | 1261 web_data_service_->OnAutofillProfileChanged(change); |
1264 | 1262 |
1265 std::vector<AutofillProfile> new_sync_profiles; | 1263 std::vector<AutofillProfile> new_sync_profiles; |
1266 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( | 1264 ASSERT_TRUE(GetAutofillProfilesFromSyncDBUnderProfileNode( |
1267 &new_sync_profiles)); | 1265 &new_sync_profiles)); |
1268 ASSERT_EQ(0U, new_sync_profiles.size()); | 1266 ASSERT_EQ(0U, new_sync_profiles.size()); |
1269 } | 1267 } |
1270 | 1268 |
1271 // crbug.com/569551 | 1269 // http://crbug.com/57884 |
1272 TEST_F(ProfileSyncServiceAutofillTest, FLAKY_ServerChangeRace) { | 1270 TEST_F(ProfileSyncServiceAutofillTest, DISABLED_ServerChangeRace) { |
1273 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via | 1271 // Once for MergeDataAndStartSyncing() and twice for ProcessSyncChanges(), via |
1274 // LoadAutofillData(). | 1272 // LoadAutofillData(). |
1275 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). | 1273 EXPECT_CALL(autofill_table_, GetAllAutofillEntries(_)). |
1276 Times(3).WillRepeatedly(Return(true)); | 1274 Times(3).WillRepeatedly(Return(true)); |
1277 // On the other hand Autofill and Autocomplete are separated now, so | 1275 // On the other hand Autofill and Autocomplete are separated now, so |
1278 // GetAutofillProfiles() should not be called. | 1276 // GetAutofillProfiles() should not be called. |
1279 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).Times(0); | 1277 EXPECT_CALL(autofill_table_, GetAutofillProfiles(_)).Times(0); |
1280 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). | 1278 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)). |
1281 WillRepeatedly(Return(true)); | 1279 WillRepeatedly(Return(true)); |
1282 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); | 1280 EXPECT_CALL(*personal_data_manager_, Refresh()).Times(3); |
(...skipping 16 matching lines...) Expand all Loading... |
1299 DVLOG(1) << "Syncapi update finished."; | 1297 DVLOG(1) << "Syncapi update finished."; |
1300 | 1298 |
1301 // If we reach here, it means syncapi succeeded and we didn't deadlock. Yay! | 1299 // If we reach here, it means syncapi succeeded and we didn't deadlock. Yay! |
1302 // Signal FakeServerUpdater that it can complete. | 1300 // Signal FakeServerUpdater that it can complete. |
1303 wait_for_syncapi->Signal(); | 1301 wait_for_syncapi->Signal(); |
1304 | 1302 |
1305 // Make another entry to ensure nothing broke afterwards and wait for finish | 1303 // Make another entry to ensure nothing broke afterwards and wait for finish |
1306 // to clean up. | 1304 // to clean up. |
1307 updater->CreateNewEntryAndWait(MakeAutofillEntry("server2", "entry2", 3)); | 1305 updater->CreateNewEntryAndWait(MakeAutofillEntry("server2", "entry2", 3)); |
1308 | 1306 |
1309 // Let callbacks posted on UI thread execute. | |
1310 base::RunLoop run_loop; | |
1311 run_loop.RunUntilIdle(); | |
1312 | |
1313 std::vector<AutofillEntry> sync_entries; | 1307 std::vector<AutofillEntry> sync_entries; |
1314 std::vector<AutofillProfile> sync_profiles; | 1308 std::vector<AutofillProfile> sync_profiles; |
1315 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1309 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
1316 EXPECT_EQ(3U, sync_entries.size()); | 1310 EXPECT_EQ(3U, sync_entries.size()); |
1317 EXPECT_EQ(0U, sync_profiles.size()); | 1311 EXPECT_EQ(0U, sync_profiles.size()); |
1318 for (size_t i = 0; i < sync_entries.size(); i++) { | 1312 for (size_t i = 0; i < sync_entries.size(); i++) { |
1319 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1313 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
1320 << ", " << sync_entries[i].key().value(); | 1314 << ", " << sync_entries[i].key().value(); |
1321 } | 1315 } |
1322 } | 1316 } |
OLD | NEW |