| 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 <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 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 51 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
| 52 #include "chrome/browser/webdata/autofill_table.h" | 52 #include "chrome/browser/webdata/autofill_table.h" |
| 53 #include "chrome/browser/webdata/web_database.h" | 53 #include "chrome/browser/webdata/web_database.h" |
| 54 #include "chrome/common/chrome_notification_types.h" | 54 #include "chrome/common/chrome_notification_types.h" |
| 55 #include "chrome/common/net/gaia/gaia_constants.h" | 55 #include "chrome/common/net/gaia/gaia_constants.h" |
| 56 #include "content/public/browser/notification_source.h" | 56 #include "content/public/browser/notification_source.h" |
| 57 #include "content/test/test_browser_thread.h" | 57 #include "content/test/test_browser_thread.h" |
| 58 #include "testing/gmock/include/gmock/gmock.h" | 58 #include "testing/gmock/include/gmock/gmock.h" |
| 59 | 59 |
| 60 using base::Time; | 60 using base::Time; |
| 61 using base::TimeDelta; |
| 61 using base::WaitableEvent; | 62 using base::WaitableEvent; |
| 62 using browser_sync::AutofillDataTypeController; | 63 using browser_sync::AutofillDataTypeController; |
| 63 using browser_sync::AutofillProfileDataTypeController; | 64 using browser_sync::AutofillProfileDataTypeController; |
| 64 using browser_sync::DataTypeController; | 65 using browser_sync::DataTypeController; |
| 65 using browser_sync::GenericChangeProcessor; | 66 using browser_sync::GenericChangeProcessor; |
| 66 using browser_sync::SharedChangeProcessor; | 67 using browser_sync::SharedChangeProcessor; |
| 67 using browser_sync::SyncableServiceAdapter; | 68 using browser_sync::SyncableServiceAdapter; |
| 68 using browser_sync::GROUP_DB; | 69 using browser_sync::GROUP_DB; |
| 69 using browser_sync::SyncBackendHostForProfileSyncTest; | 70 using browser_sync::SyncBackendHostForProfileSyncTest; |
| 70 using browser_sync::UnrecoverableErrorHandler; | 71 using browser_sync::UnrecoverableErrorHandler; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 539 } |
| 539 | 540 |
| 540 void SetIdleChangeProcessorExpectations() { | 541 void SetIdleChangeProcessorExpectations() { |
| 541 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); | 542 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); |
| 542 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); | 543 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); |
| 543 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); | 544 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); |
| 544 } | 545 } |
| 545 | 546 |
| 546 static AutofillEntry MakeAutofillEntry(const char* name, | 547 static AutofillEntry MakeAutofillEntry(const char* name, |
| 547 const char* value, | 548 const char* value, |
| 548 time_t timestamp0, | 549 int time_shift0, |
| 549 time_t timestamp1) { | 550 int time_shift1) { |
| 551 // Time deep in the past would cause Autocomplete sync to discard the |
| 552 // entries. |
| 553 static Time base_time = Time::Now().LocalMidnight(); |
| 554 |
| 550 std::vector<Time> timestamps; | 555 std::vector<Time> timestamps; |
| 551 if (timestamp0 > 0) | 556 if (time_shift0 > 0) |
| 552 timestamps.push_back(Time::FromTimeT(timestamp0)); | 557 timestamps.push_back(base_time + TimeDelta::FromSeconds(time_shift0)); |
| 553 if (timestamp1 > 0) | 558 if (time_shift1 > 0) |
| 554 timestamps.push_back(Time::FromTimeT(timestamp1)); | 559 timestamps.push_back(base_time + TimeDelta::FromSeconds(time_shift1)); |
| 555 return AutofillEntry( | 560 return AutofillEntry( |
| 556 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps); | 561 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps); |
| 557 } | 562 } |
| 558 | 563 |
| 559 static AutofillEntry MakeAutofillEntry(const char* name, | 564 static AutofillEntry MakeAutofillEntry(const char* name, |
| 560 const char* value, | 565 const char* value, |
| 561 time_t timestamp) { | 566 int time_shift) { |
| 562 return MakeAutofillEntry(name, value, timestamp, -1); | 567 return MakeAutofillEntry(name, value, time_shift, -1); |
| 563 } | 568 } |
| 564 | 569 |
| 565 friend class AddAutofillHelper<AutofillEntry>; | 570 friend class AddAutofillHelper<AutofillEntry>; |
| 566 friend class AddAutofillHelper<AutofillProfile>; | 571 friend class AddAutofillHelper<AutofillProfile>; |
| 567 friend class FakeServerUpdater; | 572 friend class FakeServerUpdater; |
| 568 | 573 |
| 569 ProfileMock profile_; | 574 ProfileMock profile_; |
| 570 AutofillTableMock autofill_table_; | 575 AutofillTableMock autofill_table_; |
| 571 scoped_ptr<WebDatabaseFake> web_database_; | 576 scoped_ptr<WebDatabaseFake> web_database_; |
| 572 scoped_refptr<WebDataServiceFake> web_data_service_; | 577 scoped_refptr<WebDataServiceFake> web_data_service_; |
| (...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1229 std::vector<AutofillEntry> sync_entries; | 1234 std::vector<AutofillEntry> sync_entries; |
| 1230 std::vector<AutofillProfile> sync_profiles; | 1235 std::vector<AutofillProfile> sync_profiles; |
| 1231 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); | 1236 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); |
| 1232 EXPECT_EQ(3U, sync_entries.size()); | 1237 EXPECT_EQ(3U, sync_entries.size()); |
| 1233 EXPECT_EQ(0U, sync_profiles.size()); | 1238 EXPECT_EQ(0U, sync_profiles.size()); |
| 1234 for (size_t i = 0; i < sync_entries.size(); i++) { | 1239 for (size_t i = 0; i < sync_entries.size(); i++) { |
| 1235 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() | 1240 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() |
| 1236 << ", " << sync_entries[i].key().value(); | 1241 << ", " << sync_entries[i].key().value(); |
| 1237 } | 1242 } |
| 1238 } | 1243 } |
| OLD | NEW |