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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" | 9 #include "chrome/browser/extensions/api/declarative/rules_registry_service.h" |
10 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" | 10 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_consta
nts.h" |
11 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_
registry.h" | 11 #include "chrome/browser/extensions/api/declarative_webrequest/webrequest_rules_
registry.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_system_factory.h" | 13 #include "chrome/browser/extensions/extension_system_factory.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
16 #include "chrome/common/chrome_switches.h" | |
17 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
20 | 19 |
21 using extensions::RulesRegistry; | 20 using extensions::RulesRegistry; |
22 using extensions::RulesRegistryService; | 21 using extensions::RulesRegistryService; |
23 using extensions::WebRequestRulesRegistry; | 22 using extensions::WebRequestRulesRegistry; |
24 | 23 |
25 class DeclarativeApiTest : public ExtensionApiTest { | 24 class DeclarativeApiTest : public ExtensionApiTest { |
26 public: | |
27 DeclarativeApiTest() {} | |
28 virtual ~DeclarativeApiTest() {} | |
29 | |
30 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
31 ExtensionApiTest::SetUpCommandLine(command_line); | |
32 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | |
33 } | |
34 }; | 25 }; |
35 | 26 |
36 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, DeclarativeApi) { | 27 IN_PROC_BROWSER_TEST_F(DeclarativeApiTest, DeclarativeApi) { |
37 ASSERT_TRUE(RunExtensionTest("declarative/api")) << message_; | 28 ASSERT_TRUE(RunExtensionTest("declarative/api")) << message_; |
38 | 29 |
39 // Check that unloading the page has removed all rules. | 30 // Check that unloading the page has removed all rules. |
40 std::string extension_id = GetSingleLoadedExtension()->id(); | 31 std::string extension_id = GetSingleLoadedExtension()->id(); |
41 UnloadExtension(extension_id); | 32 UnloadExtension(extension_id); |
42 | 33 |
43 // UnloadExtension posts a task to the owner thread of the extension | 34 // UnloadExtension posts a task to the owner thread of the extension |
(...skipping 11 matching lines...) Expand all Loading... |
55 content::BrowserThread::PostTask( | 46 content::BrowserThread::PostTask( |
56 rules_registry->owner_thread(), | 47 rules_registry->owner_thread(), |
57 FROM_HERE, | 48 FROM_HERE, |
58 base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules), | 49 base::Bind(base::IgnoreResult(&RulesRegistry::GetAllRules), |
59 rules_registry, extension_id, &known_rules)); | 50 rules_registry, extension_id, &known_rules)); |
60 | 51 |
61 content::RunAllPendingInMessageLoop(rules_registry->owner_thread()); | 52 content::RunAllPendingInMessageLoop(rules_registry->owner_thread()); |
62 | 53 |
63 EXPECT_TRUE(known_rules.empty()); | 54 EXPECT_TRUE(known_rules.empty()); |
64 } | 55 } |
OLD | NEW |