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

Unified Diff: chrome/browser/ui/webui/web_ui_browsertest.cc

Issue 7146024: Use ExecuteJavascriptInWebFrameNotifyResult to return results even in error condition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't check against |this| in the destructor, which doesn't compile on Win. Created 9 years, 6 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 | « no previous file | chrome/browser/ui/webui/web_ui_test_handler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/web_ui_browsertest.cc
diff --git a/chrome/browser/ui/webui/web_ui_browsertest.cc b/chrome/browser/ui/webui/web_ui_browsertest.cc
index 3817612619a61c8a7daf4884bbc5cab12a9f0e53..7908254723b5c34b816995306e1091a22e3a0bf0 100644
--- a/chrome/browser/ui/webui/web_ui_browsertest.cc
+++ b/chrome/browser/ui/webui/web_ui_browsertest.cc
@@ -15,6 +15,7 @@
#include "chrome/test/ui_test_utils.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/webui/web_ui.h"
+#include "testing/gtest/include/gtest/gtest-spi.h"
#include "ui/base/resource/resource_bundle.h"
static const FilePath::CharType* kWebUILibraryJS =
@@ -201,6 +202,42 @@ IN_PROC_BROWSER_TEST_F(WebUIBrowserTest, TestSamplePass) {
ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL));
ASSERT_TRUE(RunJavascriptTest("testAssertFalse"));
+ ASSERT_FALSE(RunJavascriptTest("FAILS_testAssertFalse"));
ASSERT_TRUE(RunJavascriptTest("testInitialFocus"));
ASSERT_FALSE(RunJavascriptTest("testConsoleError"));
}
+
+// According to the interface for EXPECT_FATAL_FAILURE
+// (http://code.google.com/p/googletest/wiki/AdvancedGuide#Catching_Failures)
+// the statement must be statically available. Therefore, we make a static
+// global s_test_ which should point to |this| for the duration of the test run
+// and be cleared afterward.
+class WebUIBrowserExpectFailTest : public WebUIBrowserTest {
+ public:
+ WebUIBrowserExpectFailTest() {
+ EXPECT_FALSE(s_test_);
+ s_test_ = this;
+ }
+
+ protected:
+ virtual ~WebUIBrowserExpectFailTest() {
+ EXPECT_TRUE(s_test_);
+ s_test_ = NULL;
+ }
+
+ static void RunJavascriptTestNoReturn(const std::string& testname) {
+ EXPECT_TRUE(s_test_);
+ s_test_->RunJavascriptTest(testname);
+ }
+
+ private:
+ static WebUIBrowserTest* s_test_;
+};
+WebUIBrowserTest* WebUIBrowserExpectFailTest::s_test_ = NULL;
+
+IN_PROC_BROWSER_TEST_F(WebUIBrowserExpectFailTest, TestFailsFast) {
+ AddLibrary(FilePath(FILE_PATH_LITERAL("sample_downloads.js")));
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIDownloadsURL));
+ EXPECT_FATAL_FAILURE(RunJavascriptTestNoReturn("FAILS_BogusFunctionName"),
+ "WebUITestHandler::Observe");
+}
« no previous file with comments | « no previous file | chrome/browser/ui/webui/web_ui_test_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698