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

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: Added retry logic for WidgetModeIE_Version. 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
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"
11 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "base/win/windows_version.h" 13 #include "base/win/windows_version.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "chrome/installer/util/product.h" 15 #include "chrome/installer/util/product.h"
16 #include "chrome/installer/util/install_util.h" 16 #include "chrome/installer/util/install_util.h"
17 #include "chrome/installer/util/helper.h" 17 #include "chrome/installer/util/helper.h"
18 #include "chrome_frame/html_utils.h" 18 #include "chrome_frame/html_utils.h"
19 #include "chrome_frame/utils.h" 19 #include "chrome_frame/utils.h"
20 #include "chrome_frame/test/chrome_frame_test_utils.h" 20 #include "chrome_frame/test/chrome_frame_test_utils.h"
21 #include "chrome_frame/test/mock_ie_event_sink_actions.h" 21 #include "chrome_frame/test/mock_ie_event_sink_actions.h"
22 #include "chrome_frame/test/mock_ie_event_sink_test.h" 22 #include "chrome_frame/test/mock_ie_event_sink_test.h"
23 #include "chrome_frame/test/test_scrubber.h" 23 #include "chrome_frame/test/test_scrubber.h"
24 #include "net/base/mime_util.h" 24 #include "net/base/mime_util.h"
25 #include "net/http/http_util.h" 25 #include "net/http/http_util.h"
26 26
27 using chrome_frame_test::kChromeFrameLongNavigationTimeoutInSeconds; 27 using chrome_frame_test::kChromeFrameLongNavigationTimeout;
28 using chrome_frame_test::kChromeFrameVeryLongNavigationTimeoutInSeconds; 28 using chrome_frame_test::kChromeFrameVeryLongNavigationTimeout;
29 29
30 using testing::_; 30 using testing::_;
31 using testing::StrCaseEq; 31 using testing::StrCaseEq;
32 32
33 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; 33 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data";
34 34
35 namespace { 35 namespace {
36 36
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 216 }
195 browser_handle_.Close(); 217 browser_handle_.Close();
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(int milliseconds) { 226 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(
205 loop_.RunFor(milliseconds/1000); 227 base::TimeDelta duration) {
206 return true; 228 loop().RunFor(duration);
229 return !loop().WasTimedOut();
207 } 230 }
208 231
209 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { 232 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) {
210 return false; 233 return false;
211 } 234 }
212 235
213 const wchar_t kPostedResultSubstring[] = L"/writefile/"; 236 const wchar_t kPostedResultSubstring[] = L"/writefile/";
214 237
215 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( 238 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
216 BrowserKind browser, const wchar_t* page, const char* result) { 239 BrowserKind browser, const wchar_t* page, const char* result) {
217 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 240 int tries = 0;
218 kPostedResultSubstring); 241 ExpectAndHandlePostedResult();
219 ASSERT_TRUE(LaunchBrowser(browser, page)); 242 // Retry tests that timeout once; see http://crbug.com/96449.
220 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 243 do {
221 ASSERT_EQ(result, server_mock_.posted_result()); 244 // Don't take a snapshot on the first try.
245 loop().set_snapshot_on_timeout(tries != 0);
246 ASSERT_TRUE(LaunchBrowser(browser, page));
247 if (WaitForTestToComplete(TestTimeouts::action_max_timeout())) {
248 // The test exited without timing out. Confirm that the expected response
249 // was posted and return.
250 ASSERT_EQ(result, server_mock().posted_result());
251 break;
252 }
253 ASSERT_EQ(std::string(), server_mock().posted_result())
254 << "Test timed out yet provided a result.";
255 ASSERT_EQ(0, tries++) << "Test timed out twice.";
robertshield 2012/04/11 17:03:36 Please explicitly mark this with a comment as the
grt (UTC plus 2) 2012/04/11 17:33:08 Done.
256 // Close the browser and try a second time.
257 CloseBrowser();
258 LOG(ERROR) << "Retrying test once since it timed out.";
259 } while (true);
260 loop().set_snapshot_on_timeout(true);
222 } 261 }
223 262
224 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, 263 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
225 const wchar_t* page) { 264 const wchar_t* page) {
226 SimpleBrowserTestExpectedResult(browser, page, "OK"); 265 SimpleBrowserTestExpectedResult(browser, page, "OK");
227 } 266 }
228 267
268 void ChromeFrameTestWithWebServer::ExpectAndHandlePostedResult() {
269 EXPECT_CALL(listener_mock(), OnExpectedResponse())
270 .WillRepeatedly(QUIT_LOOP_SOON(loop(),
271 base::TimeDelta::FromMilliseconds(100)));
272 server_mock().ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
273 kPostedResultSubstring);
274 }
275
229 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, 276 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
230 const wchar_t* page) { 277 const wchar_t* page) {
231 FilePath plugin_path; 278 FilePath plugin_path;
232 PathService::Get(base::DIR_MODULE, &plugin_path); 279 PathService::Get(base::DIR_MODULE, &plugin_path);
233 plugin_path = plugin_path.Append(kChromeFrameDllName); 280 plugin_path = plugin_path.Append(kChromeFrameDllName);
234 281
235 static FileVersionInfo* version_info = 282 static FileVersionInfo* version_info =
236 FileVersionInfo::CreateFileVersionInfo(plugin_path); 283 FileVersionInfo::CreateFileVersionInfo(plugin_path);
237 284
238 std::wstring version; 285 std::wstring version;
(...skipping 11 matching lines...) Expand all
250 bool system_install = ver_system.get() ? true : false; 297 bool system_install = ver_system.get() ? true : false;
251 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist)); 298 FilePath cf_dll_path(installer::GetChromeInstallPath(system_install, dist));
252 cf_dll_path = cf_dll_path.Append(UTF8ToWide( 299 cf_dll_path = cf_dll_path.Append(UTF8ToWide(
253 ver_system.get() ? ver_system->GetString() : ver_user->GetString())); 300 ver_system.get() ? ver_system->GetString() : ver_user->GetString()));
254 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); 301 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName);
255 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); 302 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path);
256 if (version_info) 303 if (version_info)
257 version = version_info->product_version(); 304 version = version_info->product_version();
258 } 305 }
259 306
260 server_mock_.set_expected_result(WideToUTF8(version)); 307 server_mock().set_expected_result(WideToUTF8(version));
261 308
262 EXPECT_TRUE(version_info); 309 EXPECT_TRUE(version_info);
263 EXPECT_FALSE(version.empty()); 310 EXPECT_FALSE(version.empty());
264 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 311
265 kPostedResultSubstring); 312 SimpleBrowserTestExpectedResult(browser, page, WideToASCII(version).c_str());
266 EXPECT_TRUE(LaunchBrowser(browser, page));
267 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
268 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result()));
269 } 313 }
270 314
271 // MockWebServer methods 315 // MockWebServer methods
272 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, 316 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation,
273 const std::wstring& url) { 317 const std::wstring& url) {
274 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); 318 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1));
275 } 319 }
276 320
277 void MockWebServer::ExpectAndServeRequestWithCardinality( 321 void MockWebServer::ExpectAndServeRequestWithCardinality(
278 CFInvocation invocation, const std::wstring& url, 322 CFInvocation invocation, const std::wstring& url,
(...skipping 18 matching lines...) Expand all
297 void MockWebServer::ExpectAndHandlePostedResult( 341 void MockWebServer::ExpectAndHandlePostedResult(
298 CFInvocation invocation, const std::wstring& post_suffix) { 342 CFInvocation invocation, const std::wstring& post_suffix) {
299 EXPECT_CALL(*this, Post(_, testing::HasSubstr(post_suffix), _)) 343 EXPECT_CALL(*this, Post(_, testing::HasSubstr(post_suffix), _))
300 .WillRepeatedly(HandlePostedResponseHelper(this, invocation)); 344 .WillRepeatedly(HandlePostedResponseHelper(this, invocation));
301 } 345 }
302 346
303 void MockWebServer::HandlePostedResponse( 347 void MockWebServer::HandlePostedResponse(
304 test_server::ConfigurableConnection* connection, 348 test_server::ConfigurableConnection* connection,
305 const test_server::Request& request) { 349 const test_server::Request& request) {
306 posted_result_ = request.content(); 350 posted_result_ = request.content();
307 if (posted_result_ == expected_result_) { 351 if (listener_ && posted_result_ == expected_result_)
308 MessageLoop::current()->PostDelayedTask(FROM_HERE, 352 listener_->OnExpectedResponse();
309 MessageLoop::QuitClosure(),
310 100);
311 }
312 connection->Send("HTTP/1.1 200 OK\r\n", ""); 353 connection->Send("HTTP/1.1 200 OK\r\n", "");
313 } 354 }
314 355
315 void MockWebServer::SendResponseHelper( 356 void MockWebServer::SendResponseHelper(
316 test_server::ConfigurableConnection* connection, 357 test_server::ConfigurableConnection* connection,
317 const std::wstring& request_uri, 358 const std::wstring& request_uri,
318 const test_server::Request& request, 359 const test_server::Request& request,
319 CFInvocation invocation, 360 CFInvocation invocation,
320 bool add_no_cache_header) { 361 bool add_no_cache_header) {
321 static const wchar_t kEchoHeader[] = L"/echoheader?"; 362 static const wchar_t kEchoHeader[] = L"/echoheader?";
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 } 459 }
419 460
420 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html"; 461 const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html";
421 462
422 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) { 463 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) {
423 SimpleBrowserTest(IE, kiframeBasicPage); 464 SimpleBrowserTest(IE, kiframeBasicPage);
424 } 465 }
425 466
426 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html"; 467 const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html";
427 468
428 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_SrcProperty) { 469 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) {
429 SimpleBrowserTest(IE, kSrcPropertyTestPage); 470 SimpleBrowserTest(IE, kSrcPropertyTestPage);
430 } 471 }
431 472
432 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html"; 473 const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html";
433 474
434 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) { 475 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) {
435 SimpleBrowserTest(IE, kCFInstanceBasicTestPage); 476 SimpleBrowserTest(IE, kCFInstanceBasicTestPage);
436 } 477 }
437 478
438 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html"; 479 const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html";
439 480
440 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) { 481 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) {
441 SimpleBrowserTest(IE, kCFISingletonPage); 482 SimpleBrowserTest(IE, kCFISingletonPage);
442 } 483 }
443 484
444 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html"; 485 const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html";
445 486
446 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceDelay) { 487 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDelay) {
447 SimpleBrowserTest(IE, kCFIDelayPage); 488 SimpleBrowserTest(IE, kCFIDelayPage);
448 } 489 }
449 490
450 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html"; 491 const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html";
451 492
452 // http://crbug.com/37088 493 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceFallback) {
453 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceFallback) {
454 SimpleBrowserTest(IE, kCFIFallbackPage); 494 SimpleBrowserTest(IE, kCFIFallbackPage);
455 } 495 }
456 496
457 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html"; 497 const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html";
458 498
459 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) { 499 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) {
460 SimpleBrowserTest(IE, kCFINoSrcPage); 500 SimpleBrowserTest(IE, kCFINoSrcPage);
461 } 501 }
462 502
463 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html"; 503 const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html";
464 504
465 // disabled since it's unlikely that we care about this case 505 // disabled since it's unlikely that we care about this case
466 TEST_F(ChromeFrameTestWithWebServer, 506 TEST_F(ChromeFrameTestWithWebServer,
467 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) { 507 DISABLED_WidgetModeIE_CFInstanceIfrOnLoad) {
468 SimpleBrowserTest(IE, kCFIIfrOnLoadPage); 508 SimpleBrowserTest(IE, kCFIIfrOnLoadPage);
469 } 509 }
470 510
471 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html"; 511 const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html";
472 512
473 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) { 513 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) {
474 SimpleBrowserTest(IE, kCFIZeroSizePage); 514 SimpleBrowserTest(IE, kCFIZeroSizePage);
475 } 515 }
476 516
477 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html"; 517 const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html";
478 518
479 // http://crbug.com/32321 519 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceIfrPost) {
480 TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceIfrPost) {
481 SimpleBrowserTest(IE, kCFIIfrPostPage); 520 SimpleBrowserTest(IE, kCFIIfrPostPage);
482 } 521 }
483 522
484 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) { 523 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) {
485 SimpleBrowserTest(CHROME, kCFIIfrPostPage); 524 SimpleBrowserTest(CHROME, kCFIIfrPostPage);
486 } 525 }
487 526
488 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html"; 527 const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html";
489 528
490 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) { 529 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) {
491 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) { 530 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
492 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 531 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
493 return; 532 return;
494 } 533 }
495 SimpleBrowserTest(IE, kCFIPostPage); 534 SimpleBrowserTest(IE, kCFIPostPage);
496 } 535 }
497 536
498 // This test randomly fails on the ChromeFrame builder. 537 // This test randomly fails on the ChromeFrame builder.
499 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) { 538 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) {
500 SimpleBrowserTest(CHROME, kCFIPostPage); 539 SimpleBrowserTest(CHROME, kCFIPostPage);
501 } 540 }
502 541
503 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html"; 542 const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html";
504 543
505 // This test consistently times out in debug builds; see http://crbug.com/112599 544 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) { 545 if (chrome_frame_test::GetInstalledIEVersion() == IE_9) {
514 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9"; 546 LOG(INFO) << "Not running test on Vista/Windows 7 with IE9";
515 return; 547 return;
516 } 548 }
517 SimpleBrowserTest(IE, kCFIRPCPage); 549 SimpleBrowserTest(IE, kCFIRPCPage);
518 } 550 }
519 551
520 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) { 552 TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) {
521 SimpleBrowserTest(CHROME, kCFIRPCPage); 553 SimpleBrowserTest(CHROME, kCFIRPCPage);
522 } 554 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 L"install_flow_test.html"; 694 L"install_flow_test.html";
663 695
664 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { 696 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) {
665 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 697 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
666 ScopedChromeFrameRegistrar::UnregisterAtPath( 698 ScopedChromeFrameRegistrar::UnregisterAtPath(
667 GetChromeFrameBuildPath().value(), 699 GetChromeFrameBuildPath().value(),
668 chrome_frame_test::GetTestBedType()); 700 chrome_frame_test::GetTestBedType());
669 701
670 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); 702 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl));
671 703
672 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 704 loop().RunFor(kChromeFrameLongNavigationTimeout);
673 705
674 ScopedChromeFrameRegistrar::RegisterAtPath( 706 ScopedChromeFrameRegistrar::RegisterAtPath(
675 GetChromeFrameBuildPath().value(), 707 GetChromeFrameBuildPath().value(),
676 chrome_frame_test::GetTestBedType()); 708 chrome_frame_test::GetTestBedType());
677 709
678 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 710 ExpectAndHandlePostedResult();
679 kPostedResultSubstring); 711 loop().RunFor(kChromeFrameLongNavigationTimeout);
680 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
681 712
682 chrome_frame_test::CloseAllIEWindows(); 713 chrome_frame_test::CloseAllIEWindows();
683 ASSERT_EQ("OK", server_mock_.posted_result()); 714 ASSERT_EQ("OK", server_mock().posted_result());
684 } 715 }
685 } 716 }
686 717
687 const wchar_t kMultipleCFInstancesTestUrl[] = 718 const wchar_t kMultipleCFInstancesTestUrl[] =
688 L"multiple_cf_instances_main.html"; 719 L"multiple_cf_instances_main.html";
689 720
690 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { 721 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) {
691 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl); 722 SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl);
692 } 723 }
693 724
(...skipping 27 matching lines...) Expand all
721 L"full_tab_post_target_cf.html", 752 L"full_tab_post_target_cf.html",
722 L"chrome_frame_tester_helpers.js", 753 L"chrome_frame_tester_helpers.js",
723 }; 754 };
724 755
725 SimpleWebServerTest server(46664); 756 SimpleWebServerTest server(46664);
726 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 757 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
727 arraysize(kPages), GetCFTestFilePath()); 758 arraysize(kPages), GetCFTestFilePath());
728 759
729 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 760 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
730 761
731 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 762 loop().RunFor(kChromeFrameLongNavigationTimeout);
732 763
733 const test_server::Request* request = NULL; 764 const test_server::Request* request = NULL;
734 server.FindRequest("/quit?OK", &request); 765 server.FindRequest("/quit?OK", &request);
735 ASSERT_TRUE(request != NULL); 766 ASSERT_TRUE(request != NULL);
736 EXPECT_EQ("OK", request->arguments()); 767 EXPECT_EQ("OK", request->arguments());
737 768
738 if (request->arguments().compare("OK") == 0) { 769 if (request->arguments().compare("OK") == 0) {
739 // Check how many requests we got for the cf page. Also expect it to be 770 // Check how many requests we got for the cf page. Also expect it to be
740 // a POST. 771 // a POST.
741 int requests = server.GetRequestCountForPage(kPages[1], "POST"); 772 int requests = server.GetRequestCountForPage(kPages[1], "POST");
(...skipping 11 matching lines...) Expand all
753 L"chrome_frame_tester_helpers.js", 784 L"chrome_frame_tester_helpers.js",
754 }; 785 };
755 786
756 SimpleWebServerTest server(46664); 787 SimpleWebServerTest server(46664);
757 788
758 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 789 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
759 arraysize(kPages), GetCFTestFilePath()); 790 arraysize(kPages), GetCFTestFilePath());
760 791
761 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 792 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
762 793
763 loop_.RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds); 794 loop().RunFor(kChromeFrameVeryLongNavigationTimeout);
764 795
765 const test_server::Request* request = NULL; 796 const test_server::Request* request = NULL;
766 server.FindRequest("/quit?OK", &request); 797 server.FindRequest("/quit?OK", &request);
767 ASSERT_TRUE(request != NULL); 798 ASSERT_TRUE(request != NULL);
768 EXPECT_EQ("OK", request->arguments()); 799 EXPECT_EQ("OK", request->arguments());
769 800
770 if (request->arguments().compare("OK") == 0) { 801 if (request->arguments().compare("OK") == 0) {
771 // Check how many requests we got for the cf page and check that it was 802 // Check how many requests we got for the cf page and check that it was
772 // a GET. 803 // a GET.
773 int requests = server.GetRequestCountForPage(kPages[1], "GET"); 804 int requests = server.GetRequestCountForPage(kPages[1], "GET");
(...skipping 11 matching lines...) Expand all
785 const wchar_t kXHRConditionalHeaderTestUrl[] = 816 const wchar_t kXHRConditionalHeaderTestUrl[] =
786 L"xmlhttprequest_conditional_header_test.html"; 817 L"xmlhttprequest_conditional_header_test.html";
787 818
788 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { 819 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) {
789 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl); 820 SimpleBrowserTest(IE, kXHRConditionalHeaderTestUrl);
790 } 821 }
791 822
792 const wchar_t kWindowCloseTestUrl[] = 823 const wchar_t kWindowCloseTestUrl[] =
793 L"window_close.html"; 824 L"window_close.html";
794 825
795 // http://code.google.com/p/chromium/issues/detail?id=111074 826 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) {
796 TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeIE_WindowClose) {
797 SimpleBrowserTest(IE, kWindowCloseTestUrl); 827 SimpleBrowserTest(IE, kWindowCloseTestUrl);
798 } 828 }
799 829
800 std::string GetHeaderValue(const std::string& headers, 830 std::string GetHeaderValue(const std::string& headers,
801 const char* header_name) { 831 const char* header_name) {
802 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(), 832 net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(),
803 "\r\n"); 833 "\r\n");
804 while (it.GetNext()) { 834 while (it.GetNext()) {
805 if (lstrcmpiA(it.name().c_str(), header_name) == 0) { 835 if (lstrcmpiA(it.name().c_str(), header_name) == 0) {
806 return it.values(); 836 return it.values();
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 L"mshtml_refresh_test.html", 901 L"mshtml_refresh_test.html",
872 L"mshtml_refresh_test_popup.html", 902 L"mshtml_refresh_test_popup.html",
873 }; 903 };
874 904
875 SimpleWebServerTest server(46664); 905 SimpleWebServerTest server(46664);
876 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, 906 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages,
877 arraysize(kPages), GetCFTestFilePath()); 907 arraysize(kPages), GetCFTestFilePath());
878 908
879 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 909 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
880 910
881 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 911 loop().RunFor(kChromeFrameLongNavigationTimeout);
882 912
883 test_server::SimpleWebServer* ws = server.web_server(); 913 test_server::SimpleWebServer* ws = server.web_server();
884 const test_server::ConnectionList& connections = ws->connections(); 914 const test_server::ConnectionList& connections = ws->connections();
885 test_server::ConnectionList::const_iterator it = connections.begin(); 915 test_server::ConnectionList::const_iterator it = connections.begin();
886 int requests_for_first_page = 0; 916 int requests_for_first_page = 0;
887 for (; it != connections.end(); ++it) { 917 for (; it != connections.end(); ++it) {
888 test_server::Connection* c = (*it); 918 test_server::Connection* c = (*it);
889 const test_server::Request& r = c->request(); 919 const test_server::Request& r = c->request();
890 if (!r.path().empty() && 920 if (!r.path().empty() &&
891 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { 921 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_; 1033 size_t post_requests_;
1004 size_t get_requests_; 1034 size_t get_requests_;
1005 }; 1035 };
1006 1036
1007 EXPECT_CALL(win_observer_mock, OnWindowOpen(_)) 1037 EXPECT_CALL(win_observer_mock, OnWindowOpen(_))
1008 .Times(testing::AtMost(1)) 1038 .Times(testing::AtMost(1))
1009 .WillOnce(chrome_frame_test::DoCloseWindow()); 1039 .WillOnce(chrome_frame_test::DoCloseWindow());
1010 1040
1011 EXPECT_CALL(win_observer_mock, OnWindowClose(_)) 1041 EXPECT_CALL(win_observer_mock, OnWindowClose(_))
1012 .Times(testing::AtMost(1)) 1042 .Times(testing::AtMost(1))
1013 .WillOnce(QUIT_LOOP(loop_)); 1043 .WillOnce(QUIT_LOOP(loop()));
1014 1044
1015 SimpleWebServerTest server(46664); 1045 SimpleWebServerTest server(46664);
1016 CustomResponse* response = new CustomResponse("/form.html"); 1046 CustomResponse* response = new CustomResponse("/form.html");
1017 server.web_server()->AddResponse(response); 1047 server.web_server()->AddResponse(response);
1018 1048
1019 std::wstring url(server.FormatHttpPath(L"form.html")); 1049 std::wstring url(server.FormatHttpPath(L"form.html"));
1020 1050
1021 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); 1051 ASSERT_TRUE(LaunchBrowser(IE, url.c_str()));
1022 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 1052 loop().RunFor(kChromeFrameLongNavigationTimeout);
1023 1053
1024 EXPECT_EQ(1, response->get_request_count()); 1054 EXPECT_EQ(1, response->get_request_count());
1025 EXPECT_EQ(1, response->post_request_count()); 1055 EXPECT_EQ(1, response->post_request_count());
1026 } 1056 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698