diff options
author | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-06 22:17:30 +0000 |
---|---|---|
committer | zmo@chromium.org <zmo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-06 22:17:30 +0000 |
commit | afb7bade5ce08a60b6c7dca30ee1189828ebc17d (patch) | |
tree | 563632a260417c88d51892af038536cbd7155742 | |
parent | 756767450156ac5de94caaa9c92ac54c4dd7fdb7 (diff) | |
download | chromium_src-afb7bade5ce08a60b6c7dca30ee1189828ebc17d.zip chromium_src-afb7bade5ce08a60b6c7dca30ee1189828ebc17d.tar.gz chromium_src-afb7bade5ce08a60b6c7dca30ee1189828ebc17d.tar.bz2 |
Remove gpu_pixel_browsertest and MapsGL endurance tests from gpu_tests.
Now the pixel tests run fine on content side.
Unfortunately we can't remove the .cc file yet, because there is a soft_gpu_tests target. I need to figure out if it's OK to switch soft_gpu_tests to content side.
BUG=111506
TEST=gpu waterfall
Review URL: https://codereview.chromium.org/12212045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181063 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/test/data/gpu/pixel_canvas2d.html | 74 | ||||
-rw-r--r-- | chrome/test/data/gpu/pixel_css3d.html | 82 | ||||
-rw-r--r-- | chrome/test/data/gpu/pixel_webgl.html | 163 | ||||
-rw-r--r-- | chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc | 347 | ||||
-rw-r--r-- | chrome/test/gpu/gpu_pixel_browsertest.cc | 68 |
6 files changed, 6 insertions, 730 deletions
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 78d5550..ebf3946 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2396,8 +2396,6 @@ ], 'sources': [ 'test/gpu/gpu_feature_browsertest.cc', - 'test/gpu/gpu_mapsgl_endurance_browsertest.cc', - 'test/gpu/gpu_pixel_browsertest.cc', 'test/gpu/webgl_infobar_browsertest.cc', ], }, diff --git a/chrome/test/data/gpu/pixel_canvas2d.html b/chrome/test/data/gpu/pixel_canvas2d.html deleted file mode 100644 index 8e54bac..0000000 --- a/chrome/test/data/gpu/pixel_canvas2d.html +++ /dev/null @@ -1,74 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<title>Canvas 2D Test: Red Box over Black Background</title> -<style type="text/css"> -.nomargin { - margin: 0px auto; -} -</style> -<script> -var g_swapsBeforeAck = 15; -var g_targetHeight, g_targetWidth; - -function onresized() -{ - if (window.outerHeight != g_targetHeight || - window.outerWidth != g_targetWidth) - return; - - main(); -} - -function main() -{ - draw(); - waitForFinish(); -} - -function draw() -{ - var canvas = document.getElementById("c"); - var c2d = canvas.getContext("2d"); - c2d.clearRect(0, 0, canvas.width, canvas.height); - c2d.fillStyle = "rgba(255, 0, 0, 0.5)"; - c2d.fillRect(50, 50, 100, 100); -} - -function waitForFinish() -{ - if (g_swapsBeforeAck == 0) { - domAutomationController.setAutomationId(1); - domAutomationController.send("resized"); - } else { - g_swapsBeforeAck--; - document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1; - window.webkitRequestAnimationFrame(waitForFinish); - } -} - -function notifyLoadFinished() -{ - domAutomationController.setAutomationId(1); - domAutomationController.send("ok"); -} - -function preCallResizeInChromium(targetWidth, targetHeight) -{ - g_targetWidth = targetWidth; - g_targetHeight = targetHeight; - window.onresize = onresized; - // Call main() on a timeout in case the window did not resize for whatever - // reason. - setTimeout(main, 10000); -} -</script> -</head> -<body onload="notifyLoadFinished()"> -<div style="position:relative; width:200px; height:200px; background-color:black"> -</div> -<div id="container" style="position:absolute; top:0px; left:0px"> -<canvas id="c" width="200" height="200" class="nomargin"></canvas> -</div> -</body> -</html> diff --git a/chrome/test/data/gpu/pixel_css3d.html b/chrome/test/data/gpu/pixel_css3d.html deleted file mode 100644 index 3fa0fe42..0000000 --- a/chrome/test/data/gpu/pixel_css3d.html +++ /dev/null @@ -1,82 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<title>CSS 3D Test: Projected Blue Box over Black Background</title> -<style type="text/css"> -.nomargin { - margin: 0px auto; -} - -#container { - -webkit-perspective: 500; -} - -#container > div { - position: relative; - margin: 50px; - width: 125px; - height: 75px; -} - -#container > :first-child { - background-color: blue; - -webkit-transform: rotateY(45deg); -} -</style> -<script> -var g_swapsBeforeAck = 15; -var g_targetWidth, g_targetHeight; - -function onresized() -{ - if (g_targetWidth != window.outerWidth || - g_targetHeight != window.outerHeight) - return; - - main(); -} - - -function main() -{ - waitForFinish(); -} - -function waitForFinish() -{ - if (g_swapsBeforeAck == 0) { - domAutomationController.setAutomationId(1); - domAutomationController.send("resized"); - } else { - g_swapsBeforeAck--; - document.getElementById('blue_box').style.zIndex = g_swapsBeforeAck + 1; - window.webkitRequestAnimationFrame(waitForFinish); - } -} - -function notifyLoadFinished() -{ - domAutomationController.setAutomationId(1); - domAutomationController.send("ok"); -} - -function preCallResizeInChromium(targetWidth, targetHeight) -{ - g_targetWidth = targetWidth; - g_targetHeight = targetHeight; - window.onresize = onresized; - - // Call main() on a timeout in case the window did not resize for whatever - // reason. - setTimeout(main, 10000); -} -</script> -</head> -<body onload="notifyLoadFinished()"> -<div style="position:relative; width:200px; height:200px; background-color:black; zindex-0"> -</div> -<div id="container" style="position:absolute; top:0px; left:0px"> - <div id="blue_box"></div> -</div> -</body> -</html> diff --git a/chrome/test/data/gpu/pixel_webgl.html b/chrome/test/data/gpu/pixel_webgl.html deleted file mode 100644 index 2232b84..0000000 --- a/chrome/test/data/gpu/pixel_webgl.html +++ /dev/null @@ -1,163 +0,0 @@ -<!DOCTYPE HTML> -<html> -<head> -<title>WebGL Test: Green Triangle over Black Background</title> -<style type="text/css"> -.nomargin { - margin: 0px auto; -} -</style> - -<script id="shader-vs" type="x-shader/x-vertex"> -attribute vec3 pos; -void main(void) -{ - gl_Position = vec4(pos, 1.0); -} -</script> - -<script id="shader-fs" type="x-shader/x-fragment"> -precision mediump float; -void main(void) -{ - gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); -} -</script> - -<script> -var g_swapsBeforeAck = 15; -var g_targetWidth, g_targetHeight; -var gl; - -function onresized() -{ - if (window.outerWidth != g_targetWidth || - window.outerHeight != g_targetHeight) - return; - - main(); -} - -function main() -{ - var canvas = document.getElementById("c"); - gl = initGL(canvas); - if (gl && setup(gl)) { - drawSomeFrames(); - } else { - domAutomationController.setAutomationId(1); - domAutomationController.send("resized"); - } -} - -function notifyLoadFinished() -{ - domAutomationController.setAutomationId(1); - domAutomationController.send("ok"); -} - -function preCallResizeInChromium(targetWidth, targetHeight) -{ - g_targetWidth = targetWidth; - g_targetHeight = targetHeight; - window.onresize = onresized; - // Call main() on a timeout in case the window did not resize for whatever - // reason. - setTimeout(main, 10000); -} - -function drawSomeFrames() -{ - if (g_swapsBeforeAck == 0) { - domAutomationController.setAutomationId(1); - domAutomationController.send("resized"); - } else { - g_swapsBeforeAck--; - draw(gl); - window.webkitRequestAnimationFrame(drawSomeFrames); - } -} - -function initGL(canvas) -{ - var gl = null; - try { - gl = canvas.getContext("experimental-webgl"); - } catch (e) {} - if (!gl) { - try { - gl = canvas.getContext("webgl"); - } catch (e) { } - } - return gl; -} - -function setupShader(gl, source, type) { - var shader = gl.createShader(type); - gl.shaderSource(shader, source); - gl.compileShader(shader); - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) - return null; - return shader; -} - -function setupProgram(gl, vs_id, fs_id) { - var vs_node = document.getElementById(vs_id); - var fs_node = document.getElementById(fs_id); - if (!vs_node || !fs_node) - return null; - var vs = setupShader(gl, vs_node.text, gl.VERTEX_SHADER); - var fs = setupShader(gl, fs_node.text, gl.FRAGMENT_SHADER); - if (!vs || !fs) - return null; - var program = gl.createProgram(); - gl.attachShader(program, vs); - gl.attachShader(program, fs); - gl.linkProgram(program); - if (!gl.getProgramParameter(program, gl.LINK_STATUS)) - return null; - gl.useProgram(program); - return program; -} - -function setupBuffer(gl) { - var buffer = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, buffer); - var vertexData = [ - 0.0, 0.6, 0.0, // Vertex 1 position - -0.6, -0.6, 0.0, // Vertex 2 position - 0.6, -0.6, 0.0, // Vertex 3 position - ]; - gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexData), gl.STATIC_DRAW); -} - -function setup(gl) { - var program = setupProgram(gl, "shader-vs", "shader-fs"); - if (!program) - return false; - var posAttr = gl.getAttribLocation(program, "pos"); - gl.enableVertexAttribArray(posAttr); - setupBuffer(gl); - var stride = 3 * Float32Array.BYTES_PER_ELEMENT; - gl.vertexAttribPointer(posAttr, 3, gl.FLOAT, false, stride, 0); - gl.clearColor(0.0, 0.0, 0.0, 0.0); - gl.viewport(0, 0, 200, 200); - gl.disable(gl.DEPTH_TEST); - if (gl.getError() != gl.NO_ERROR) - return false; - return true; -} - -function draw(gl) { - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - gl.drawArrays(gl.TRIANGLES, 0, 3); -} -</script> -</head> -<body onload="notifyLoadFinished()"> -<div style="position:relative; width:200px; height:200px; background-color:black"></div> -<div style="position:absolute; top:0px; left:0px"> -<canvas id="c" width="200" height="200" class="nomargin"></canvas> -</div> -</body> -</html> diff --git a/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc b/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc deleted file mode 100644 index 891f18a..0000000 --- a/chrome/test/gpu/gpu_mapsgl_endurance_browsertest.cc +++ /dev/null @@ -1,347 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include <cmath> - -#include "base/command_line.h" -#include "base/file_path.h" -#include "base/file_util.h" -#include "base/json/json_reader.h" -#include "base/path_service.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/browser_window.h" -#include "chrome/browser/ui/tabs/tab_strip_model.h" -#include "chrome/browser/ui/window_snapshot/window_snapshot.h" -#include "chrome/common/chrome_paths.h" -#include "chrome/test/base/in_process_browser_test.h" -#include "chrome/test/base/tracing.h" -#include "chrome/test/base/ui_test_utils.h" -#include "content/public/browser/web_contents.h" -#include "content/public/test/browser_test_utils.h" -#include "googleurl/src/gurl.h" -#include "net/base/net_util.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "third_party/skia/include/core/SkColor.h" -#include "third_party/skia/include/core/SkPoint.h" -#include "ui/compositor/compositor_setup.h" -#include "ui/gfx/codec/png_codec.h" -#include "ui/gfx/size.h" - -using ::testing::AllOf; -using ::testing::Le; -using ::testing::Ge; - -// Test fixture for the MapsGL endurance tests. -// -// This runs the MapsGL harness one or more times, and checks the -// value of certain pixels at the end of the run in order to make sure -// that the rendering actually occurred as we expected it to. Which -// pixels are checked, their expected values and tolerances are all -// encoded in a JSON file accompanying the test. -// -// Pass the command line argument --save-test-failures to save the PNG -// of any failing test runs. Currently there is only one test and it -// will write its output to "single-run-basic-output.png" in the -// current working directory. -// -// TODO(kbr): Add more documentation on adding to and modifying these -// tests. -class MapsGLEnduranceTest : public InProcessBrowserTest { - public: - MapsGLEnduranceTest() { - } - - virtual void SetUpInProcessBrowserTestFixture() { - InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); - - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); - test_data_dir_ = test_data_dir_.AppendASCII("gpu"); - - ui::DisableTestCompositor(); - } - - void RunSingleTest(const gfx::Size& tab_container_size, - const std::string& url, - const std::string& json_test_expectations_filename, - const std::string& failure_filename_prefix) { - std::vector<SinglePixelExpectation> expectations; - FilePath test_expectations_path = - test_data_dir().AppendASCII(json_test_expectations_filename); - if (!ReadTestExpectations(test_expectations_path, &expectations)) { - LOG(ERROR) << "Failed to read test expectations from file " - << test_expectations_path.value(); - return; - } - -#if defined(OS_WIN) - ASSERT_TRUE(tracing::BeginTracing("-test_*")); -#endif - - browser()->window()->Activate(); - gfx::Rect new_bounds = GetNewTabContainerBounds(tab_container_size); - browser()->window()->SetBounds(new_bounds); - - content::DOMMessageQueue message_queue; - ui_test_utils::NavigateToURL(browser(), GURL(url)); - - // Wait for notification that the test completed. - std::string message; - ASSERT_TRUE(message_queue.WaitForMessage(&message)); - message_queue.ClearQueue(); - // TODO(kbr): figure out why this is escaped - EXPECT_EQ("\"FINISHED\"", message); - - // Take a snapshot of the web page and compare it to the test - // expectations. - SkBitmap bitmap; - ASSERT_TRUE(TabSnapShotToImage(&bitmap)); - - bool all_pixels_match = - CompareToExpectedResults(bitmap, expectations); - - if (!all_pixels_match && - CommandLine::ForCurrentProcess()->HasSwitch("save-test-failures")) { - std::vector<unsigned char> output; - if (!gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, true, &output)) { - LOG(ERROR) << "Re-encode PNG failed"; - } else { - FilePath output_path; - output_path = output_path.AppendASCII( - failure_filename_prefix + "-output.png"); - if (file_util::WriteFile( - output_path, - reinterpret_cast<char*>(&*output.begin()), output.size()) < 0) { - LOG(ERROR) << "Write PNG to disk failed"; - } - } - } - -#if defined(OS_WIN) - // For debugging the flaky test, this prints out a trace of what happened on - // failure. - std::string trace_events; - ASSERT_TRUE(tracing::EndTracing(&trace_events)); - if (!all_pixels_match) - fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events.c_str()); -#endif - } - - const FilePath& test_data_dir() const { - return test_data_dir_; - } - - private: - struct SinglePixelExpectation { - SkIPoint location; - SkColor color; - int tolerance; - }; - - FilePath test_data_dir_; - - // Test expectations are expressed in the following JSON format: - // [ - // { "location": [ 25, 50 ], // x, y (upper left origin) - // "color": [ 127, 127, 127 ], // red, green, blue - // "tolerance": 3 - // }, ... - // ] - bool ReadTestExpectations(const FilePath& json_test_expectations_path, - std::vector<SinglePixelExpectation>* expectations) { - std::string json_contents; - if (!file_util::ReadFileToString( - json_test_expectations_path, &json_contents)) { - DLOG(ERROR) << "ReadFileToString failed for " - << json_test_expectations_path.value(); - return false; - } - scoped_ptr<Value> root; - int error_code; - std::string error_msg; - root.reset(base::JSONReader::ReadAndReturnError( - json_contents, base::JSON_ALLOW_TRAILING_COMMAS, - &error_code, &error_msg)); - if (root.get() == NULL) { - DLOG(ERROR) << "Root was NULL: error code " - << error_code << ", error message " << error_msg; - return false; - } - ListValue* root_list; - if (!root->GetAsList(&root_list)) { - DLOG(ERROR) << "Root was not a list (type == " << root->GetType() << ")"; - return false; - } - for (size_t ii = 0; ii < root_list->GetSize(); ++ii) { - DictionaryValue* entry; - if (!root_list->GetDictionary(ii, &entry)) { - DLOG(ERROR) << "Root entry " << ii << " was not a dictionary"; - return false; - } - ListValue* location; - if (!entry->GetList("location", &location)) { - DLOG(ERROR) << "Root entry " << ii << "'s location was not a list"; - return false; - } - if (location->GetSize() != 2) { - DLOG(ERROR) << "Root entry " << ii << "'s location list not length 2"; - return false; - } - int x, y; - if (!location->GetInteger(0, &x) || - !location->GetInteger(1, &y)) { - DLOG(ERROR) << "Root entry " << ii << "'s location list not integers"; - return false; - } - ListValue* color; - if (!entry->GetList("color", &color)) { - DLOG(ERROR) << "Root entry " << ii << "'s color was not a list"; - return false; - } - if (color->GetSize() != 3) { - DLOG(ERROR) << "Root entry " << ii << "'s color list not length 3"; - return false; - } - int red, green, blue; - if (!color->GetInteger(0, &red) || - !color->GetInteger(1, &green) || - !color->GetInteger(2, &blue)) { - DLOG(ERROR) << "Root entry " << ii << "'s color list not integers"; - return false; - } - int tolerance; - if (!entry->GetInteger("tolerance", &tolerance)) { - DLOG(ERROR) << "Root entry " << ii << "'s tolerance not an integer"; - return false; - } - SinglePixelExpectation expectation; - expectation.location = SkIPoint::Make(x, y); - expectation.color = SkColorSetRGB(red, green, blue); - expectation.tolerance = tolerance; - expectations->push_back(expectation); - } - return true; - } - - // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. - bool TabSnapShotToImage(SkBitmap* bitmap) { - CHECK(bitmap); - std::vector<unsigned char> png; - - gfx::Rect root_bounds = browser()->window()->GetBounds(); - gfx::Rect tab_contents_bounds; - browser()->tab_strip_model()->GetActiveWebContents()->GetContainerBounds( - &tab_contents_bounds); - - gfx::Rect snapshot_bounds(tab_contents_bounds.x() - root_bounds.x(), - tab_contents_bounds.y() - root_bounds.y(), - tab_contents_bounds.width(), - tab_contents_bounds.height()); - - gfx::NativeWindow native_window = browser()->window()->GetNativeWindow(); - if (!chrome::GrabWindowSnapshotForUser(native_window, &png, - snapshot_bounds)) { - LOG(ERROR) << "browser::GrabWindowSnapShot() failed"; - return false; - } - - if (!gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&*png.begin()), - png.size(), bitmap)) { - LOG(ERROR) << "Decode PNG to a SkBitmap failed"; - return false; - } - return true; - } - - // Returns a gfx::Rect representing the bounds that the browser window should - // have if the tab contents have the desired size. - gfx::Rect GetNewTabContainerBounds(const gfx::Size& desired_size) { - gfx::Rect container_rect; - browser()->tab_strip_model()->GetActiveWebContents()-> - GetContainerBounds(&container_rect); - // Size cannot be negative, so use a point. - gfx::Point correction( - desired_size.width() - container_rect.size().width(), - desired_size.height() - container_rect.size().height()); - - gfx::Rect window_rect = browser()->window()->GetRestoredBounds(); - gfx::Size new_size = window_rect.size(); - new_size.Enlarge(correction.x(), correction.y()); - window_rect.set_size(new_size); - return window_rect; - } - - bool CompareColorChannel(uint8_t value, - uint8_t expected, - int tolerance) { - int32_t signed_value = value; - int32_t signed_expected = expected; - EXPECT_THAT(signed_value, AllOf( - Ge(signed_expected - tolerance), - Le(signed_expected + tolerance))); - return (signed_value >= signed_expected - tolerance && - signed_value <= signed_expected + tolerance); - } - - bool CompareToExpectedResults( - const SkBitmap& bitmap, - const std::vector<SinglePixelExpectation>& expectations) { - SkAutoLockPixels lock_bitmap(bitmap); - bool result = true; - for (size_t ii = 0; ii < expectations.size(); ++ii) { - const SinglePixelExpectation& expectation = expectations[ii]; - SkColor color = bitmap.getColor(expectation.location.x(), - expectation.location.y()); - result &= CompareColorChannel(SkColorGetR(color), - SkColorGetR(expectation.color), - expectation.tolerance); - result &= CompareColorChannel(SkColorGetG(color), - SkColorGetG(expectation.color), - expectation.tolerance); - result &= CompareColorChannel(SkColorGetB(color), - SkColorGetB(expectation.color), - expectation.tolerance); - } - return result; - } - - FRIEND_TEST_ALL_PREFIXES(MapsGLEnduranceTest, TestParseExpectations); - - DISALLOW_COPY_AND_ASSIGN(MapsGLEnduranceTest); -}; - -IN_PROC_BROWSER_TEST_F(MapsGLEnduranceTest, TestParseExpectations) { - std::vector<SinglePixelExpectation> expectations; - ASSERT_TRUE(ReadTestExpectations( - test_data_dir().AppendASCII("mapsgl_unittest_expectations.json"), - &expectations)); - ASSERT_EQ(2u, expectations.size()); - // These values are hardcoded in the test data. - EXPECT_EQ(25, expectations[0].location.x()); - EXPECT_EQ(50, expectations[0].location.y()); - EXPECT_EQ(64u, SkColorGetR(expectations[0].color)); - EXPECT_EQ(128u, SkColorGetG(expectations[0].color)); - EXPECT_EQ(192u, SkColorGetB(expectations[0].color)); - EXPECT_EQ(3, expectations[0].tolerance); - - EXPECT_EQ(1920, expectations[1].location.x()); - EXPECT_EQ(1200, expectations[1].location.y()); - EXPECT_EQ(0u, SkColorGetR(expectations[1].color)); - EXPECT_EQ(255u, SkColorGetG(expectations[1].color)); - EXPECT_EQ(127u, SkColorGetB(expectations[1].color)); - EXPECT_EQ(12, expectations[1].tolerance); -} - -// This test is being marked MANUAL so that it does not run -// automatically yet, but can be run on demand with the --run-manual -// command line argument. More work is needed to get the test harness -// running on the bots, and to fix flakiness in the test. -IN_PROC_BROWSER_TEST_F(MapsGLEnduranceTest, MANUAL_SingleRunBasic) { - // This expects the MapsGL python server to be running. - RunSingleTest(gfx::Size(1024, 768), - "http://localhost:8000/basic.html", - "mapsgl_single_run_basic_expectations.json", - "single-run-basic"); -} diff --git a/chrome/test/gpu/gpu_pixel_browsertest.cc b/chrome/test/gpu/gpu_pixel_browsertest.cc index b70b98a..4177f02 100644 --- a/chrome/test/gpu/gpu_pixel_browsertest.cc +++ b/chrome/test/gpu/gpu_pixel_browsertest.cc @@ -13,7 +13,6 @@ #include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/window_snapshot/window_snapshot.h" -#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_version_info.h" #include "chrome/test/base/in_process_browser_test.h" @@ -22,6 +21,7 @@ #include "chrome/test/base/ui_test_utils.h" #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" +#include "content/public/common/content_paths.h" #include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "googleurl/src/gurl.h" @@ -53,11 +53,6 @@ const char kGeneratedDir[] = "generated-dir"; // Command line flag for overriding the default location for reference images. const char kReferenceDir[] = "reference-dir"; -// Corner shadow size. -const int kCornerDecorationSize = 15; -// Side shadow size. -const int kSideDecorationSize = 2; - // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG // should have been encoded using |gfx::PNGCodec::Encode|. bool ReadPNGFile(const FilePath& file_path, SkBitmap* bitmap) { @@ -123,7 +118,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { if (command_line->HasSwitch(switches::kUseGpuInTests)) ref_img_option_ = kReferenceImageLocal; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir_)); + ASSERT_TRUE(PathService::Get(content::DIR_TEST_DATA, &test_data_dir_)); test_data_dir_ = test_data_dir_.AppendASCII("gpu"); if (command_line->HasSwitch(kGeneratedDir)) @@ -176,36 +171,10 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { content::DOMMessageQueue message_queue; ui_test_utils::NavigateToURL(browser(), net::FilePathToFileURL(url)); - // Wait for notification that page is loaded. - ASSERT_TRUE(message_queue.WaitForMessage(NULL)); - message_queue.ClearQueue(); - - gfx::Rect new_bounds = GetNewTabContainerBounds(tab_container_size); - - std::ostringstream js_call; - js_call << "preCallResizeInChromium("; - js_call << new_bounds.width() << ", " << new_bounds.height(); - js_call << ");"; - - ASSERT_TRUE(content::ExecuteScript( - browser()->tab_strip_model()->GetActiveWebContents(), js_call.str())); - std::string message; + // Wait for notification that page is loaded. ASSERT_TRUE(message_queue.WaitForMessage(&message)); - message_queue.ClearQueue(); - browser()->window()->SetBounds(new_bounds); - - // Wait for message from test page indicating the rendering is done. - while (message.compare("\"resized\"")) { - ASSERT_TRUE(message_queue.WaitForMessage(&message)); - message_queue.ClearQueue(); - } - - bool ignore_bottom_corners = false; -#if defined(OS_MACOSX) - // On Mac Lion, bottom corners have shadows with random pixels. - ignore_bottom_corners = true; -#endif + EXPECT_STREQ("\"SUCCESS\"", message.c_str()) << message; SkBitmap bitmap; ASSERT_TRUE(TabSnapShotToImage(&bitmap)); @@ -213,7 +182,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { if (ref_img_option_ == kReferenceImageNone && ref_pixels && ref_pixel_count) same_pixels = ComparePixels(bitmap, ref_pixels, ref_pixel_count); else - same_pixels = CompareImages(bitmap, ignore_bottom_corners); + same_pixels = CompareImages(bitmap); EXPECT_TRUE(same_pixels); #if defined(OS_WIN) @@ -260,7 +229,7 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { // FAIL_<ref_image_name>, DIFF_<ref_image_name> // E.g., // FAIL_WebGLTeapot_19762.png, DIFF_WebGLTeapot_19762.png - bool CompareImages(const SkBitmap& gen_bmp, bool skip_bottom_corners) { + bool CompareImages(const SkBitmap& gen_bmp) { SkBitmap ref_bmp_on_disk; FilePath img_path = ref_img_dir_.AppendASCII(test_name_ + ".png"); @@ -344,13 +313,6 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { uint32_t kAlphaMask = 0x00FFFFFF; for (int x = 0; x < gen_bmp.width(); ++x) { for (int y = 0; y < gen_bmp.height(); ++y) { - if (skip_bottom_corners && - (((x < kCornerDecorationSize || - x >= gen_bmp.width() - kCornerDecorationSize) && - y >= gen_bmp.height() - kCornerDecorationSize) || - (x < kSideDecorationSize || - x >= gen_bmp.width() - kSideDecorationSize))) - continue; if ((*gen_bmp.getAddr32(x, y) & kAlphaMask) != (*ref_bmp->getAddr32(x, y) & kAlphaMask)) { ++diff_pixels_count; @@ -423,24 +385,6 @@ class GpuPixelBrowserTest : public InProcessBrowserTest { return true; } - // Returns a gfx::Rect representing the bounds that the browser window should - // have if the tab contents have the desired size. - gfx::Rect GetNewTabContainerBounds(const gfx::Size& desired_size) { - gfx::Rect container_rect; - browser()->tab_strip_model()->GetActiveWebContents()->GetContainerBounds( - &container_rect); - // Size cannot be negative, so use a point. - gfx::Point correction( - desired_size.width() - container_rect.size().width(), - desired_size.height() - container_rect.size().height()); - - gfx::Rect window_rect = browser()->window()->GetRestoredBounds(); - gfx::Size new_size = window_rect.size(); - new_size.Enlarge(correction.x(), correction.y()); - window_rect.set_size(new_size); - return window_rect; - } - // Take snapshot of the current tab, encode it as PNG, and save to a SkBitmap. bool TabSnapShotToImage(SkBitmap* bitmap) { CHECK(bitmap); |