diff options
author | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 23:40:55 +0000 |
---|---|---|
committer | zmo@google.com <zmo@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-09 23:40:55 +0000 |
commit | 2ee178bd82a60dfb6e6e009362a892095a707653 (patch) | |
tree | 1b5265e8ab01cf275f4da4f4a2f972f837c0a3bf | |
parent | 01c23958e0366f2b8cdc978bfb51f152f93951d9 (diff) | |
download | chromium_src-2ee178bd82a60dfb6e6e009362a892095a707653.zip chromium_src-2ee178bd82a60dfb6e6e009362a892095a707653.tar.gz chromium_src-2ee178bd82a60dfb6e6e009362a892095a707653.tar.bz2 |
Revert 109328 - Add tests to make sure gpu blacklist actually block gpu features.
The general idea is to use jbates's newly added tracing: if a feature is blacklisted, we check the tracing data to make sure gpu process hasn't launched.
BUG=101222
TEST=browser_tests
Review URL: http://codereview.chromium.org/8497034
TBR=zmo@google.com
Review URL: http://codereview.chromium.org/8510030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109334 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome_tests.gypi | 1 | ||||
-rw-r--r-- | chrome/test/data/gpu/feature_canvas2d.html | 35 | ||||
-rw-r--r-- | chrome/test/data/gpu/feature_compositing.html | 21 | ||||
-rw-r--r-- | chrome/test/data/gpu/feature_webgl.html | 33 | ||||
-rw-r--r-- | chrome/test/gpu/gpu_feature_browsertest.cc | 171 | ||||
-rw-r--r-- | content/browser/gpu/gpu_process_host.cc | 2 |
6 files changed, 0 insertions, 263 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 4ebff16..b6c52df 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2669,7 +2669,6 @@ 'test/data/webui/certificate_viewer_ui_test-inl.h', 'test/data/webui/ntp4.js', 'test/data/webui/print_preview.js', - 'test/gpu/gpu_feature_browsertest.cc', # TODO(craig): Rename this and run from base_unittests when the test # is safe to run there. See http://crbug.com/78722 for details. '../base/files/file_path_watcher_browsertest.cc', diff --git a/chrome/test/data/gpu/feature_canvas2d.html b/chrome/test/data/gpu/feature_canvas2d.html deleted file mode 100644 index eb07a6a..0000000 --- a/chrome/test/data/gpu/feature_canvas2d.html +++ /dev/null @@ -1,35 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<meta charset="utf-8"> -<title>GPU Feature Testing: Canvas2D</title> -<script> -function init() { - var canvas = document.createElement("canvas"); - if (!canvas) - return null; - // Make sure canvas is large enough to trigger gpu acceleration. - canvas.width = 500; - canvas.height = 500; - var context = null; - try { - context = canvas.getContext("2d"); - } catch(e) {} - return context; -} - -function runTest() { - var c2d = init(); - if (c2d) { - // Initialization was triggered lazily on the first draw. - c2d.fillRect(0, 0, 1, 1); - } - domAutomationController.setAutomationId(1); - domAutomationController.send("FINISHED"); -} -</script> -</head> -<body onload="runTest()"> -Canvas2D should trigger GPU process launch if accelerated-2d-canvas is allowed. -</body> -</html> diff --git a/chrome/test/data/gpu/feature_compositing.html b/chrome/test/data/gpu/feature_compositing.html deleted file mode 100644 index 2ffed5e..0000000 --- a/chrome/test/data/gpu/feature_compositing.html +++ /dev/null @@ -1,21 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<meta charset="utf-8"> -<title>GPU Feature Testing: Accelerated Compositing</title> -<style> -body { - -webkit-transform: translateZ(0); -} -</style> -<script> -function runTest() { - domAutomationController.setAutomationId(1); - domAutomationController.send("FINISHED"); -} -</script> -</head> -<body onload="runTest()"> -This page should trigger accelerated-compositing, i.e., gpu process should launch, if accelerated-compositing is allowed. -</body> -</html> diff --git a/chrome/test/data/gpu/feature_webgl.html b/chrome/test/data/gpu/feature_webgl.html deleted file mode 100644 index cd6566d..0000000 --- a/chrome/test/data/gpu/feature_webgl.html +++ /dev/null @@ -1,33 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<meta charset="utf-8"> -<title>GPU Feature Testing: WebGL</title> -<script> -function init() { - var canvas = document.createElement("canvas"); - if (!canvas) - return null; - var context = null; - try { - context = canvas.getContext("webgl"); - } catch(e) {} - if (!context) { - try { - context = canvas.getContext("experimental-webgl"); - } catch(e) {} - } - return context; -} - -function runTest() { - var gl = init(); - domAutomationController.setAutomationId(1); - domAutomationController.send("FINISHED"); -} -</script> -</head> -<body onload="runTest()"> -WebGL should trigger GPU process launch if it is allowed. -</body> -</html> diff --git a/chrome/test/gpu/gpu_feature_browsertest.cc b/chrome/test/gpu/gpu_feature_browsertest.cc deleted file mode 100644 index dc4827c..0000000 --- a/chrome/test/gpu/gpu_feature_browsertest.cc +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/file_util.h" -#include "base/memory/scoped_ptr.h" -#include "base/path_service.h" -#include "base/test/trace_event_analyzer.h" -#include "base/version.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/tracing.h" -#include "chrome/test/base/ui_test_utils.h" -#include "content/browser/gpu/gpu_blacklist.h" -#include "content/browser/gpu/gpu_data_manager.h" -#include "net/base/net_util.h" - -namespace { - -class GpuFeatureTest : public InProcessBrowserTest { - public: - GpuFeatureTest() {} - - virtual void SetUpCommandLine(CommandLine* command_line) { - // This enables DOM automation for tab contents. - EnableDOMAutomation(); - } - - void SetupBlacklist(const std::string& json_blacklist) { - scoped_ptr<Version> os_version(Version::GetVersionFromString("1.0")); - GpuBlacklist* blacklist = new GpuBlacklist("1.0 unknown"); - - ASSERT_TRUE(blacklist->LoadGpuBlacklist( - json_blacklist, GpuBlacklist::kAllOs)); - GpuDataManager::GetInstance()->SetBuiltInGpuBlacklist(blacklist); - } - - void RunTest(const std::string& url, bool expect_gpu_process) { - using namespace trace_analyzer; - - FilePath test_path; - PathService::Get(chrome::DIR_TEST_DATA, &test_path); - test_path = test_path.Append(FILE_PATH_LITERAL("gpu")); - test_path = test_path.Append(FILE_PATH_LITERAL(url)); - - ASSERT_TRUE(file_util::PathExists(test_path)) - << "Missing test file: " << test_path.value(); - - ASSERT_TRUE(tracing::BeginTracing("test_gpu")); - - ui_test_utils::DOMMessageQueue message_queue; - // Have to use a new tab for the blacklist to work. - ui_test_utils::NavigateToURLWithDisposition( - browser(), net::FilePathToFileURL(test_path), NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_NONE); - // Wait for message indicating the test has finished running. - ASSERT_TRUE(message_queue.WaitForMessage(NULL)); - - std::string json_events; - ASSERT_TRUE(tracing::EndTracing(&json_events)); - - scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events)); - EXPECT_EQ(expect_gpu_process, analyzer->FindOneEvent( - Query(EVENT_NAME) == Query::String("GpuProcessLaunched")) != NULL); - } -}; - -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { - GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); - EXPECT_EQ(flags.flags(), 0u); - - const bool expect_gpu_process = true; - RunTest("feature_compositing.html", expect_gpu_process); -} - -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) { - const std::string json_blacklist = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"1.0\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"blacklist\": [\n" - " \"accelerated_compositing\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - SetupBlacklist(json_blacklist); - GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing)); - - const bool expect_gpu_process = false; - RunTest("feature_compositing.html", expect_gpu_process); -} - -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) { - GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); - EXPECT_EQ(flags.flags(), 0u); - - const bool expect_gpu_process = true; - RunTest("feature_webgl.html", expect_gpu_process); -} - -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { - 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" - "}"; - SetupBlacklist(json_blacklist); - GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl)); - - const bool expect_gpu_process = false; - RunTest("feature_webgl.html", expect_gpu_process); -} - -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) { - GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); - EXPECT_EQ(flags.flags(), 0u); - -#if defined(OS_MACOSX) - // TODO(zmo): enabling Mac when skia backend is enabled. - const bool expect_gpu_process = false; -#else - const bool expect_gpu_process = true; -#endif - RunTest("feature_canvas2d.html", expect_gpu_process); -} - -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) { - const std::string json_blacklist = - "{\n" - " \"name\": \"gpu blacklist\",\n" - " \"version\": \"1.0\",\n" - " \"entries\": [\n" - " {\n" - " \"id\": 1,\n" - " \"blacklist\": [\n" - " \"accelerated_2d_canvas\"\n" - " ]\n" - " }\n" - " ]\n" - "}"; - SetupBlacklist(json_blacklist); - GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags(); - EXPECT_EQ( - flags.flags(), - static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas)); - - const bool expect_gpu_process = false; - RunTest("feature_canvas2d.html", expect_gpu_process); -} - -} // namespace anonymous - diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index fade001a..0612fca 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -467,8 +467,6 @@ void GpuProcessHost::OnProcessLaunched() { // respond to any requests to establish a GPU channel. The response // to such requests require that the GPU process handle be known. - TRACE_EVENT0("test_gpu", "GpuProcessLaunched"); - base::ProcessHandle child_handle = in_process_ ? base::GetCurrentProcessHandle() : handle(); |