diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/test/perf/frame_rate/frame_rate_tests.cc | 121 |
1 files changed, 83 insertions, 38 deletions
diff --git a/chrome/test/perf/frame_rate/frame_rate_tests.cc b/chrome/test/perf/frame_rate/frame_rate_tests.cc index 9990d54..58919b8 100644 --- a/chrome/test/perf/frame_rate/frame_rate_tests.cc +++ b/chrome/test/perf/frame_rate/frame_rate_tests.cc @@ -4,6 +4,7 @@ #include <map> +#include "base/command_line.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/string_number_conversions.h" @@ -20,11 +21,13 @@ namespace { enum FrameRateTestFlags { - kMakeBodyComposited = 1 << 0, - kDisableVsync = 1 << 1, - kDisableGpu = 1 << 2, - kUseReferenceBuild = 1 << 3, - kInternal = 1 << 4, + kRequiresGpu = 1 << 0, // only execute test if --enable-gpu + kDisableGpu = 1 << 1, // run test without gpu acceleration + kMakeBodyComposited = 1 << 2, // force the test to use the compositor + kDisableVsync = 1 << 3, // do not lock animation on vertical refresh + kUseReferenceBuild = 1 << 4, // run test using the reference chrome build + kInternal = 1 << 5, // Test uses internal test data + kHasRedirect = 1 << 6, // Test page contains an HTML redirect }; std::string GetSuffixForTestFlags(int flags) { @@ -75,9 +78,20 @@ class FrameRateTest // pass kAllowWebUICompositing. launch_arguments_.AppendSwitch(switches::kAllowWebUICompositing); + // Some of the tests may launch http requests through JSON or AJAX + // which causes a security error (cross domain request) when the page + // is loaded from the local file system ( file:// ). The following switch + // fixes that error. + launch_arguments_.AppendSwitch(switches::kAllowFileAccessFromFiles); + if (GetParam() & kDisableGpu) { launch_arguments_.AppendSwitch(switches::kDisableAcceleratedCompositing); launch_arguments_.AppendSwitch(switches::kDisableExperimentalWebGL); + } else { + // This switch is required for enabling the accelerated 2d canvas on + // Chrome versions prior to Chrome 15, which may be the case for the + // reference build. + launch_arguments_.AppendSwitch(switches::kEnableAccelerated2dCanvas); } if (GetParam() & kDisableVsync) { @@ -88,6 +102,11 @@ class FrameRateTest } void RunTest(const std::string& name) { + if ((GetParam() & kRequiresGpu) && + !CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu")) { + printf("Test skipped: requires gpu\n"); + return; + } FilePath test_path = GetDataPath(name); ASSERT_TRUE(file_util::DirectoryExists(test_path)) << "Missing test directory: " << test_path.value(); @@ -97,19 +116,36 @@ class FrameRateTest scoped_refptr<TabProxy> tab(GetActiveTab()); ASSERT_TRUE(tab.get()); - ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, - tab->NavigateToURL(net::FilePathToFileURL(test_path))); + if (GetParam() & kHasRedirect) { + // If the test file is known to contain an html redirect, we must block + // until the second navigation is complete and reacquire the active tab + // in order to avoid a race condition. + // If the following assertion is triggered due to a timeout, it is + // possible that the current test does not re-direct and therefore should + // not have the kHasRedirect flag turned on. + ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, + tab->NavigateToURLBlockUntilNavigationsComplete( + net::FilePathToFileURL(test_path), 2)); + tab = GetActiveTab(); + ASSERT_TRUE(tab.get()); + } else { + ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, + tab->NavigateToURL(net::FilePathToFileURL(test_path))); + } + + // Block until initialization completes + // If the following assertion fails intermittently, it could be due to a + // race condition caused by an html redirect. If that is the case, verify + // that flag kHasRedirect is enabled for the current test. + ASSERT_TRUE(WaitUntilJavaScriptCondition( + tab, L"", L"window.domAutomationController.send(__initialized);", + TestTimeouts::large_test_timeout_ms())); if (GetParam() & kMakeBodyComposited) { ASSERT_TRUE(tab->NavigateToURLAsync( GURL("javascript:__make_body_composited();"))); } - // 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();"))); @@ -169,23 +205,6 @@ INSTANTIATE_TEST_CASE_P(, FrameRateCompositingTest, ::testing::Values( FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(blank); FRAME_RATE_TEST_WITH_AND_WITHOUT_ACCELERATED_COMPOSITING(googleblog); -typedef FrameRateTest FrameRateCanvasInternalTest; - -// Tests for animated 2D canvas content -#define INTERNAL_FRAME_RATE_TEST_CANVAS(content) \ -TEST_P(FrameRateCanvasInternalTest, content) { \ - RunTest(#content); \ -} \ - -INSTANTIATE_TEST_CASE_P(, FrameRateCanvasInternalTest, ::testing::Values( - kInternal, - kInternal | kDisableGpu, - kInternal | kUseReferenceBuild)); - -// Fails on all platforms. See http://crbug.com/102428 -//INTERNAL_FRAME_RATE_TEST_CANVAS(fireflies) -//INTERNAL_FRAME_RATE_TEST_CANVAS(FishIE) - typedef FrameRateTest FrameRateNoVsyncCanvasInternalTest; // Tests for animated 2D canvas content with and without disabling vsync @@ -195,14 +214,40 @@ TEST_P(FrameRateNoVsyncCanvasInternalTest, content) { \ } \ INSTANTIATE_TEST_CASE_P(, FrameRateNoVsyncCanvasInternalTest, ::testing::Values( - kInternal, - kInternal | kDisableVsync, - kInternal | kDisableGpu, - kInternal | kUseReferenceBuild, - kInternal | kDisableVsync | kUseReferenceBuild)); - -// Fails on all platforms. See http://crbug.com/102428 -//INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(fishbowl) -//INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(speedreading) + kInternal | kHasRedirect | kRequiresGpu, + kInternal | kHasRedirect | kDisableVsync | + kRequiresGpu, + kInternal | kHasRedirect | kDisableGpu, + kInternal | kHasRedirect | kDisableGpu | + kUseReferenceBuild, + kInternal | kHasRedirect | kUseReferenceBuild | + kRequiresGpu, + kInternal | kHasRedirect | kDisableVsync | + kRequiresGpu | kUseReferenceBuild)); + +INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(speedreading) +INTERNAL_FRAME_RATE_TEST_CANVAS_WITH_AND_WITHOUT_NOVSYNC(fishbowl) + +typedef FrameRateTest FrameRateGpuCanvasInternalTest; + +// Tests for animated 2D canvas content to be tested only with GPU +// acceleration. +// tests are run with and without Vsync +#define INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(content) \ +TEST_P(FrameRateGpuCanvasInternalTest, content) { \ + RunTest(#content); \ +} \ + +INSTANTIATE_TEST_CASE_P(, FrameRateGpuCanvasInternalTest, ::testing::Values( + kInternal | kHasRedirect | kRequiresGpu, + kInternal | kHasRedirect | kDisableVsync | + kRequiresGpu, + kInternal | kHasRedirect | kUseReferenceBuild | + kRequiresGpu, + kInternal | kHasRedirect | kDisableVsync | + kRequiresGpu | kUseReferenceBuild)); + +INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(fireflies) +INTERNAL_FRAME_RATE_TEST_CANVAS_GPU(FishIE) } // namespace |