| Index: chrome/test/gpu/gpu_feature_browsertest.cc
|
| diff --git a/chrome/test/gpu/gpu_feature_browsertest.cc b/chrome/test/gpu/gpu_feature_browsertest.cc
|
| index 3329150fd1e41478b2c6d8c09b1343c6185372d5..574fc19c8913b9ecf475aceced82d428c00ee25b 100644
|
| --- a/chrome/test/gpu/gpu_feature_browsertest.cc
|
| +++ b/chrome/test/gpu/gpu_feature_browsertest.cc
|
| @@ -2,6 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "base/command_line.h"
|
| #include "base/file_util.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/path_service.h"
|
| @@ -15,16 +16,33 @@
|
| #include "content/browser/gpu/gpu_blacklist.h"
|
| #include "content/browser/gpu/gpu_data_manager.h"
|
| #include "net/base/net_util.h"
|
| +#include "ui/gfx/gl/gl_switches.h"
|
|
|
| namespace {
|
|
|
| +typedef uint32 GpuResultFlags;
|
| +#define EXPECT_NO_GPU_PROCESS GpuResultFlags(0)
|
| +// Expect GPU process to be created.
|
| +#define EXPECT_GPU_PROCESS GpuResultFlags(1<<0)
|
| +// Expect num_contexts_ to be created (onscreen or offscreen).
|
| +#define EXPECT_GPU_CONTEXTS GpuResultFlags(1<<1)
|
| +// Expect a SwapBuffers to occur (see gles2_cmd_decoder.cc).
|
| +#define EXPECT_GPU_SWAP_BUFFERS GpuResultFlags(1<<2)
|
| +
|
| class GpuFeatureTest : public InProcessBrowserTest {
|
| public:
|
| - GpuFeatureTest() {}
|
| + GpuFeatureTest()
|
| + : num_contexts_(0),
|
| + num_offscreen_contexts_(0) {}
|
|
|
| virtual void SetUpCommandLine(CommandLine* command_line) {
|
| // This enables DOM automation for tab contents.
|
| EnableDOMAutomation();
|
| +#if !defined(OS_MACOSX)
|
| + CHECK(!command_line->HasSwitch(switches::kUseGL)) <<
|
| + "kUseGL must not be set by test framework code!";
|
| + command_line->AppendSwitchASCII(switches::kUseGL, "osmesa");
|
| +#endif
|
| }
|
|
|
| void SetupBlacklist(const std::string& json_blacklist) {
|
| @@ -36,7 +54,7 @@ class GpuFeatureTest : public InProcessBrowserTest {
|
| GpuDataManager::GetInstance()->SetBuiltInGpuBlacklist(blacklist);
|
| }
|
|
|
| - void RunTest(const FilePath& url, bool expect_gpu_process) {
|
| + void RunTest(const FilePath& url, GpuResultFlags expectations) {
|
| using namespace trace_analyzer;
|
|
|
| FilePath test_path;
|
| @@ -61,18 +79,48 @@ class GpuFeatureTest : public InProcessBrowserTest {
|
| 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);
|
| + analyzer->AssociateBeginEndEvents();
|
| + TraceAnalyzer::TraceEventVector events;
|
| +
|
| + size_t num_gpu_processes = (expectations & EXPECT_GPU_PROCESS) ? 1 : 0;
|
| + analyzer->FindEvents(Query::MatchBeginName("OnGraphicsInfoCollected"),
|
| + &events);
|
| + EXPECT_EQ(num_gpu_processes, events.size());
|
| +
|
| + // Check for context creation if expected:
|
| + if (expectations & EXPECT_GPU_CONTEXTS) {
|
| + analyzer->FindEvents(
|
| + Query(EVENT_NAME) == Query::String("TryCreateGLContext"),
|
| + &events);
|
| + EXPECT_EQ(num_contexts_, events.size());
|
| + analyzer->FindEvents(
|
| + Query(EVENT_NAME) == Query::String("CreateGLContextSuccess"),
|
| + &events);
|
| + EXPECT_EQ(num_contexts_, events.size());
|
| + }
|
| +
|
| + // Check for swap buffers if expected:
|
| + if (expectations & EXPECT_GPU_SWAP_BUFFERS) {
|
| + analyzer->FindEvents(
|
| + Query(EVENT_NAME) == Query::String("SwapBuffers"),
|
| + &events);
|
| + EXPECT_GT(events.size(), size_t(0));
|
| + }
|
| }
|
| +
|
| + protected:
|
| + size_t num_contexts_;
|
| + size_t num_offscreen_contexts_;
|
| };
|
|
|
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) {
|
| GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
|
| EXPECT_EQ(flags.flags(), 0u);
|
|
|
| - const bool expect_gpu_process = true;
|
| + num_contexts_ = 1;
|
| const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
|
| - RunTest(url, expect_gpu_process);
|
| + RunTest(url, EXPECT_GPU_PROCESS | EXPECT_GPU_SWAP_BUFFERS |
|
| + EXPECT_GPU_CONTEXTS);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) {
|
| @@ -95,24 +143,18 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) {
|
| flags.flags(),
|
| static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAcceleratedCompositing));
|
|
|
| - const bool expect_gpu_process = false;
|
| const FilePath url(FILE_PATH_LITERAL("feature_compositing.html"));
|
| - RunTest(url, expect_gpu_process);
|
| + RunTest(url, EXPECT_NO_GPU_PROCESS);
|
| }
|
|
|
| -#if defined(OS_LINUX)
|
| -// http://crbug.com/104142
|
| -#define MAYBE_WebGLAllowed DISABLED_WebGLAllowed
|
| -#else
|
| -#define MAYBE_WebGLAllowed WebGLAllowed
|
| -#endif
|
| -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_WebGLAllowed) {
|
| +IN_PROC_BROWSER_TEST_F(GpuFeatureTest, FLAKY_WebGLAllowed) {
|
| GpuFeatureFlags flags = GpuDataManager::GetInstance()->GetGpuFeatureFlags();
|
| EXPECT_EQ(flags.flags(), 0u);
|
|
|
| - const bool expect_gpu_process = true;
|
| + num_contexts_ = 2;
|
| const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
|
| - RunTest(url, expect_gpu_process);
|
| + RunTest(url, EXPECT_GPU_PROCESS | EXPECT_GPU_SWAP_BUFFERS |
|
| + EXPECT_GPU_CONTEXTS);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) {
|
| @@ -135,9 +177,8 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) {
|
| flags.flags(),
|
| static_cast<uint32>(GpuFeatureFlags::kGpuFeatureWebgl));
|
|
|
| - const bool expect_gpu_process = false;
|
| const FilePath url(FILE_PATH_LITERAL("feature_webgl.html"));
|
| - RunTest(url, expect_gpu_process);
|
| + RunTest(url, EXPECT_NO_GPU_PROCESS);
|
| }
|
|
|
| #if defined(OS_LINUX)
|
| @@ -150,12 +191,15 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) {
|
|
|
| #if defined(OS_MACOSX)
|
| // TODO(zmo): enabling Mac when skia backend is enabled.
|
| - const bool expect_gpu_process = false;
|
| + const GpuResultFlags expectations = EXPECT_NO_GPU_PROCESS;
|
| #else
|
| - const bool expect_gpu_process = true;
|
| + num_contexts_ = 2;
|
| + const GpuResultFlags expectations = EXPECT_GPU_PROCESS |
|
| + EXPECT_GPU_SWAP_BUFFERS |
|
| + EXPECT_GPU_CONTEXTS;
|
| #endif
|
| const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
|
| - RunTest(url, expect_gpu_process);
|
| + RunTest(url, expectations);
|
| }
|
|
|
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) {
|
| @@ -178,9 +222,8 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) {
|
| flags.flags(),
|
| static_cast<uint32>(GpuFeatureFlags::kGpuFeatureAccelerated2dCanvas));
|
|
|
| - const bool expect_gpu_process = false;
|
| const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html"));
|
| - RunTest(url, expect_gpu_process);
|
| + RunTest(url, EXPECT_NO_GPU_PROCESS);
|
| }
|
|
|
| } // namespace anonymous
|
|
|