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

Side by Side Diff: chrome/browser/extensions/api/declarative/initializing_rules_registry_unittest.cc

Issue 14113053: chrome: Use base::MessageLoop. (Part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase again Created 7 years, 6 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 "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"
11 #include "content/public/test/test_browser_thread.h" 11 #include "content/public/test/test_browser_thread.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 13
14 namespace { 14 namespace {
15 const char kExtensionId[] = "foobar"; 15 const char kExtensionId[] = "foobar";
16 const char kRuleId[] = "foo"; 16 const char kRuleId[] = "foo";
17 } // namespace 17 } // namespace
18 18
19 namespace extensions { 19 namespace extensions {
20 20
21 TEST(InitializingRulesRegistryTest, FillOptionalIdentifiers) { 21 TEST(InitializingRulesRegistryTest, FillOptionalIdentifiers) {
22 MessageLoopForUI message_loop; 22 base::MessageLoopForUI message_loop;
23 content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop); 23 content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop);
24 24
25 std::string error; 25 std::string error;
26 scoped_refptr<RulesRegistry> registry = new InitializingRulesRegistry( 26 scoped_refptr<RulesRegistry> registry = new InitializingRulesRegistry(
27 new TestRulesRegistry(content::BrowserThread::UI, "" /*event_name*/)); 27 new TestRulesRegistry(content::BrowserThread::UI, "" /*event_name*/));
28 InitializingRulesRegistry* init_registry = 28 InitializingRulesRegistry* init_registry =
29 static_cast<InitializingRulesRegistry*>(registry.get()); 29 static_cast<InitializingRulesRegistry*>(registry.get());
30 30
31 // Add rules and check that their identifiers are filled and unique. 31 // Add rules and check that their identifiers are filled and unique.
32 32
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 registry->OnExtensionUnloaded(kExtensionId); 129 registry->OnExtensionUnloaded(kExtensionId);
130 EXPECT_EQ(0u /*extensions*/ + 0u /*rules*/, 130 EXPECT_EQ(0u /*extensions*/ + 0u /*rules*/,
131 init_registry->GetNumberOfUsedRuleIdentifiersForTesting()); 131 init_registry->GetNumberOfUsedRuleIdentifiersForTesting());
132 132
133 // Make sure that deletion traits of registry are executed. 133 // Make sure that deletion traits of registry are executed.
134 registry = NULL; 134 registry = NULL;
135 message_loop.RunUntilIdle(); 135 message_loop.RunUntilIdle();
136 } 136 }
137 137
138 TEST(InitializingRulesRegistryTest, FillOptionalPriority) { 138 TEST(InitializingRulesRegistryTest, FillOptionalPriority) {
139 MessageLoopForUI message_loop; 139 base::MessageLoopForUI message_loop;
140 content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop); 140 content::TestBrowserThread thread(content::BrowserThread::UI, &message_loop);
141 141
142 std::string error; 142 std::string error;
143 scoped_refptr<RulesRegistry> registry = new InitializingRulesRegistry( 143 scoped_refptr<RulesRegistry> registry = new InitializingRulesRegistry(
144 new TestRulesRegistry(content::BrowserThread::UI, "" /*event_name*/)); 144 new TestRulesRegistry(content::BrowserThread::UI, "" /*event_name*/));
145 145
146 // Add rules and check that their priorities are filled if they are empty. 146 // Add rules and check that their priorities are filled if they are empty.
147 147
148 std::vector<linked_ptr<RulesRegistry::Rule> > add_rules; 148 std::vector<linked_ptr<RulesRegistry::Rule> > add_rules;
149 add_rules.push_back(make_linked_ptr(new RulesRegistry::Rule)); 149 add_rules.push_back(make_linked_ptr(new RulesRegistry::Rule));
(...skipping 16 matching lines...) Expand all
166 EXPECT_EQ(2, std::min(*get_rules[0]->priority, *get_rules[1]->priority)); 166 EXPECT_EQ(2, std::min(*get_rules[0]->priority, *get_rules[1]->priority));
167 EXPECT_EQ(InitializingRulesRegistry::DEFAULT_PRIORITY, 167 EXPECT_EQ(InitializingRulesRegistry::DEFAULT_PRIORITY,
168 std::max(*get_rules[0]->priority, *get_rules[1]->priority)); 168 std::max(*get_rules[0]->priority, *get_rules[1]->priority));
169 169
170 // Make sure that deletion traits of registry are executed. 170 // Make sure that deletion traits of registry are executed.
171 registry = NULL; 171 registry = NULL;
172 message_loop.RunUntilIdle(); 172 message_loop.RunUntilIdle();
173 } 173 }
174 174
175 } // namespace extensions 175 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698