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

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

Issue 10053004: Use TimeDelta for Chrome Frame test's TimedMsgLoop. (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') | chrome_frame/test/ui_test.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"
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,
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 194 }
195 browser_handle_.Close(); 195 browser_handle_.Close();
196 } 196 }
197 } 197 }
198 198
199 bool ChromeFrameTestWithWebServer::BringBrowserToTop() { 199 bool ChromeFrameTestWithWebServer::BringBrowserToTop() {
200 return simulate_input::EnsureProcessInForeground( 200 return simulate_input::EnsureProcessInForeground(
201 GetProcessId(browser_handle_)); 201 GetProcessId(browser_handle_));
202 } 202 }
203 203
204 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(int milliseconds) { 204 bool ChromeFrameTestWithWebServer::WaitForTestToComplete(
205 loop_.RunFor(milliseconds/1000); 205 base::TimeDelta duration) {
206 loop_.RunFor(duration);
206 return true; 207 return true;
207 } 208 }
208 209
209 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) { 210 bool ChromeFrameTestWithWebServer::WaitForOnLoad(int milliseconds) {
210 return false; 211 return false;
211 } 212 }
212 213
213 const wchar_t kPostedResultSubstring[] = L"/writefile/"; 214 const wchar_t kPostedResultSubstring[] = L"/writefile/";
214 215
215 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult( 216 void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
216 BrowserKind browser, const wchar_t* page, const char* result) { 217 BrowserKind browser, const wchar_t* page, const char* result) {
217 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 218 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
218 kPostedResultSubstring); 219 kPostedResultSubstring);
219 ASSERT_TRUE(LaunchBrowser(browser, page)); 220 ASSERT_TRUE(LaunchBrowser(browser, page));
220 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 221 WaitForTestToComplete(TestTimeouts::action_max_timeout());
221 ASSERT_EQ(result, server_mock_.posted_result()); 222 ASSERT_EQ(result, server_mock_.posted_result());
222 } 223 }
223 224
224 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, 225 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
225 const wchar_t* page) { 226 const wchar_t* page) {
226 SimpleBrowserTestExpectedResult(browser, page, "OK"); 227 SimpleBrowserTestExpectedResult(browser, page, "OK");
227 } 228 }
228 229
229 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, 230 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
230 const wchar_t* page) { 231 const wchar_t* page) {
(...skipping 26 matching lines...) Expand all
257 version = version_info->product_version(); 258 version = version_info->product_version();
258 } 259 }
259 260
260 server_mock_.set_expected_result(WideToUTF8(version)); 261 server_mock_.set_expected_result(WideToUTF8(version));
261 262
262 EXPECT_TRUE(version_info); 263 EXPECT_TRUE(version_info);
263 EXPECT_FALSE(version.empty()); 264 EXPECT_FALSE(version.empty());
264 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 265 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
265 kPostedResultSubstring); 266 kPostedResultSubstring);
266 EXPECT_TRUE(LaunchBrowser(browser, page)); 267 EXPECT_TRUE(LaunchBrowser(browser, page));
267 WaitForTestToComplete(TestTimeouts::action_max_timeout_ms()); 268 WaitForTestToComplete(TestTimeouts::action_max_timeout());
268 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result())); 269 ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result()));
269 } 270 }
270 271
271 // MockWebServer methods 272 // MockWebServer methods
272 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, 273 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation,
273 const std::wstring& url) { 274 const std::wstring& url) {
274 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1)); 275 ExpectAndServeRequestWithCardinality(invocation, url, testing::Exactly(1));
275 } 276 }
276 277
277 void MockWebServer::ExpectAndServeRequestWithCardinality( 278 void MockWebServer::ExpectAndServeRequestWithCardinality(
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 L"install_flow_test.html"; 663 L"install_flow_test.html";
663 664
664 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) { 665 TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_InstallFlowTest) {
665 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 666 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
666 ScopedChromeFrameRegistrar::UnregisterAtPath( 667 ScopedChromeFrameRegistrar::UnregisterAtPath(
667 GetChromeFrameBuildPath().value(), 668 GetChromeFrameBuildPath().value(),
668 chrome_frame_test::GetTestBedType()); 669 chrome_frame_test::GetTestBedType());
669 670
670 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl)); 671 ASSERT_TRUE(LaunchBrowser(IE, kInstallFlowTestUrl));
671 672
672 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 673 loop_.RunFor(kChromeFrameLongNavigationTimeout);
673 674
674 ScopedChromeFrameRegistrar::RegisterAtPath( 675 ScopedChromeFrameRegistrar::RegisterAtPath(
675 GetChromeFrameBuildPath().value(), 676 GetChromeFrameBuildPath().value(),
676 chrome_frame_test::GetTestBedType()); 677 chrome_frame_test::GetTestBedType());
677 678
678 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE), 679 server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
679 kPostedResultSubstring); 680 kPostedResultSubstring);
680 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 681 loop_.RunFor(kChromeFrameLongNavigationTimeout);
681 682
682 chrome_frame_test::CloseAllIEWindows(); 683 chrome_frame_test::CloseAllIEWindows();
683 ASSERT_EQ("OK", server_mock_.posted_result()); 684 ASSERT_EQ("OK", server_mock_.posted_result());
684 } 685 }
685 } 686 }
686 687
687 const wchar_t kMultipleCFInstancesTestUrl[] = 688 const wchar_t kMultipleCFInstancesTestUrl[] =
688 L"multiple_cf_instances_main.html"; 689 L"multiple_cf_instances_main.html";
689 690
690 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) { 691 TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) {
(...skipping 30 matching lines...) Expand all
721 L"full_tab_post_target_cf.html", 722 L"full_tab_post_target_cf.html",
722 L"chrome_frame_tester_helpers.js", 723 L"chrome_frame_tester_helpers.js",
723 }; 724 };
724 725
725 SimpleWebServerTest server(46664); 726 SimpleWebServerTest server(46664);
726 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 727 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
727 arraysize(kPages), GetCFTestFilePath()); 728 arraysize(kPages), GetCFTestFilePath());
728 729
729 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 730 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
730 731
731 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 732 loop_.RunFor(kChromeFrameLongNavigationTimeout);
732 733
733 const test_server::Request* request = NULL; 734 const test_server::Request* request = NULL;
734 server.FindRequest("/quit?OK", &request); 735 server.FindRequest("/quit?OK", &request);
735 ASSERT_TRUE(request != NULL); 736 ASSERT_TRUE(request != NULL);
736 EXPECT_EQ("OK", request->arguments()); 737 EXPECT_EQ("OK", request->arguments());
737 738
738 if (request->arguments().compare("OK") == 0) { 739 if (request->arguments().compare("OK") == 0) {
739 // Check how many requests we got for the cf page. Also expect it to be 740 // Check how many requests we got for the cf page. Also expect it to be
740 // a POST. 741 // a POST.
741 int requests = server.GetRequestCountForPage(kPages[1], "POST"); 742 int requests = server.GetRequestCountForPage(kPages[1], "POST");
(...skipping 11 matching lines...) Expand all
753 L"chrome_frame_tester_helpers.js", 754 L"chrome_frame_tester_helpers.js",
754 }; 755 };
755 756
756 SimpleWebServerTest server(46664); 757 SimpleWebServerTest server(46664);
757 758
758 server.PopulateStaticFileListT<test_server::FileResponse>(kPages, 759 server.PopulateStaticFileListT<test_server::FileResponse>(kPages,
759 arraysize(kPages), GetCFTestFilePath()); 760 arraysize(kPages), GetCFTestFilePath());
760 761
761 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 762 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
762 763
763 loop_.RunFor(kChromeFrameVeryLongNavigationTimeoutInSeconds); 764 loop_.RunFor(kChromeFrameVeryLongNavigationTimeout);
764 765
765 const test_server::Request* request = NULL; 766 const test_server::Request* request = NULL;
766 server.FindRequest("/quit?OK", &request); 767 server.FindRequest("/quit?OK", &request);
767 ASSERT_TRUE(request != NULL); 768 ASSERT_TRUE(request != NULL);
768 EXPECT_EQ("OK", request->arguments()); 769 EXPECT_EQ("OK", request->arguments());
769 770
770 if (request->arguments().compare("OK") == 0) { 771 if (request->arguments().compare("OK") == 0) {
771 // Check how many requests we got for the cf page and check that it was 772 // Check how many requests we got for the cf page and check that it was
772 // a GET. 773 // a GET.
773 int requests = server.GetRequestCountForPage(kPages[1], "GET"); 774 int requests = server.GetRequestCountForPage(kPages[1], "GET");
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
871 L"mshtml_refresh_test.html", 872 L"mshtml_refresh_test.html",
872 L"mshtml_refresh_test_popup.html", 873 L"mshtml_refresh_test_popup.html",
873 }; 874 };
874 875
875 SimpleWebServerTest server(46664); 876 SimpleWebServerTest server(46664);
876 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages, 877 server.PopulateStaticFileListT<UaTemplateFileResponse>(kPages,
877 arraysize(kPages), GetCFTestFilePath()); 878 arraysize(kPages), GetCFTestFilePath());
878 879
879 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str())); 880 ASSERT_TRUE(LaunchBrowser(IE, server.FormatHttpPath(kPages[0]).c_str()));
880 881
881 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 882 loop_.RunFor(kChromeFrameLongNavigationTimeout);
882 883
883 test_server::SimpleWebServer* ws = server.web_server(); 884 test_server::SimpleWebServer* ws = server.web_server();
884 const test_server::ConnectionList& connections = ws->connections(); 885 const test_server::ConnectionList& connections = ws->connections();
885 test_server::ConnectionList::const_iterator it = connections.begin(); 886 test_server::ConnectionList::const_iterator it = connections.begin();
886 int requests_for_first_page = 0; 887 int requests_for_first_page = 0;
887 for (; it != connections.end(); ++it) { 888 for (; it != connections.end(); ++it) {
888 test_server::Connection* c = (*it); 889 test_server::Connection* c = (*it);
889 const test_server::Request& r = c->request(); 890 const test_server::Request& r = c->request();
890 if (!r.path().empty() && 891 if (!r.path().empty() &&
891 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) { 892 ASCIIToWide(r.path().substr(1)).compare(kPages[0]) == 0) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 .Times(testing::AtMost(1)) 1013 .Times(testing::AtMost(1))
1013 .WillOnce(QUIT_LOOP(loop_)); 1014 .WillOnce(QUIT_LOOP(loop_));
1014 1015
1015 SimpleWebServerTest server(46664); 1016 SimpleWebServerTest server(46664);
1016 CustomResponse* response = new CustomResponse("/form.html"); 1017 CustomResponse* response = new CustomResponse("/form.html");
1017 server.web_server()->AddResponse(response); 1018 server.web_server()->AddResponse(response);
1018 1019
1019 std::wstring url(server.FormatHttpPath(L"form.html")); 1020 std::wstring url(server.FormatHttpPath(L"form.html"));
1020 1021
1021 ASSERT_TRUE(LaunchBrowser(IE, url.c_str())); 1022 ASSERT_TRUE(LaunchBrowser(IE, url.c_str()));
1022 loop_.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); 1023 loop_.RunFor(kChromeFrameLongNavigationTimeout);
1023 1024
1024 EXPECT_EQ(1, response->get_request_count()); 1025 EXPECT_EQ(1, response->get_request_count());
1025 EXPECT_EQ(1, response->post_request_count()); 1026 EXPECT_EQ(1, response->post_request_count());
1026 } 1027 }
OLDNEW
« no previous file with comments | « chrome_frame/test/test_with_web_server.h ('k') | chrome_frame/test/ui_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698