diff options
author | phoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 13:54:02 +0000 |
---|---|---|
committer | phoglund@chromium.org <phoglund@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 13:54:02 +0000 |
commit | cdaf13d1e037f0119bc8724d0907e31a2729b233 (patch) | |
tree | 7c0ee35a4e2c300bc19c88e1929353fc45c26252 | |
parent | cc5f78155f857e3e2a3570fe56e06a219e2eb839 (diff) | |
download | chromium_src-cdaf13d1e037f0119bc8724d0907e31a2729b233.zip chromium_src-cdaf13d1e037f0119bc8724d0907e31a2729b233.tar.gz chromium_src-cdaf13d1e037f0119bc8724d0907e31a2729b233.tar.bz2 |
Made the WebRTC PyAuto test detect assertions.
BUG=
TEST=
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/10454004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139782 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-x | chrome/test/functional/webrtc_call.py | 1 | ||||
-rw-r--r-- | chrome/test/pyautolib/pyautolib.i | 6 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 66 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 7 |
4 files changed, 53 insertions, 27 deletions
diff --git a/chrome/test/functional/webrtc_call.py b/chrome/test/functional/webrtc_call.py index ab7029d..9d2a060 100755 --- a/chrome/test/functional/webrtc_call.py +++ b/chrome/test/functional/webrtc_call.py @@ -55,6 +55,7 @@ class WebRTCCallTest(pyauto.PyUITest): self._server_process.kill() pyauto.PyUITest.tearDown(self) + self.assertEquals('', self.CheckErrorsAndCrashes()) def _SimpleWebRtcCall(self, test_page): """Tests we can call and hang up with WebRTC using ROAP/JSEP. diff --git a/chrome/test/pyautolib/pyautolib.i b/chrome/test/pyautolib/pyautolib.i index 1041ab6..0710404 100644 --- a/chrome/test/pyautolib/pyautolib.i +++ b/chrome/test/pyautolib/pyautolib.i @@ -427,6 +427,12 @@ class PyUITestBase { "Returns true on success.") ResetToDefaultTheme; bool ResetToDefaultTheme(); + %feature("docstring", + "Returns empty string if there were no unexpected Chrome asserts or " + "crashes, a string describing the failures otherwise. As a side " + "effect, it will fail with EXPECT_EQ macros if this code runs " + "within a gtest harness.") GetErrorsAndCrashes; + std::string CheckErrorsAndCrashes() const; }; namespace net { diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 6ed374f..eef01e5 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -131,31 +131,7 @@ void UITestBase::TearDown() { if (launcher_.get()) launcher_->TerminateConnection(); - // Make sure that we didn't encounter any assertion failures - logging::AssertionList assertions; - logging::GetFatalAssertions(&assertions); - - // If there were errors, get all the error strings for display. - std::wstring failures = - L"The following error(s) occurred in the application during this test:"; - if (assertions.size() > expected_errors_) { - logging::AssertionList::const_iterator iter = assertions.begin(); - for (; iter != assertions.end(); ++iter) { - failures.append(L"\n\n"); - failures.append(*iter); - } - } - EXPECT_EQ(expected_errors_, assertions.size()) << failures; - - int actual_crashes = GetCrashCount(); - - std::wstring error_msg = - L"Encountered an unexpected crash in the program during this test."; - if (expected_crashes_ > 0 && actual_crashes == 0) { - error_msg += L" "; - error_msg += kFailedNoCrashService; - } - EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg; + CheckErrorsAndCrashes(); } AutomationProxy* UITestBase::automation() const { @@ -477,7 +453,7 @@ FilePath UITestBase::ComputeTypicalUserDataSource( return source_history_file; } -int UITestBase::GetCrashCount() { +int UITestBase::GetCrashCount() const { FilePath crash_dump_path; PathService::Get(chrome::DIR_CRASH_DUMPS, &crash_dump_path); int actual_crashes = file_util::CountFilesCreatedAfter( @@ -491,6 +467,44 @@ int UITestBase::GetCrashCount() { return actual_crashes; } +std::string UITestBase::CheckErrorsAndCrashes() const { + // Make sure that we didn't encounter any assertion failures + logging::AssertionList assertions; + logging::GetFatalAssertions(&assertions); + + // If there were errors, get all the error strings for display. + std::wstring failures = + L"The following error(s) occurred in the application during this test:"; + if (assertions.size() > expected_errors_) { + logging::AssertionList::const_iterator iter = assertions.begin(); + for (; iter != assertions.end(); ++iter) { + failures += L"\n\n"; + failures += *iter; + } + } + EXPECT_EQ(expected_errors_, assertions.size()) << failures; + + int actual_crashes = GetCrashCount(); + + std::wstring error_msg = + L"Encountered an unexpected crash in the program during this test."; + if (expected_crashes_ > 0 && actual_crashes == 0) { + error_msg += L" "; + error_msg += kFailedNoCrashService; + } + EXPECT_EQ(expected_crashes_, actual_crashes) << error_msg; + + std::wstring wide_result; + if (expected_errors_ != assertions.size()) { + wide_result += failures; + wide_result += L"\n\n"; + } + if (expected_crashes_ != actual_crashes) + wide_result += error_msg; + + return std::string(wide_result.begin(), wide_result.end()); +} + void UITestBase::SetBrowserDirectory(const FilePath& dir) { browser_directory_ = dir; } diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index 8a9947f..7748e30 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -226,7 +226,12 @@ class UITestBase { } // Get the number of crash dumps we've logged since the test started. - int GetCrashCount(); + int GetCrashCount() const; + + // Returns empty string if there were no unexpected Chrome asserts or crashes, + // a string describing the failures otherwise. As a side effect, it will fail + // with EXPECT_EQ macros if this code runs within a gtest harness. + std::string CheckErrorsAndCrashes() const; // Use Chromium binaries from the given directory. void SetBrowserDirectory(const FilePath& dir); |