| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
| 14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
| 15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
| 16 #include "extensions/features/features.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 18 |
| 18 #if defined(ENABLE_EXTENSIONS) | 19 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 19 #include "base/strings/string_split.h" | 20 #include "base/strings/string_split.h" |
| 20 #include "chrome/browser/browsing_data/hosted_apps_counter.h" | 21 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
| 21 #endif | 22 #endif |
| 22 | 23 |
| 23 class BrowsingDataCounterUtilsTest : public testing::Test { | 24 class BrowsingDataCounterUtilsTest : public testing::Test { |
| 24 public: | 25 public: |
| 25 BrowsingDataCounterUtilsTest() {} | 26 BrowsingDataCounterUtilsTest() {} |
| 26 ~BrowsingDataCounterUtilsTest() override {} | 27 ~BrowsingDataCounterUtilsTest() override {} |
| 27 | 28 |
| 28 TestingProfile* GetProfile() { return &profile_; } | 29 TestingProfile* GetProfile() { return &profile_; } |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 content::TestBrowserThreadBundle thread_bundle_; | 32 content::TestBrowserThreadBundle thread_bundle_; |
| 32 TestingProfile profile_; | 33 TestingProfile profile_; |
| 33 }; | 34 }; |
| 34 | 35 |
| 35 #if defined(ENABLE_EXTENSIONS) | 36 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 36 // Tests the complex output of the hosted apps counter. | 37 // Tests the complex output of the hosted apps counter. |
| 37 TEST_F(BrowsingDataCounterUtilsTest, HostedAppsCounterResult) { | 38 TEST_F(BrowsingDataCounterUtilsTest, HostedAppsCounterResult) { |
| 38 HostedAppsCounter counter(GetProfile()); | 39 HostedAppsCounter counter(GetProfile()); |
| 39 | 40 |
| 40 // This test assumes that the strings are served exactly as defined, | 41 // This test assumes that the strings are served exactly as defined, |
| 41 // i.e. that the locale is set to the default "en". | 42 // i.e. that the locale is set to the default "en". |
| 42 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale()); | 43 ASSERT_EQ("en", TestingBrowserProcess::GetGlobal()->GetApplicationLocale()); |
| 43 | 44 |
| 44 // Test the output for various numbers of hosted apps. | 45 // Test the output for various numbers of hosted apps. |
| 45 const struct TestCase { | 46 const struct TestCase { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 68 HostedAppsCounter::HostedAppsResult result( | 69 HostedAppsCounter::HostedAppsResult result( |
| 69 &counter, | 70 &counter, |
| 70 apps.size(), | 71 apps.size(), |
| 71 examples); | 72 examples); |
| 72 | 73 |
| 73 base::string16 output = GetChromeCounterTextFromResult(&result); | 74 base::string16 output = GetChromeCounterTextFromResult(&result); |
| 74 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output)); | 75 EXPECT_EQ(output, base::ASCIIToUTF16(test_case.expected_output)); |
| 75 } | 76 } |
| 76 } | 77 } |
| 77 #endif | 78 #endif |
| OLD | NEW |