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 "chrome/browser/download/download_crx_util.h" | 5 #include "chrome/browser/download/download_crx_util.h" |
6 #include "chrome/browser/download/download_service.h" | 6 #include "chrome/browser/download/download_service.h" |
7 #include "chrome/browser/download/download_service_factory.h" | 7 #include "chrome/browser/download/download_service_factory.h" |
8 #include "chrome/browser/download/download_test_observer.h" | 8 #include "chrome/browser/download/download_test_observer.h" |
9 #include "chrome/browser/extensions/crx_installer.h" | 9 #include "chrome/browser/extensions/crx_installer.h" |
10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
11 #include "chrome/browser/extensions/extension_install_ui.h" | 11 #include "chrome/browser/extensions/extension_install_ui.h" |
12 #include "chrome/browser/extensions/extension_service.h" | 12 #include "chrome/browser/extensions/extension_service.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
16 #include "chrome/common/extensions/extension_file_util.h" | 16 #include "chrome/common/extensions/extension_file_util.h" |
| 17 #include "chrome/common/extensions/extension_switch_utils.h" |
17 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
18 | 19 |
19 class SkBitmap; | 20 class SkBitmap; |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Observer waits for exactly one download to finish. | 24 // Observer waits for exactly one download to finish. |
24 | 25 |
25 class MockInstallUI : public ExtensionInstallUI { | 26 class MockInstallUI : public ExtensionInstallUI { |
26 public: | 27 public: |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 118 |
118 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) { | 119 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PlatformAppCrx) { |
119 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 120 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
120 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); | 121 command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis); |
121 command_line->AppendSwitch(switches::kEnablePlatformApps); | 122 command_line->AppendSwitch(switches::kEnablePlatformApps); |
122 EXPECT_TRUE(InstallExtension( | 123 EXPECT_TRUE(InstallExtension( |
123 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1)); | 124 test_data_dir_.AppendASCII("minimal_platform_app.crx"), 1)); |
124 } | 125 } |
125 | 126 |
126 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) { | 127 IN_PROC_BROWSER_TEST_F(ExtensionCrxInstallerTest, PackAndInstallExtension) { |
| 128 if (!extensions::switch_utils::IsOffStoreInstallEnabled()) |
| 129 return; |
| 130 |
127 const int kNumDownloadsExpected = 1; | 131 const int kNumDownloadsExpected = 1; |
128 const bool kExpectFileSelectDialog = false; | 132 const bool kExpectFileSelectDialog = false; |
129 | 133 |
130 LOG(ERROR) << "PackAndInstallExtension: Packing extension"; | 134 LOG(ERROR) << "PackAndInstallExtension: Packing extension"; |
131 FilePath crx_path = PackExtension( | 135 FilePath crx_path = PackExtension( |
132 test_data_dir_.AppendASCII("common/background_page")); | 136 test_data_dir_.AppendASCII("common/background_page")); |
133 ASSERT_FALSE(crx_path.empty()); | 137 ASSERT_FALSE(crx_path.empty()); |
134 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); | 138 std::string crx_path_string(crx_path.value().begin(), crx_path.value().end()); |
135 GURL url = GURL(std::string("file:///").append(crx_path_string)); | 139 GURL url = GURL(std::string("file:///").append(crx_path_string)); |
136 | 140 |
(...skipping 12 matching lines...) Expand all Loading... |
149 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); | 153 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_ACCEPT)); |
150 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL"; | 154 LOG(ERROR) << "PackAndInstallExtension: Navigating to URL"; |
151 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, | 155 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, |
152 ui_test_utils::BROWSER_TEST_NONE); | 156 ui_test_utils::BROWSER_TEST_NONE); |
153 | 157 |
154 EXPECT_TRUE(WaitForExtensionInstall()); | 158 EXPECT_TRUE(WaitForExtensionInstall()); |
155 LOG(ERROR) << "PackAndInstallExtension: Extension install"; | 159 LOG(ERROR) << "PackAndInstallExtension: Extension install"; |
156 EXPECT_TRUE(mock_ui->confirmation_requested()); | 160 EXPECT_TRUE(mock_ui->confirmation_requested()); |
157 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed"; | 161 LOG(ERROR) << "PackAndInstallExtension: Extension install confirmed"; |
158 } | 162 } |
OLD | NEW |