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 "extensions/browser/api/declarative/rules_registry_service.h" | 5 #include "extensions/browser/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/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "content/public/test/test_browser_thread.h" | 10 #include "content/public/test/test_browser_thread.h" |
11 #include "extensions/browser/api/declarative/test_rules_registry.h" | 11 #include "extensions/browser/api/declarative/test_rules_registry.h" |
12 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" | 12 #include "extensions/browser/api/declarative_webrequest/webrequest_constants.h" |
| 13 #include "extensions/common/extension.h" |
| 14 #include "extensions/common/extension_builder.h" |
| 15 #include "extensions/common/value_builder.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
14 | 17 |
15 namespace { | 18 namespace { |
16 const char kExtensionId[] = "foo"; | 19 const char kExtensionId[] = "foo"; |
17 | 20 |
18 void InsertRule(scoped_refptr<extensions::RulesRegistry> registry, | 21 void InsertRule(scoped_refptr<extensions::RulesRegistry> registry, |
19 const std::string& id) { | 22 const std::string& id) { |
20 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > add_rules; | 23 std::vector<linked_ptr<extensions::RulesRegistry::Rule> > add_rules; |
21 add_rules.push_back(make_linked_ptr(new extensions::RulesRegistry::Rule)); | 24 add_rules.push_back(make_linked_ptr(new extensions::RulesRegistry::Rule)); |
22 add_rules[0]->id.reset(new std::string(id)); | 25 add_rules[0]->id.reset(new std::string(id)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 registry_service.GetRulesRegistry(key, "ui"), 1)); | 92 registry_service.GetRulesRegistry(key, "ui"), 1)); |
90 | 93 |
91 content::BrowserThread::PostTask( | 94 content::BrowserThread::PostTask( |
92 content::BrowserThread::IO, FROM_HERE, | 95 content::BrowserThread::IO, FROM_HERE, |
93 base::Bind(&VerifyNumberOfRules, | 96 base::Bind(&VerifyNumberOfRules, |
94 registry_service.GetRulesRegistry(key, "io"), 1)); | 97 registry_service.GetRulesRegistry(key, "io"), 1)); |
95 | 98 |
96 message_loop_.RunUntilIdle(); | 99 message_loop_.RunUntilIdle(); |
97 | 100 |
98 // Test extension uninstalling. | 101 // Test extension uninstalling. |
99 | 102 scoped_ptr<base::DictionaryValue> manifest = DictionaryBuilder() |
100 registry_service.SimulateExtensionUninstalled(kExtensionId); | 103 .Set("name", "Extension") |
| 104 .Set("version", "1.0") |
| 105 .Set("manifest_version", 2) |
| 106 .Build(); |
| 107 scoped_refptr<Extension> extension = ExtensionBuilder() |
| 108 .SetManifest(manifest.Pass()) |
| 109 .SetID(kExtensionId) |
| 110 .Build(); |
| 111 registry_service.SimulateExtensionUninstalled(extension.get()); |
101 | 112 |
102 content::BrowserThread::PostTask( | 113 content::BrowserThread::PostTask( |
103 content::BrowserThread::UI, FROM_HERE, | 114 content::BrowserThread::UI, FROM_HERE, |
104 base::Bind(&VerifyNumberOfRules, | 115 base::Bind(&VerifyNumberOfRules, |
105 registry_service.GetRulesRegistry(key, "ui"), 0)); | 116 registry_service.GetRulesRegistry(key, "ui"), 0)); |
106 | 117 |
107 content::BrowserThread::PostTask( | 118 content::BrowserThread::PostTask( |
108 content::BrowserThread::IO, FROM_HERE, | 119 content::BrowserThread::IO, FROM_HERE, |
109 base::Bind(&VerifyNumberOfRules, | 120 base::Bind(&VerifyNumberOfRules, |
110 registry_service.GetRulesRegistry(key, "io"), 0)); | 121 registry_service.GetRulesRegistry(key, "io"), 0)); |
111 | 122 |
112 message_loop_.RunUntilIdle(); | 123 message_loop_.RunUntilIdle(); |
113 } | 124 } |
114 | 125 |
115 } // namespace extensions | 126 } // namespace extensions |
OLD | NEW |