Chromium Code Reviews| Index: chrome/browser/extensions/extension_webstore_private_apitest.cc |
| =================================================================== |
| --- chrome/browser/extensions/extension_webstore_private_apitest.cc (revision 112998) |
| +++ chrome/browser/extensions/extension_webstore_private_apitest.cc (working copy) |
| @@ -8,6 +8,7 @@ |
| #include "base/file_util.h" |
| #include "base/stringprintf.h" |
| #include "chrome/browser/extensions/extension_apitest.h" |
| +#include "chrome/browser/extensions/extension_function_test_utils.h" |
| #include "chrome/browser/extensions/extension_install_dialog.h" |
| #include "chrome/browser/extensions/extension_install_ui.h" |
| #include "chrome/browser/extensions/extension_service.h" |
| @@ -17,11 +18,16 @@ |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/chrome_switches.h" |
| +#include "chrome/test/base/test_launcher_utils.h" |
| #include "chrome/test/base/ui_test_utils.h" |
| +#include "content/browser/gpu/gpu_blacklist.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| #include "net/base/mock_host_resolver.h" |
| +#include "ui/gfx/gl/gl_switches.h" |
| +using namespace extension_function_test_utils; |
| + |
| namespace { |
| class WebstoreInstallListener : public WebstoreInstaller::Delegate { |
| @@ -86,6 +92,14 @@ |
| ExtensionApiTest::SetUpCommandLine(command_line); |
| command_line->AppendSwitchASCII(switches::kAppsGalleryURL, |
| "http://www.example.com"); |
| + |
| + // 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.
|
| + // Run it on top of osmesa to avoid bot driver issues. |
| +#if defined(OS_LINUX) |
| + CHECK(test_launcher_utils::OverrideGLImplementation( |
| + command_line, gfx::kGLImplementationOSMesaName)) << |
| + "kUseGL must not be set multiple times!"; |
| +#endif |
| } |
| void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| @@ -229,3 +243,53 @@ |
| WebstorePrivateApi::SetTrustTestIDsForTesting(true); |
| ASSERT_TRUE(RunPageTest(GetTestServerURL("silently_install.html").spec())); |
| } |
| + |
| +// Tests getWebGLStatus function when WebGL is allowed. |
| +IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
| + GetWebGLStatusAllowed) { |
|
Ken Russell (switch to Gerrit)
2011/12/06 22:42:04
Are these tests run in the same process, and if so
|
| + static const char kEmptyArgs[] = "[]"; |
| + scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| + new GetWebGLStatusFunction(), kEmptyArgs, browser())); |
| + EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); |
| + StringValue* value = static_cast<StringValue*>(result.get()); |
| + std::string webgl_status = ""; |
| + EXPECT_TRUE(value && value->GetAsString(&webgl_status)); |
| + EXPECT_STREQ("webgl_allowed", webgl_status.c_str()); |
| +} |
| + |
| +// Tests getWebGLStatus function when WebGL is blacklisted. |
| +IN_PROC_BROWSER_TEST_F(ExtensionWebstorePrivateApiTest, |
| + GetWebGLStatusBlocked) { |
| + static const std::string json_blacklist = |
| + "{\n" |
| + " \"name\": \"gpu blacklist\",\n" |
| + " \"version\": \"1.0\",\n" |
| + " \"entries\": [\n" |
| + " {\n" |
| + " \"id\": 1,\n" |
| + " \"blacklist\": [\n" |
| + " \"webgl\"\n" |
| + " ]\n" |
| + " }\n" |
| + " ]\n" |
| + "}"; |
| + scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0")); |
| + GpuBlacklist* blacklist = new GpuBlacklist("1.0"); |
| + |
| + ASSERT_TRUE(blacklist->LoadGpuBlacklist( |
| + json_blacklist, GpuBlacklist::kAllOs)); |
| + GpuDataManager::GetInstance()->SetGpuBlacklist(blacklist); |
| + GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); |
| + EXPECT_EQ( |
| + flags.flags(), static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); |
| + |
| + static const char kEmptyArgs[] = "[]"; |
| + scoped_ptr<base::Value> result(RunFunctionAndReturnResult( |
| + new GetWebGLStatusFunction(), kEmptyArgs, browser())); |
| + EXPECT_EQ(base::Value::TYPE_STRING, result->GetType()); |
| + StringValue* value = static_cast<StringValue*>(result.get()); |
| + std::string webgl_status = ""; |
| + EXPECT_TRUE(value && value->GetAsString(&webgl_status)); |
| + EXPECT_STREQ("webgl_blocked", webgl_status.c_str()); |
| +} |
| + |