OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/hosted_apps_counter.h" | 5 #include "chrome/browser/browsing_data/hosted_apps_counter.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/guid.h" | 13 #include "base/guid.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/test/base/testing_profile.h" | 15 #include "chrome/test/base/testing_profile.h" |
16 #include "components/browsing_data/core/browsing_data_utils.h" | 16 #include "components/browsing_data/core/browsing_data_utils.h" |
17 #include "components/browsing_data/core/pref_names.h" | 17 #include "components/browsing_data/core/pref_names.h" |
18 #include "components/crx_file/id_util.h" | 18 #include "components/crx_file/id_util.h" |
19 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
| 20 #include "content/public/test/test_browser_thread_bundle.h" |
20 #include "extensions/browser/extension_registry.h" | 21 #include "extensions/browser/extension_registry.h" |
21 #include "extensions/common/extension_builder.h" | 22 #include "extensions/common/extension_builder.h" |
22 #include "extensions/common/value_builder.h" | 23 #include "extensions/common/value_builder.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 using extensions::DictionaryBuilder; | 28 using extensions::DictionaryBuilder; |
28 using extensions::ListBuilder; | 29 using extensions::ListBuilder; |
29 | 30 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 132 } |
132 } | 133 } |
133 | 134 |
134 // Miscellaneous. ------------------------------------------------------------ | 135 // Miscellaneous. ------------------------------------------------------------ |
135 | 136 |
136 Profile* GetProfile() { | 137 Profile* GetProfile() { |
137 return profile_.get(); | 138 return profile_.get(); |
138 } | 139 } |
139 | 140 |
140 private: | 141 private: |
141 base::MessageLoop loop_; | 142 content::TestBrowserThreadBundle thread_bundle_; |
142 std::unique_ptr<TestingProfile> profile_; | 143 std::unique_ptr<TestingProfile> profile_; |
143 extensions::ExtensionRegistry* extension_registry_; | 144 extensions::ExtensionRegistry* extension_registry_; |
144 | 145 |
145 bool finished_; | 146 bool finished_; |
146 browsing_data::BrowsingDataCounter::ResultInt num_apps_; | 147 browsing_data::BrowsingDataCounter::ResultInt num_apps_; |
147 std::vector<std::string> examples_; | 148 std::vector<std::string> examples_; |
148 }; | 149 }; |
149 | 150 |
150 // Tests that we count the total number of hosted apps correctly. | 151 // Tests that we count the total number of hosted apps correctly. |
151 TEST_F(HostedAppsCounterTest, Count) { | 152 TEST_F(HostedAppsCounterTest, Count) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 EXPECT_EQ("App 2", GetExamples().back()); | 232 EXPECT_EQ("App 2", GetExamples().back()); |
232 | 233 |
233 AddHostedAppWithName("App 3"); | 234 AddHostedAppWithName("App 3"); |
234 counter.Restart(); | 235 counter.Restart(); |
235 EXPECT_EQ(2u, GetExamples().size()); | 236 EXPECT_EQ(2u, GetExamples().size()); |
236 EXPECT_EQ("App 1", GetExamples().front()); | 237 EXPECT_EQ("App 1", GetExamples().front()); |
237 EXPECT_EQ("App 2", GetExamples().back()); | 238 EXPECT_EQ("App 2", GetExamples().back()); |
238 } | 239 } |
239 | 240 |
240 } // namespace | 241 } // namespace |
OLD | NEW |