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

Side by Side Diff: chrome/browser/ui/webui/options/clear_browser_data_handler_unittest.cc

Issue 1527653004: Move browsing data counters helper functions to an 'utils' file. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, solved conflict in #includes Created 4 years, 11 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/options/clear_browser_data_handler.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browsing_data/autofill_counter.h"
10 #include "chrome/test/base/testing_browser_process.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 namespace options {
14
15 // Tests the complex output of the Autofill counter.
16 TEST(ClearBrowserDataTest, AutofillCounterResult) {
17 AutofillCounter counter;
18
19 // This test assumes that the strings are served exactly as defined,
20 // i.e. that the locale is set to the default "en".
21 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale());
22
23 // Test all configurations of zero and nonzero partial results for datatypes.
24 // Test singular and plural for each datatype.
25 struct TestCase {
26 int num_credit_cards;
27 int num_addresses;
28 int num_suggestions;
29 std::string expected_output;
30 } test_cases[] = {
31 {0, 0, 0, "none"},
32 {1, 0, 0, "1 credit card"},
33 {0, 5, 0, "5 addresses"},
34 {0, 0, 1, "1 suggestion"},
35 {0, 0, 2, "2 suggestions"},
36 {4, 7, 0, "4 credit cards, 7 addresses"},
37 {3, 0, 9, "3 credit cards, 9 other suggestions"},
38 {0, 1, 1, "1 address, 1 other suggestion"},
39 {9, 6, 3, "9 credit cards, 6 addresses, 3 others"},
40 {4, 2, 1, "4 credit cards, 2 addresses, 1 other"},
41 };
42
43 for (const TestCase& test_case : test_cases) {
44 AutofillCounter::AutofillResult result(
45 &counter,
46 test_case.num_suggestions,
47 test_case.num_credit_cards,
48 test_case.num_addresses);
49
50 SCOPED_TRACE(base::StringPrintf(
51 "Test params: %d credit card(s), "
52 "%d address(es), %d suggestion(s).",
53 test_case.num_credit_cards,
54 test_case.num_addresses,
55 test_case.num_suggestions
56 ));
57
58 base::string16 output = ClearBrowserDataHandler::GetCounterTextFromResult(
59 &result);
60 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output));
61 }
62 }
63
64 } // namespace options
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/clear_browser_data_handler.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698