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

Side by Side Diff: chrome/browser/profiles/profile_dependency_manager_unittest.cc

Issue 13454032: Extract DependencyGraph from ProfileDependencyManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added tests Created 7 years, 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
6 6
7 #include "chrome/browser/profiles/profile_dependency_manager.h" 7 #include "chrome/browser/profiles/profile_dependency_manager.h"
8 #include "chrome/browser/profiles/profile_keyed_service_factory.h" 8 #include "chrome/browser/profiles/profile_keyed_service_factory.h"
9 9
10 class ProfileDependencyManagerUnittests : public ::testing::Test { 10 class ProfileDependencyManagerUnittests : public ::testing::Test {
11 protected: 11 protected:
12 virtual ~ProfileDependencyManagerUnittests() {
13 EXPECT_TRUE(dependency_manager_.all_components_.empty());
14 EXPECT_TRUE(dependency_manager_.edges_.empty());
15 EXPECT_TRUE(dependency_manager_.destruction_order_.empty());
16 }
17
18 // To get around class access: 12 // To get around class access:
19 void DependOn(ProfileKeyedServiceFactory* child, 13 void DependOn(ProfileKeyedServiceFactory* child,
20 ProfileKeyedServiceFactory* parent) { 14 ProfileKeyedServiceFactory* parent) {
21 child->DependsOn(parent); 15 child->DependsOn(parent);
22 } 16 }
23 17
24 ProfileDependencyManager* manager() { return &dependency_manager_; } 18 ProfileDependencyManager* manager() { return &dependency_manager_; }
25 19
26 std::vector<std::string>* shutdown_order() { return &shutdown_order_; } 20 std::vector<std::string>* shutdown_order() { return &shutdown_order_; }
27 21
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 83
90 manager()->DestroyProfileServices(NULL); 84 manager()->DestroyProfileServices(NULL);
91 85
92 ASSERT_EQ(3U, shutdown_order()->size()); 86 ASSERT_EQ(3U, shutdown_order()->size());
93 EXPECT_STREQ("child2", (*shutdown_order())[0].c_str()); 87 EXPECT_STREQ("child2", (*shutdown_order())[0].c_str());
94 EXPECT_STREQ("child1", (*shutdown_order())[1].c_str()); 88 EXPECT_STREQ("child1", (*shutdown_order())[1].c_str());
95 EXPECT_STREQ("parent", (*shutdown_order())[2].c_str()); 89 EXPECT_STREQ("parent", (*shutdown_order())[2].c_str());
96 } 90 }
97 91
98 // Tests an M configuration 92 // Tests an M configuration
99 TEST_F(ProfileDependencyManagerUnittests, MConfiguration) { 93 TEST_F(ProfileDependencyManagerUnittests, MConfiguration) {
Jói 2013/04/16 08:36:01 Just to check: Is it intentional to leave the same
Paweł Hajdan Jr. 2013/04/16 16:44:57 Yes, I think if the tests are there I'd rather kee
100 TestService parent1("parent1", shutdown_order(), manager()); 94 TestService parent1("parent1", shutdown_order(), manager());
101 TestService parent2("parent2", shutdown_order(), manager()); 95 TestService parent2("parent2", shutdown_order(), manager());
102 96
103 TestService child_of_1("child_of_1", shutdown_order(), manager()); 97 TestService child_of_1("child_of_1", shutdown_order(), manager());
104 DependOn(&child_of_1, &parent1); 98 DependOn(&child_of_1, &parent1);
105 99
106 TestService child_of_12("child_of_12", shutdown_order(), manager()); 100 TestService child_of_12("child_of_12", shutdown_order(), manager());
107 DependOn(&child_of_12, &parent1); 101 DependOn(&child_of_12, &parent1);
108 DependOn(&child_of_12, &parent2); 102 DependOn(&child_of_12, &parent2);
109 103
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 manager()->DestroyProfileServices(NULL); 164 manager()->DestroyProfileServices(NULL);
171 165
172 ASSERT_EQ(6U, shutdown_order()->size()); 166 ASSERT_EQ(6U, shutdown_order()->size());
173 EXPECT_STREQ("bottom", (*shutdown_order())[0].c_str()); 167 EXPECT_STREQ("bottom", (*shutdown_order())[0].c_str());
174 EXPECT_STREQ("specialized_service", (*shutdown_order())[1].c_str()); 168 EXPECT_STREQ("specialized_service", (*shutdown_order())[1].c_str());
175 EXPECT_STREQ("other_intermediary", (*shutdown_order())[2].c_str()); 169 EXPECT_STREQ("other_intermediary", (*shutdown_order())[2].c_str());
176 EXPECT_STREQ("intermediary_service", (*shutdown_order())[3].c_str()); 170 EXPECT_STREQ("intermediary_service", (*shutdown_order())[3].c_str());
177 EXPECT_STREQ("other_root", (*shutdown_order())[4].c_str()); 171 EXPECT_STREQ("other_root", (*shutdown_order())[4].c_str());
178 EXPECT_STREQ("everything_depends_on_me", (*shutdown_order())[5].c_str()); 172 EXPECT_STREQ("everything_depends_on_me", (*shutdown_order())[5].c_str());
179 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_dependency_manager.cc ('k') | chrome/browser/profiles/profile_keyed_base_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698