OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/keyed_service/content/browser_context_dependency_manager.h" | 5 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
6 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 6 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 | 8 |
9 class BrowserContextDependencyManagerUnittests : public ::testing::Test { | 9 class BrowserContextDependencyManagerUnittests : public ::testing::Test { |
10 protected: | 10 protected: |
(...skipping 16 matching lines...) Expand all Loading... |
27 class TestService : public BrowserContextKeyedServiceFactory { | 27 class TestService : public BrowserContextKeyedServiceFactory { |
28 public: | 28 public: |
29 TestService(const std::string& name, | 29 TestService(const std::string& name, |
30 std::vector<std::string>* fill_on_shutdown, | 30 std::vector<std::string>* fill_on_shutdown, |
31 BrowserContextDependencyManager* manager) | 31 BrowserContextDependencyManager* manager) |
32 : BrowserContextKeyedServiceFactory("TestService", manager), | 32 : BrowserContextKeyedServiceFactory("TestService", manager), |
33 name_(name), | 33 name_(name), |
34 fill_on_shutdown_(fill_on_shutdown) {} | 34 fill_on_shutdown_(fill_on_shutdown) {} |
35 | 35 |
36 virtual KeyedService* BuildServiceInstanceFor( | 36 virtual KeyedService* BuildServiceInstanceFor( |
37 content::BrowserContext* context) const OVERRIDE { | 37 content::BrowserContext* context) const override { |
38 ADD_FAILURE() << "This isn't part of the tests!"; | 38 ADD_FAILURE() << "This isn't part of the tests!"; |
39 return NULL; | 39 return NULL; |
40 } | 40 } |
41 | 41 |
42 virtual void BrowserContextShutdown(content::BrowserContext* context) | 42 virtual void BrowserContextShutdown(content::BrowserContext* context) |
43 OVERRIDE { | 43 override { |
44 fill_on_shutdown_->push_back(name_); | 44 fill_on_shutdown_->push_back(name_); |
45 } | 45 } |
46 | 46 |
47 private: | 47 private: |
48 const std::string name_; | 48 const std::string name_; |
49 std::vector<std::string>* fill_on_shutdown_; | 49 std::vector<std::string>* fill_on_shutdown_; |
50 }; | 50 }; |
51 | 51 |
52 // Tests that we can deal with a single component. | 52 // Tests that we can deal with a single component. |
53 TEST_F(BrowserContextDependencyManagerUnittests, SingleCase) { | 53 TEST_F(BrowserContextDependencyManagerUnittests, SingleCase) { |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 manager()->DestroyBrowserContextServices(NULL); | 163 manager()->DestroyBrowserContextServices(NULL); |
164 | 164 |
165 ASSERT_EQ(6U, shutdown_order()->size()); | 165 ASSERT_EQ(6U, shutdown_order()->size()); |
166 EXPECT_STREQ("bottom", (*shutdown_order())[0].c_str()); | 166 EXPECT_STREQ("bottom", (*shutdown_order())[0].c_str()); |
167 EXPECT_STREQ("specialized_service", (*shutdown_order())[1].c_str()); | 167 EXPECT_STREQ("specialized_service", (*shutdown_order())[1].c_str()); |
168 EXPECT_STREQ("other_intermediary", (*shutdown_order())[2].c_str()); | 168 EXPECT_STREQ("other_intermediary", (*shutdown_order())[2].c_str()); |
169 EXPECT_STREQ("intermediary_service", (*shutdown_order())[3].c_str()); | 169 EXPECT_STREQ("intermediary_service", (*shutdown_order())[3].c_str()); |
170 EXPECT_STREQ("other_root", (*shutdown_order())[4].c_str()); | 170 EXPECT_STREQ("other_root", (*shutdown_order())[4].c_str()); |
171 EXPECT_STREQ("everything_depends_on_me", (*shutdown_order())[5].c_str()); | 171 EXPECT_STREQ("everything_depends_on_me", (*shutdown_order())[5].c_str()); |
172 } | 172 } |
OLD | NEW |