OLD | NEW |
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 "chrome/browser/extensions/api/declarative/initializing_rules_registry.
h" | 5 #include "chrome/browser/extensions/api/declarative/initializing_rules_registry.
h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "chrome/browser/extensions/api/declarative/test_rules_registry.h" | 10 #include "chrome/browser/extensions/api/declarative/test_rules_registry.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 error = registry->GetAllRules(kExtensionId, &get_rules_4b); | 104 error = registry->GetAllRules(kExtensionId, &get_rules_4b); |
105 EXPECT_TRUE(error.empty()); | 105 EXPECT_TRUE(error.empty()); |
106 | 106 |
107 ASSERT_EQ(1u, get_rules_4b.size()); | 107 ASSERT_EQ(1u, get_rules_4b.size()); |
108 | 108 |
109 ASSERT_TRUE(get_rules_4b[0]->id.get()); | 109 ASSERT_TRUE(get_rules_4b[0]->id.get()); |
110 EXPECT_EQ(kRuleId, *get_rules_4b[0]->id); | 110 EXPECT_EQ(kRuleId, *get_rules_4b[0]->id); |
111 | 111 |
112 // Make sure that deletion traits of registry are executed. | 112 // Make sure that deletion traits of registry are executed. |
113 registry = NULL; | 113 registry = NULL; |
114 message_loop.RunAllPending(); | 114 message_loop.RunUntilIdle(); |
115 } | 115 } |
116 | 116 |
117 TEST(InitializingRulesRegistryTest, FillOptionalPriority) { | 117 TEST(InitializingRulesRegistryTest, FillOptionalPriority) { |
118 MessageLoopForUI message_loop; | 118 MessageLoopForUI message_loop; |
119 content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop); | 119 content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop); |
120 | 120 |
121 std::string error; | 121 std::string error; |
122 scoped_refptr<RulesRegistry> registry = | 122 scoped_refptr<RulesRegistry> registry = |
123 new InitializingRulesRegistry(new TestRulesRegistry); | 123 new InitializingRulesRegistry(new TestRulesRegistry); |
124 | 124 |
(...skipping 16 matching lines...) Expand all Loading... |
141 ASSERT_TRUE(get_rules[1]->priority.get()); | 141 ASSERT_TRUE(get_rules[1]->priority.get()); |
142 | 142 |
143 // Verify the precondition so that the following EXPECT_EQ statements work. | 143 // Verify the precondition so that the following EXPECT_EQ statements work. |
144 EXPECT_GT(InitializingRulesRegistry::DEFAULT_PRIORITY, 2); | 144 EXPECT_GT(InitializingRulesRegistry::DEFAULT_PRIORITY, 2); |
145 EXPECT_EQ(2, std::min(*get_rules[0]->priority, *get_rules[1]->priority)); | 145 EXPECT_EQ(2, std::min(*get_rules[0]->priority, *get_rules[1]->priority)); |
146 EXPECT_EQ(InitializingRulesRegistry::DEFAULT_PRIORITY, | 146 EXPECT_EQ(InitializingRulesRegistry::DEFAULT_PRIORITY, |
147 std::max(*get_rules[0]->priority, *get_rules[1]->priority)); | 147 std::max(*get_rules[0]->priority, *get_rules[1]->priority)); |
148 | 148 |
149 // Make sure that deletion traits of registry are executed. | 149 // Make sure that deletion traits of registry are executed. |
150 registry = NULL; | 150 registry = NULL; |
151 message_loop.RunAllPending(); | 151 message_loop.RunUntilIdle(); |
152 } | 152 } |
153 | 153 |
154 } // namespace extensions | 154 } // namespace extensions |
OLD | NEW |