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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" | 12 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
| 13 #include "chrome/browser/extensions/bundle_installer.h" |
13 #include "chrome/browser/extensions/extension_apitest.h" | 14 #include "chrome/browser/extensions/extension_apitest.h" |
14 #include "chrome/browser/extensions/extension_function_test_utils.h" | 15 #include "chrome/browser/extensions/extension_function_test_utils.h" |
15 #include "chrome/browser/extensions/extension_install_prompt.h" | 16 #include "chrome/browser/extensions/extension_install_prompt.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/webstore_installer.h" | 18 #include "chrome/browser/extensions/webstore_installer.h" |
18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 23 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 | 428 |
428 // Run tests when the --enable-ephemeral-apps switch is enabled. | 429 // Run tests when the --enable-ephemeral-apps switch is enabled. |
429 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, LaunchEphemeralApp) { | 430 IN_PROC_BROWSER_TEST_F(EphemeralAppWebstorePrivateApiTest, LaunchEphemeralApp) { |
430 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 431 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
431 switches::kEnableEphemeralAppsInWebstore); | 432 switches::kEnableEphemeralAppsInWebstore); |
432 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 433 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
433 app_list::switches::kEnableExperimentalAppList); | 434 app_list::switches::kEnableExperimentalAppList); |
434 ASSERT_TRUE(RunInstallTest("webstore_launch_app.html", "app.crx")); | 435 ASSERT_TRUE(RunInstallTest("webstore_launch_app.html", "app.crx")); |
435 } | 436 } |
436 | 437 |
| 438 class BundleWebstorePrivateApiTest |
| 439 : public ExtensionWebstorePrivateApiTest { |
| 440 public: |
| 441 void SetUpInProcessBrowserTestFixture() override { |
| 442 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); |
| 443 |
| 444 test_data_dir_ = test_data_dir_.AppendASCII("webstore_private/bundle"); |
| 445 |
| 446 // The test server needs to have already started, so setup the switch here |
| 447 // rather than in SetUpCommandLine. |
| 448 base::FilePath server_path = base::FilePath("bundle").AppendASCII("%s.crx"); |
| 449 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 450 switches::kAppsGalleryDownloadURL, |
| 451 GetTestServerURL(server_path.value()).spec()); |
| 452 } |
| 453 }; |
| 454 |
| 455 // Tests successfully installing a bundle of 2 apps and 2 extensions. |
| 456 IN_PROC_BROWSER_TEST_F(BundleWebstorePrivateApiTest, InstallBundle) { |
| 457 extensions::BundleInstaller::SetAutoApproveForTesting(true); |
| 458 ASSERT_TRUE(RunPageTest(GetTestServerURL("install_bundle.html").spec())); |
| 459 } |
| 460 |
| 461 // Tests that bundles can be installed from incognito windows. |
| 462 IN_PROC_BROWSER_TEST_F(BundleWebstorePrivateApiTest, InstallBundleIncognito) { |
| 463 extensions::BundleInstaller::SetAutoApproveForTesting(true); |
| 464 |
| 465 ASSERT_TRUE(RunPageTest(GetTestServerURL("install_bundle.html").spec(), |
| 466 ExtensionApiTest::kFlagUseIncognito)); |
| 467 } |
| 468 |
| 469 // Tests the user canceling the bundle install prompt. |
| 470 IN_PROC_BROWSER_TEST_F(BundleWebstorePrivateApiTest, InstallBundleCancel) { |
| 471 // We don't need to create the CRX files since we are aborting the install. |
| 472 extensions::BundleInstaller::SetAutoApproveForTesting(false); |
| 473 |
| 474 ASSERT_TRUE( |
| 475 RunPageTest(GetTestServerURL("install_bundle_cancel.html").spec())); |
| 476 } |
| 477 |
| 478 // Tests partially installing a bundle (1 succeeds, 1 fails due to an invalid |
| 479 // CRX, 1 fails due to the manifests not matching, and 1 fails due to a missing |
| 480 // crx file). |
| 481 IN_PROC_BROWSER_TEST_F(BundleWebstorePrivateApiTest, InstallBundleInvalid) { |
| 482 extensions::BundleInstaller::SetAutoApproveForTesting(true); |
| 483 |
| 484 ASSERT_TRUE( |
| 485 RunPageTest(GetTestServerURL("install_bundle_invalid.html").spec())); |
| 486 } |
| 487 |
437 } // namespace extensions | 488 } // namespace extensions |
OLD | NEW |