Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/mock_ie_event_sink_test.h" | 5 #include "chrome_frame/test/mock_ie_event_sink_test.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/win/scoped_variant.h" | 10 #include "base/win/scoped_variant.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 if (result.type() == VT_I4) { | 173 if (result.type() == VT_I4) { |
| 174 EXPECT_EQ(ready_state, static_cast<int>(V_I4(&result))); | 174 EXPECT_EQ(ready_state, static_cast<int>(V_I4(&result))); |
| 175 } | 175 } |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 } | 178 } |
| 179 | 179 |
| 180 // MockIEEventSinkTest methods | 180 // MockIEEventSinkTest methods |
| 181 MockIEEventSinkTest::MockIEEventSinkTest() : server_mock_(1337, L"127.0.0.1", | 181 MockIEEventSinkTest::MockIEEventSinkTest() : server_mock_(1337, L"127.0.0.1", |
| 182 GetTestDataFolder()) { | 182 GetTestDataFolder()) { |
| 183 loop_.set_snapshot_on_timeout(true); | |
| 183 EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) | 184 EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) |
| 184 .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); | 185 .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); |
| 185 } | 186 } |
| 186 | 187 |
| 187 MockIEEventSinkTest::MockIEEventSinkTest(int port, const std::wstring& address, | 188 MockIEEventSinkTest::MockIEEventSinkTest(int port, const std::wstring& address, |
| 188 const FilePath& root_dir) | 189 const FilePath& root_dir) |
| 189 : server_mock_(port, address, root_dir) { | 190 : server_mock_(port, address, root_dir) { |
| 191 loop_.set_snapshot_on_timeout(true); | |
| 190 EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) | 192 EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) |
| 191 .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); | 193 .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); |
| 192 } | 194 } |
| 193 | 195 |
| 194 void MockIEEventSinkTest::LaunchIEAndNavigate(const std::wstring& url) { | 196 void MockIEEventSinkTest::LaunchIEAndNavigate(const std::wstring& url) { |
| 195 LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeoutInSeconds); | 197 LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeout); |
| 196 } | 198 } |
| 197 | 199 |
| 198 void MockIEEventSinkTest::LaunchIENavigateAndLoop(const std::wstring& url, | 200 void MockIEEventSinkTest::LaunchIENavigateAndLoop(const std::wstring& url, |
| 199 int timeout) { | 201 base::TimeDelta timeout) { |
| 200 if (GetInstalledIEVersion() >= IE_8) { | 202 if (GetInstalledIEVersion() >= IE_8) { |
| 201 chrome_frame_test::ClearIESessionHistory(); | 203 chrome_frame_test::ClearIESessionHistory(); |
| 202 } | 204 } |
| 203 hung_call_detector_ = HungCOMCallDetector::Setup(timeout); | 205 hung_call_detector_ = HungCOMCallDetector::Setup(ceil(timeout.InSecondsF())); |
|
robertshield
2012/04/11 17:03:36
why no InSeconds()?
grt (UTC plus 2)
2012/04/11 17:33:08
InSeconds would return 0 if timeout is less than 5
| |
| 204 EXPECT_TRUE(hung_call_detector_ != NULL); | 206 EXPECT_TRUE(hung_call_detector_ != NULL); |
| 205 | 207 |
| 206 IEEventSink::SetAbnormalShutdown(false); | 208 IEEventSink::SetAbnormalShutdown(false); |
| 207 | 209 |
| 208 EXPECT_CALL(ie_mock_, OnQuit()) | 210 EXPECT_CALL(ie_mock_, OnQuit()) |
| 209 .WillOnce(QUIT_LOOP(loop_)); | 211 .WillOnce(QUIT_LOOP(loop_)); |
| 210 | 212 |
| 211 HRESULT hr = ie_mock_.event_sink()->LaunchIEAndNavigate(url, &ie_mock_); | 213 HRESULT hr = ie_mock_.event_sink()->LaunchIEAndNavigate(url, &ie_mock_); |
| 212 ASSERT_HRESULT_SUCCEEDED(hr); | 214 ASSERT_HRESULT_SUCCEEDED(hr); |
| 213 if (hr != S_FALSE) { | 215 if (hr != S_FALSE) { |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 225 const std::wstring& relative_path) { | 227 const std::wstring& relative_path) { |
| 226 return server_mock_.root_dir().Append(relative_path); | 228 return server_mock_.root_dir().Append(relative_path); |
| 227 } | 229 } |
| 228 | 230 |
| 229 std::wstring MockIEEventSinkTest::GetTestUrl( | 231 std::wstring MockIEEventSinkTest::GetTestUrl( |
| 230 const std::wstring& relative_path) { | 232 const std::wstring& relative_path) { |
| 231 return server_mock_.Resolve(relative_path.c_str()); | 233 return server_mock_.Resolve(relative_path.c_str()); |
| 232 } | 234 } |
| 233 | 235 |
| 234 } // namespace chrome_frame_test | 236 } // namespace chrome_frame_test |
| OLD | NEW |