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

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: 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<MockWebServer>* ChromeFrameTestWithWebServer::server_mock_;
77 81
78 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() 82 ChromeFrameTestWithWebServer::ChromeFrameTestWithWebServer() {
79 : loop_(),
80 server_mock_(1337, L"127.0.0.1",
81 chrome_frame_test::GetTestDataFolder()) {
82 } 83 }
83 84
84 // static 85 // static
85 void ChromeFrameTestWithWebServer::SetUpTestCase() { 86 void ChromeFrameTestWithWebServer::SetUpTestCase() {
86 FilePath chrome_frame_source_path; 87 FilePath chrome_frame_source_path;
87 PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path); 88 PathService::Get(base::DIR_SOURCE_ROOT, &chrome_frame_source_path);
88 chrome_frame_source_path = chrome_frame_source_path.Append( 89 chrome_frame_source_path = chrome_frame_source_path.Append(
89 FILE_PATH_LITERAL("chrome_frame")); 90 FILE_PATH_LITERAL("chrome_frame"));
90 91
91 test_file_path_ = chrome_frame_source_path 92 test_file_path_ = chrome_frame_source_path
92 .Append(FILE_PATH_LITERAL("test")) 93 .Append(FILE_PATH_LITERAL("test"))
93 .Append(FILE_PATH_LITERAL("data")); 94 .Append(FILE_PATH_LITERAL("data"));
94 95
95 results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump"); 96 results_dir_ = chrome_frame_test::GetTestDataFolder().AppendASCII("dump");
96 97
97 // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to 98 // Copy the CFInstance.js and CFInstall.js files from src\chrome_frame to
98 // src\chrome_frame\test\data. 99 // src\chrome_frame\test\data.
99 FilePath CFInstance_src_path; 100 FilePath CFInstance_src_path;
100 FilePath CFInstall_src_path; 101 FilePath CFInstall_src_path;
101 102
102 CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js"); 103 CFInstance_src_path = chrome_frame_source_path.AppendASCII("CFInstance.js");
103 CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js"); 104 CFInstance_path_ = test_file_path_.AppendASCII("CFInstance.js");
104 105
105 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_)); 106 ASSERT_TRUE(file_util::CopyFile(CFInstance_src_path, CFInstance_path_));
106 107
107 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js"); 108 CFInstall_src_path = chrome_frame_source_path.AppendASCII("CFInstall.js");
108 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js"); 109 CFInstall_path_ = test_file_path_.AppendASCII("CFInstall.js");
109 110
110 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_)); 111 ASSERT_TRUE(file_util::CopyFile(CFInstall_src_path, CFInstall_path_));
112
113 loop_ = new chrome_frame_test::TimedMsgLoop();
114 server_mock_ = new testing::StrictMock<MockWebServer>(
115 1337, L"127.0.0.1", chrome_frame_test::GetTestDataFolder());
robertshield 2012/04/06 21:16:14 I wonder if Erik's code to listen on one of the ac
grt (UTC plus 2) 2012/04/09 14:02:39 Good suggestion. I tried it out and it didn't hel
111 } 116 }
112 117
113 // static 118 // static
114 void ChromeFrameTestWithWebServer::TearDownTestCase() { 119 void ChromeFrameTestWithWebServer::TearDownTestCase() {
120 delete server_mock_;
121 server_mock_ = NULL;
122 delete loop_;
123 loop_ = NULL;
115 file_util::Delete(CFInstall_path_, false); 124 file_util::Delete(CFInstall_path_, false);
116 file_util::Delete(CFInstance_path_, false); 125 file_util::Delete(CFInstance_path_, false);
117 EXPECT_TRUE(temp_dir_.Delete()); 126 if (temp_dir_.IsValid())
127 EXPECT_TRUE(temp_dir_.Delete());
118 } 128 }
119 129
120 // static 130 // static
121 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() { 131 const FilePath& ChromeFrameTestWithWebServer::GetChromeUserDataDirectory() {
122 if (!temp_dir_.IsValid()) { 132 if (!temp_dir_.IsValid()) {
123 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir()); 133 EXPECT_TRUE(temp_dir_.CreateUniqueTempDir());
124 chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data"); 134 chrome_user_data_dir_ = temp_dir_.path().AppendASCII("User Data");
125 } 135 }
126 return chrome_user_data_dir_; 136 return chrome_user_data_dir_;
127 } 137 }
128 138
129 void ChromeFrameTestWithWebServer::SetUp() { 139 void ChromeFrameTestWithWebServer::SetUp() {
130 // Make sure that we are not accidentally enabling gcf protocol. 140 // Make sure that we are not accidentally enabling gcf protocol.
131 SetConfigBool(kAllowUnsafeURLs, false); 141 SetConfigBool(kAllowUnsafeURLs, false);
132 142
133 server_mock_.ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE)); 143 server_mock().ClearResults();
134 server_mock_.set_expected_result("OK"); 144 server_mock().ExpectAndServeAnyRequests(CFInvocation(CFInvocation::NONE));
145 server_mock().set_expected_result("OK");
135 } 146 }
136 147
137 void ChromeFrameTestWithWebServer::TearDown() { 148 void ChromeFrameTestWithWebServer::TearDown() {
138 CloseBrowser(); 149 CloseBrowser();
150 loop().RunAllPending();
151 testing::Mock::VerifyAndClear(server_mock_);
139 } 152 }
140 153
141 bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser, 154 bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser,
142 const wchar_t* page) { 155 const wchar_t* page) {
143 std::wstring url = page; 156 std::wstring url = page;
144 157
145 // We should resolve the URL only if it is a relative url. 158 // We should resolve the URL only if it is a relative url.
146 GURL parsed_url(WideToUTF8(page)); 159 GURL parsed_url(WideToUTF8(page));
147 if (!parsed_url.has_scheme()) { 160 if (!parsed_url.has_scheme()) {
148 url = server_mock_.Resolve(page); 161 url = server_mock().Resolve(page);
149 } 162 }
150 163
151 browser_ = browser; 164 browser_ = browser;
152 if (browser == IE) { 165 if (browser == IE) {
153 browser_handle_.Set(chrome_frame_test::LaunchIE(url)); 166 browser_handle_.Set(chrome_frame_test::LaunchIE(url));
154 } else if (browser == CHROME) { 167 } else if (browser == CHROME) {
155 const FilePath& user_data_dir = GetChromeUserDataDirectory(); 168 const FilePath& user_data_dir = GetChromeUserDataDirectory();
156 chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value()); 169 chrome_frame_test::OverrideDataDirectoryForThisTest(user_data_dir.value());
157 browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir)); 170 browser_handle_.Set(chrome_frame_test::LaunchChrome(url, user_data_dir));
158 } else { 171 } else {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 browser_handle_.Close(); 208 browser_handle_.Close();
196 } 209 }
197 } 210 }
198 211
199 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { 212 bool ChromeFrameTestWithWebServer::BringBrowserToTop() {
200 return simulate_input::EnsureProcessInForeground( 213 return simulate_input::EnsureProcessInForeground(
201 GetProcessId(browser_handle_)); 214 GetProcessId(browser_handle_));
202 } 215 }
203 216
204 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { 217 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) {
205 loop_.RunFor(milliseconds/1000); 218 loop().RunFor(milliseconds/1000);
206 return true; 219 return true;
207 } 220 }
208 221
209 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { 222 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) {
210 return false; 223 return false;
211 } 224 }
212 225
213 const wchar_t kPostedResultSubstring[] = L"/writefile/"; 226 const wchar_t kPostedResultSubstring[] = L"/writefile/";
214 227
215 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( 228 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
216 BrowserKind browser, const wchar_t* page, const char* result) { 229 BrowserKind browser, const wchar_t* page, const char* result) {
217 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 230 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
218 kPostedResultSubstring); 231 kPostedResultSubstring);
219 ASSERT_TRUE(LaunchBrowser(browser, page)); 232 ASSERT_TRUE(LaunchBrowser(browser, page));
220 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 233 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
221 ASSERT_EQ(result, server_mock_.posted_result()); 234 ASSERT_EQ(result, server_mock().posted_result());
222 } 235 }
223 236
224 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, 237 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
225 const wchar_t* page) { 238 const wchar_t* page) {
226 SimpleBrowserTestExpectedResult(browser, page, "OK"); 239 SimpleBrowserTestExpectedResult(browser, page, "OK");
227 } 240 }
228 241
229 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, 242 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
230 const wchar_t* page) { 243 const wchar_t* page) {
231 FilePath plugin_path; 244 FilePath plugin_path;
(...skipping 18 matching lines...) Expand all
250 bool system_install = ver_system.get() ? true : false; 263 bool system_install = ver_system.get() ? true : false;
251 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); 264 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist));
252 cf_dll_path = cf_dll_path.Append(UTF8ToWide( 265 cf_dll_path = cf_dll_path.Append(UTF8ToWide(
253 ver_system.get() ? ver_system->GetString() : ver_user->GetString())); 266 ver_system.get() ? ver_system->GetString() : ver_user->GetString()));
254 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); 267 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName);
255 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); 268 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path);
256 if (version_info) 269 if (version_info)
257 version = version_info->product_version(); 270 version = version_info->product_version();
258 } 271 }
259 272
260 server_mock_.set_expected_result(WideToUTF8(version)); 273 server_mock().set_expected_result(WideToUTF8(version));
261 274
262 EXPECT_TRUE(version_info); 275 EXPECT_TRUE(version_info);
263 EXPECT_FALSE(version.empty()); 276 EXPECT_FALSE(version.empty());
264 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 277 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
265 kPostedResultSubstring); 278 kPostedResultSubstring);
266 EXPECT_TRUE(LaunchBrowser(browser, page)); 279 EXPECT_TRUE(LaunchBrowser(browser, page));
267 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 280 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
268 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result())); 281 ASSERT_EQ(version, UTF8ToWide(server_mock().posted_result()));
269 } 282 }
270 283
271 // MockWebServer methods 284 // MockWebServer methods
272 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, 285 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation,
273 const std::wstring& url) { 286 const std::wstring& url) {
274 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); 287 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1));
275 } 288 }
276 289
277 void MockWebServer::ExpectAndServeRequestWithCardinality( 290 void MockWebServer::ExpectAndServeRequestWithCardinality(
278 CFInvocation invocation, const std::wstring& url, 291 CFInvocation invocation, const std::wstring& url,
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 431 }
419 432
420 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html"; 433 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html";
421 434
422 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { 435 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) {
423 SimpleBrowserTest(IE, kiframeBasicPage); 436 SimpleBrowserTest(IE, kiframeBasicPage);
424 } 437 }
425 438
426 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html"; 439 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html";
427 440
428 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_SrcProperty) { 441 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) {
429 SimpleBrowserTest(IE, kSrcPropertyTestPage); 442 SimpleBrowserTest(IE, kSrcPropertyTestPage);
430 } 443 }
431 444
432 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html"; 445 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html";
433 446
434 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) { 447 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) {
435 SimpleBrowserTest(IE, kCFInstanceBasicTestPage); 448 SimpleBrowserTest(IE, kCFInstanceBasicTestPage);
436 } 449 }
437 450
438 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html"; 451 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html";
439 452
440 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) { 453 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) {
441 SimpleBrowserTest(IE, kCFISingletonPage); 454 SimpleBrowserTest(IE, kCFISingletonPage);
442 } 455 }
443 456
444 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html"; 457 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html";
445 458
446 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceDelay) { 459 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDelay) {
447 SimpleBrowserTest(IE, kCFIDelayPage); 460 SimpleBrowserTest(IE, kCFIDelayPage);
448 } 461 }
449 462
450 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html"; 463 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html";
451 464
452 // http://crbug.com/37088 465 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceFallback) {
453 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceFallback) {
454 SimpleBrowserTest(IE, kCFIFallbackPage); 466 SimpleBrowserTest(IE, kCFIFallbackPage);
455 } 467 }
456 468
457 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html"; 469 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html";
458 470
459 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) { 471 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) {
460 SimpleBrowserTest(IE, kCFINoSrcPage); 472 SimpleBrowserTest(IE, kCFINoSrcPage);
461 } 473 }
462 474
463 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html"; 475 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html";
464 476
465 // disabled since it's unlikely that we care about this case 477 // disabled since it's unlikely that we care about this case
466 TEST_F(ChromeFrameTestWithWebServer, 478 TEST_F(ChromeFrameTestWithWebServer,
467 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) { 479 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) {
468 SimpleBrowserTest(IE, kCFIIfrOnLoadPage); 480 SimpleBrowserTest(IE, kCFIIfrOnLoadPage);
469 } 481 }
470 482
471 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html"; 483 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html";
472 484
473 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) { 485 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) {
474 SimpleBrowserTest(IE, kCFIZeroSizePage); 486 SimpleBrowserTest(IE, kCFIZeroSizePage);
475 } 487 }
476 488
477 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html"; 489 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html";
478 490
479 // http://crbug.com/32321 491 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceIfrPost) {
480 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceIfrPost) {
481 SimpleBrowserTest(IE, kCFIIfrPostPage); 492 SimpleBrowserTest(IE, kCFIIfrPostPage);
482 } 493 }
483 494
484 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) { 495 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) {
485 SimpleBrowserTest(CHROME, kCFIIfrPostPage); 496 SimpleBrowserTest(CHROME, kCFIIfrPostPage);
486 } 497 }
487 498
488 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html"; 499 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html";
489 500
490 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) { 501 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) {
491 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 502 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
492 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 503 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
493 return; 504 return;
494 } 505 }
495 SimpleBrowserTest(IE, kCFIPostPage); 506 SimpleBrowserTest(IE, kCFIPostPage);
496 } 507 }
497 508
498 // This test randomly fails on the ChromeFrame builder. 509 // This test randomly fails on the ChromeFrame builder.
499 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) { 510 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) {
500 SimpleBrowserTest(CHROME, kCFIPostPage); 511 SimpleBrowserTest(CHROME, kCFIPostPage);
501 } 512 }
502 513
503 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html"; 514 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html";
504 515
505 // This test consistently times out in debug builds; see http://crbug.com/112599 516 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) {
506 #ifndef NDEBUG
507 #define MAYBE_WidgetModeIE_CFInstanceRPC DISABLED_WidgetModeIE_CFInstanceRPC
508 #else
509 #define MAYBE_WidgetModeIE_CFInstanceRPC WidgetModeIE_CFInstanceRPC
510 #endif
511
512 TEST_F(ChromeFrameTestWithWebServer, MAYBE_WidgetModeIE_CFInstanceRPC) {
513 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 517 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
514 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 518 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
515 return; 519 return;
516 } 520 }
517 SimpleBrowserTest(IE, kCFIRPCPage); 521 SimpleBrowserTest(IE, kCFIRPCPage);
518 } 522 }
519 523
520 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) { 524 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) {
521 SimpleBrowserTest(CHROME, kCFIRPCPage); 525 SimpleBrowserTest(CHROME, kCFIRPCPage);
522 } 526 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 L"install_flow_test.html"; 666 L"install_flow_test.html";
663 667
664 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { 668 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) {
665 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 669 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
666 ScopedChromeFrameRegistrar::UnregisterAtPath( 670 ScopedChromeFrameRegistrar::UnregisterAtPath(
667 GetChromeFrameBuildPath().value(), 671 GetChromeFrameBuildPath().value(),
668 chrome_frame_test::GetTestBedType()); 672 chrome_frame_test::GetTestBedType());
669 673
670 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); 674 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl));
671 675
672 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 676 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
673 677
674 ScopedChromeFrameRegistrar::RegisterAtPath( 678 ScopedChromeFrameRegistrar::RegisterAtPath(
675 GetChromeFrameBuildPath().value(), 679 GetChromeFrameBuildPath().value(),
676 chrome_frame_test::GetTestBedType()); 680 chrome_frame_test::GetTestBedType());
677 681
678 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 682 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
679 kPostedResultSubstring); 683 kPostedResultSubstring);
680 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 684 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
681 685
682 chrome_frame_test::CloseAllIEWindows(); 686 chrome_frame_test::CloseAllIEWindows();
683 ASSERT_EQ("OK", server_mock_.posted_result()); 687 ASSERT_EQ("OK", server_mock().posted_result());
684 } 688 }
685 } 689 }
686 690
687 const wchar_t kMultipleCFInstancesTestUrl[] = 691 const wchar_t kMultipleCFInstancesTestUrl[] =
688 L"multiple_cf_instances_main.html"; 692 L"multiple_cf_instances_main.html";
689 693
690 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { 694 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) {
691 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl); 695 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl);
692 } 696 }
693 697
(...skipping 27 matching lines...) Expand all
721 L"full_tab_post_target_cf.html", 725 L"full_tab_post_target_cf.html",
722 L"chrome_frame_tester_helpers.js", 726 L"chrome_frame_tester_helpers.js",
723 }; 727 };
724 728
725 SimpleWebServerTest server(46664); 729 SimpleWebServerTest server(46664);
726 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 730 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
727 arraysize(kPages), GetCFTestFilePath()); 731 arraysize(kPages), GetCFTestFilePath());
728 732
729 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 733 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
730 734
731 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 735 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
732 736
733 const test_server::Request* request = NULL; 737 const test_server::Request* request = NULL;
734 server.FindRequest("/quit?OK", &request); 738 server.FindRequest("/quit?OK", &request);
735 ASSERT_TRUE(request != NULL); 739 ASSERT_TRUE(request != NULL);
736 EXPECT_EQ("OK", request->arguments()); 740 EXPECT_EQ("OK", request->arguments());
737 741
738 if (request->arguments().compare("OK") == 0) { 742 if (request->arguments().compare("OK") == 0) {
739 // Check how many requests we got for the cf page. Also expect it to be 743 // Check how many requests we got for the cf page. Also expect it to be
740 // a POST. 744 // a POST.
741 int requests = server.GetRequestCountForPage(kPages[1], "POST"); 745 int requests = server.GetRequestCountForPage(kPages[1], "POST");
(...skipping 11 matching lines...) Expand all
753 L"chrome_frame_tester_helpers.js", 757 L"chrome_frame_tester_helpers.js",
754 }; 758 };
755 759
756 SimpleWebServerTest server(46664); 760 SimpleWebServerTest server(46664);
757 761
758 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 762 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
759 arraysize(kPages), GetCFTestFilePath()); 763 arraysize(kPages), GetCFTestFilePath());
760 764
761 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 765 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
762 766
763 loop_.RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds); 767 loop().RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds);
764 768
765 const test_server::Request* request = NULL; 769 const test_server::Request* request = NULL;
766 server.FindRequest("/quit?OK", &request); 770 server.FindRequest("/quit?OK", &request);
767 ASSERT_TRUE(request != NULL); 771 ASSERT_TRUE(request != NULL);
768 EXPECT_EQ("OK", request->arguments()); 772 EXPECT_EQ("OK", request->arguments());
769 773
770 if (request->arguments().compare("OK") == 0) { 774 if (request->arguments().compare("OK") == 0) {
771 // Check how many requests we got for the cf page and check that it was 775 // Check how many requests we got for the cf page and check that it was
772 // a GET. 776 // a GET.
773 int requests = server.GetRequestCountForPage(kPages[1], "GET"); 777 int requests = server.GetRequestCountForPage(kPages[1], "GET");
(...skipping 11 matching lines...) Expand all
785 const wchar_t kXHRConditionalHeaderTestUrl[] = 789 const wchar_t kXHRConditionalHeaderTestUrl[] =
786 L"xmlhttprequest_conditional_header_test.html"; 790 L"xmlhttprequest_conditional_header_test.html";
787 791
788 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { 792 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) {
789 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl); 793 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl);
790 } 794 }
791 795
792 const wchar_t kWindowCloseTestUrl[] = 796 const wchar_t kWindowCloseTestUrl[] =
793 L"window_close.html"; 797 L"window_close.html";
794 798
795 // http://code.google.com/p/chromium/issues/detail?id=111074 799 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) {
796 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowClose) {
797 SimpleBrowserTest(IE, kWindowCloseTestUrl); 800 SimpleBrowserTest(IE, kWindowCloseTestUrl);
798 } 801 }
799 802
800 std::string GetHeaderValue(const std::string& headers, 803 std::string GetHeaderValue(const std::string& headers,
801 const char* header_name) { 804 const char* header_name) {
802 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), 805 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(),
803 "\r\n"); 806 "\r\n");
804 while (it.GetNext()) { 807 while (it.GetNext()) {
805 if (lstrcmpiA(it.name().c_str(), header_name) == 0) { 808 if (lstrcmpiA(it.name().c_str(), header_name) == 0) {
806 return it.values(); 809 return it.values();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 L"mshtml_refresh_test.html", 874 L"mshtml_refresh_test.html",
872 L"mshtml_refresh_test_popup.html", 875 L"mshtml_refresh_test_popup.html",
873 }; 876 };
874 877
875 SimpleWebServerTest server(46664); 878 SimpleWebServerTest server(46664);
876 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, 879 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages,
877 arraysize(kPages), GetCFTestFilePath()); 880 arraysize(kPages), GetCFTestFilePath());
878 881
879 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 882 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
880 883
881 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 884 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
882 885
883 test_server::SimpleWebServer* ws = server.web_server(); 886 test_server::SimpleWebServer* ws = server.web_server();
884 const test_server::ConnectionList& connections = ws->connections(); 887 const test_server::ConnectionList& connections = ws->connections();
885 test_server::ConnectionList::const_iterator it = connections.begin(); 888 test_server::ConnectionList::const_iterator it = connections.begin();
886 int requests_for_first_page = 0; 889 int requests_for_first_page = 0;
887 for (; it != connections.end(); ++it) { 890 for (; it != connections.end(); ++it) {
888 test_server::Connection* c = (*it); 891 test_server::Connection* c = (*it);
889 const test_server::Request& r = c->request(); 892 const test_server::Request& r = c->request();
890 if (!r.path().empty() && 893 if (!r.path().empty() &&
891 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { 894 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 size_t post_requests_; 1006 size_t post_requests_;
1004 size_t get_requests_; 1007 size_t get_requests_;
1005 }; 1008 };
1006 1009
1007 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) 1010 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
1008 .Times(testing::AtMost(1)) 1011 .Times(testing::AtMost(1))
1009 .WillOnce(chrome_frame_test::DoCloseWindow()); 1012 .WillOnce(chrome_frame_test::DoCloseWindow());
1010 1013
1011 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) 1014 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
1012 .Times(testing::AtMost(1)) 1015 .Times(testing::AtMost(1))
1013 .WillOnce(QUIT_LOOP(loop_)); 1016 .WillOnce(QUIT_LOOP(loop()));
1014 1017
1015 SimpleWebServerTest server(46664); 1018 SimpleWebServerTest server(46664);
1016 CustomResponse* response = new CustomResponse("/form.html"); 1019 CustomResponse* response = new CustomResponse("/form.html");
1017 server.web_server()->AddResponse(response); 1020 server.web_server()->AddResponse(response);
1018 1021
1019 std::wstring url(server.FormatHttpPath(L"form.html")); 1022 std::wstring url(server.FormatHttpPath(L"form.html"));
1020 1023
1021 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); 1024 ASSERT_TRUE(LaunchBrowser(IE, url.c_str()));
1022 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 1025 loop().RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
1023 1026
1024 EXPECT_EQ(1, response->get_request_count()); 1027 EXPECT_EQ(1, response->get_request_count());
1025 EXPECT_EQ(1, response->post_request_count()); 1028 EXPECT_EQ(1, response->post_request_count());
1026 } 1029 }
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