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

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

Issue 2084903002: Moved BrowsingDataCounter and part of BrowsingDataCounterUtils to components. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed deps Created 4 years, 6 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 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/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/browsing_data/autofill_counter.h" 13 #include "chrome/browser/browsing_data/autofill_counter.h"
13 #include "chrome/test/base/testing_browser_process.h" 14 #include "chrome/test/base/testing_browser_process.h"
15 #include "chrome/test/base/testing_profile.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 #if defined(ENABLE_EXTENSIONS) 18 #if defined(ENABLE_EXTENSIONS)
17 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
18 #include "chrome/browser/browsing_data/hosted_apps_counter.h" 20 #include "chrome/browser/browsing_data/hosted_apps_counter.h"
19 #endif 21 #endif
20 22
23 class BrowsingDataCounterUtilsTest : public testing::Test {
24 public:
25 BrowsingDataCounterUtilsTest() : profile_(new TestingProfile()) {}
26
27 ~BrowsingDataCounterUtilsTest() override {}
28
29 void TearDown() override {
30 profile_.reset();
31 base::MessageLoop::current()->RunUntilIdle();
32 }
33
34 TestingProfile* GetProfile() { return profile_.get(); }
35
36 private:
37 base::MessageLoop loop_;
38 std::unique_ptr<TestingProfile> profile_;
39 };
40
21 // Tests the complex output of the Autofill counter. 41 // Tests the complex output of the Autofill counter.
22 TEST(BrowsingDataCounterUtilsTest, AutofillCounterResult) { 42 TEST_F(BrowsingDataCounterUtilsTest, AutofillCounterResult) {
23 AutofillCounter counter; 43 // std::unique_ptr<Profile> profile_(new TestingProfile());
44
45 AutofillCounter counter(GetProfile());
24 46
25 // This test assumes that the strings are served exactly as defined, 47 // This test assumes that the strings are served exactly as defined,
26 // i.e. that the locale is set to the default "en". 48 // i.e. that the locale is set to the default "en".
27 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale()); 49 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale());
28 50
29 // Test all configurations of zero and nonzero partial results for datatypes. 51 // Test all configurations of zero and nonzero partial results for datatypes.
30 // Test singular and plural for each datatype. 52 // Test singular and plural for each datatype.
31 const struct TestCase { 53 const struct TestCase {
32 int num_credit_cards; 54 int num_credit_cards;
33 int num_addresses; 55 int num_addresses;
(...skipping 27 matching lines...) Expand all
61 test_case.num_suggestions 83 test_case.num_suggestions
62 )); 84 ));
63 85
64 base::string16 output = GetCounterTextFromResult(&result); 86 base::string16 output = GetCounterTextFromResult(&result);
65 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output)); 87 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output));
66 } 88 }
67 } 89 }
68 90
69 #if defined(ENABLE_EXTENSIONS) 91 #if defined(ENABLE_EXTENSIONS)
70 // Tests the complex output of the hosted apps counter. 92 // Tests the complex output of the hosted apps counter.
71 TEST(BrowsingDataCounterUtilsTest, HostedAppsCounterResult) { 93 TEST_F(BrowsingDataCounterUtilsTest, HostedAppsCounterResult) {
72 HostedAppsCounter counter; 94 HostedAppsCounter counter(GetProfile());
73 95
74 // This test assumes that the strings are served exactly as defined, 96 // This test assumes that the strings are served exactly as defined,
75 // i.e. that the locale is set to the default "en". 97 // i.e. that the locale is set to the default "en".
76 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale()); 98 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale());
77 99
78 // Test the output for various numbers of hosted apps. 100 // Test the output for various numbers of hosted apps.
79 const struct TestCase { 101 const struct TestCase {
80 std::string apps_list; 102 std::string apps_list;
81 std::string expected_output; 103 std::string expected_output;
82 } kTestCases[] = { 104 } kTestCases[] = {
(...skipping 19 matching lines...) Expand all
102 HostedAppsCounter::HostedAppsResult result( 124 HostedAppsCounter::HostedAppsResult result(
103 &counter, 125 &counter,
104 apps.size(), 126 apps.size(),
105 examples); 127 examples);
106 128
107 base::string16 output = GetCounterTextFromResult(&result); 129 base::string16 output = GetCounterTextFromResult(&result);
108 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output)); 130 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output));
109 } 131 }
110 } 132 }
111 #endif 133 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698