diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-15 15:57:53 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-15 15:57:53 +0000 |
commit | f8e0050398ee884d2cc342eeb8a2c08e5815e419 (patch) | |
tree | 4a0cd0c2eb7606a5b323438a2eb429fcf57d0278 /chrome_frame | |
parent | 2e4db56feeae5556d3ab6d9a01d09cbc4e88b99a (diff) | |
download | chromium_src-f8e0050398ee884d2cc342eeb8a2c08e5815e419.zip chromium_src-f8e0050398ee884d2cc342eeb8a2c08e5815e419.tar.gz chromium_src-f8e0050398ee884d2cc342eeb8a2c08e5815e419.tar.bz2 |
Attempt to fix flake in FullTabDownloadTest.CF_DownloadFileFromPost.
Increase timeout for the file to appear from 2s to 3s, and take a
snapshot when it doesn't appear in time.
BUG=189099
TEST=chrome_frame_tests.exe
Review URL: https://chromiumcodereview.appspot.com/12779010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@188401 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.cc | 24 | ||||
-rw-r--r-- | chrome_frame/test/chrome_frame_test_utils.h | 20 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_actions.h | 4 | ||||
-rw-r--r-- | chrome_frame/test/navigation_test.cc | 4 |
4 files changed, 33 insertions, 19 deletions
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc index 5e77f93..7e14bca 100644 --- a/chrome_frame/test/chrome_frame_test_utils.cc +++ b/chrome_frame/test/chrome_frame_test_utils.cc @@ -30,6 +30,7 @@ #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths_internal.h" #include "chrome/common/chrome_switches.h" +#include "chrome/test/base/ui_test_utils.h" #include "chrome_frame/utils.h" #include "net/base/net_util.h" #include "testing/gtest/include/gtest/gtest.h" @@ -239,6 +240,29 @@ base::ProcessHandle LaunchIE(const std::wstring& url) { return LaunchExecutable(kIEImageName, url); } +bool TakeSnapshotAndLog() { + testing::UnitTest* unit_test = testing::UnitTest::GetInstance(); + const testing::TestInfo* test_info = unit_test->current_test_info(); + std::string name; + if (test_info != NULL) { + name.append(test_info->test_case_name()) + .append(1, '.') + .append(test_info->name()); + } else { + name = "unknown test"; + } + + base::FilePath snapshot; + if (!ui_test_utils::SaveScreenSnapshotToDesktop(&snapshot)) { + LOG(ERROR) << "Failed saving screen snapshot for " << name; + return false; + } + + LOG(ERROR) << "Saved screen snapshot for " << name << " to " + << snapshot.value(); + return true; +} + int CloseAllIEWindows() { int ret = 0; diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h index bb3480df..5d2e44c 100644 --- a/chrome_frame/test/chrome_frame_test_utils.h +++ b/chrome_frame/test/chrome_frame_test_utils.h @@ -25,7 +25,6 @@ #include "base/time.h" #include "base/win/registry.h" #include "base/win/scoped_comptr.h" -#include "chrome/test/base/ui_test_utils.h" #include "chrome_frame/chrome_tab.h" #include "chrome_frame/test/simulate_input.h" #include "chrome_frame/test_utils.h" @@ -58,6 +57,9 @@ base::ProcessHandle LaunchChrome(const std::wstring& url, // not perform this initialization itself. int CloseAllIEWindows(); +// Saves a screen snapshot to the desktop and logs its location. +bool TakeSnapshotAndLog(); + extern const wchar_t kIEImageName[]; extern const wchar_t kIEBrokerImageName[]; extern const char kChromeImageName[]; @@ -246,21 +248,7 @@ class TimedMsgLoop { private: static void SnapshotAndQuit() { - base::FilePath snapshot; - if (ui_test_utils::SaveScreenSnapshotToDesktop(&snapshot)) { - testing::UnitTest* unit_test = testing::UnitTest::GetInstance(); - const testing::TestInfo* test_info = unit_test->current_test_info(); - std::string name; - if (test_info != NULL) { - name.append(test_info->test_case_name()) - .append(1, '.') - .append(test_info->name()); - } else { - name = "unknown test"; - } - LOG(ERROR) << name << " timed out. Screen snapshot saved to " - << snapshot.value(); - } + TakeSnapshotAndLog(); MessageLoop::current()->Quit(); } diff --git a/chrome_frame/test/mock_ie_event_sink_actions.h b/chrome_frame/test/mock_ie_event_sink_actions.h index aee5772..a2f864a 100644 --- a/chrome_frame/test/mock_ie_event_sink_actions.h +++ b/chrome_frame/test/mock_ie_event_sink_actions.h @@ -17,7 +17,7 @@ #include "base/threading/platform_thread.h" #include "base/time.h" #include "chrome/common/chrome_switches.h" -#include "chrome_frame/test/chrome_frame_ui_test_utils.h" +#include "chrome_frame/test/chrome_frame_test_utils.h" #include "chrome_frame/test/ie_event_sink.h" #include "chrome_frame/test/mock_ie_event_sink_test.h" #include "chrome_frame/test/simulate_input.h" @@ -389,6 +389,7 @@ ACTION_P3(CloseWhenFileSaved, mock, file, timeout_ms) { while (!file_util::PathExists(file)) { if ((base::Time::Now() - start).InMilliseconds() > timeout_ms) { ADD_FAILURE() << "File was not saved within timeout"; + TakeSnapshotAndLog(); break; } base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(200)); @@ -402,6 +403,7 @@ ACTION_P2(WaitForFileSave, file, timeout_ms) { base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(200)); if ((base::Time::Now() - start).InMilliseconds() > timeout_ms) { ADD_FAILURE() << "File was not saved within timeout"; + TakeSnapshotAndLog(); break; } } diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc index 45026b3..a8f3d40 100644 --- a/chrome_frame/test/navigation_test.cc +++ b/chrome_frame/test/navigation_test.cc @@ -749,7 +749,7 @@ void CloseWindow(HWND* window) { // IE brings up a file open dialog in this context. // We bring up the Save dialog via accessibility and save the file // and validate that all is well. -TEST_F(FullTabDownloadTest, DISABLED_CF_DownloadFileFromPost) { +TEST_F(FullTabDownloadTest, CF_DownloadFileFromPost) { // Please see http://code.google.com/p/chromium/issues/detail?id=60987 // for more information on why this test is disabled for Vista with IE7. if (base::win::GetVersion() >= base::win::VERSION_VISTA) { @@ -857,7 +857,7 @@ TEST_F(FullTabDownloadTest, DISABLED_CF_DownloadFileFromPost) { EXPECT_CALL(save_dialog_watcher, OnWindowClose(_)) .WillOnce(testing::DoAll( - WaitForFileSave(temp_file_path, 2000), + WaitForFileSave(temp_file_path, 3000), testing::InvokeWithoutArgs( testing::CreateFunctor(CloseWindow, &owner_window)), CloseBrowserMock(&ie_mock_))); |