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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/scoped_observer.h" | 6 #include "base/scoped_observer.h" |
7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/extensions/extension_install_prompt.h" | 8 #include "chrome/browser/extensions/extension_install_prompt.h" |
9 #include "chrome/browser/extensions/extension_install_ui.h" | 9 #include "chrome/browser/extensions/extension_install_ui.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 283 |
284 content::NotificationRegistrar registrar_; | 284 content::NotificationRegistrar registrar_; |
285 | 285 |
286 // Have we seen an installation notification for kTestExtensionId ? | 286 // Have we seen an installation notification for kTestExtensionId ? |
287 bool saw_install_; | 287 bool saw_install_; |
288 | 288 |
289 // How many NOTIFICATION_BROWSER_OPENED notifications have we seen? | 289 // How many NOTIFICATION_BROWSER_OPENED notifications have we seen? |
290 int browser_open_count_; | 290 int browser_open_count_; |
291 }; | 291 }; |
292 | 292 |
293 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Accept) { | 293 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, CannotInstallNonEphemeral) { |
294 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 294 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
295 command_line->AppendSwitchASCII( | 295 command_line->AppendSwitchASCII( |
296 switches::kInstallFromWebstore, kTestExtensionId); | 296 switches::kInstallEphemeralAppFromWebstore, kTestExtensionId); |
297 ExtensionInstallPrompt::g_auto_confirm_for_tests = | 297 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
298 ExtensionInstallPrompt::ACCEPT; | 298 ExtensionInstallPrompt::ACCEPT; |
299 extensions::StartupHelper helper; | 299 extensions::StartupHelper helper; |
300 EXPECT_TRUE(helper.InstallFromWebstore(*command_line, browser()->profile())); | 300 EXPECT_FALSE(helper.InstallEphemeralApp(*command_line, browser()->profile())); |
301 EXPECT_TRUE(saw_install()); | |
302 EXPECT_EQ(0, browser_open_count()); | |
303 } | |
304 | |
305 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, Cancel) { | |
306 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
307 command_line->AppendSwitchASCII( | |
308 switches::kInstallFromWebstore, kTestExtensionId); | |
309 ExtensionInstallPrompt::g_auto_confirm_for_tests = | |
310 ExtensionInstallPrompt::CANCEL; | |
311 extensions::StartupHelper helper; | |
312 EXPECT_FALSE(helper.InstallFromWebstore(*command_line, browser()->profile())); | |
313 EXPECT_FALSE(saw_install()); | 301 EXPECT_FALSE(saw_install()); |
314 EXPECT_EQ(0, browser_open_count()); | 302 EXPECT_EQ(0, browser_open_count()); |
315 } | 303 } |
316 | |
317 IN_PROC_BROWSER_TEST_F(CommandLineWebstoreInstall, LimitedAccept) { | |
318 extensions::StartupHelper helper; | |
319 | |
320 // Small test of "WebStoreIdFromLimitedInstallCmdLine" which made more | |
321 // sense together with the rest of the test for "LimitedInstallFromWebstore". | |
322 base::CommandLine command_line_test1(base::CommandLine::NO_PROGRAM); | |
323 command_line_test1.AppendSwitchASCII(switches::kLimitedInstallFromWebstore, | |
324 "1"); | |
325 EXPECT_EQ("nckgahadagoaajjgafhacjanaoiihapd", | |
326 helper.WebStoreIdFromLimitedInstallCmdLine(command_line_test1)); | |
327 | |
328 base::CommandLine command_line_test2(base::CommandLine::NO_PROGRAM); | |
329 command_line_test1.AppendSwitchASCII(switches::kLimitedInstallFromWebstore, | |
330 "2"); | |
331 EXPECT_EQ(kTestExtensionId, | |
332 helper.WebStoreIdFromLimitedInstallCmdLine(command_line_test1)); | |
333 | |
334 // Now, on to the real test for LimitedInstallFromWebstore. | |
335 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
336 command_line->AppendSwitchASCII( | |
337 switches::kLimitedInstallFromWebstore, "2"); | |
338 helper.LimitedInstallFromWebstore(*command_line, browser()->profile(), | |
339 base::MessageLoop::QuitWhenIdleClosure()); | |
340 base::MessageLoop::current()->Run(); | |
341 | |
342 EXPECT_TRUE(saw_install()); | |
343 EXPECT_EQ(0, browser_open_count()); | |
344 } | |
OLD | NEW |