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

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 comments and added culling when the sync is off. Created 8 years, 9 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 "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::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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 } 538 }
538 539
539 void SetIdleChangeProcessorExpectations() { 540 void SetIdleChangeProcessorExpectations() {
540 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0); 541 EXPECT_CALL(autofill_table_, RemoveFormElement(_, _)).Times(0);
541 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0); 542 EXPECT_CALL(autofill_table_, GetAutofillTimestamps(_, _, _)).Times(0);
542 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0); 543 EXPECT_CALL(autofill_table_, UpdateAutofillEntries(_)).Times(0);
543 } 544 }
544 545
545 static AutofillEntry MakeAutofillEntry(const char* name, 546 static AutofillEntry MakeAutofillEntry(const char* name,
546 const char* value, 547 const char* value,
547 time_t timestamp0, 548 int time_shift0,
548 time_t timestamp1) { 549 int time_shift1) {
550 // Time deep in the past would cause Autocomplete sync to discard the
551 // entries.
552 static Time base_time = Time::Now().LocalMidnight();
553
549 std::vector<Time> timestamps; 554 std::vector<Time> timestamps;
550 if (timestamp0 > 0) 555 if (time_shift0 > 0)
551 timestamps.push_back(Time::FromTimeT(timestamp0)); 556 timestamps.push_back(base_time + TimeDelta::FromSeconds(time_shift0));
552 if (timestamp1 > 0) 557 if (time_shift1 > 0)
553 timestamps.push_back(Time::FromTimeT(timestamp1)); 558 timestamps.push_back(base_time + TimeDelta::FromSeconds(time_shift1));
554 return AutofillEntry( 559 return AutofillEntry(
555 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps); 560 AutofillKey(ASCIIToUTF16(name), ASCIIToUTF16(value)), timestamps);
556 } 561 }
557 562
558 static AutofillEntry MakeAutofillEntry(const char* name, 563 static AutofillEntry MakeAutofillEntry(const char* name,
559 const char* value, 564 const char* value,
560 time_t timestamp) { 565 int time_shift) {
561 return MakeAutofillEntry(name, value, timestamp, -1); 566 return MakeAutofillEntry(name, value, time_shift, -1);
562 } 567 }
563 568
564 friend class AddAutofillHelper<AutofillEntry>; 569 friend class AddAutofillHelper<AutofillEntry>;
565 friend class AddAutofillHelper<AutofillProfile>; 570 friend class AddAutofillHelper<AutofillProfile>;
566 friend class FakeServerUpdater; 571 friend class FakeServerUpdater;
567 572
568 ProfileMock profile_; 573 ProfileMock profile_;
569 AutofillTableMock autofill_table_; 574 AutofillTableMock autofill_table_;
570 scoped_ptr<WebDatabaseFake> web_database_; 575 scoped_ptr<WebDatabaseFake> web_database_;
571 scoped_refptr<WebDataServiceFake> web_data_service_; 576 scoped_refptr<WebDataServiceFake> web_data_service_;
(...skipping 655 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 std::vector<AutofillEntry> sync_entries; 1232 std::vector<AutofillEntry> sync_entries;
1228 std::vector<AutofillProfile> sync_profiles; 1233 std::vector<AutofillProfile> sync_profiles;
1229 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles)); 1234 ASSERT_TRUE(GetAutofillEntriesFromSyncDB(&sync_entries, &sync_profiles));
1230 EXPECT_EQ(3U, sync_entries.size()); 1235 EXPECT_EQ(3U, sync_entries.size());
1231 EXPECT_EQ(0U, sync_profiles.size()); 1236 EXPECT_EQ(0U, sync_profiles.size());
1232 for (size_t i = 0; i < sync_entries.size(); i++) { 1237 for (size_t i = 0; i < sync_entries.size(); i++) {
1233 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name() 1238 DVLOG(1) << "Entry " << i << ": " << sync_entries[i].key().name()
1234 << ", " << sync_entries[i].key().value(); 1239 << ", " << sync_entries[i].key().value();
1235 } 1240 }
1236 } 1241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698