Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: content/test/layout_browsertest.cc

Issue 10869061: Make IndexedDB layout browser tests save incorrect results to a file (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix << Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/layout_browsertest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/layout_browsertest.cc
diff --git a/content/test/layout_browsertest.cc b/content/test/layout_browsertest.cc
index b0fac406abd02ff24baf3e7d8b555c8297f92730..d8fc383eee2e65066dc7c5e0e0704159973ee4a5 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);
+ } 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());
+}
« no previous file with comments | « content/test/layout_browsertest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698