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

Side by Side Diff: chrome/browser/extensions/webstore_startup_installer_browsertest.cc

Issue 428123004: Revert of Remove deprecated extension notification from WebstoreStartupInstallerTest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/scoped_observer.h"
7 #include "chrome/browser/chrome_notification_types.h" 6 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_install_prompt.h" 7 #include "chrome/browser/extensions/extension_install_prompt.h"
9 #include "chrome/browser/extensions/extension_install_ui.h" 8 #include "chrome/browser/extensions/extension_install_ui.h"
10 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/startup_helper.h" 10 #include "chrome/browser/extensions/startup_helper.h"
12 #include "chrome/browser/extensions/webstore_installer_test.h" 11 #include "chrome/browser/extensions/webstore_installer_test.h"
13 #include "chrome/browser/infobars/infobar_service.h" 12 #include "chrome/browser/infobars/infobar_service.h"
14 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
17 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
18 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
19 #include "chrome/test/base/in_process_browser_test.h" 18 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/test_switches.h" 19 #include "chrome/test/base/test_switches.h"
21 #include "chrome/test/base/ui_test_utils.h" 20 #include "chrome/test/base/ui_test_utils.h"
22 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
23 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
24 #include "content/public/browser/notification_types.h" 23 #include "content/public/browser/notification_types.h"
25 #include "content/public/browser/web_contents.h" 24 #include "content/public/browser/web_contents.h"
26 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
27 #include "extensions/browser/extension_host.h" 26 #include "extensions/browser/extension_host.h"
28 #include "extensions/browser/extension_registry.h" 27 #include "extensions/browser/extension_registry.h"
29 #include "extensions/browser/extension_registry_observer.h"
30 #include "extensions/browser/extension_system.h" 28 #include "extensions/browser/extension_system.h"
31 #include "extensions/common/extension_builder.h" 29 #include "extensions/common/extension_builder.h"
32 #include "extensions/common/value_builder.h" 30 #include "extensions/common/value_builder.h"
33 #include "net/dns/mock_host_resolver.h" 31 #include "net/dns/mock_host_resolver.h"
34 #include "url/gurl.h" 32 #include "url/gurl.h"
35 33
36 using content::WebContents; 34 using content::WebContents;
37 using extensions::DictionaryBuilder; 35 using extensions::DictionaryBuilder;
38 using extensions::Extension; 36 using extensions::Extension;
39 using extensions::ExtensionBuilder; 37 using extensions::ExtensionBuilder;
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 WebstoreStartupInstallUnpackFailureTest) { 229 WebstoreStartupInstallUnpackFailureTest) {
232 ExtensionInstallPrompt::g_auto_confirm_for_tests = 230 ExtensionInstallPrompt::g_auto_confirm_for_tests =
233 ExtensionInstallPrompt::ACCEPT; 231 ExtensionInstallPrompt::ACCEPT;
234 232
235 ui_test_utils::NavigateToURL(browser(), 233 ui_test_utils::NavigateToURL(browser(),
236 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html")); 234 GenerateTestServerUrl(kAppDomain, "install_unpack_failure.html"));
237 235
238 RunTest("runTest"); 236 RunTest("runTest");
239 } 237 }
240 238
241 class CommandLineWebstoreInstall 239 class CommandLineWebstoreInstall : public WebstoreStartupInstallerTest,
242 : public WebstoreStartupInstallerTest, 240 public content::NotificationObserver {
243 public content::NotificationObserver,
244 public extensions::ExtensionRegistryObserver {
245 public: 241 public:
246 CommandLineWebstoreInstall() 242 CommandLineWebstoreInstall() : saw_install_(false), browser_open_count_(0) {}
247 : extensions_registry_observer_(this),
248 saw_install_(false),
249 browser_open_count_(0) {}
250 virtual ~CommandLineWebstoreInstall() {} 243 virtual ~CommandLineWebstoreInstall() {}
251 244
252 virtual void SetUpOnMainThread() OVERRIDE { 245 virtual void SetUpOnMainThread() OVERRIDE {
253 WebstoreStartupInstallerTest::SetUpOnMainThread(); 246 WebstoreStartupInstallerTest::SetUpOnMainThread();
254 extensions_registry_observer_.Add( 247 registrar_.Add(
255 extensions::ExtensionRegistry::Get(browser()->profile())); 248 this,
249 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
250 content::NotificationService::AllSources());
256 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED, 251 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_OPENED,
257 content::NotificationService::AllSources()); 252 content::NotificationService::AllSources());
258 } 253 }
259 254
260 bool saw_install() { return saw_install_; } 255 bool saw_install() { return saw_install_; }
261 256
262 int browser_open_count() { return browser_open_count_; } 257 int browser_open_count() { return browser_open_count_; }
263 258
264 // NotificationObserver interface. 259 // NotificationObserver interface.
265 virtual void Observe(int type, 260 virtual void Observe(int type,
266 const content::NotificationSource& source, 261 const content::NotificationSource& source,
267 const content::NotificationDetails& details) OVERRIDE { 262 const content::NotificationDetails& details) OVERRIDE {
268 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_OPENED); 263 if (type ==
269 ++browser_open_count_; 264 extensions::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED) {
270 } 265 const Extension* extension =
271 266 content::Details<const extensions::InstalledExtensionInfo>(details)->
272 virtual void OnExtensionWillBeInstalled( 267 extension;
273 content::BrowserContext* browser_context, 268 ASSERT_TRUE(extension != NULL);
274 const extensions::Extension* extension, 269 EXPECT_EQ(extension->id(), kTestExtensionId);
275 bool is_update, 270 saw_install_ = true;
276 bool from_ephemeral, 271 } else if (type == chrome::NOTIFICATION_BROWSER_OPENED) {
277 const std::string& old_name) OVERRIDE { 272 browser_open_count_++;
278 EXPECT_EQ(extension->id(), kTestExtensionId); 273 } else {
279 saw_install_ = true; 274 ASSERT_TRUE(false) << "Unexpected notification type : " << type;
275 }
280 } 276 }
281 277
282 content::NotificationRegistrar registrar_; 278 content::NotificationRegistrar registrar_;
283 279
284 ScopedObserver<extensions::ExtensionRegistry,
285 extensions::ExtensionRegistryObserver>
286 extensions_registry_observer_;
287
288 // Have we seen an installation notification for kTestExtensionId ? 280 // Have we seen an installation notification for kTestExtensionId ?
289 bool saw_install_; 281 bool saw_install_;
290 282
291 // How many NOTIFICATION_BROWSER_OPENED notifications have we seen? 283 // How many NOTIFICATION_BROWSER_OPENED notifications have we seen?
292 int browser_open_count_; 284 int browser_open_count_;
293 }; 285 };
294 286
295 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Accept) { 287 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Accept) {
296 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 288 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
297 command_line->AppendSwitchASCII( 289 command_line->AppendSwitchASCII(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); 329 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
338 command_line->AppendSwitchASCII( 330 command_line->AppendSwitchASCII(
339 switches::kLimitedInstallFromWebstore, "2"); 331 switches::kLimitedInstallFromWebstore, "2");
340 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(), 332 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(),
341 base::MessageLoop::QuitWhenIdleClosure()); 333 base::MessageLoop::QuitWhenIdleClosure());
342 base::MessageLoop::current()->Run(); 334 base::MessageLoop::current()->Run();
343 335
344 EXPECT_TRUE(saw_install()); 336 EXPECT_TRUE(saw_install());
345 EXPECT_EQ(0, browser_open_count()); 337 EXPECT_EQ(0, browser_open_count());
346 } 338 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698