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

Side by Side Diff: chrome_frame/test/test_with_web_server.cc

Issue 9838058: More non-debug logging in Chrome Frame tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright and formatting tweaks Created 8 years, 9 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_server.cc ('k') | chrome_frame/test/win_event_receiver.cc » ('j') | 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 } else { 172 } else {
173 attempts = chrome_frame_test::CloseVisibleWindowsOnAllThreads( 173 attempts = chrome_frame_test::CloseVisibleWindowsOnAllThreads(
174 browser_handle_); 174 browser_handle_);
175 } 175 }
176 176
177 if (attempts > 0) { 177 if (attempts > 0) {
178 DWORD wait = ::WaitForSingleObject(browser_handle_, 20000); 178 DWORD wait = ::WaitForSingleObject(browser_handle_, 20000);
179 if (wait == WAIT_OBJECT_0) { 179 if (wait == WAIT_OBJECT_0) {
180 browser_handle_.Close(); 180 browser_handle_.Close();
181 } else { 181 } else {
182 DLOG(ERROR) << "WaitForSingleObject returned " << wait; 182 LOG(ERROR) << "WaitForSingleObject returned " << wait;
183 } 183 }
184 } else { 184 } else {
185 DLOG(ERROR) << "No attempts to close browser windows"; 185 LOG(ERROR) << "No attempts to close browser windows";
186 } 186 }
187 187
188 if (browser_handle_.IsValid()) { 188 if (browser_handle_.IsValid()) {
189 DWORD exit_code = 0; 189 DWORD exit_code = 0;
190 if (!::GetExitCodeProcess(browser_handle_, &exit_code) || 190 if (!::GetExitCodeProcess(browser_handle_, &exit_code) ||
191 exit_code == STILL_ACTIVE) { 191 exit_code == STILL_ACTIVE) {
192 LOG(ERROR) << L"Forcefully killing browser process. Exit:" << exit_code; 192 LOG(ERROR) << L"Forcefully killing browser process. Exit:" << exit_code;
193 base::KillProcess(browser_handle_, 0, true); 193 base::KillProcess(browser_handle_, 0, true);
194 } 194 }
195 browser_handle_.Close(); 195 browser_handle_.Close();
(...skipping 11 matching lines...) Expand all
207 } 207 }
208 208
209 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { 209 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) {
210 return false; 210 return false;
211 } 211 }
212 212
213 const wchar_t kPostedResultSubstring[] = L"/writefile/"; 213 const wchar_t kPostedResultSubstring[] = L"/writefile/";
214 214
215 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( 215 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
216 BrowserKind browser, const wchar_t* page, const char* result) { 216 BrowserKind browser, const wchar_t* page, const char* result) {
217 ASSERT_TRUE(LaunchBrowser(browser, page));
218 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 217 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
219 kPostedResultSubstring); 218 kPostedResultSubstring);
219 ASSERT_TRUE(LaunchBrowser(browser, page));
220 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 220 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
221 ASSERT_EQ(result, server_mock_.posted_result()); 221 ASSERT_EQ(result, server_mock_.posted_result());
222 } 222 }
223 223
224 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, 224 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
225 const wchar_t* page) { 225 const wchar_t* page) {
226 SimpleBrowserTestExpectedResult(browser, page, "OK"); 226 SimpleBrowserTestExpectedResult(browser, page, "OK");
227 } 227 }
228 228
229 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, 229 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
(...skipping 24 matching lines...) Expand all
254 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); 254 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName);
255 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); 255 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path);
256 if (version_info) 256 if (version_info)
257 version = version_info->product_version(); 257 version = version_info->product_version();
258 } 258 }
259 259
260 server_mock_.set_expected_result(WideToUTF8(version)); 260 server_mock_.set_expected_result(WideToUTF8(version));
261 261
262 EXPECT_TRUE(version_info); 262 EXPECT_TRUE(version_info);
263 EXPECT_FALSE(version.empty()); 263 EXPECT_FALSE(version.empty());
264 EXPECT_TRUE(LaunchBrowser(browser, page));
265 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 264 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
266 kPostedResultSubstring); 265 kPostedResultSubstring);
266 EXPECT_TRUE(LaunchBrowser(browser, page));
267 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 267 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
268 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result())); 268 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result()));
269 } 269 }
270 270
271 // MockWebServer methods 271 // MockWebServer methods
272 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, 272 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation,
273 const std::wstring& url) { 273 const std::wstring& url) {
274 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); 274 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1));
275 } 275 }
276 276
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 std::string content_type; 343 std::string content_type;
344 if (file_util::PathExists(file_path) && 344 if (file_util::PathExists(file_path) &&
345 !file_util::DirectoryExists(file_path)) { 345 !file_util::DirectoryExists(file_path)) {
346 FilePath mock_http_headers(file_path.value() + L".mock-http-headers"); 346 FilePath mock_http_headers(file_path.value() + L".mock-http-headers");
347 if (file_util::PathExists(mock_http_headers)) { 347 if (file_util::PathExists(mock_http_headers)) {
348 headers = GetMockHttpHeaders(mock_http_headers); 348 headers = GetMockHttpHeaders(mock_http_headers);
349 content_type = http_utils::GetHttpHeaderFromHeaderList("Content-type", 349 content_type = http_utils::GetHttpHeaderFromHeaderList("Content-type",
350 headers); 350 headers);
351 } else { 351 } else {
352 EXPECT_TRUE(net::GetMimeTypeFromFile(file_path, &content_type)); 352 EXPECT_TRUE(net::GetMimeTypeFromFile(file_path, &content_type));
353 DVLOG(1) << "Going to send file (" << WideToUTF8(file_path.value()) 353 VLOG(1) << "Going to send file (" << WideToUTF8(file_path.value())
354 << ") with content type (" << content_type << ")"; 354 << ") with content type (" << content_type << ")";
355 headers = CreateHttpHeaders(invocation, add_no_cache_header, 355 headers = CreateHttpHeaders(invocation, add_no_cache_header,
356 content_type); 356 content_type);
357 } 357 }
358 358
359 EXPECT_FALSE(headers.empty()); 359 EXPECT_FALSE(headers.empty());
360 360
361 EXPECT_TRUE(file_util::ReadFileToString(file_path, &body)) 361 EXPECT_TRUE(file_util::ReadFileToString(file_path, &body))
362 << "Could not read file (" << WideToUTF8(file_path.value()) << ")"; 362 << "Could not read file (" << WideToUTF8(file_path.value()) << ")";
363 if (invocation.type() == CFInvocation::META_TAG && 363 if (invocation.type() == CFInvocation::META_TAG &&
364 StartsWithASCII(content_type, "text/html", false)) { 364 StartsWithASCII(content_type, "text/html", false)) {
365 EXPECT_TRUE(chrome_frame_test::AddCFMetaTag(&body)) << "Could not add " 365 EXPECT_TRUE(chrome_frame_test::AddCFMetaTag(&body)) << "Could not add "
366 << "meta tag to HTML file."; 366 << "meta tag to HTML file.";
367 } 367 }
368 } else { 368 } else {
369 DVLOG(1) << "Going to send 404 for non-existent file (" 369 VLOG(1) << "Going to send 404 for non-existent file ("
370 << WideToUTF8(file_path.value()) << ")"; 370 << WideToUTF8(file_path.value()) << ")";
371 headers = "HTTP/1.1 404 Not Found"; 371 headers = "HTTP/1.1 404 Not Found";
372 body = ""; 372 body = "";
373 } 373 }
374 connection->Send(headers, body); 374 connection->Send(headers, body);
375 } 375 }
376 376
377 const wchar_t kPostMessageBasicPage[] = L"postmessage_basic_host.html"; 377 const wchar_t kPostMessageBasicPage[] = L"postmessage_basic_host.html";
378 378
379 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_PostMessageBasic) { 379 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_PostMessageBasic) {
380 SimpleBrowserTest(IE, kPostMessageBasicPage); 380 SimpleBrowserTest(IE, kPostMessageBasicPage);
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
1017 server.web_server()->AddResponse(response); 1017 server.web_server()->AddResponse(response);
1018 1018
1019 std::wstring url(server.FormatHttpPath(L"form.html")); 1019 std::wstring url(server.FormatHttpPath(L"form.html"));
1020 1020
1021 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); 1021 ASSERT_TRUE(LaunchBrowser(IE, url.c_str()));
1022 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 1022 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
1023 1023
1024 EXPECT_EQ(1, response->get_request_count()); 1024 EXPECT_EQ(1, response->get_request_count());
1025 EXPECT_EQ(1, response->post_request_count()); 1025 EXPECT_EQ(1, response->post_request_count());
1026 } 1026 }
OLDNEW
« no previous file with comments | « chrome_frame/test/test_server.cc ('k') | chrome_frame/test/win_event_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698