OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/browsing_data/browsing_data_counter_utils.h" | 5 #include "chrome/browser/browsing_data/browsing_data_counter_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 // This test assumes that the strings are served exactly as defined, | 40 // This test assumes that the strings are served exactly as defined, |
41 // i.e. that the locale is set to the default "en". | 41 // i.e. that the locale is set to the default "en". |
42 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale()); | 42 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale()); |
43 | 43 |
44 // Test the output for various numbers of hosted apps. | 44 // Test the output for various numbers of hosted apps. |
45 const struct TestCase { | 45 const struct TestCase { |
46 std::string apps_list; | 46 std::string apps_list; |
47 std::string expected_output; | 47 std::string expected_output; |
48 } kTestCases[] = { | 48 } kTestCases[] = { |
49 { "", "none" }, | 49 {"", "None"}, |
50 { "App1", "1 app (App1)" }, | 50 {"App1", "1 app (App1)"}, |
51 { "App1, App2", "2 apps (App1, App2)" }, | 51 {"App1, App2", "2 apps (App1, App2)"}, |
52 { "App1, App2, App3", "3 apps (App1, App2, and 1 more)" }, | 52 {"App1, App2, App3", "3 apps (App1, App2, and 1 more)"}, |
53 { "App1, App2, App3, App4", "4 apps (App1, App2, and 2 more)" }, | 53 {"App1, App2, App3, App4", "4 apps (App1, App2, and 2 more)"}, |
54 { "App1, App2, App3, App4, App5", "5 apps (App1, App2, and 3 more)" }, | 54 {"App1, App2, App3, App4, App5", "5 apps (App1, App2, and 3 more)"}, |
55 }; | 55 }; |
56 | 56 |
57 for (const TestCase& test_case : kTestCases) { | 57 for (const TestCase& test_case : kTestCases) { |
58 // Split the list of installed apps by commas. | 58 // Split the list of installed apps by commas. |
59 std::vector<std::string> apps = base::SplitString( | 59 std::vector<std::string> apps = base::SplitString( |
60 test_case.apps_list, ",", | 60 test_case.apps_list, ",", |
61 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); | 61 base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
62 | 62 |
63 // The first two apps in the list are used as examples. | 63 // The first two apps in the list are used as examples. |
64 std::vector<std::string> examples; | 64 std::vector<std::string> examples; |
65 examples.assign( | 65 examples.assign( |
66 apps.begin(), apps.begin() + (apps.size() > 2 ? 2 : apps.size())); | 66 apps.begin(), apps.begin() + (apps.size() > 2 ? 2 : apps.size())); |
67 | 67 |
68 HostedAppsCounter::HostedAppsResult result( | 68 HostedAppsCounter::HostedAppsResult result( |
69 &counter, | 69 &counter, |
70 apps.size(), | 70 apps.size(), |
71 examples); | 71 examples); |
72 | 72 |
73 base::string16 output = GetChromeCounterTextFromResult(&result); | 73 base::string16 output = GetChromeCounterTextFromResult(&result); |
74 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output)); | 74 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output)); |
75 } | 75 } |
76 } | 76 } |
77 #endif | 77 #endif |
OLD | NEW |