OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extension_registry.h" | 5 #include "extensions/browser/extension_registry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 bool from_ephemeral, | 67 bool from_ephemeral, |
68 const std::string& old_name) OVERRIDE { | 68 const std::string& old_name) OVERRIDE { |
69 installed_.push_back(extension); | 69 installed_.push_back(extension); |
70 } | 70 } |
71 | 71 |
72 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, | 72 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, |
73 const Extension* extension) OVERRIDE { | 73 const Extension* extension) OVERRIDE { |
74 uninstalled_.push_back(extension); | 74 uninstalled_.push_back(extension); |
75 } | 75 } |
76 | 76 |
| 77 virtual void OnShutdown(extensions::ExtensionRegistry* registry) OVERRIDE { |
| 78 Reset(); |
| 79 } |
| 80 |
77 ExtensionList loaded_; | 81 ExtensionList loaded_; |
78 ExtensionList unloaded_; | 82 ExtensionList unloaded_; |
79 ExtensionList installed_; | 83 ExtensionList installed_; |
80 ExtensionList uninstalled_; | 84 ExtensionList uninstalled_; |
81 }; | 85 }; |
82 | 86 |
83 TEST_F(ExtensionRegistryTest, FillAndClearRegistry) { | 87 TEST_F(ExtensionRegistryTest, FillAndClearRegistry) { |
84 ExtensionRegistry registry(NULL); | 88 ExtensionRegistry registry(NULL); |
85 scoped_refptr<Extension> extension1 = test_util::CreateExtensionWithID("id1"); | 89 scoped_refptr<Extension> extension1 = test_util::CreateExtensionWithID("id1"); |
86 scoped_refptr<Extension> extension2 = test_util::CreateExtensionWithID("id2"); | 90 scoped_refptr<Extension> extension2 = test_util::CreateExtensionWithID("id2"); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 extension, false, false, base::EmptyString()); | 249 extension, false, false, base::EmptyString()); |
246 EXPECT_TRUE(HasSingleExtension(observer.installed(), extension.get())); | 250 EXPECT_TRUE(HasSingleExtension(observer.installed(), extension.get())); |
247 | 251 |
248 registry.AddEnabled(extension); | 252 registry.AddEnabled(extension); |
249 registry.TriggerOnLoaded(extension); | 253 registry.TriggerOnLoaded(extension); |
250 | 254 |
251 registry.TriggerOnWillBeInstalled(extension, true, false, "foo"); | 255 registry.TriggerOnWillBeInstalled(extension, true, false, "foo"); |
252 | 256 |
253 EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get())); | 257 EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get())); |
254 EXPECT_TRUE(observer.unloaded().empty()); | 258 EXPECT_TRUE(observer.unloaded().empty()); |
255 observer.Reset(); | 259 registry.Shutdown(); |
256 | 260 |
257 registry.RemoveEnabled(extension->id()); | 261 registry.RemoveEnabled(extension->id()); |
258 registry.TriggerOnUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); | 262 registry.TriggerOnUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); |
259 | 263 |
260 EXPECT_TRUE(observer.loaded().empty()); | 264 EXPECT_TRUE(observer.loaded().empty()); |
261 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); | 265 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); |
262 observer.Reset(); | 266 registry.Shutdown(); |
263 | 267 |
264 registry.TriggerOnUninstalled(extension); | 268 registry.TriggerOnUninstalled(extension); |
265 EXPECT_TRUE(observer.installed().empty()); | 269 EXPECT_TRUE(observer.installed().empty()); |
266 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); | 270 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); |
267 | 271 |
268 registry.RemoveObserver(&observer); | 272 registry.RemoveObserver(&observer); |
269 } | 273 } |
270 | 274 |
271 } // namespace | 275 } // namespace |
272 } // namespace extensions | 276 } // namespace extensions |
OLD | NEW |