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

Side by Side Diff: chrome/browser/browsing_data/autofill_counter_browsertest.cc

Issue 2671743002: Separate state of basic and advanced tab in CBD dialog (Closed)
Patch Set: fix .classpath file Created 3 years, 10 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "components/browsing_data/core/counters/autofill_counter.h" 5 #include "components/browsing_data/core/counters/autofill_counter.h"
6 6
7 #include "base/guid.h" 7 #include "base/guid.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 browsing_data::BrowsingDataCounter::ResultInt num_credit_cards_; 198 browsing_data::BrowsingDataCounter::ResultInt num_credit_cards_;
199 browsing_data::BrowsingDataCounter::ResultInt num_addresses_; 199 browsing_data::BrowsingDataCounter::ResultInt num_addresses_;
200 200
201 DISALLOW_COPY_AND_ASSIGN(AutofillCounterTest); 201 DISALLOW_COPY_AND_ASSIGN(AutofillCounterTest);
202 }; 202 };
203 203
204 // Tests that we count the correct number of autocomplete suggestions. 204 // Tests that we count the correct number of autocomplete suggestions.
205 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, AutocompleteSuggestions) { 205 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, AutocompleteSuggestions) {
206 Profile* profile = browser()->profile(); 206 Profile* profile = browser()->profile();
207 browsing_data::AutofillCounter counter(GetWebDataService()); 207 browsing_data::AutofillCounter counter(GetWebDataService());
208 counter.Init(profile->GetPrefs(), base::Bind(&AutofillCounterTest::Callback, 208 counter.Init(
209 base::Unretained(this))); 209 profile->GetPrefs(),
210 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT,
211 base::Bind(&AutofillCounterTest::Callback, base::Unretained(this)));
210 counter.Restart(); 212 counter.Restart();
211 WaitForCounting(); 213 WaitForCounting();
212 EXPECT_EQ(0, GetNumSuggestions()); 214 EXPECT_EQ(0, GetNumSuggestions());
213 215
214 AddAutocompleteSuggestion("email", "example@example.com"); 216 AddAutocompleteSuggestion("email", "example@example.com");
215 counter.Restart(); 217 counter.Restart();
216 WaitForCounting(); 218 WaitForCounting();
217 EXPECT_EQ(1, GetNumSuggestions()); 219 EXPECT_EQ(1, GetNumSuggestions());
218 220
219 AddAutocompleteSuggestion("tel", "+123456789"); 221 AddAutocompleteSuggestion("tel", "+123456789");
(...skipping 14 matching lines...) Expand all
234 ClearAutocompleteSuggestions(); 236 ClearAutocompleteSuggestions();
235 counter.Restart(); 237 counter.Restart();
236 WaitForCounting(); 238 WaitForCounting();
237 EXPECT_EQ(0, GetNumSuggestions()); 239 EXPECT_EQ(0, GetNumSuggestions());
238 } 240 }
239 241
240 // Tests that we count the correct number of credit cards. 242 // Tests that we count the correct number of credit cards.
241 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, CreditCards) { 243 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, CreditCards) {
242 Profile* profile = browser()->profile(); 244 Profile* profile = browser()->profile();
243 browsing_data::AutofillCounter counter(GetWebDataService()); 245 browsing_data::AutofillCounter counter(GetWebDataService());
244 counter.Init(profile->GetPrefs(), base::Bind(&AutofillCounterTest::Callback, 246 counter.Init(
245 base::Unretained(this))); 247 profile->GetPrefs(),
248 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT,
249 base::Bind(&AutofillCounterTest::Callback, base::Unretained(this)));
246 counter.Restart(); 250 counter.Restart();
247 WaitForCounting(); 251 WaitForCounting();
248 EXPECT_EQ(0, GetNumCreditCards()); 252 EXPECT_EQ(0, GetNumCreditCards());
249 253
250 AddCreditCard("0000-0000-0000-0000", "1", "2015"); 254 AddCreditCard("0000-0000-0000-0000", "1", "2015");
251 counter.Restart(); 255 counter.Restart();
252 WaitForCounting(); 256 WaitForCounting();
253 EXPECT_EQ(1, GetNumCreditCards()); 257 EXPECT_EQ(1, GetNumCreditCards());
254 258
255 AddCreditCard("0123-4567-8910-1112", "10", "2015"); 259 AddCreditCard("0123-4567-8910-1112", "10", "2015");
(...skipping 14 matching lines...) Expand all
270 ClearCreditCardsAndAddresses(); 274 ClearCreditCardsAndAddresses();
271 counter.Restart(); 275 counter.Restart();
272 WaitForCounting(); 276 WaitForCounting();
273 EXPECT_EQ(0, GetNumCreditCards()); 277 EXPECT_EQ(0, GetNumCreditCards());
274 } 278 }
275 279
276 // Tests that we count the correct number of addresses. 280 // Tests that we count the correct number of addresses.
277 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, Addresses) { 281 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, Addresses) {
278 Profile* profile = browser()->profile(); 282 Profile* profile = browser()->profile();
279 browsing_data::AutofillCounter counter(GetWebDataService()); 283 browsing_data::AutofillCounter counter(GetWebDataService());
280 counter.Init(profile->GetPrefs(), base::Bind(&AutofillCounterTest::Callback, 284 counter.Init(
281 base::Unretained(this))); 285 profile->GetPrefs(),
286 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT,
287 base::Bind(&AutofillCounterTest::Callback, base::Unretained(this)));
282 counter.Restart(); 288 counter.Restart();
283 WaitForCounting(); 289 WaitForCounting();
284 EXPECT_EQ(0, GetNumAddresses()); 290 EXPECT_EQ(0, GetNumAddresses());
285 291
286 AddAddress("John", "Doe", "Main Street 12345"); 292 AddAddress("John", "Doe", "Main Street 12345");
287 counter.Restart(); 293 counter.Restart();
288 WaitForCounting(); 294 WaitForCounting();
289 EXPECT_EQ(1, GetNumAddresses()); 295 EXPECT_EQ(1, GetNumAddresses());
290 296
291 AddAddress("Jane", "Smith", "Main Street 12346"); 297 AddAddress("Jane", "Smith", "Main Street 12346");
(...skipping 28 matching lines...) Expand all
320 326
321 AddCreditCard("0000-0000-0000-0000", "1", "2015"); 327 AddCreditCard("0000-0000-0000-0000", "1", "2015");
322 AddCreditCard("1211-1098-7654-3210", "10", "2030"); 328 AddCreditCard("1211-1098-7654-3210", "10", "2030");
323 329
324 AddAddress("John", "Doe", "Main Street 12345"); 330 AddAddress("John", "Doe", "Main Street 12345");
325 AddAddress("Jane", "Smith", "Main Street 12346"); 331 AddAddress("Jane", "Smith", "Main Street 12346");
326 AddAddress("John", "Smith", "Side Street 47"); 332 AddAddress("John", "Smith", "Side Street 47");
327 333
328 Profile* profile = browser()->profile(); 334 Profile* profile = browser()->profile();
329 browsing_data::AutofillCounter counter(GetWebDataService()); 335 browsing_data::AutofillCounter counter(GetWebDataService());
330 counter.Init(profile->GetPrefs(), base::Bind(&AutofillCounterTest::Callback, 336 counter.Init(
331 base::Unretained(this))); 337 profile->GetPrefs(),
338 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT,
339 base::Bind(&AutofillCounterTest::Callback, base::Unretained(this)));
332 counter.Restart(); 340 counter.Restart();
333 WaitForCounting(); 341 WaitForCounting();
334 EXPECT_EQ(5, GetNumSuggestions()); 342 EXPECT_EQ(5, GetNumSuggestions());
335 EXPECT_EQ(2, GetNumCreditCards()); 343 EXPECT_EQ(2, GetNumCreditCards());
336 EXPECT_EQ(3, GetNumAddresses()); 344 EXPECT_EQ(3, GetNumAddresses());
337 } 345 }
338 346
339 // Tests that the counting respects time ranges. 347 // Tests that the counting respects time ranges.
340 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, TimeRanges) { 348 IN_PROC_BROWSER_TEST_F(AutofillCounterTest, TimeRanges) {
341 // This test makes time comparisons that are precise to a microsecond, but the 349 // This test makes time comparisons that are precise to a microsecond, but the
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 const browsing_data::BrowsingDataCounter::ResultInt expected_num_addresses; 383 const browsing_data::BrowsingDataCounter::ResultInt expected_num_addresses;
376 } test_cases[] = { 384 } test_cases[] = {
377 { base::Time(), 2, 3, 3}, 385 { base::Time(), 2, 3, 3},
378 { time1, 2, 3, 3}, 386 { time1, 2, 3, 3},
379 { time2, 1, 2, 2}, 387 { time2, 1, 2, 2},
380 { time3, 1, 1, 0} 388 { time3, 1, 1, 0}
381 }; 389 };
382 390
383 Profile* profile = browser()->profile(); 391 Profile* profile = browser()->profile();
384 browsing_data::AutofillCounter counter(GetWebDataService()); 392 browsing_data::AutofillCounter counter(GetWebDataService());
385 counter.Init(profile->GetPrefs(), base::Bind(&AutofillCounterTest::Callback, 393 counter.Init(
386 base::Unretained(this))); 394 profile->GetPrefs(),
395 browsing_data::ClearBrowsingDataPreferenceType::DEFAULT,
396 base::Bind(&AutofillCounterTest::Callback, base::Unretained(this)));
387 397
388 for (const TestCase& test_case : test_cases) { 398 for (const TestCase& test_case : test_cases) {
389 counter.SetPeriodStartForTesting(test_case.period_start); 399 counter.SetPeriodStartForTesting(test_case.period_start);
390 counter.Restart(); 400 counter.Restart();
391 WaitForCounting(); 401 WaitForCounting();
392 EXPECT_EQ(test_case.expected_num_suggestions, GetNumSuggestions()); 402 EXPECT_EQ(test_case.expected_num_suggestions, GetNumSuggestions());
393 EXPECT_EQ(test_case.expected_num_credit_cards, GetNumCreditCards()); 403 EXPECT_EQ(test_case.expected_num_credit_cards, GetNumCreditCards());
394 EXPECT_EQ(test_case.expected_num_addresses, GetNumAddresses()); 404 EXPECT_EQ(test_case.expected_num_addresses, GetNumAddresses());
395 } 405 }
396 } 406 }
397 407
398 } // namespace 408 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698