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/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
11 #include "chrome/browser/extensions/bundle_installer.h" | 12 #include "chrome/browser/extensions/bundle_installer.h" |
12 #include "chrome/browser/extensions/extension_apitest.h" | 13 #include "chrome/browser/extensions/extension_apitest.h" |
13 #include "chrome/browser/extensions/extension_function_test_utils.h" | 14 #include "chrome/browser/extensions/extension_function_test_utils.h" |
14 #include "chrome/browser/extensions/extension_install_prompt.h" | 15 #include "chrome/browser/extensions/extension_install_prompt.h" |
15 #include "chrome/browser/extensions/extension_install_ui.h" | 16 #include "chrome/browser/extensions/extension_install_ui.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" | |
18 #include "chrome/browser/extensions/webstore_installer.h" | 18 #include "chrome/browser/extensions/webstore_installer.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
22 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/test/base/test_launcher_utils.h" | 24 #include "chrome/test/base/test_launcher_utils.h" |
25 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
26 #include "content/public/browser/gpu_data_manager.h" | 26 #include "content/public/browser/gpu_data_manager.h" |
27 #include "content/public/browser/notification_observer.h" | 27 #include "content/public/browser/notification_observer.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 switches::kAppsGalleryUpdateURL, crx_url.spec()); | 146 switches::kAppsGalleryUpdateURL, crx_url.spec()); |
147 | 147 |
148 GURL page_url = GetTestServerURL(page); | 148 GURL page_url = GetTestServerURL(page); |
149 return RunPageTest(page_url.spec()); | 149 return RunPageTest(page_url.spec()); |
150 } | 150 } |
151 | 151 |
152 ExtensionService* service() { | 152 ExtensionService* service() { |
153 return browser()->profile()->GetExtensionService(); | 153 return browser()->profile()->GetExtensionService(); |
154 } | 154 } |
155 | 155 |
156 ScopedTempDir tmp_; | 156 base::ScopedTempDir tmp_; |
157 }; | 157 }; |
158 | 158 |
159 class ExtensionWebstorePrivateBundleTest | 159 class ExtensionWebstorePrivateBundleTest |
160 : public ExtensionWebstorePrivateApiTest { | 160 : public ExtensionWebstorePrivateApiTest { |
161 public: | 161 public: |
162 void SetUpInProcessBrowserTestFixture() OVERRIDE { | 162 void SetUpInProcessBrowserTestFixture() OVERRIDE { |
163 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); | 163 ExtensionWebstorePrivateApiTest::SetUpInProcessBrowserTestFixture(); |
164 | 164 |
165 // The test server needs to have already started, so setup the switch here | 165 // The test server needs to have already started, so setup the switch here |
166 // rather than in SetUpCommandLine. | 166 // rather than in SetUpCommandLine. |
(...skipping 13 matching lines...) Expand all Loading... |
180 FilePath dir_path = tmp_.path() | 180 FilePath dir_path = tmp_.path() |
181 .AppendASCII("webstore_private/bundle") | 181 .AppendASCII("webstore_private/bundle") |
182 .AppendASCII(id); | 182 .AppendASCII(id); |
183 | 183 |
184 PackCRX(id, dir_path); | 184 PackCRX(id, dir_path); |
185 } | 185 } |
186 | 186 |
187 // Packs the |manifest| file into a CRX using |id|'s PEM key. | 187 // Packs the |manifest| file into a CRX using |id|'s PEM key. |
188 void PackCRX(const std::string& id, const std::string& manifest) { | 188 void PackCRX(const std::string& id, const std::string& manifest) { |
189 // Move the extension to a temporary directory. | 189 // Move the extension to a temporary directory. |
190 ScopedTempDir tmp; | 190 base::ScopedTempDir tmp; |
191 ASSERT_TRUE(tmp.CreateUniqueTempDir()); | 191 ASSERT_TRUE(tmp.CreateUniqueTempDir()); |
192 ASSERT_TRUE(file_util::CreateDirectory(tmp.path())); | 192 ASSERT_TRUE(file_util::CreateDirectory(tmp.path())); |
193 | 193 |
194 FilePath tmp_manifest = tmp.path().AppendASCII("manifest.json"); | 194 FilePath tmp_manifest = tmp.path().AppendASCII("manifest.json"); |
195 FilePath data_path = test_data_dir_.AppendASCII("webstore_private/bundle"); | 195 FilePath data_path = test_data_dir_.AppendASCII("webstore_private/bundle"); |
196 FilePath manifest_path = data_path.AppendASCII(manifest); | 196 FilePath manifest_path = data_path.AppendASCII(manifest); |
197 | 197 |
198 ASSERT_TRUE(file_util::PathExists(manifest_path)); | 198 ASSERT_TRUE(file_util::PathExists(manifest_path)); |
199 ASSERT_TRUE(file_util::CopyFile(manifest_path, tmp_manifest)); | 199 ASSERT_TRUE(file_util::CopyFile(manifest_path, tmp_manifest)); |
200 | 200 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 } | 293 } |
294 | 294 |
295 // Test cases where the user accepts the install confirmation dialog. | 295 // Test cases where the user accepts the install confirmation dialog. |
296 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallAccepted) { | 296 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, InstallAccepted) { |
297 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); | 297 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); |
298 } | 298 } |
299 | 299 |
300 // Test having the default download directory missing. | 300 // Test having the default download directory missing. |
301 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, MissingDownloadDir) { | 301 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, MissingDownloadDir) { |
302 // Set a non-existent directory as the download path. | 302 // Set a non-existent directory as the download path. |
303 ScopedTempDir temp_dir; | 303 base::ScopedTempDir temp_dir; |
304 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); | 304 EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
305 FilePath missing_directory = temp_dir.Take(); | 305 FilePath missing_directory = temp_dir.Take(); |
306 EXPECT_TRUE(file_util::Delete(missing_directory, true)); | 306 EXPECT_TRUE(file_util::Delete(missing_directory, true)); |
307 WebstoreInstaller::SetDownloadDirectoryForTests(&missing_directory); | 307 WebstoreInstaller::SetDownloadDirectoryForTests(&missing_directory); |
308 | 308 |
309 // Now run the install test, which should succeed. | 309 // Now run the install test, which should succeed. |
310 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); | 310 ASSERT_TRUE(RunInstallTest("accepted.html", "extension.crx")); |
311 | 311 |
312 // Cleanup. | 312 // Cleanup. |
313 if (file_util::DirectoryExists(missing_directory)) | 313 if (file_util::DirectoryExists(missing_directory)) |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 GpuFeatureType type = | 478 GpuFeatureType type = |
479 content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); | 479 content::GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
480 EXPECT_EQ((type & content::GPU_FEATURE_TYPE_WEBGL), | 480 EXPECT_EQ((type & content::GPU_FEATURE_TYPE_WEBGL), |
481 content::GPU_FEATURE_TYPE_WEBGL); | 481 content::GPU_FEATURE_TYPE_WEBGL); |
482 | 482 |
483 bool webgl_allowed = false; | 483 bool webgl_allowed = false; |
484 RunTest(webgl_allowed); | 484 RunTest(webgl_allowed); |
485 } | 485 } |
486 | 486 |
487 } // namespace extensions | 487 } // namespace extensions |
OLD | NEW |