OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "base/win_util.h" | 11 #include "base/win_util.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/installer/util/install_util.h" | 13 #include "chrome/installer/util/install_util.h" |
14 #include "chrome/installer/util/helper.h" | 14 #include "chrome/installer/util/helper.h" |
15 #include "chrome_frame/utils.h" | 15 #include "chrome_frame/utils.h" |
16 #include "chrome_frame/test/chrome_frame_test_utils.h" | 16 #include "chrome_frame/test/chrome_frame_test_utils.h" |
17 #include "chrome_frame/test/mock_ie_event_sink_actions.h" | 17 #include "chrome_frame/test/mock_ie_event_sink_actions.h" |
18 #include "net/base/mime_util.h" | 18 #include "net/base/mime_util.h" |
19 | 19 |
20 using chrome_frame_test::kChromeFrameLongNavigationTimeoutInSeconds; | 20 using chrome_frame_test::kChromeFrameLongNavigationTimeoutInSeconds; |
21 using testing::_; | 21 using testing::_; |
22 using testing::StrCaseEq; | 22 using testing::StrCaseEq; |
23 | 23 |
24 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; | 24 const wchar_t kDocRoot[] = L"chrome_frame\\test\\data"; |
25 const int kLongWaitTimeout = 60 * 1000; | 25 const int kLongWaitTimeout = 15 * 1000; |
26 const int kShortWaitTimeout = 25 * 1000; | 26 const int kShortWaitTimeout = 5 * 1000; |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Helper method for creating the appropriate HTTP response headers. | 30 // Helper method for creating the appropriate HTTP response headers. |
31 std::string CreateHttpHeaders(CFInvocation invocation, | 31 std::string CreateHttpHeaders(CFInvocation invocation, |
32 bool add_no_cache_header, | 32 bool add_no_cache_header, |
33 const std::string& content_type) { | 33 const std::string& content_type) { |
34 std::ostringstream ss; | 34 std::ostringstream ss; |
35 ss << "HTTP/1.1 200 OK\r\n" | 35 ss << "HTTP/1.1 200 OK\r\n" |
36 << "Connection: close\r\n" | 36 << "Connection: close\r\n" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (!ret) { | 196 if (!ret) { |
197 LOG(ERROR) << "Error text: " << (data.empty() ? "<empty>" : data.c_str()); | 197 LOG(ERROR) << "Error text: " << (data.empty() ? "<empty>" : data.c_str()); |
198 } | 198 } |
199 | 199 |
200 return ret; | 200 return ret; |
201 } | 201 } |
202 | 202 |
203 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, | 203 void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser, |
204 const wchar_t* page, const wchar_t* result_file_to_check) { | 204 const wchar_t* page, const wchar_t* result_file_to_check) { |
205 ASSERT_TRUE(LaunchBrowser(browser, page)); | 205 ASSERT_TRUE(LaunchBrowser(browser, page)); |
206 ASSERT_TRUE(WaitForTestToComplete(kLongWaitTimeout)); | 206 WaitForTestToComplete(kLongWaitTimeout); |
207 ASSERT_TRUE(CheckResultFile(result_file_to_check, "OK")); | 207 ASSERT_TRUE(CheckResultFile(result_file_to_check, "OK")); |
208 } | 208 } |
209 | 209 |
210 void ChromeFrameTestWithWebServer::OptionalBrowserTest(BrowserKind browser, | 210 void ChromeFrameTestWithWebServer::OptionalBrowserTest(BrowserKind browser, |
211 const wchar_t* page, const wchar_t* result_file_to_check) { | 211 const wchar_t* page, const wchar_t* result_file_to_check) { |
212 DCHECK(browser != CHROME) << "Chrome tests shouldn't be optional"; | 212 DCHECK(browser != CHROME) << "Chrome tests shouldn't be optional"; |
213 if (!LaunchBrowser(browser, page)) { | 213 if (!LaunchBrowser(browser, page)) { |
214 LOG(ERROR) << "Failed to launch browser " << ToString(browser); | 214 LOG(ERROR) << "Failed to launch browser " << ToString(browser); |
215 } else { | 215 } else { |
216 ASSERT_TRUE(WaitForTestToComplete(kLongWaitTimeout)); | 216 WaitForTestToComplete(kLongWaitTimeout); |
217 ASSERT_TRUE(CheckResultFile(result_file_to_check, "OK")); | 217 ASSERT_TRUE(CheckResultFile(result_file_to_check, "OK")); |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, | 221 void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser, |
222 const wchar_t* page, const wchar_t* result_file_to_check) { | 222 const wchar_t* page, const wchar_t* result_file_to_check) { |
223 FilePath plugin_path; | 223 FilePath plugin_path; |
224 PathService::Get(base::DIR_MODULE, &plugin_path); | 224 PathService::Get(base::DIR_MODULE, &plugin_path); |
225 plugin_path = plugin_path.AppendASCII("servers"); | 225 plugin_path = plugin_path.AppendASCII("servers"); |
226 plugin_path = plugin_path.Append(kChromeFrameDllName); | 226 plugin_path = plugin_path.Append(kChromeFrameDllName); |
(...skipping 19 matching lines...) Expand all Loading... |
246 ver_system ? ver_system->GetString() : ver_user->GetString()); | 246 ver_system ? ver_system->GetString() : ver_user->GetString()); |
247 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); | 247 cf_dll_path = cf_dll_path.Append(kChromeFrameDllName); |
248 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); | 248 version_info = FileVersionInfo::CreateFileVersionInfo(cf_dll_path); |
249 if (version_info) | 249 if (version_info) |
250 version = version_info->product_version(); | 250 version = version_info->product_version(); |
251 } | 251 } |
252 | 252 |
253 EXPECT_TRUE(version_info); | 253 EXPECT_TRUE(version_info); |
254 EXPECT_FALSE(version.empty()); | 254 EXPECT_FALSE(version.empty()); |
255 EXPECT_TRUE(LaunchBrowser(browser, page)); | 255 EXPECT_TRUE(LaunchBrowser(browser, page)); |
256 ASSERT_TRUE(WaitForTestToComplete(kLongWaitTimeout)); | 256 WaitForTestToComplete(kLongWaitTimeout); |
257 ASSERT_TRUE(CheckResultFile(result_file_to_check, WideToUTF8(version))); | 257 ASSERT_TRUE(CheckResultFile(result_file_to_check, WideToUTF8(version))); |
258 } | 258 } |
259 | 259 |
260 // MockWebServer methods | 260 // MockWebServer methods |
261 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, | 261 void MockWebServer::ExpectAndServeRequest(CFInvocation invocation, |
262 const std::wstring& url) { | 262 const std::wstring& url) { |
263 EXPECT_CALL(*this, Get(_, chrome_frame_test::UrlPathEq(url), _)) | 263 EXPECT_CALL(*this, Get(_, chrome_frame_test::UrlPathEq(url), _)) |
264 .WillOnce(SendResponse(this, invocation)); | 264 .WillOnce(SendResponse(this, invocation)); |
265 } | 265 } |
266 | 266 |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 chrome_frame_test::TimedMsgLoop loop; | 985 chrome_frame_test::TimedMsgLoop loop; |
986 ASSERT_TRUE(LaunchBrowser(IE, kXHRConditionalHeaderTestUrl)); | 986 ASSERT_TRUE(LaunchBrowser(IE, kXHRConditionalHeaderTestUrl)); |
987 | 987 |
988 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); | 988 loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); |
989 | 989 |
990 chrome_frame_test::CloseAllIEWindows(); | 990 chrome_frame_test::CloseAllIEWindows(); |
991 ASSERT_TRUE(CheckResultFile(L"FullTab_XMLHttpRequestConditionalHeaderTest", | 991 ASSERT_TRUE(CheckResultFile(L"FullTab_XMLHttpRequestConditionalHeaderTest", |
992 "OK")); | 992 "OK")); |
993 } | 993 } |
994 | 994 |
OLD | NEW |