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

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

Issue 28273006: <webview>: Implement declarativeWebRequest API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed browser_tests build Created 7 years, 1 month 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
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/rules_registry_service.h" 5 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "chrome/browser/extensions/api/declarative/test_rules_registry.h" 9 #include "chrome/browser/extensions/api/declarative/test_rules_registry.h"
10 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread.h"
(...skipping 15 matching lines...) Expand all
26 size_t expected_number_of_rules) { 26 size_t expected_number_of_rules) {
27 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > get_rules; 27 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > get_rules;
28 std::string error = registry->GetAllRules(kExtensionId, &get_rules); 28 std::string error = registry->GetAllRules(kExtensionId, &get_rules);
29 EXPECT_EQ(expected_number_of_rules, get_rules.size()); 29 EXPECT_EQ(expected_number_of_rules, get_rules.size());
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 namespace extensions { 34 namespace extensions {
35 35
36 class RulesRegistryServiceTest : public testing::Test { 36 class RulesRegistryServiceTest : public testing::Test {
Jeffrey Yasskin 2013/11/09 02:47:22 Please test that the remove-by-process logic does
Fady Samuel 2013/11/10 03:39:56 Done.
37 public: 37 public:
38 RulesRegistryServiceTest() 38 RulesRegistryServiceTest()
39 : ui_(content::BrowserThread::UI, &message_loop_), 39 : ui_(content::BrowserThread::UI, &message_loop_),
40 io_(content::BrowserThread::IO, &message_loop_) {} 40 io_(content::BrowserThread::IO, &message_loop_) {}
41 41
42 virtual ~RulesRegistryServiceTest() {} 42 virtual ~RulesRegistryServiceTest() {}
43 43
44 virtual void TearDown() OVERRIDE { 44 virtual void TearDown() OVERRIDE {
45 // Make sure that deletion traits of all registries are executed. 45 // Make sure that deletion traits of all registries are executed.
46 message_loop_.RunUntilIdle(); 46 message_loop_.RunUntilIdle();
(...skipping 11 matching lines...) Expand all
58 58
59 TestRulesRegistry* io_registry = 59 TestRulesRegistry* io_registry =
60 new TestRulesRegistry(content::BrowserThread::IO, "io"); 60 new TestRulesRegistry(content::BrowserThread::IO, "io");
61 61
62 // Test registration. 62 // Test registration.
63 63
64 RulesRegistryService registry_service(NULL); 64 RulesRegistryService registry_service(NULL);
65 registry_service.RegisterRulesRegistry(make_scoped_refptr(ui_registry)); 65 registry_service.RegisterRulesRegistry(make_scoped_refptr(ui_registry));
66 registry_service.RegisterRulesRegistry(make_scoped_refptr(io_registry)); 66 registry_service.RegisterRulesRegistry(make_scoped_refptr(io_registry));
67 67
68 EXPECT_TRUE(registry_service.GetRulesRegistry("ui").get()); 68 const RulesRegistry::WebViewKey key(0, 0);
69 EXPECT_TRUE(registry_service.GetRulesRegistry("io").get()); 69 EXPECT_TRUE(registry_service.GetRulesRegistry(key, "ui").get());
70 EXPECT_FALSE(registry_service.GetRulesRegistry("foo").get()); 70 EXPECT_TRUE(registry_service.GetRulesRegistry(key, "io").get());
71 EXPECT_FALSE(registry_service.GetRulesRegistry(key, "foo").get());
71 72
72 content::BrowserThread::PostTask( 73 content::BrowserThread::PostTask(
73 content::BrowserThread::UI, FROM_HERE, 74 content::BrowserThread::UI, FROM_HERE,
74 base::Bind(&InsertRule, registry_service.GetRulesRegistry("ui"), 75 base::Bind(&InsertRule, registry_service.GetRulesRegistry(key, "ui"),
75 "ui_task")); 76 "ui_task"));
76 77
77 content::BrowserThread::PostTask( 78 content::BrowserThread::PostTask(
78 content::BrowserThread::IO, FROM_HERE, 79 content::BrowserThread::IO, FROM_HERE,
79 base::Bind(&InsertRule, registry_service.GetRulesRegistry("io"), 80 base::Bind(&InsertRule, registry_service.GetRulesRegistry(key, "io"),
80 "io_task")); 81 "io_task"));
81 82
82 content::BrowserThread::PostTask( 83 content::BrowserThread::PostTask(
83 content::BrowserThread::UI, FROM_HERE, 84 content::BrowserThread::UI, FROM_HERE,
84 base::Bind(&VerifyNumberOfRules, 85 base::Bind(&VerifyNumberOfRules,
85 registry_service.GetRulesRegistry("ui"), 1)); 86 registry_service.GetRulesRegistry(key, "ui"), 1));
86 87
87 content::BrowserThread::PostTask( 88 content::BrowserThread::PostTask(
88 content::BrowserThread::IO, FROM_HERE, 89 content::BrowserThread::IO, FROM_HERE,
89 base::Bind(&VerifyNumberOfRules, 90 base::Bind(&VerifyNumberOfRules,
90 registry_service.GetRulesRegistry("io"), 1)); 91 registry_service.GetRulesRegistry(key, "io"), 1));
91 92
92 message_loop_.RunUntilIdle(); 93 message_loop_.RunUntilIdle();
93 94
94 // Test extension unloading. 95 // Test extension unloading.
95 96
96 registry_service.SimulateExtensionUnloaded(kExtensionId); 97 registry_service.SimulateExtensionUnloaded(kExtensionId);
97 98
98 content::BrowserThread::PostTask( 99 content::BrowserThread::PostTask(
99 content::BrowserThread::UI, FROM_HERE, 100 content::BrowserThread::UI, FROM_HERE,
100 base::Bind(&VerifyNumberOfRules, 101 base::Bind(&VerifyNumberOfRules,
101 registry_service.GetRulesRegistry("ui"), 0)); 102 registry_service.GetRulesRegistry(key, "ui"), 0));
102 103
103 content::BrowserThread::PostTask( 104 content::BrowserThread::PostTask(
104 content::BrowserThread::IO, FROM_HERE, 105 content::BrowserThread::IO, FROM_HERE,
105 base::Bind(&VerifyNumberOfRules, 106 base::Bind(&VerifyNumberOfRules,
106 registry_service.GetRulesRegistry("io"), 0)); 107 registry_service.GetRulesRegistry(key, "io"), 0));
107 108
108 message_loop_.RunUntilIdle(); 109 message_loop_.RunUntilIdle();
109 } 110 }
110 111
111 } // namespace extensions 112 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698