OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
11 #include "chrome/browser/extensions/extension_install_dialog.h" | 11 #include "chrome/browser/extensions/extension_install_dialog.h" |
12 #include "chrome/browser/extensions/extension_install_ui.h" | 12 #include "chrome/browser/extensions/extension_install_ui.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 14 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
15 #include "chrome/browser/extensions/webstore_installer.h" | 15 #include "chrome/browser/extensions/webstore_installer.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/test/base/test_launcher_utils.h" | |
20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
22 #include "content/browser/gpu/gpu_blacklist.h" | |
21 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 24 #include "content/public/browser/notification_registrar.h" |
23 #include "net/base/mock_host_resolver.h" | 25 #include "net/base/mock_host_resolver.h" |
26 #include "ui/gfx/gl/gl_switches.h" | |
24 | 27 |
25 namespace { | 28 namespace { |
26 | 29 |
27 class WebstoreInstallListener : public WebstoreInstaller::Delegate { | 30 class WebstoreInstallListener : public WebstoreInstaller::Delegate { |
28 public: | 31 public: |
29 WebstoreInstallListener() | 32 WebstoreInstallListener() |
30 : received_failure_(false), received_success_(false), waiting_(false) {} | 33 : received_failure_(false), received_success_(false), waiting_(false) {} |
31 | 34 |
32 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | 35 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
33 void OnExtensionInstallFailure(const std::string& id, | 36 void OnExtensionInstallFailure(const std::string& id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 82 |
80 } // namespace | 83 } // namespace |
81 | 84 |
82 // A base class for tests below. | 85 // A base class for tests below. |
83 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { | 86 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { |
84 public: | 87 public: |
85 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 88 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
86 ExtensionApiTest::SetUpCommandLine(command_line); | 89 ExtensionApiTest::SetUpCommandLine(command_line); |
87 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, | 90 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, |
88 "http://www.example.com"); | 91 "http://www.example.com"); |
92 | |
93 // In linux, we need to launch GPU process to decide if WebGL is allowed. | |
94 // Run it on top of osmesa to avoid bot driver issues. | |
95 #if defined(OS_LINUX) | |
96 test_launcher_utils::OverrideGLImplementation( | |
97 command_line, gfx::kGLImplementationOSMesaName); | |
98 #endif | |
89 } | 99 } |
90 | 100 |
91 void SetUpInProcessBrowserTestFixture() OVERRIDE { | 101 void SetUpInProcessBrowserTestFixture() OVERRIDE { |
92 // Start up the test server and get us ready for calling the install | 102 // Start up the test server and get us ready for calling the install |
93 // API functions. | 103 // API functions. |
94 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 104 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
95 ASSERT_TRUE(test_server()->Start()); | 105 ASSERT_TRUE(test_server()->Start()); |
96 SetExtensionInstallDialogAutoConfirmForTests(true); | 106 SetExtensionInstallDialogAutoConfirmForTests(true); |
97 ExtensionInstallUI::DisableFailureUIForTests(); | 107 ExtensionInstallUI::DisableFailureUIForTests(); |
98 } | 108 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 232 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
223 IconUrl) { | 233 IconUrl) { |
224 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); | 234 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); |
225 } | 235 } |
226 | 236 |
227 // Tests using silentlyInstall to install extensions. | 237 // Tests using silentlyInstall to install extensions. |
228 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) { | 238 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) { |
229 WebstorePrivateApi::SetTrustTestIDsForTesting(true); | 239 WebstorePrivateApi::SetTrustTestIDsForTesting(true); |
230 ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec())); | 240 ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec())); |
231 } | 241 } |
242 | |
243 // Tests getWebGLStatus function when webgl is allowed. | |
Mihai Parparita -not on Chrome
2011/12/06 02:58:11
Nit: Capitalize WebGL (applies below too).
Zhenyao Mo
2011/12/06 20:00:15
Done.
| |
244 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, | |
245 GetWebGLStatusAllowed) { | |
246 ASSERT_TRUE( | |
247 RunPageTest(GetTestServerURL("get_webgl_status_allowed.html").spec())); | |
Mihai Parparita -not on Chrome
2011/12/06 02:58:11
For testing single function behavior, rather than
Zhenyao Mo
2011/12/06 20:00:15
I tried, but it didn't work because RunFunctionAnd
Zhenyao Mo
2011/12/06 20:19:57
Never mind. It's a bug in my own code. I switche
| |
248 } | |
249 | |
250 // Tests getWebGLStatus function when webgl is blacklisted. | |
251 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, | |
252 GetWebGLStatusBlocked) { | |
253 const std::string json_blacklist = | |
254 "{\n" | |
255 " \"name\": \"gpu blacklist\",\n" | |
256 " \"version\": \"1.0\",\n" | |
257 " \"entries\": [\n" | |
258 " {\n" | |
259 " \"id\": 1,\n" | |
260 " \"blacklist\": [\n" | |
261 " \"webgl\"\n" | |
262 " ]\n" | |
263 " }\n" | |
264 " ]\n" | |
265 "}"; | |
266 scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0")); | |
267 GpuBlacklist* blacklist = new GpuBlacklist("1.0"); | |
268 | |
269 ASSERT_TRUE(blacklist->LoadGpuBlacklist( | |
270 json_blacklist, GpuBlacklist::kAllOs)); | |
271 GpuDataManager::GetInstance()->SetGpuBlacklist(blacklist); | |
272 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); | |
273 EXPECT_EQ( | |
274 flags.flags(), static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); | |
275 | |
276 ASSERT_TRUE( | |
277 RunPageTest(GetTestServerURL("get_webgl_status_blocked.html").spec())); | |
278 } | |
279 | |
OLD | NEW |