Chromium Code Reviews| Index: content/test/layout_browsertest.cc |
| diff --git a/content/test/layout_browsertest.cc b/content/test/layout_browsertest.cc |
| index b0fac406abd02ff24baf3e7d8b555c8297f92730..3e9458221b33dea7c25f1530bb0f17e292681ac3 100644 |
| --- a/content/test/layout_browsertest.cc |
| +++ b/content/test/layout_browsertest.cc |
| @@ -4,6 +4,7 @@ |
| #include "content/test/layout_browsertest.h" |
| +#include "base/command_line.h" |
| #include "base/file_path.h" |
| #include "base/file_util.h" |
| #include "base/path_service.h" |
| @@ -16,6 +17,7 @@ |
| #include "content/public/common/content_paths.h" |
| #include "content/public/test/browser_test_utils.h" |
| #include "content/shell/shell.h" |
| +#include "content/shell/shell_switches.h" |
| #include "content/test/content_browser_test_utils.h" |
| #include "content/test/layout_test_http_server.h" |
| #include "net/base/net_util.h" |
| @@ -215,7 +217,13 @@ void InProcessBrowserLayoutTest::RunLayoutTestInternal( |
| ReplaceSubstringsAfterOffset(&expected_text, 0, "\r", ""); |
| TrimString(expected_text, "\n", &expected_text); |
| - EXPECT_EQ(expected_text, actual_text); |
| + CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| + if (command_line->HasSwitch(switches::kOutputLayoutTestDifferences)) { |
| + EXPECT_EQ(expected_text, actual_text) |
| + << SaveResults(expected_text, actual_text); |
|
jam
2012/09/05 01:33:37
nit: I believe "<<" has to be at the start of the
dgrogan
2012/09/05 02:03:30
Done.
I couldn't find this case in (or infer from
|
| + } else { |
| + EXPECT_EQ(expected_text, actual_text); |
| + } |
| } |
| void InProcessBrowserLayoutTest::AddResourceForLayoutTest( |
| @@ -256,3 +264,20 @@ void InProcessBrowserLayoutTest::WriteModifiedFile( |
| &test_html.at(0), |
| static_cast<int>(test_html.size()))); |
| } |
| + |
| +std::string InProcessBrowserLayoutTest::SaveResults(const std::string& expected, |
| + const std::string& actual) { |
| + FilePath cwd; |
| + EXPECT_TRUE(file_util::CreateNewTempDirectory(FILE_PATH_LITERAL(""), &cwd)); |
| + FilePath expected_filename = cwd.Append(FILE_PATH_LITERAL("expected.txt")); |
| + FilePath actual_filename = cwd.Append(FILE_PATH_LITERAL("actual.txt")); |
| + EXPECT_NE(-1, file_util::WriteFile(expected_filename, |
| + expected.c_str(), |
| + expected.size())); |
| + EXPECT_NE(-1, file_util::WriteFile(actual_filename, |
| + actual.c_str(), |
| + actual.size())); |
| + return StringPrintf("Wrote %"PRFilePath" %"PRFilePath, |
| + expected_filename.value().c_str(), |
| + actual_filename.value().c_str()); |
| +} |