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

Side by Side 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: move snapshot fn into ui_test_utils_win.cc 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/test/test_with_web_server.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome_frame/test/test_with_web_server.h" 5 #include "chrome_frame/test/test_with_web_server.h"
6 6
7 #include "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/file_version_info.h" 8 #include "base/file_version_info.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 26 matching lines...) Expand all
37 // Helper method for creating the appropriate HTTP response headers. 37 // Helper method for creating the appropriate HTTP response headers.
38 std::string CreateHttpHeaders(CFInvocation invocation, 38 std::string CreateHttpHeaders(CFInvocation invocation,
39 bool add_no_cache_header, 39 bool add_no_cache_header,
40 const std::string& content_type) { 40 const std::string& content_type) {
41 std::ostringstream ss; 41 std::ostringstream ss;
42 ss << "HTTP/1.1 200 OK\r\n" 42 ss << "HTTP/1.1 200 OK\r\n"
43 << "Connection: close\r\n" 43 << "Connection: close\r\n"
44 << "Content-Type: " << content_type << "\r\n"; 44 << "Content-Type: " << content_type << "\r\n";
45 if (invocation.type() == CFInvocation::HTTP_HEADER) 45 if (invocation.type() == CFInvocation::HTTP_HEADER)
46 ss << "X-UA-Compatible: chrome=1\r\n"; 46 ss << "X-UA-Compatible: chrome=1\r\n";
47 if (add_no_cache_header) 47 if (add_no_cache_header) {
48 ss << "Cache-Control: no-cache\r\n"; 48 ss << "Cache-Control: no-cache\r\n";
49 ss << "Expires: Tue, 15 Nov 1994 08:12:31 GMT\r\n";
50 }
49 return ss.str(); 51 return ss.str();
50 } 52 }
51 53
52 std::string GetMockHttpHeaders(const FilePath& mock_http_headers_path) { 54 std::string GetMockHttpHeaders(const FilePath& mock_http_headers_path) {
53 std::string headers; 55 std::string headers;
54 file_util::ReadFileToString(mock_http_headers_path, &headers); 56 file_util::ReadFileToString(mock_http_headers_path, &headers);
55 return headers; 57 return headers;
56 } 58 }
57 59
58 class ChromeFrameTestEnvironment: public testing::Environment { 60 class ChromeFrameTestEnvironment: public testing::Environment {
59 public: 61 public:
60 virtual ~ChromeFrameTestEnvironment() {} 62 virtual ~ChromeFrameTestEnvironment() {}
61 virtual void SetUp() OVERRIDE { 63 virtual void SetUp() OVERRIDE {
62 ScopedChromeFrameRegistrar::RegisterDefaults(); 64 ScopedChromeFrameRegistrar::RegisterDefaults();
63 } 65 }
64 }; 66 };
65 67
66 ::testing::Environment* const chrome_frame_env = 68 ::testing::Environment* const chrome_frame_env =
67 ::testing::AddGlobalTestEnvironment(new ChromeFrameTestEnvironment); 69 ::testing::AddGlobalTestEnvironment(new ChromeFrameTestEnvironment);
68 70
69 } // namespace 71 } // namespace
70 72
71 FilePath ChromeFrameTestWithWebServer::test_file_path_; 73 FilePath ChromeFrameTestWithWebServer::test_file_path_;
72 FilePath ChromeFrameTestWithWebServer::results_dir_; 74 FilePath ChromeFrameTestWithWebServer::results_dir_;
73 FilePath ChromeFrameTestWithWebServer::CFInstall_path_; 75 FilePath ChromeFrameTestWithWebServer::CFInstall_path_;
74 FilePath ChromeFrameTestWithWebServer::CFInstance_path_; 76 FilePath ChromeFrameTestWithWebServer::CFInstance_path_;
75 ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_; 77 ScopedTempDir ChromeFrameTestWithWebServer::temp_dir_;
76 FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_; 78 FilePath ChromeFrameTestWithWebServer::chrome_user_data_dir_;
79 chrome_frame_test::TimedMsgLoop* ChromeFrameTestWithWebServer::loop_;
80 testing::StrictMock<MockWebServerListener>*
81 ChromeFrameTestWithWebServer::listener_mock_;
82 testing::StrictMock<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_;
77 83
78 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() 84 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() {
79 : loop_(),
80 server_mock_(1337, L"127.0.0.1",
81 chrome_frame_test::GetTestDataFolder()) {
82 } 85 }
83 86
84 // static 87 // static
85 void ChromeFrameTestWithWebServer::SetUpTestCase() { 88 void ChromeFrameTestWithWebServer::SetUpTestCase() {
86 FilePath chrome_frame_source_path; 89 FilePath chrome_frame_source_path;
87 PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path); 90 PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path);
88 chrome_frame_source_path = chrome_frame_source_path.Append( 91 chrome_frame_source_path = chrome_frame_source_path.Append(
89 FILE_PATH_LITERAL("chrome_frame")); 92 FILE_PATH_LITERAL("chrome_frame"));
90 93
91 test_file_path_ = chrome_frame_source_path 94 test_file_path_ = chrome_frame_source_path
92 .Append(FILE_PATH_LITERAL("test")) 95 .Append(FILE_PATH_LITERAL("test"))
93 .Append(FILE_PATH_LITERAL("data")); 96 .Append(FILE_PATH_LITERAL("data"));
94 97
95 results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump"); 98 results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump");
96 99
97 // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to 100 // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to
98 // src\chrome_frame\test\data. 101 // src\chrome_frame\test\data.
99 FilePath CFInstance_src_path; 102 FilePath CFInstance_src_path;
100 FilePath CFInstall_src_path; 103 FilePath CFInstall_src_path;
101 104
102 CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js"); 105 CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js");
103 CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js"); 106 CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js");
104 107
105 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_)); 108 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_));
106 109
107 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); 110 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js");
108 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); 111 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js");
109 112
110 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_)); 113 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_));
114
115 loop_ = new chrome_frame_test::TimedMsgLoop();
116 loop_->set_snapshot_on_timeout(true);
117 listener_mock_ = new testing::StrictMock<MockWebServerListener>();
118 server_mock_ = new testing::StrictMock<MockWebServer>(
119 1337, ASCIIToWide(chrome_frame_test::GetLocalIPv4Address()),
120 chrome_frame_test::GetTestDataFolder());
121 server_mock_->set_listener(listener_mock_);
111 } 122 }
112 123
113 // static 124 // static
114 void ChromeFrameTestWithWebServer::TearDownTestCase() { 125 void ChromeFrameTestWithWebServer::TearDownTestCase() {
126 delete server_mock_;
127 server_mock_ = NULL;
128 delete listener_mock_;
129 listener_mock_ = NULL;
130 delete loop_;
131 loop_ = NULL;
115 file_util::Delete(CFInstall_path_, false); 132 file_util::Delete(CFInstall_path_, false);
116 file_util::Delete(CFInstance_path_, false); 133 file_util::Delete(CFInstance_path_, false);
117 EXPECT_TRUE(temp_dir_.Delete()); 134 if (temp_dir_.IsValid())
135 EXPECT_TRUE(temp_dir_.Delete());
118 } 136 }
119 137
120 // static 138 // static
121 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { 139 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() {
122 if (!temp_dir_.IsValid()) { 140 if (!temp_dir_.IsValid()) {
123 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 141 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
124 chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data"); 142 chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data");
125 } 143 }
126 return chrome_user_data_dir_; 144 return chrome_user_data_dir_;
127 } 145 }
128 146
129 void ChromeFrameTestWithWebServer::SetUp() { 147 void ChromeFrameTestWithWebServer::SetUp() {
130 // Make sure that we are not accidentally enabling gcf protocol. 148 // Make sure that we are not accidentally enabling gcf protocol.
131 SetConfigBool(kAllowUnsafeURLs, false); 149 SetConfigBool(kAllowUnsafeURLs, false);
132 150
133 server_mock_.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); 151 server_mock().ClearResults();
134 server_mock_.set_expected_result("OK"); 152 server_mock().ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
153 server_mock().set_expected_result("OK");
135 } 154 }
136 155
137 void ChromeFrameTestWithWebServer::TearDown() { 156 void ChromeFrameTestWithWebServer::TearDown() {
138 CloseBrowser(); 157 CloseBrowser();
158 loop().RunAllPending();
159 testing::Mock::VerifyAndClear(listener_mock_);
160 testing::Mock::VerifyAndClear(server_mock_);
139 } 161 }
140 162
141 bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser, 163 bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser,
142 const wchar_t* page) { 164 const wchar_t* page) {
143 std::wstring url = page; 165 std::wstring url = page;
144 166
145 // We should resolve the URL only if it is a relative url. 167 // We should resolve the URL only if it is a relative url.
146 GURL parsed_url(WideToUTF8(page)); 168 GURL parsed_url(WideToUTF8(page));
147 if (!parsed_url.has_scheme()) { 169 if (!parsed_url.has_scheme()) {
148 url = server_mock_.Resolve(page); 170 url = server_mock().Resolve(page);
149 } 171 }
150 172
151 browser_ = browser; 173 browser_ = browser;
152 if (browser == IE) { 174 if (browser == IE) {
153 browser_handle_.Set(chrome_frame_test::LaunchIE(url)); 175 browser_handle_.Set(chrome_frame_test::LaunchIE(url));
154 } else if (browser == CHROME) { 176 } else if (browser == CHROME) {
155 const FilePath& user_data_dir = GetChromeUserDataDirectory(); 177 const FilePath& user_data_dir = GetChromeUserDataDirectory();
156 chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value()); 178 chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value());
157 browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir)); 179 browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir));
158 } else { 180 } else {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 218 }
197 } 219 }
198 220
199 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { 221 bool ChromeFrameTestWithWebServer::BringBrowserToTop() {
200 return simulate_input::EnsureProcessInForeground( 222 return simulate_input::EnsureProcessInForeground(
201 GetProcessId(browser_handle_)); 223 GetProcessId(browser_handle_));
202 } 224 }
203 225
204 bool ChromeFrameTestWithWebServer::WaitForTestToComplete( 226 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(
205 base::TimeDelta duration) { 227 base::TimeDelta duration) {
206 loop_.RunFor(duration); 228 loop().RunFor(duration);
207 return true; 229 return !loop().WasTimedOut();
208 } 230 }
209 231
210 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { 232 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) {
211 return false; 233 return false;
212 } 234 }
213 235
214 const wchar_t kPostedResultSubstring[] = L"/writefile/"; 236 const wchar_t kPostedResultSubstring[] = L"/writefile/";
215 237
216 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( 238 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
217 BrowserKind browser, const wchar_t* page, const char* result) { 239 BrowserKind browser, const wchar_t* page, const char* result) {
218 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 240 int tries = 0;
219 kPostedResultSubstring); 241 ExpectAndHandlePostedResult();
220 ASSERT_TRUE(LaunchBrowser(browser, page)); 242 // Retry tests that timeout once; see http://crbug.com/96449.
221 WaitForTestToComplete(TestTimeouts::action_max_timeout()); 243 do {
222 ASSERT_EQ(result, server_mock_.posted_result()); 244 // NOTE: Failed ASSERTs cause this function to exit immediately.
245 // Don't take a snapshot on the first try.
246 loop().set_snapshot_on_timeout(tries != 0);
247 ASSERT_TRUE(LaunchBrowser(browser, page));
248 if (WaitForTestToComplete(TestTimeouts::action_max_timeout())) {
249 // The test exited without timing out. Confirm that the expected response
250 // was posted and return.
251 ASSERT_EQ(result, server_mock().posted_result());
252 break;
253 }
254 ASSERT_EQ(std::string(), server_mock().posted_result())
255 << "Test timed out yet provided a result.";
256 ASSERT_EQ(0, tries++) << "Failing test due to two timeouts.";
257 // Close the browser and try a second time.
258 CloseBrowser();
259 LOG(ERROR) << "Retrying test once since it timed out.";
260 } while (true);
261 loop().set_snapshot_on_timeout(true);
223 } 262 }
224 263
225 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, 264 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
226 const wchar_t* page) { 265 const wchar_t* page) {
227 SimpleBrowserTestExpectedResult(browser, page, "OK"); 266 SimpleBrowserTestExpectedResult(browser, page, "OK");
228 } 267 }
229 268
269 void ChromeFrameTestWithWebServer::ExpectAndHandlePostedResult() {
270 EXPECT_CALL(listener_mock(), OnExpectedResponse())
271 .WillRepeatedly(QUIT_LOOP_SOON(loop(),
272 base::TimeDelta::FromMilliseconds(100)));
273 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
274 kPostedResultSubstring);
275 }
276
230 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, 277 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
231 const wchar_t* page) { 278 const wchar_t* page) {
232 FilePath plugin_path; 279 FilePath plugin_path;
233 PathService::Get(base::DIR_MODULE, &plugin_path); 280 PathService::Get(base::DIR_MODULE, &plugin_path);
234 plugin_path = plugin_path.Append(kChromeFrameDllName); 281 plugin_path = plugin_path.Append(kChromeFrameDllName);
235 282
236 static FileVersionInfo* version_info = 283 static FileVersionInfo* version_info =
237 FileVersionInfo::CreateFileVersionInfo(plugin_path); 284 FileVersionInfo::CreateFileVersionInfo(plugin_path);
238 285
239 std::wstring version; 286 std::wstring version;
(...skipping 11 matching lines...) Expand all
251 bool system_install = ver_system.get() ? true : false; 298 bool system_install = ver_system.get() ? true : false;
252 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); 299 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist));
253 cf_dll_path = cf_dll_path.Append(UTF8ToWide( 300 cf_dll_path = cf_dll_path.Append(UTF8ToWide(
254 ver_system.get() ? ver_system->GetString() : ver_user->GetString())); 301 ver_system.get() ? ver_system->GetString() : ver_user->GetString()));
255 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); 302 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName);
256 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); 303 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path);
257 if (version_info) 304 if (version_info)
258 version = version_info->product_version(); 305 version = version_info->product_version();
259 } 306 }
260 307
261 server_mock_.set_expected_result(WideToUTF8(version)); 308 server_mock().set_expected_result(WideToUTF8(version));
262 309
263 EXPECT_TRUE(version_info); 310 EXPECT_TRUE(version_info);
264 EXPECT_FALSE(version.empty()); 311 EXPECT_FALSE(version.empty());
265 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 312
266 kPostedResultSubstring); 313 SimpleBrowserTestExpectedResult(browser, page, WideToASCII(version).c_str());
267 EXPECT_TRUE(LaunchBrowser(browser, page));
268 WaitForTestToComplete(TestTimeouts::action_max_timeout());
269 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result()));
270 } 314 }
271 315
272 // MockWebServer methods 316 // MockWebServer methods
273 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, 317 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation,
274 const std::wstring& url) { 318 const std::wstring& url) {
275 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); 319 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1));
276 } 320 }
277 321
278 void MockWebServer::ExpectAndServeRequestWithCardinality( 322 void MockWebServer::ExpectAndServeRequestWithCardinality(
279 CFInvocation invocation, const std::wstring& url, 323 CFInvocation invocation, const std::wstring& url,
(...skipping 18 matching lines...) Expand all
298 void MockWebServer::ExpectAndHandlePostedResult( 342 void MockWebServer::ExpectAndHandlePostedResult(
299 CFInvocation invocation, const std::wstring& post_suffix) { 343 CFInvocation invocation, const std::wstring& post_suffix) {
300 EXPECT_CALL(*this, Post(_, testing::HasSubstr(post_suffix), _)) 344 EXPECT_CALL(*this, Post(_, testing::HasSubstr(post_suffix), _))
301 .WillRepeatedly(HandlePostedResponseHelper(this, invocation)); 345 .WillRepeatedly(HandlePostedResponseHelper(this, invocation));
302 } 346 }
303 347
304 void MockWebServer::HandlePostedResponse( 348 void MockWebServer::HandlePostedResponse(
305 test_server::ConfigurableConnection* connection, 349 test_server::ConfigurableConnection* connection,
306 const test_server::Request& request) { 350 const test_server::Request& request) {
307 posted_result_ = request.content(); 351 posted_result_ = request.content();
308 if (posted_result_ == expected_result_) { 352 if (listener_ && posted_result_ == expected_result_)
309 MessageLoop::current()->PostDelayedTask(FROM_HERE, 353 listener_->OnExpectedResponse();
310 MessageLoop::QuitClosure(),
311 100);
312 }
313 connection->Send("HTTP/1.1 200 OK\r\n", ""); 354 connection->Send("HTTP/1.1 200 OK\r\n", "");
314 } 355 }
315 356
316 void MockWebServer::SendResponseHelper( 357 void MockWebServer::SendResponseHelper(
317 test_server::ConfigurableConnection* connection, 358 test_server::ConfigurableConnection* connection,
318 const std::wstring& request_uri, 359 const std::wstring& request_uri,
319 const test_server::Request& request, 360 const test_server::Request& request,
320 CFInvocation invocation, 361 CFInvocation invocation,
321 bool add_no_cache_header) { 362 bool add_no_cache_header) {
322 static const wchar_t kEchoHeader[] = L"/echoheader?"; 363 static const wchar_t kEchoHeader[] = L"/echoheader?";
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 } 460 }
420 461
421 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html"; 462 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html";
422 463
423 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { 464 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) {
424 SimpleBrowserTest(IE, kiframeBasicPage); 465 SimpleBrowserTest(IE, kiframeBasicPage);
425 } 466 }
426 467
427 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html"; 468 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html";
428 469
429 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_SrcProperty) { 470 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) {
430 SimpleBrowserTest(IE, kSrcPropertyTestPage); 471 SimpleBrowserTest(IE, kSrcPropertyTestPage);
431 } 472 }
432 473
433 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html"; 474 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html";
434 475
435 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) { 476 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) {
436 SimpleBrowserTest(IE, kCFInstanceBasicTestPage); 477 SimpleBrowserTest(IE, kCFInstanceBasicTestPage);
437 } 478 }
438 479
439 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html"; 480 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html";
440 481
441 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) { 482 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) {
442 SimpleBrowserTest(IE, kCFISingletonPage); 483 SimpleBrowserTest(IE, kCFISingletonPage);
443 } 484 }
444 485
445 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html"; 486 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html";
446 487
447 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceDelay) { 488 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDelay) {
448 SimpleBrowserTest(IE, kCFIDelayPage); 489 SimpleBrowserTest(IE, kCFIDelayPage);
449 } 490 }
450 491
451 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html"; 492 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html";
452 493
453 // http://crbug.com/37088 494 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceFallback) {
454 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceFallback) {
455 SimpleBrowserTest(IE, kCFIFallbackPage); 495 SimpleBrowserTest(IE, kCFIFallbackPage);
456 } 496 }
457 497
458 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html"; 498 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html";
459 499
460 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) { 500 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) {
461 SimpleBrowserTest(IE, kCFINoSrcPage); 501 SimpleBrowserTest(IE, kCFINoSrcPage);
462 } 502 }
463 503
464 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html"; 504 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html";
465 505
466 // disabled since it's unlikely that we care about this case 506 // disabled since it's unlikely that we care about this case
467 TEST_F(ChromeFrameTestWithWebServer, 507 TEST_F(ChromeFrameTestWithWebServer,
468 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) { 508 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) {
469 SimpleBrowserTest(IE, kCFIIfrOnLoadPage); 509 SimpleBrowserTest(IE, kCFIIfrOnLoadPage);
470 } 510 }
471 511
472 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html"; 512 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html";
473 513
474 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) { 514 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) {
475 SimpleBrowserTest(IE, kCFIZeroSizePage); 515 SimpleBrowserTest(IE, kCFIZeroSizePage);
476 } 516 }
477 517
478 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html"; 518 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html";
479 519
480 // http://crbug.com/32321 520 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceIfrPost) {
481 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceIfrPost) {
482 SimpleBrowserTest(IE, kCFIIfrPostPage); 521 SimpleBrowserTest(IE, kCFIIfrPostPage);
483 } 522 }
484 523
485 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) { 524 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) {
486 SimpleBrowserTest(CHROME, kCFIIfrPostPage); 525 SimpleBrowserTest(CHROME, kCFIIfrPostPage);
487 } 526 }
488 527
489 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html"; 528 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html";
490 529
491 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) { 530 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) {
492 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 531 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
493 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 532 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
494 return; 533 return;
495 } 534 }
496 SimpleBrowserTest(IE, kCFIPostPage); 535 SimpleBrowserTest(IE, kCFIPostPage);
497 } 536 }
498 537
499 // This test randomly fails on the ChromeFrame builder. 538 // This test randomly fails on the ChromeFrame builder.
500 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) { 539 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) {
501 SimpleBrowserTest(CHROME, kCFIPostPage); 540 SimpleBrowserTest(CHROME, kCFIPostPage);
502 } 541 }
503 542
504 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html"; 543 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html";
505 544
506 // This test consistently times out in debug builds; see http://crbug.com/112599 545 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) {
507 #ifndef NDEBUG
508 #define MAYBE_WidgetModeIE_CFInstanceRPC DISABLED_WidgetModeIE_CFInstanceRPC
509 #else
510 #define MAYBE_WidgetModeIE_CFInstanceRPC WidgetModeIE_CFInstanceRPC
511 #endif
512
513 TEST_F(ChromeFrameTestWithWebServer, MAYBE_WidgetModeIE_CFInstanceRPC) {
514 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 546 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
515 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 547 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
516 return; 548 return;
517 } 549 }
518 SimpleBrowserTest(IE, kCFIRPCPage); 550 SimpleBrowserTest(IE, kCFIRPCPage);
519 } 551 }
520 552
521 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) { 553 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) {
522 SimpleBrowserTest(CHROME, kCFIRPCPage); 554 SimpleBrowserTest(CHROME, kCFIRPCPage);
523 } 555 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 L"install_flow_test.html"; 695 L"install_flow_test.html";
664 696
665 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { 697 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) {
666 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 698 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
667 ScopedChromeFrameRegistrar::UnregisterAtPath( 699 ScopedChromeFrameRegistrar::UnregisterAtPath(
668 GetChromeFrameBuildPath().value(), 700 GetChromeFrameBuildPath().value(),
669 chrome_frame_test::GetTestBedType()); 701 chrome_frame_test::GetTestBedType());
670 702
671 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); 703 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl));
672 704
673 loop_.RunFor(kChromeFrameLongNavigationTimeout); 705 loop().RunFor(kChromeFrameLongNavigationTimeout);
674 706
675 ScopedChromeFrameRegistrar::RegisterAtPath( 707 ScopedChromeFrameRegistrar::RegisterAtPath(
676 GetChromeFrameBuildPath().value(), 708 GetChromeFrameBuildPath().value(),
677 chrome_frame_test::GetTestBedType()); 709 chrome_frame_test::GetTestBedType());
678 710
679 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 711 ExpectAndHandlePostedResult();
680 kPostedResultSubstring); 712 loop().RunFor(kChromeFrameLongNavigationTimeout);
681 loop_.RunFor(kChromeFrameLongNavigationTimeout);
682 713
683 chrome_frame_test::CloseAllIEWindows(); 714 chrome_frame_test::CloseAllIEWindows();
684 ASSERT_EQ("OK", server_mock_.posted_result()); 715 ASSERT_EQ("OK", server_mock().posted_result());
685 } 716 }
686 } 717 }
687 718
688 const wchar_t kMultipleCFInstancesTestUrl[] = 719 const wchar_t kMultipleCFInstancesTestUrl[] =
689 L"multiple_cf_instances_main.html"; 720 L"multiple_cf_instances_main.html";
690 721
691 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { 722 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) {
692 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl); 723 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl);
693 } 724 }
694 725
(...skipping 27 matching lines...) Expand all
722 L"full_tab_post_target_cf.html", 753 L"full_tab_post_target_cf.html",
723 L"chrome_frame_tester_helpers.js", 754 L"chrome_frame_tester_helpers.js",
724 }; 755 };
725 756
726 SimpleWebServerTest server(46664); 757 SimpleWebServerTest server(46664);
727 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 758 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
728 arraysize(kPages), GetCFTestFilePath()); 759 arraysize(kPages), GetCFTestFilePath());
729 760
730 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 761 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
731 762
732 loop_.RunFor(kChromeFrameLongNavigationTimeout); 763 loop().RunFor(kChromeFrameLongNavigationTimeout);
733 764
734 const test_server::Request* request = NULL; 765 const test_server::Request* request = NULL;
735 server.FindRequest("/quit?OK", &request); 766 server.FindRequest("/quit?OK", &request);
736 ASSERT_TRUE(request != NULL); 767 ASSERT_TRUE(request != NULL);
737 EXPECT_EQ("OK", request->arguments()); 768 EXPECT_EQ("OK", request->arguments());
738 769
739 if (request->arguments().compare("OK") == 0) { 770 if (request->arguments().compare("OK") == 0) {
740 // Check how many requests we got for the cf page. Also expect it to be 771 // Check how many requests we got for the cf page. Also expect it to be
741 // a POST. 772 // a POST.
742 int requests = server.GetRequestCountForPage(kPages[1], "POST"); 773 int requests = server.GetRequestCountForPage(kPages[1], "POST");
(...skipping 11 matching lines...) Expand all
754 L"chrome_frame_tester_helpers.js", 785 L"chrome_frame_tester_helpers.js",
755 }; 786 };
756 787
757 SimpleWebServerTest server(46664); 788 SimpleWebServerTest server(46664);
758 789
759 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 790 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
760 arraysize(kPages), GetCFTestFilePath()); 791 arraysize(kPages), GetCFTestFilePath());
761 792
762 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 793 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
763 794
764 loop_.RunFor(kChromeFrameVeryLongNavigationTimeout); 795 loop().RunFor(kChromeFrameVeryLongNavigationTimeout);
765 796
766 const test_server::Request* request = NULL; 797 const test_server::Request* request = NULL;
767 server.FindRequest("/quit?OK", &request); 798 server.FindRequest("/quit?OK", &request);
768 ASSERT_TRUE(request != NULL); 799 ASSERT_TRUE(request != NULL);
769 EXPECT_EQ("OK", request->arguments()); 800 EXPECT_EQ("OK", request->arguments());
770 801
771 if (request->arguments().compare("OK") == 0) { 802 if (request->arguments().compare("OK") == 0) {
772 // Check how many requests we got for the cf page and check that it was 803 // Check how many requests we got for the cf page and check that it was
773 // a GET. 804 // a GET.
774 int requests = server.GetRequestCountForPage(kPages[1], "GET"); 805 int requests = server.GetRequestCountForPage(kPages[1], "GET");
(...skipping 11 matching lines...) Expand all
786 const wchar_t kXHRConditionalHeaderTestUrl[] = 817 const wchar_t kXHRConditionalHeaderTestUrl[] =
787 L"xmlhttprequest_conditional_header_test.html"; 818 L"xmlhttprequest_conditional_header_test.html";
788 819
789 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { 820 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) {
790 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl); 821 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl);
791 } 822 }
792 823
793 const wchar_t kWindowCloseTestUrl[] = 824 const wchar_t kWindowCloseTestUrl[] =
794 L"window_close.html"; 825 L"window_close.html";
795 826
796 // http://code.google.com/p/chromium/issues/detail?id=111074 827 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) {
797 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowClose) {
798 SimpleBrowserTest(IE, kWindowCloseTestUrl); 828 SimpleBrowserTest(IE, kWindowCloseTestUrl);
799 } 829 }
800 830
801 std::string GetHeaderValue(const std::string& headers, 831 std::string GetHeaderValue(const std::string& headers,
802 const char* header_name) { 832 const char* header_name) {
803 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), 833 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(),
804 "\r\n"); 834 "\r\n");
805 while (it.GetNext()) { 835 while (it.GetNext()) {
806 if (lstrcmpiA(it.name().c_str(), header_name) == 0) { 836 if (lstrcmpiA(it.name().c_str(), header_name) == 0) {
807 return it.values(); 837 return it.values();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
872 L"mshtml_refresh_test.html", 902 L"mshtml_refresh_test.html",
873 L"mshtml_refresh_test_popup.html", 903 L"mshtml_refresh_test_popup.html",
874 }; 904 };
875 905
876 SimpleWebServerTest server(46664); 906 SimpleWebServerTest server(46664);
877 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, 907 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages,
878 arraysize(kPages), GetCFTestFilePath()); 908 arraysize(kPages), GetCFTestFilePath());
879 909
880 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 910 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
881 911
882 loop_.RunFor(kChromeFrameLongNavigationTimeout); 912 loop().RunFor(kChromeFrameLongNavigationTimeout);
883 913
884 test_server::SimpleWebServer* ws = server.web_server(); 914 test_server::SimpleWebServer* ws = server.web_server();
885 const test_server::ConnectionList& connections = ws->connections(); 915 const test_server::ConnectionList& connections = ws->connections();
886 test_server::ConnectionList::const_iterator it = connections.begin(); 916 test_server::ConnectionList::const_iterator it = connections.begin();
887 int requests_for_first_page = 0; 917 int requests_for_first_page = 0;
888 for (; it != connections.end(); ++it) { 918 for (; it != connections.end(); ++it) {
889 test_server::Connection* c = (*it); 919 test_server::Connection* c = (*it);
890 const test_server::Request& r = c->request(); 920 const test_server::Request& r = c->request();
891 if (!r.path().empty() && 921 if (!r.path().empty() &&
892 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { 922 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 size_t post_requests_; 1034 size_t post_requests_;
1005 size_t get_requests_; 1035 size_t get_requests_;
1006 }; 1036 };
1007 1037
1008 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) 1038 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
1009 .Times(testing::AtMost(1)) 1039 .Times(testing::AtMost(1))
1010 .WillOnce(chrome_frame_test::DoCloseWindow()); 1040 .WillOnce(chrome_frame_test::DoCloseWindow());
1011 1041
1012 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) 1042 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
1013 .Times(testing::AtMost(1)) 1043 .Times(testing::AtMost(1))
1014 .WillOnce(QUIT_LOOP(loop_)); 1044 .WillOnce(QUIT_LOOP(loop()));
1015 1045
1016 SimpleWebServerTest server(46664); 1046 SimpleWebServerTest server(46664);
1017 CustomResponse* response = new CustomResponse("/form.html"); 1047 CustomResponse* response = new CustomResponse("/form.html");
1018 server.web_server()->AddResponse(response); 1048 server.web_server()->AddResponse(response);
1019 1049
1020 std::wstring url(server.FormatHttpPath(L"form.html")); 1050 std::wstring url(server.FormatHttpPath(L"form.html"));
1021 1051
1022 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); 1052 ASSERT_TRUE(LaunchBrowser(IE, url.c_str()));
1023 loop_.RunFor(kChromeFrameLongNavigationTimeout); 1053 loop().RunFor(kChromeFrameLongNavigationTimeout);
1024 1054
1025 EXPECT_EQ(1, response->get_request_count()); 1055 EXPECT_EQ(1, response->get_request_count());
1026 EXPECT_EQ(1, response->post_request_count()); 1056 EXPECT_EQ(1, response->post_request_count());
1027 } 1057 }
OLDNEW
« no previous file with comments | « 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