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_function_test_utils.h" | |
11 #include "chrome/browser/extensions/extension_install_dialog.h" | 12 #include "chrome/browser/extensions/extension_install_dialog.h" |
12 #include "chrome/browser/extensions/extension_install_ui.h" | 13 #include "chrome/browser/extensions/extension_install_ui.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/extension_webstore_private_api.h" | 15 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
15 #include "chrome/browser/extensions/webstore_installer.h" | 16 #include "chrome/browser/extensions/webstore_installer.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/common/chrome_notification_types.h" | 19 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/test/base/test_launcher_utils.h" | |
20 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
23 #include "content/browser/gpu/gpu_blacklist.h" | |
21 #include "content/public/browser/notification_observer.h" | 24 #include "content/public/browser/notification_observer.h" |
22 #include "content/public/browser/notification_registrar.h" | 25 #include "content/public/browser/notification_registrar.h" |
23 #include "net/base/mock_host_resolver.h" | 26 #include "net/base/mock_host_resolver.h" |
27 #include "ui/gfx/gl/gl_switches.h" | |
28 | |
29 using namespace extension_function_test_utils; | |
24 | 30 |
25 namespace { | 31 namespace { |
26 | 32 |
27 class WebstoreInstallListener : public WebstoreInstaller::Delegate { | 33 class WebstoreInstallListener : public WebstoreInstaller::Delegate { |
28 public: | 34 public: |
29 WebstoreInstallListener() | 35 WebstoreInstallListener() |
30 : received_failure_(false), received_success_(false), waiting_(false) {} | 36 : received_failure_(false), received_success_(false), waiting_(false) {} |
31 | 37 |
32 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | 38 void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; |
33 void OnExtensionInstallFailure(const std::string& id, | 39 void OnExtensionInstallFailure(const std::string& id, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 85 |
80 } // namespace | 86 } // namespace |
81 | 87 |
82 // A base class for tests below. | 88 // A base class for tests below. |
83 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { | 89 class ExtensionWebstorePrivateApiTest : public ExtensionApiTest { |
84 public: | 90 public: |
85 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 91 void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
86 ExtensionApiTest::SetUpCommandLine(command_line); | 92 ExtensionApiTest::SetUpCommandLine(command_line); |
87 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, | 93 command_line->AppendSwitchASCII(switches::kAppsGalleryURL, |
88 "http://www.example.com"); | 94 "http://www.example.com"); |
95 | |
96 // In linux, we need to launch GPU process to decide if WebGL is allowed. | |
Mihai Parparita -not on Chrome
2011/12/07 00:01:38
Can you move this to a separate subclass that you
Zhenyao Mo
2011/12/07 17:26:51
Done.
| |
97 // Run it on top of osmesa to avoid bot driver issues. | |
98 #if defined(OS_LINUX) | |
99 CHECK(test_launcher_utils::OverrideGLImplementation( | |
100 command_line, gfx::kGLImplementationOSMesaName)) << | |
101 "kUseGL must not be set multiple times!"; | |
102 #endif | |
89 } | 103 } |
90 | 104 |
91 void SetUpInProcessBrowserTestFixture() OVERRIDE { | 105 void SetUpInProcessBrowserTestFixture() OVERRIDE { |
92 // Start up the test server and get us ready for calling the install | 106 // Start up the test server and get us ready for calling the install |
93 // API functions. | 107 // API functions. |
94 host_resolver()->AddRule("www.example.com", "127.0.0.1"); | 108 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
95 ASSERT_TRUE(test_server()->Start()); | 109 ASSERT_TRUE(test_server()->Start()); |
96 SetExtensionInstallDialogAutoConfirmForTests(true); | 110 SetExtensionInstallDialogAutoConfirmForTests(true); |
97 ExtensionInstallUI::DisableFailureUIForTests(); | 111 ExtensionInstallUI::DisableFailureUIForTests(); |
98 } | 112 } |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
222 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | 236 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
223 IconUrl) { | 237 IconUrl) { |
224 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); | 238 ASSERT_TRUE(RunInstallTest("icon_url.html", "extension.crx")); |
225 } | 239 } |
226 | 240 |
227 // Tests using silentlyInstall to install extensions. | 241 // Tests using silentlyInstall to install extensions. |
228 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) { | 242 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateBundleTest, SilentlyInstall) { |
229 WebstorePrivateApi::SetTrustTestIDsForTesting(true); | 243 WebstorePrivateApi::SetTrustTestIDsForTesting(true); |
230 ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec())); | 244 ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec())); |
231 } | 245 } |
246 | |
247 // Tests getWebGLStatus function when WebGL is allowed. | |
248 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | |
249 GetWebGLStatusAllowed) { | |
Ken Russell (switch to Gerrit)
2011/12/06 22:42:04
Are these tests run in the same process, and if so
| |
250 static const char kEmptyArgs[] = "[]"; | |
251 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | |
252 new GetWebGLStatusFunction(), kEmptyArgs, browser())); | |
253 EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); | |
254 StringValue* value = static_cast<StringValue*>(result.get()); | |
255 std::string webgl_status = ""; | |
256 EXPECT_TRUE(value && value->GetAsString(&webgl_status)); | |
257 EXPECT_STREQ("webgl_allowed", webgl_status.c_str()); | |
258 } | |
259 | |
260 // Tests getWebGLStatus function when WebGL is blacklisted. | |
261 IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, | |
262 GetWebGLStatusBlocked) { | |
263 static const std::string json_blacklist = | |
264 "{\n" | |
265 " \"name\": \"gpu blacklist\",\n" | |
266 " \"version\": \"1.0\",\n" | |
267 " \"entries\": [\n" | |
268 " {\n" | |
269 " \"id\": 1,\n" | |
270 " \"blacklist\": [\n" | |
271 " \"webgl\"\n" | |
272 " ]\n" | |
273 " }\n" | |
274 " ]\n" | |
275 "}"; | |
276 scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0")); | |
277 GpuBlacklist* blacklist = new GpuBlacklist("1.0"); | |
278 | |
279 ASSERT_TRUE(blacklist->LoadGpuBlacklist( | |
280 json_blacklist, GpuBlacklist::kAllOs)); | |
281 GpuDataManager::GetInstance()->SetGpuBlacklist(blacklist); | |
282 GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); | |
283 EXPECT_EQ( | |
284 flags.flags(), static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); | |
285 | |
286 static const char kEmptyArgs[] = "[]"; | |
287 scoped_ptr<base::Value> result(RunFunctionAndReturnResult( | |
288 new GetWebGLStatusFunction(), kEmptyArgs, browser())); | |
289 EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); | |
290 StringValue* value = static_cast<StringValue*>(result.get()); | |
291 std::string webgl_status = ""; | |
292 EXPECT_TRUE(value && value->GetAsString(&webgl_status)); | |
293 EXPECT_STREQ("webgl_blocked", webgl_status.c_str()); | |
294 } | |
295 | |
OLD | NEW |