diff options
author | amarinichev@chromium.org <amarinichev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 01:23:24 +0000 |
---|---|---|
committer | amarinichev@chromium.org <amarinichev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-04-22 01:23:24 +0000 |
commit | c45e51d7158a68ed9122169af502a812e11fd960 (patch) | |
tree | 3068cafd54280f38e14b4eac0cd5e1ea5aab2269 /chrome | |
parent | 29fab56b506f5971b1aa9d5d26e335f871d075a4 (diff) | |
download | chromium_src-c45e51d7158a68ed9122169af502a812e11fd960.zip chromium_src-c45e51d7158a68ed9122169af502a812e11fd960.tar.gz chromium_src-c45e51d7158a68ed9122169af502a812e11fd960.tar.bz2 |
Cleanups of gpu_crash test:
Unhardcoded dimentions;
Added a testcase that uses WEBKIT_lose_context extension.
BUG=
TEST=it is failing before WebGLLayerChromium fix is applied
Review URL: http://codereview.chromium.org/6879050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@82603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/gpu_crash_browsertest.cc (renamed from chrome/test/gpu/gpu_crash.cc) | 41 | ||||
-rw-r--r-- | chrome/browser/gpu_pixel_browsertest.cc (renamed from chrome/test/gpu/gpu_pixel_browsertest.cc) | 0 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 4 | ||||
-rw-r--r-- | chrome/test/data/OWNERS | 1 | ||||
-rw-r--r-- | chrome/test/data/gpu/webgl.html | 67 |
5 files changed, 90 insertions, 23 deletions
diff --git a/chrome/test/gpu/gpu_crash.cc b/chrome/browser/gpu_crash_browsertest.cc index b0d090b..f333155 100644 --- a/chrome/test/gpu/gpu_crash.cc +++ b/chrome/browser/gpu_crash_browsertest.cc @@ -22,8 +22,8 @@ void SimulateGPUCrash(Browser* browser) { LOG(ERROR) << "SimulateGPUCrash, before NavigateToURLWithDisposition"; ui_test_utils::NavigateToURLWithDisposition(browser, GURL(chrome::kAboutGpuCrashURL), NEW_FOREGROUND_TAB, - ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); - browser->CloseTab(); + ui_test_utils::BROWSER_TEST_NONE); + browser->SelectPreviousTab(); LOG(ERROR) << "SimulateGPUCrash, after CloseTab"; } @@ -32,6 +32,7 @@ void SimulateGPUCrash(Browser* browser) { class GPUCrashTest : public InProcessBrowserTest { protected: virtual void SetUpCommandLine(CommandLine* command_line) { + EnableDOMAutomation(); InProcessBrowserTest::SetUpCommandLine(command_line); // OverrideGLImplementation and kDisableAcceleratedCompositing for @@ -46,21 +47,35 @@ class GPUCrashTest : public InProcessBrowserTest { command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); #endif } + virtual void SetUpInProcessBrowserTestFixture() { + FilePath test_dir; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); + gpu_test_dir_ = test_dir.AppendASCII("gpu"); + } + FilePath gpu_test_dir_; }; -IN_PROC_BROWSER_TEST_F(GPUCrashTest, Reload) { - FilePath test_dir; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); - FilePath gpu_test_dir_; - gpu_test_dir_ = test_dir.AppendASCII("gpu"); - ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL( - gpu_test_dir_.AppendASCII("webgl.html"))); +IN_PROC_BROWSER_TEST_F(GPUCrashTest, Kill) { + ui_test_utils::DOMMessageQueue message_queue; + ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL( + gpu_test_dir_.AppendASCII("webgl.html?query=kill"))); SimulateGPUCrash(browser()); - browser()->Reload(CURRENT_TAB); - ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); - EXPECT_EQ(ASCIIToUTF16("SUCCESS"), - browser()->GetSelectedTabContents()->GetTitle().substr(0, 7)); + std::string m; + ASSERT_TRUE(message_queue.WaitForMessage(&m)); + EXPECT_EQ("\"SUCCESS\"", m); +} + + +IN_PROC_BROWSER_TEST_F(GPUCrashTest, WebkitLoseContext) { + ui_test_utils::DOMMessageQueue message_queue; + + ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL( + gpu_test_dir_.AppendASCII("webgl.html?query=WEBKIT_lose_context"))); + + std::string m; + ASSERT_TRUE(message_queue.WaitForMessage(&m)); + EXPECT_EQ("\"SUCCESS\"", m); } diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/browser/gpu_pixel_browsertest.cc index ae71982..ae71982 100644 --- a/chrome/test/gpu/gpu_pixel_browsertest.cc +++ b/chrome/browser/gpu_pixel_browsertest.cc diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index fb54c6d..d03fabf 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -3253,8 +3253,8 @@ ], 'defines': [ 'ALLOW_IN_PROC_BROWSER_TEST' ], 'sources': [ - 'test/gpu/gpu_pixel_browsertest.cc', - 'test/gpu/gpu_crash.cc', + 'browser/gpu_pixel_browsertest.cc', + 'browser/gpu_crash_browsertest.cc', 'test/out_of_proc_test_runner.cc', ], 'conditions': [ diff --git a/chrome/test/data/OWNERS b/chrome/test/data/OWNERS new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/chrome/test/data/OWNERS @@ -0,0 +1 @@ +* diff --git a/chrome/test/data/gpu/webgl.html b/chrome/test/data/gpu/webgl.html index d070e48..4cf4b2b 100644 --- a/chrome/test/data/gpu/webgl.html +++ b/chrome/test/data/gpu/webgl.html @@ -2,34 +2,80 @@ <head> <script type="text/javascript"> var canvas; +var w, h; var gl; function testHorizontalBands() { gl.enable(gl.SCISSOR_TEST); gl.clearColor(1, 0, 0, 1); - gl.scissor(0, 0, 16, 16); + gl.scissor(0, 0, w, h/2); gl.clear(gl.COLOR_BUFFER_BIT); gl.clearColor(0, 1, 0, 1); - gl.scissor(0, 16, 16, 16); + gl.scissor(0, h/2, w, h/2); gl.clear(gl.COLOR_BUFFER_BIT); gl.disable(gl.SCISSOR_TEST); - var array = new Uint8Array(16 * 32 * 4); - gl.readPixels(0, 0, 16, 32, gl.RGBA, gl.UNSIGNED_BYTE, array); - + var size = w * h * 4; + var array = new Uint8Array(size); + gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, array); + return array[0] == 255 && array[1] == 0 && - array[16 * 32 * 4 - 4] == 0 && array[16 * 32 * 4 - 3] == 255; + array[size - 4] == 0 && array[size - 3] == 255; +} + +function testContextLost(e) { + e.preventDefault(); +} + +function testContextRestored() { + gl = canvas.getContext("experimental-webgl"); + if (!gl) { + document.title = "FAILED: could not get recovered context"; + return; + } + gl.clearColor(0, 0, 1, 1); + gl.clear(gl.COLOR_BUFFER_BIT); + + var a = new Uint8Array(w * h * 4); + gl.readPixels(0, 0, w, h, gl.RGBA, gl.UNSIGNED_BYTE, a); + + window.domAutomationController.setAutomationId(1); + if (a[0] == 0 && a[1] == 0 && a[2] == 255) + window.domAutomationController.send("SUCCESS"); + else + window.domAutomationController.send("FAILED"); +} + +function contetLostTest(kind) +{ + switch (kind) { + case "WEBKIT_lose_context": { + var extension = gl.getExtension("WEBKIT_lose_context"); + extension.loseContext(); + if (extension.restoreContext) + extension.restoreContext(); + break; + } + case "kill": + // nothing -- the browser test navigates to about:gpucrash and kills + // the GPU process. + break; + } } function onLoad() { canvas = document.getElementById("canvas1"); + w = canvas.width; + h = canvas.height if (!canvas) { document.title = "FAILED: canvas element not found"; return; } + canvas.addEventListener("webglcontextlost", testContextLost, false); + canvas.addEventListener("webglcontextrestored", testContextRestored, false); gl = canvas.getContext("experimental-webgl"); if (!gl) { @@ -42,8 +88,13 @@ function onLoad() { return; } - var renderer = gl.getParameter(gl.RENDERER); - document.title = "SUCCESS: " + renderer; + var query = /query=(.*)/.exec(window.location.href); + if (query) { + contetLostTest(query[1]); + } else { + var renderer = gl.getParameter(gl.RENDERER); + document.title = "SUCCESS: " + renderer; + } } </script> </head> |