Chromium Code Reviews| Index: chrome/test/perf/frame_rate/frame_rate_tests.cc |
| =================================================================== |
| --- chrome/test/perf/frame_rate/frame_rate_tests.cc (revision 102775) |
| +++ chrome/test/perf/frame_rate/frame_rate_tests.cc (working copy) |
| @@ -18,9 +18,18 @@ |
| namespace { |
| -class FrameRateTest : public UIPerfTest { |
| +enum FrameRateTestFlags { |
| + kMakeBodyComposited = 1 << 0, |
| + kDisableRaf = 1 << 1, |
| + kDisableGpu = 1 << 2, |
| + kReference = 1 << 3, |
| +}; |
| + |
| +template<unsigned TestFlags> |
|
Justin Novosad
2011/10/13 22:04:55
I chose to use a template arg here because the TES
|
| +class FrameRateTest_ : public UIPerfTest { |
| public: |
| - FrameRateTest() { |
| + |
| + FrameRateTest_() { |
| show_window_ = true; |
| dom_automation_enabled_ = true; |
| // Since this is a performance test, try to use the host machine's GPU |
| @@ -41,18 +50,29 @@ |
| } |
| virtual void SetUp() { |
| - // UI tests boot up render views starting from about:blank. This causes the |
| - // renderer to start up thinking it cannot use the GPU. To work around that, |
| - // and allow the frame rate test to use the GPU, we must pass |
| - // kAllowWebUICompositing. |
| - launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); |
| + if (TestFlags & kReference) { |
| + UseReferenceBuild(); |
| + } |
| + if (TestFlags & kDisableGpu) { |
| + launch_arguments_.AppendSwitch(switches::kDisableAccelerated2dCanvas); |
|
Justin Novosad
2011/10/13 22:04:55
because the switch dependencies may change over ti
|
| + launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing); |
| + launch_arguments_.AppendSwitch(switches::kDisableAcceleratedLayers); |
| + launch_arguments_.AppendSwitch(switches::kDisableAcceleratedPlugins); |
| + launch_arguments_.AppendSwitch(switches::kDisableAcceleratedVideo); |
| + } else { |
| + // UI tests boot up render views starting from about:blank. This causes |
| + // the renderer to start up thinking it cannot use the GPU. To work |
| + // around that, and allow the frame rate test to use the GPU, we must |
| + // pass kAllowWebUICompositing. |
| + launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); |
| + } |
| + |
| UIPerfTest::SetUp(); |
| } |
| void RunTest(const std::string& name, |
| - const std::string& suffix, |
| - bool make_body_composited) { |
| + const std::string& suffix) { |
| FilePath test_path = GetDataPath(name); |
| ASSERT_TRUE(file_util::DirectoryExists(test_path)) |
| << "Missing test directory: " << test_path.value(); |
| @@ -65,11 +85,21 @@ |
| ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, |
| tab->NavigateToURL(net::FilePathToFileURL(test_path))); |
| - if (make_body_composited) { |
| + if (TestFlags & kMakeBodyComposited) { |
| ASSERT_TRUE(tab->NavigateToURLAsync( |
| - GURL("javascript:__make_body_composited();"))); |
| + GURL("javascript:__make_body_composited();"))); |
| } |
| + if (TestFlags & kDisableRaf) { |
| + ASSERT_TRUE(tab->NavigateToURLAsync( |
| + GURL("javascript:__init_raf(false);"))); |
|
Justin Novosad
2011/10/13 22:04:55
I attempted to use the --disable-gpu-vsync switch
|
| + } |
| + |
| + // Block until initialization completes. |
| + ASSERT_TRUE(WaitUntilJavaScriptCondition( |
| + tab, L"", L"window.domAutomationController.send(__initialized);", |
| + TestTimeouts::large_test_timeout_ms())); |
| + |
| // Start the tests. |
| ASSERT_TRUE(tab->NavigateToURLAsync(GURL("javascript:__start_all();"))); |
| @@ -108,39 +138,84 @@ |
| } |
| }; |
| -class FrameRateTest_Reference : public FrameRateTest { |
| - public: |
| - void SetUp() { |
| - UseReferenceBuild(); |
| - FrameRateTest::SetUp(); |
| - } |
| -}; |
| +typedef FrameRateTest_<0> |
| + FrameRateTest; |
| +typedef FrameRateTest_<kReference> |
| + FrameRateTest_Reference; |
| +typedef FrameRateTest_<kMakeBodyComposited> |
| + FrameRateTest_Comp; |
| +typedef FrameRateTest_<kReference | kMakeBodyComposited> |
| + FrameRateTest_Comp_Reference; |
| +typedef FrameRateTest_<kDisableRaf> |
| + FrameRateTest_NoRaf; |
| +typedef FrameRateTest_<kReference | kDisableRaf> |
| + FrameRateTest_NoRaf_Reference; |
| +typedef FrameRateTest_<kDisableGpu> |
| + FrameRateTest_NoGpu; |
| +typedef FrameRateTest_<kReference | kDisableGpu> |
| + FrameRateTest_NoGpu_Reference; |
| +typedef FrameRateTest_<kDisableRaf | kDisableGpu> |
| + FrameRateTest_NoRaf_NoGpu; |
| +typedef FrameRateTest_<kReference | kDisableRaf | kDisableGpu> |
| + FrameRateTest_NoRaf_NoGpu_Reference; |
| + |
| #define FRAME_RATE_TEST(content) \ |
| TEST_F(FrameRateTest, content) { \ |
| - RunTest(#content, "", false); \ |
| + RunTest(#content, ""); \ |
| } \ |
| TEST_F(FrameRateTest_Reference, content) { \ |
| - RunTest(#content, "_ref", false); \ |
| + RunTest(#content, "_ref"); \ |
| } |
| // Tests that trigger compositing with a -webkit-translateZ(0) |
| #define FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(content) \ |
| TEST_F(FrameRateTest, content) { \ |
| - RunTest(#content, "", false); \ |
| + RunTest(#content, ""); \ |
| } \ |
| -TEST_F(FrameRateTest, content ## _comp) { \ |
| - RunTest(#content, "_comp", true); \ |
| +TEST_F(FrameRateTest_Comp, content ## _comp) { \ |
| + RunTest(#content, "_comp"); \ |
| } \ |
| TEST_F(FrameRateTest_Reference, content) { \ |
| - RunTest(#content, "_ref", false); \ |
| + RunTest(#content, "_ref"); \ |
| } \ |
| -TEST_F(FrameRateTest_Reference, content ## _comp) { \ |
| - RunTest(#content, "_comp_ref", true); \ |
| +TEST_F(FrameRateTest_Comp_Reference, content ## _comp) { \ |
| + RunTest(#content, "_comp_ref"); \ |
| } |
| +// Tests for pages that have animated 2d canvas content. |
| +// Tests run with and without RAF, and with and without GPU acceleration. |
| +#define FRAME_RATE_TEST_ANIMATED_2D_CANVAS(content) \ |
| +TEST_F(FrameRateTest, content) { \ |
| + RunTest(#content, ""); \ |
| +} \ |
| +TEST_F(FrameRateTest_NoRaf, content) { \ |
| + RunTest(#content, "_noraf"); \ |
| +} \ |
| +TEST_F(FrameRateTest_NoGpu, content) { \ |
| + RunTest(#content, "_nogpu"); \ |
| +} \ |
| +TEST_F(FrameRateTest_NoRaf_NoGpu, content) { \ |
| + RunTest(#content, "_noraf_nogpu"); \ |
| +} \ |
| +TEST_F(FrameRateTest_Reference, content) { \ |
| + RunTest(#content, "_ref"); \ |
| +} \ |
| +TEST_F(FrameRateTest_NoRaf_Reference, content) { \ |
| + RunTest(#content, "_noraf_ref"); \ |
| +} \ |
| +TEST_F(FrameRateTest_NoGpu_Reference, content) { \ |
| + RunTest(#content, "_nogpu_ref"); \ |
| +} \ |
| +TEST_F(FrameRateTest_NoRaf_NoGpu_Reference, content) { \ |
| + RunTest(#content, "_noraf_nogpu_ref"); \ |
| +} \ |
| + |
| FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); |
| FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); |
| +// Canvas 2D tests |
| +//FRAME_RATE_TEST_ANIMATED_2D_CANVAS( canvas2d_balls_drawImage ); |
| + |
| } // namespace |