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

Side by Side Diff: chrome/browser/webdata/autofill_table_unittest.cc

Issue 9959086: Add probability of culling if sync is enabled to https://chromiumcodereview.appspot.com/9585020/ In… (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
« no previous file with comments | « chrome/browser/webdata/autofill_table.cc ('k') | chrome/browser/webdata/web_data_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <vector> 5 #include <vector>
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 ASSERT_EQ(sql::INIT_OK, db.Init(file_)); 134 ASSERT_EQ(sql::INIT_OK, db.Init(file_));
135 135
136 Time t1 = Time::Now(); 136 Time t1 = Time::Now();
137 137
138 // Simulate the submission of a handful of entries in a field called "Name", 138 // Simulate the submission of a handful of entries in a field called "Name",
139 // some more often than others. 139 // some more often than others.
140 AutofillChangeList changes; 140 AutofillChangeList changes;
141 FormField field; 141 FormField field;
142 field.name = ASCIIToUTF16("Name"); 142 field.name = ASCIIToUTF16("Name");
143 field.value = ASCIIToUTF16("Superman"); 143 field.value = ASCIIToUTF16("Superman");
144 base::Time now = base::Time::Now();
145 base::TimeDelta two_seconds = base::TimeDelta::FromSeconds(2);
144 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); 146 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes));
145 std::vector<string16> v; 147 std::vector<string16> v;
146 for (int i = 0; i < 5; i++) { 148 for (int i = 0; i < 5; i++) {
147 field.value = ASCIIToUTF16("Clark Kent"); 149 field.value = ASCIIToUTF16("Clark Kent");
148 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); 150 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes,
151 now + i * two_seconds));
149 } 152 }
150 for (int i = 0; i < 3; i++) { 153 for (int i = 0; i < 3; i++) {
151 field.value = ASCIIToUTF16("Clark Sutter"); 154 field.value = ASCIIToUTF16("Clark Sutter");
152 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); 155 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes,
156 now + i * two_seconds));
153 } 157 }
154 for (int i = 0; i < 2; i++) { 158 for (int i = 0; i < 2; i++) {
155 field.name = ASCIIToUTF16("Favorite Color"); 159 field.name = ASCIIToUTF16("Favorite Color");
156 field.value = ASCIIToUTF16("Green"); 160 field.value = ASCIIToUTF16("Green");
157 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValue(field, &changes)); 161 EXPECT_TRUE(db.GetAutofillTable()->AddFormFieldValueTime(field, &changes,
162 now + i * two_seconds));
158 } 163 }
159 164
160 int count = 0; 165 int count = 0;
161 int64 pair_id = 0; 166 int64 pair_id = 0;
162 167
163 // We have added the name Clark Kent 5 times, so count should be 5 and pair_id 168 // We have added the name Clark Kent 5 times, so count should be 5 and pair_id
164 // should be somthing non-zero. 169 // should be somthing non-zero.
165 field.name = ASCIIToUTF16("Name"); 170 field.name = ASCIIToUTF16("Name");
166 field.value = ASCIIToUTF16("Clark Kent"); 171 field.value = ASCIIToUTF16("Clark Kent");
167 EXPECT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement(field, &pair_id, 172 EXPECT_TRUE(db.GetAutofillTable()->GetIDAndCountOfFormElement(field, &pair_id,
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 1438
1434 // make sure the lists of entries match 1439 // make sure the lists of entries match
1435 ASSERT_EQ(expected_entries.size(), entry_set.size()); 1440 ASSERT_EQ(expected_entries.size(), entry_set.size());
1436 AutofillEntrySetIterator it; 1441 AutofillEntrySetIterator it;
1437 for (it = entry_set.begin(); it != entry_set.end(); it++) { 1442 for (it = entry_set.begin(); it != entry_set.end(); it++) {
1438 expected_entries.erase(*it); 1443 expected_entries.erase(*it);
1439 } 1444 }
1440 1445
1441 EXPECT_EQ(0U, expected_entries.size()); 1446 EXPECT_EQ(0U, expected_entries.size());
1442 } 1447 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/autofill_table.cc ('k') | chrome/browser/webdata/web_data_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698