summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-31 01:01:10 +0000
committerdanakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-31 01:01:10 +0000
commit776c6a700e856b2a26fe1f1bb038eb6602dc7700 (patch)
tree0614251af1b0e48c559770c834874c6574d0ea77
parenta9e7cd60248bb3c00c836bc99d796331da690f69 (diff)
downloadchromium_src-776c6a700e856b2a26fe1f1bb038eb6602dc7700.zip
chromium_src-776c6a700e856b2a26fe1f1bb038eb6602dc7700.tar.gz
chromium_src-776c6a700e856b2a26fe1f1bb038eb6602dc7700.tar.bz2
cc: Add --cc-rebaseline-pixeltests command line flag.
When present, pixel tests write their output instead of reading it. This allows rebaselining tests without requiring a recompile of the code. R=enne BUG= Review URL: https://codereview.chromium.org/48733009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231965 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--cc/base/switches.cc3
-rw-r--r--cc/base/switches.h1
-rw-r--r--cc/test/layer_tree_pixel_test.cc7
-rw-r--r--cc/test/pixel_test.cc7
4 files changed, 14 insertions, 4 deletions
diff --git a/cc/base/switches.cc b/cc/base/switches.cc
index 2eab547..be4a2c5 100644
--- a/cc/base/switches.cc
+++ b/cc/base/switches.cc
@@ -141,6 +141,9 @@ const char kDisableMapImage[] = "disable-map-image";
// Prevents the layer tree unit tests from timing out.
const char kCCLayerTreeTestNoTimeout[] = "cc-layer-tree-test-no-timeout";
+// Makes pixel tests write their output instead of read it.
+const char kCCRebaselinePixeltests[] = "cc-rebaseline-pixeltests";
+
// Disable textures using RGBA_4444 layout.
const char kDisable4444Textures[] = "disable-4444-textures";
diff --git a/cc/base/switches.h b/cc/base/switches.h
index ed6555a..e92eb2e 100644
--- a/cc/base/switches.h
+++ b/cc/base/switches.h
@@ -69,6 +69,7 @@ CC_EXPORT extern const char kUIShowNonOccludingRects[];
// Unit test related.
CC_EXPORT extern const char kCCLayerTreeTestNoTimeout[];
+CC_EXPORT extern const char kCCRebaselinePixeltests[];
CC_EXPORT bool IsLCDTextEnabled();
CC_EXPORT bool IsImplSidePaintingEnabled();
diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc
index 70e6223..d0a5c59 100644
--- a/cc/test/layer_tree_pixel_test.cc
+++ b/cc/test/layer_tree_pixel_test.cc
@@ -4,7 +4,9 @@
#include "cc/test/layer_tree_pixel_test.h"
+#include "base/command_line.h"
#include "base/path_service.h"
+#include "cc/base/switches.h"
#include "cc/layers/solid_color_layer.h"
#include "cc/layers/texture_layer.h"
#include "cc/output/copy_output_request.h"
@@ -96,8 +98,9 @@ void LayerTreePixelTest::AfterTest() {
EXPECT_TRUE(PathService::Get(cc::DIR_TEST_DATA, &test_data_dir));
base::FilePath ref_file_path = test_data_dir.Append(ref_file_);
- // To rebaseline:
- // EXPECT_TRUE(WritePNGFile(*result_bitmap_, ref_file_path, true));
+ CommandLine* cmd = CommandLine::ForCurrentProcess();
+ if (cmd->HasSwitch(switches::kCCRebaselinePixeltests))
+ EXPECT_TRUE(WritePNGFile(*result_bitmap_, ref_file_path, true));
EXPECT_TRUE(MatchesPNGFile(*result_bitmap_,
ref_file_path,
diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc
index 8504c28..12b729b 100644
--- a/cc/test/pixel_test.cc
+++ b/cc/test/pixel_test.cc
@@ -4,8 +4,10 @@
#include "cc/test/pixel_test.h"
+#include "base/command_line.h"
#include "base/path_service.h"
#include "base/run_loop.h"
+#include "cc/base/switches.h"
#include "cc/output/compositor_frame_metadata.h"
#include "cc/output/copy_output_request.h"
#include "cc/output/copy_output_result.h"
@@ -147,8 +149,9 @@ bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file,
if (!result_bitmap_)
return false;
- // To rebaseline:
- // return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true);
+ CommandLine* cmd = CommandLine::ForCurrentProcess();
+ if (cmd->HasSwitch(switches::kCCRebaselinePixeltests))
+ return WritePNGFile(*result_bitmap_, test_data_dir.Append(ref_file), true);
return MatchesPNGFile(*result_bitmap_,
test_data_dir.Append(ref_file),