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

Side by Side Diff: extensions/browser/extension_registry_unittest.cc

Issue 297263003: Optimize promotion of ephemeral apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 const Extension* extension, 57 const Extension* extension,
58 UnloadedExtensionInfo::Reason reason) 58 UnloadedExtensionInfo::Reason reason)
59 OVERRIDE { 59 OVERRIDE {
60 unloaded_.push_back(extension); 60 unloaded_.push_back(extension);
61 } 61 }
62 62
63 virtual void OnExtensionWillBeInstalled( 63 virtual void OnExtensionWillBeInstalled(
64 content::BrowserContext* browser_context, 64 content::BrowserContext* browser_context,
65 const Extension* extension, 65 const Extension* extension,
66 bool is_update, 66 bool is_update,
67 bool from_ephemeral,
67 const std::string& old_name) OVERRIDE { 68 const std::string& old_name) OVERRIDE {
68 installed_.push_back(extension); 69 installed_.push_back(extension);
69 } 70 }
70 71
71 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, 72 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context,
72 const Extension* extension) OVERRIDE { 73 const Extension* extension) OVERRIDE {
73 uninstalled_.push_back(extension); 74 uninstalled_.push_back(extension);
74 } 75 }
75 76
76 ExtensionList loaded_; 77 ExtensionList loaded_;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 TestObserver observer; 234 TestObserver observer;
234 registry.AddObserver(&observer); 235 registry.AddObserver(&observer);
235 236
236 EXPECT_TRUE(observer.loaded().empty()); 237 EXPECT_TRUE(observer.loaded().empty());
237 EXPECT_TRUE(observer.unloaded().empty()); 238 EXPECT_TRUE(observer.unloaded().empty());
238 EXPECT_TRUE(observer.installed().empty()); 239 EXPECT_TRUE(observer.installed().empty());
239 240
240 scoped_refptr<const Extension> extension = 241 scoped_refptr<const Extension> extension =
241 test_util::CreateExtensionWithID("id"); 242 test_util::CreateExtensionWithID("id");
242 243
243 registry.TriggerOnWillBeInstalled(extension, false, base::EmptyString()); 244 registry.TriggerOnWillBeInstalled(
245 extension, false, false, base::EmptyString());
244 EXPECT_TRUE(HasSingleExtension(observer.installed(), extension.get())); 246 EXPECT_TRUE(HasSingleExtension(observer.installed(), extension.get()));
245 247
246 registry.AddEnabled(extension); 248 registry.AddEnabled(extension);
247 registry.TriggerOnLoaded(extension); 249 registry.TriggerOnLoaded(extension);
248 250
249 registry.TriggerOnWillBeInstalled(extension, true, "foo"); 251 registry.TriggerOnWillBeInstalled(extension, true, false, "foo");
250 252
251 EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get())); 253 EXPECT_TRUE(HasSingleExtension(observer.loaded(), extension.get()));
252 EXPECT_TRUE(observer.unloaded().empty()); 254 EXPECT_TRUE(observer.unloaded().empty());
253 observer.Reset(); 255 observer.Reset();
254 256
255 registry.RemoveEnabled(extension->id()); 257 registry.RemoveEnabled(extension->id());
256 registry.TriggerOnUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE); 258 registry.TriggerOnUnloaded(extension, UnloadedExtensionInfo::REASON_DISABLE);
257 259
258 EXPECT_TRUE(observer.loaded().empty()); 260 EXPECT_TRUE(observer.loaded().empty());
259 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get())); 261 EXPECT_TRUE(HasSingleExtension(observer.unloaded(), extension.get()));
260 observer.Reset(); 262 observer.Reset();
261 263
262 registry.TriggerOnUninstalled(extension); 264 registry.TriggerOnUninstalled(extension);
263 EXPECT_TRUE(observer.installed().empty()); 265 EXPECT_TRUE(observer.installed().empty());
264 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get())); 266 EXPECT_TRUE(HasSingleExtension(observer.uninstalled(), extension.get()));
265 267
266 registry.RemoveObserver(&observer); 268 registry.RemoveObserver(&observer);
267 } 269 }
268 270
269 } // namespace 271 } // namespace
270 } // namespace extensions 272 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698