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

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

Issue 9315010: RulesRegistry for declarative APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/memory/scoped_ptr.h"
7 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h"
8 #include "chrome/browser/extensions/api/declarative/test_rules_registry.h"
9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/extensions/extension.h"
15
16 namespace {
17 const char kTestEvent[] = "experimental.declarative.testEvent";
18 } // namespace
19
20 class DeclarativeApiTest : public ExtensionApiTest {
21 public:
22 DeclarativeApiTest() : test_rules_registry_(NULL) {}
23 virtual ~DeclarativeApiTest() {}
24
25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
26 ExtensionApiTest::SetUpCommandLine(command_line);
27 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
28 }
29
30 void RegisterTestRuleRegistry() {
31 using namespace extensions;
32 Profile* profile = browser()->profile();
33 RulesRegistryService* rules_registry =
34 profile->GetExtensionService()->GetRulesRegistryService();
35 scoped_ptr<RulesRegistry> test_rules_registry(new TestRulesRegistry());
36 test_rules_registry_ = test_rules_registry.get();
37 rules_registry->RegisterRulesRegistry(kTestEvent,
38 test_rules_registry.Pass());
39 }
40
41 // Weak pointer that is deleted when the profile is destroyed.
42 extensions::RulesRegistry* test_rules_registry_;
43 };
44
45 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, DeclarativeApi) {
46 RegisterTestRuleRegistry();
47 ASSERT_TRUE(RunExtensionTest("declarative/api")) << message_;
48
49 // Check that unloading the page has removed all rules.
50 std::string extension_id = GetSingleLoadedExtension()->id();
51 UnloadExtension(extension_id);
52
53 std::vector<std::string> rule_identifiers; // Empty to get all rules.
54 std::vector<DictionaryValue*> known_rules;
55 test_rules_registry_->GetRules(extension_id,
56 rule_identifiers,
57 &known_rules);
58 EXPECT_TRUE(known_rules.empty());
59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698