Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: chrome/browser/sync/profile_sync_service_autofill_unittest.cc

Issue 9585020: Cull autofill entries older than 60 days. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
51 #include "content/public/browser/notification_source.h" 51 #include "content/public/browser/notification_source.h"
52 #include "content/test/test_browser_thread.h" 52 #include "content/test/test_browser_thread.h"
53 #include "sync/engine/model_changing_syncer_command.h" 53 #include "sync/engine/model_changing_syncer_command.h"
54 #include "sync/protocol/autofill_specifics.pb.h" 54 #include "sync/protocol/autofill_specifics.pb.h"
55 #include "sync/syncable/model_type.h" 55 #include "sync/syncable/model_type.h"
56 #include "sync/syncable/syncable.h" 56 #include "sync/syncable/syncable.h"
57 #include "sync/test/engine/test_id_factory.h" 57 #include "sync/test/engine/test_id_factory.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::GROUP_DB; 68 using browser_sync::GROUP_DB;
68 using browser_sync::SyncBackendHostForProfileSyncTest; 69 using browser_sync::SyncBackendHostForProfileSyncTest;
69 using browser_sync::UnrecoverableErrorHandler; 70 using browser_sync::UnrecoverableErrorHandler;
70 using content::BrowserThread; 71 using content::BrowserThread;
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 } 536 }
536 537
537 void SetIdleChangeProcessorExpectations() { 538 void SetIdleChangeProcessorExpectations() {
538 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); 539 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0);
539 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); 540 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0);
540 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); 541 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0);
541 } 542 }
542 543
543 static AutofillEntry MakeAutofillEntry(const char* name, 544 static AutofillEntry MakeAutofillEntry(const char* name,
544 const char* value, 545 const char* value,
545 time_t timestamp0, 546 int time_shift0,
546 time_t timestamp1) { 547 int time_shift1) {
548 // Time deep in the past would cause Autocomplete sync to discard the
549 // entries.
550 static Time base_time = Time::Now().LocalMidnight();
551
547 std::vector<Time> timestamps; 552 std::vector<Time> timestamps;
548 if (timestamp0 > 0) 553 if (time_shift0 > 0)
549 timestamps.push_back(Time::FromTimeT(timestamp0)); 554 timestamps.push_back(base_time + TimeDelta::FromSeconds(time_shift0));
550 if (timestamp1 > 0) 555 if (time_shift1 > 0)
551 timestamps.push_back(Time::FromTimeT(timestamp1)); 556 timestamps.push_back(base_time + TimeDelta::FromSeconds(time_shift1));
552 return AutofillEntry( 557 return AutofillEntry(
553 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps); 558 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps);
554 } 559 }
555 560
556 static AutofillEntry MakeAutofillEntry(const char* name, 561 static AutofillEntry MakeAutofillEntry(const char* name,
557 const char* value, 562 const char* value,
558 time_t timestamp) { 563 int time_shift) {
559 return MakeAutofillEntry(name, value, timestamp, -1); 564 return MakeAutofillEntry(name, value, time_shift, -1);
560 } 565 }
561 566
562 friend class AddAutofillHelper<AutofillEntry>; 567 friend class AddAutofillHelper<AutofillEntry>;
563 friend class AddAutofillHelper<AutofillProfile>; 568 friend class AddAutofillHelper<AutofillProfile>;
564 friend class FakeServerUpdater; 569 friend class FakeServerUpdater;
565 570
566 ProfileMock profile_; 571 ProfileMock profile_;
567 AutofillTableMock autofill_table_; 572 AutofillTableMock autofill_table_;
568 scoped_ptr<WebDatabaseFake> web_database_; 573 scoped_ptr<WebDatabaseFake> web_database_;
569 scoped_refptr<WebDataServiceFake> web_data_service_; 574 scoped_refptr<WebDataServiceFake> web_data_service_;
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1225 std::vector<AutofillEntry> sync_entries; 1230 std::vector<AutofillEntry> sync_entries;
1226 std::vector<AutofillProfile> sync_profiles; 1231 std::vector<AutofillProfile> sync_profiles;
1227 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1232 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1228 EXPECT_EQ(3U, sync_entries.size()); 1233 EXPECT_EQ(3U, sync_entries.size());
1229 EXPECT_EQ(0U, sync_profiles.size()); 1234 EXPECT_EQ(0U, sync_profiles.size());
1230 for (size_t i = 0; i < sync_entries.size(); i++) { 1235 for (size_t i = 0; i < sync_entries.size(); i++) {
1231 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1236 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1232 << ", " << sync_entries[i].key().value(); 1237 << ", " << sync_entries[i].key().value();
1233 } 1238 }
1234 } 1239 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/personal_data_manager.cc ('k') | chrome/browser/webdata/autocomplete_syncable_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698