Chromium Code Reviews| 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 384f0c4c9134bb9c4558855640467b9eefb47003..e078922a5163393fd2d1f7ff7338f5feee4648db 100644 |
| --- a/chrome/test/gpu/gpu_feature_browsertest.cc |
| +++ b/chrome/test/gpu/gpu_feature_browsertest.cc |
| @@ -37,10 +37,9 @@ using trace_analyzer::TraceEventVector; |
| namespace { |
| -typedef uint32 GpuResultFlags; |
| -#define EXPECT_NO_GPU_SWAP_BUFFERS GpuResultFlags(1<<0) |
| -// Expect a SwapBuffers to occur (see gles2_cmd_decoder.cc). |
| -#define EXPECT_GPU_SWAP_BUFFERS GpuResultFlags(1<<1) |
| +#define SWAP_BUFFERS_EVENT "SwapBuffers" |
|
Alexei Svitkine (slow)
2012/09/17 20:23:47
Nit: Declare these per the Chromium style conventi
Vangelis Kokkevis
2012/09/17 21:47:54
Done.
|
| +#define ACCELERATED_CANVAS_CREATION_EVENT "Canvas2DLayerBridgeCreation" |
| +#define WEBGL_CREATION_EVENT "DrawingBufferCreation" |
| class GpuFeatureTest : public InProcessBrowserTest { |
| public: |
| @@ -106,7 +105,10 @@ class GpuFeatureTest : public InProcessBrowserTest { |
| EXPECT_STREQ(expected_reply, result.c_str()); |
| } |
| - void RunTest(const FilePath& url, GpuResultFlags expectations) { |
| + // Open the URL and check the trace stream for the given event. |
| + void RunEventTest(const FilePath& url, |
| + const char* event_name = NULL, |
| + bool event_expected = false) { |
| #if defined(OS_LINUX) && !defined(NDEBUG) |
| // Bypass tests on GPU Linux Debug bots. |
| if (gpu_enabled_) |
| @@ -129,16 +131,16 @@ class GpuFeatureTest : public InProcessBrowserTest { |
| analyzer_->AssociateBeginEndEvents(); |
| TraceEventVector events; |
| - if (expectations & EXPECT_NO_GPU_SWAP_BUFFERS) { |
| - EXPECT_EQ(analyzer_->FindEvents(Query::EventNameIs("SwapBuffers"), |
| - &events), size_t(0)); |
| - } |
| + if (!event_name) |
| + return; |
| - // Check for swap buffers if expected: |
| - if (expectations & EXPECT_GPU_SWAP_BUFFERS) { |
| - EXPECT_GT(analyzer_->FindEvents(Query::EventNameIs("SwapBuffers"), |
| - &events), size_t(0)); |
| - } |
| + size_t event_count = |
| + analyzer_->FindEvents(Query::EventNameIs(event_name), &events); |
| + |
| + if (event_expected) |
| + EXPECT_GT(event_count, size_t(0)); |
|
Alexei Svitkine (slow)
2012/09/17 20:23:47
Nit: Instead of size_t(0), use 0U.
Vangelis Kokkevis
2012/09/17 21:47:54
Done.
|
| + else |
| + EXPECT_EQ(event_count, size_t(0)); |
| } |
| // Trigger a resize of the chrome window, and use tracing to wait for the |
| @@ -174,11 +176,14 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { |
| EXPECT_EQ(type, 0); |
| const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| - RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, SWAP_BUFFERS_EVENT, true); |
| } |
| -IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) { |
| - const std::string json_blacklist = |
| +class AcceleratedCompositingBlockedTest : public GpuFeatureTest { |
| + public: |
| + virtual void SetUpInProcessBrowserTestFixture() { |
|
Alexei Svitkine (slow)
2012/09/17 20:23:47
Nit: OVERRIDE.
Vangelis Kokkevis
2012/09/17 21:47:54
Done.
|
| + GpuFeatureTest::SetUpInProcessBrowserTestFixture(); |
| + const std::string json_blacklist = |
| "{\n" |
| " \"name\": \"gpu blacklist\",\n" |
| " \"version\": \"1.0\",\n" |
| @@ -191,13 +196,18 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) { |
| " }\n" |
| " ]\n" |
| "}"; |
| - SetupBlacklist(json_blacklist); |
| + SetupBlacklist(json_blacklist); |
| + } |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(AcceleratedCompositingBlockedTest, |
| + AcceleratedCompositingBlocked) { |
| GpuFeatureType type = |
| - GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| + GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING); |
| const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| - RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, SWAP_BUFFERS_EVENT, false); |
| } |
| class AcceleratedCompositingTest : public GpuFeatureTest { |
| @@ -211,7 +221,7 @@ class AcceleratedCompositingTest : public GpuFeatureTest { |
| IN_PROC_BROWSER_TEST_F(AcceleratedCompositingTest, |
| AcceleratedCompositingDisabled) { |
| const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| - RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, SWAP_BUFFERS_EVENT, false); |
| } |
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) { |
| @@ -220,7 +230,7 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) { |
| EXPECT_EQ(type, 0); |
| const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| - RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, WEBGL_CREATION_EVENT, true); |
| } |
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { |
| @@ -243,7 +253,7 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { |
| EXPECT_EQ(type, content::GPU_FEATURE_TYPE_WEBGL); |
| const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| - RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, WEBGL_CREATION_EVENT, false); |
| } |
| class WebGLTest : public GpuFeatureTest { |
| @@ -259,7 +269,7 @@ class WebGLTest : public GpuFeatureTest { |
| IN_PROC_BROWSER_TEST_F(WebGLTest, WebGLDisabled) { |
| const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| - RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, WEBGL_CREATION_EVENT, false); |
| } |
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MultisamplingAllowed) { |
| @@ -339,7 +349,7 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) { |
| EXPECT_EQ(type, 0); |
| const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); |
| - RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, ACCELERATED_CANVAS_CREATION_EVENT, true); |
| } |
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) { |
| @@ -362,7 +372,7 @@ IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) { |
| EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS); |
| const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); |
| - RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, ACCELERATED_CANVAS_CREATION_EVENT, false); |
| } |
| class Canvas2DDisabledTest : public GpuFeatureTest { |
| @@ -375,7 +385,7 @@ class Canvas2DDisabledTest : public GpuFeatureTest { |
| IN_PROC_BROWSER_TEST_F(Canvas2DDisabledTest, Canvas2DDisabled) { |
| const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); |
| - RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, ACCELERATED_CANVAS_CREATION_EVENT, false); |
| } |
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, |
| @@ -400,13 +410,13 @@ class ThreadedCompositorTest : public GpuFeatureTest { |
| // disabled in http://crbug.com/123503 |
| IN_PROC_BROWSER_TEST_F(ThreadedCompositorTest, ThreadedCompositor) { |
| const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| - RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| + RunEventTest(url, SWAP_BUFFERS_EVENT, true); |
| } |
| IN_PROC_BROWSER_TEST_F(GpuFeatureTest, RafNoDamage) { |
| trace_categories_ = "-test_*"; |
| const FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); |
| - RunTest(url, GpuResultFlags(0)); |
| + RunEventTest(url); |
| if (!analyzer_.get()) |
| return; |