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

Unified Diff: chrome_frame/test/test_with_web_server.cc

Issue 10007043: Attempt to fix ChromeFrameTestWithWebServer tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: take snapshots on timeout Created 8 years, 8 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
Index: chrome_frame/test/test_with_web_server.cc
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index e01733efdfbab2e351e9ea721a3c464627b4833b..17b197eedc9d673749d3496ed6763bb0b9d2fea7 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -44,8 +44,10 @@ std::string CreateHttpHeaders(CFInvocation invocation,
<< "Content-Type: " << content_type << "\r\n";
if (invocation.type() == CFInvocation::HTTP_HEADER)
ss << "X-UA-Compatible: chrome=1\r\n";
- if (add_no_cache_header)
+ if (add_no_cache_header) {
ss << "Cache-Control: no-cache\r\n";
+ ss << "Expires: Tue, 15 Nov 1994 08:12:31 GMT\r\n";
+ }
return ss.str();
}
@@ -74,11 +76,10 @@ FilePath ChromeFrameTestWithWebServer::CFInstall_path_;
FilePath ChromeFrameTestWithWebServer::CFInstance_path_;
ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_;
FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_;
+chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_;
+testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_;
-ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer()
- : loop_(),
- server_mock_(1337, L"127.0.0.1",
- chrome_frame_test::GetTestDataFolder()) {
+ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() {
}
// static
@@ -108,13 +109,23 @@ void ChromeFrameTestWithWebServer::SetUpTestCase() {
CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js");
ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_));
+
+ loop_ = new chrome_frame_test::TimedMsgLoop();
+ loop_->set_snapshot_on_timeout(true);
+ server_mock_ = new testing::StrictMock<MockWebServer>(
+ 1337, L"127.0.0.1", chrome_frame_test::GetTestDataFolder());
}
// static
void ChromeFrameTestWithWebServer::TearDownTestCase() {
+ delete server_mock_;
+ server_mock_ = NULL;
+ delete loop_;
+ loop_ = NULL;
file_util::Delete(CFInstall_path_, false);
file_util::Delete(CFInstance_path_, false);
- EXPECT_TRUE(temp_dir_.Delete());
+ if (temp_dir_.IsValid())
+ EXPECT_TRUE(temp_dir_.Delete());
}
// static
@@ -130,12 +141,15 @@ void ChromeFrameTestWithWebServer::SetUp() {
// Make sure that we are not accidentally enabling gcf protocol.
SetConfigBool(kAllowUnsafeURLs, false);
- server_mock_.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
- server_mock_.set_expected_result("OK");
+ server_mock().ClearResults();
+ server_mock().ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
+ server_mock().set_expected_result("OK");
}
void ChromeFrameTestWithWebServer::TearDown() {
CloseBrowser();
+ loop().RunAllPending();
+ testing::Mock::VerifyAndClear(server_mock_);
}
bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser,
@@ -145,7 +159,7 @@ bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser,
// We should resolve the URL only if it is a relative url.
GURL parsed_url(WideToUTF8(page));
if (!parsed_url.has_scheme()) {
- url = server_mock_.Resolve(page);
+ url = server_mock().Resolve(page);
}
browser_ = browser;
@@ -202,7 +216,7 @@ bool ChromeFrameTestWithWebServer::BringBrowserToTop() {
}
bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) {
- loop_.RunFor(milliseconds/1000);
+ loop().RunFor(milliseconds/1000);
return true;
}
@@ -214,11 +228,11 @@ const wchar_t kPostedResultSubstring[] = L"/writefile/";
void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
BrowserKind browser, const wchar_t* page, const char* result) {
- server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
- kPostedResultSubstring);
+ server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
+ kPostedResultSubstring);
ASSERT_TRUE(LaunchBrowser(browser, page));
WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
- ASSERT_EQ(result, server_mock_.posted_result());
+ ASSERT_EQ(result, server_mock().posted_result());
}
void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
@@ -257,15 +271,15 @@ void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
version = version_info->product_version();
}
- server_mock_.set_expected_result(WideToUTF8(version));
+ server_mock().set_expected_result(WideToUTF8(version));
EXPECT_TRUE(version_info);
EXPECT_FALSE(version.empty());
- server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
- kPostedResultSubstring);
+ server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
+ kPostedResultSubstring);
EXPECT_TRUE(LaunchBrowser(browser, page));
WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
- ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result()));
+ ASSERT_EQ(version, UTF8ToWide(server_mock().posted_result()));
}
// MockWebServer methods
@@ -425,7 +439,7 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) {
const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html";
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_SrcProperty) {
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) {
SimpleBrowserTest(IE, kSrcPropertyTestPage);
}
@@ -443,14 +457,13 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) {
const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html";
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceDelay) {
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDelay) {
SimpleBrowserTest(IE, kCFIDelayPage);
}
const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html";
-// http://crbug.com/37088
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceFallback) {
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceFallback) {
SimpleBrowserTest(IE, kCFIFallbackPage);
}
@@ -476,8 +489,7 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) {
const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html";
-// http://crbug.com/32321
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceIfrPost) {
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceIfrPost) {
SimpleBrowserTest(IE, kCFIIfrPostPage);
}
@@ -502,14 +514,7 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) {
const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html";
-// This test consistently times out in debug builds; see http://crbug.com/112599
-#ifndef NDEBUG
-#define MAYBE_WidgetModeIE_CFInstanceRPC DISABLED_WidgetModeIE_CFInstanceRPC
-#else
-#define MAYBE_WidgetModeIE_CFInstanceRPC WidgetModeIE_CFInstanceRPC
-#endif
-
-TEST_F(ChromeFrameTestWithWebServer, MAYBE_WidgetModeIE_CFInstanceRPC) {
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) {
if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
return;
@@ -669,18 +674,18 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) {
ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl));
- loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
+ loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
ScopedChromeFrameRegistrar::RegisterAtPath(
GetChromeFrameBuildPath().value(),
chrome_frame_test::GetTestBedType());
- server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
- kPostedResultSubstring);
- loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
+ server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
+ kPostedResultSubstring);
+ loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
chrome_frame_test::CloseAllIEWindows();
- ASSERT_EQ("OK", server_mock_.posted_result());
+ ASSERT_EQ("OK", server_mock().posted_result());
}
}
@@ -728,7 +733,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestPostReissue) {
ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
- loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
+ loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
const test_server::Request* request = NULL;
server.FindRequest("/quit?OK", &request);
@@ -760,7 +765,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestMultipleGet) {
ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
- loop_.RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds);
+ loop().RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds);
const test_server::Request* request = NULL;
server.FindRequest("/quit?OK", &request);
@@ -792,8 +797,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) {
const wchar_t kWindowCloseTestUrl[] =
L"window_close.html";
-// http://code.google.com/p/chromium/issues/detail?id=111074
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowClose) {
+TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) {
SimpleBrowserTest(IE, kWindowCloseTestUrl);
}
@@ -878,7 +882,7 @@ TEST_F(ChromeFrameTestWithWebServer, FAILS_FullTabModeIE_RefreshMshtmlTest) {
ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
- loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
+ loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
test_server::SimpleWebServer* ws = server.web_server();
const test_server::ConnectionList& connections = ws->connections();
@@ -1010,7 +1014,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) {
EXPECT_CALL(win_observer_mock, OnWindowClose(_))
.Times(testing::AtMost(1))
- .WillOnce(QUIT_LOOP(loop_));
+ .WillOnce(QUIT_LOOP(loop()));
SimpleWebServerTest server(46664);
CustomResponse* response = new CustomResponse("/form.html");
@@ -1019,7 +1023,7 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) {
std::wstring url(server.FormatHttpPath(L"form.html"));
ASSERT_TRUE(LaunchBrowser(IE, url.c_str()));
- loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
+ loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
EXPECT_EQ(1, response->get_request_count());
EXPECT_EQ(1, response->post_request_count());
« chrome/test/base/ui_test_utils.cc ('K') | « chrome_frame/test/test_with_web_server.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698