| 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/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/scoped_variant_win.h" |
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 10 #include "chrome_frame/test/mock_ie_event_sink_actions.h" | 11 #include "chrome_frame/test/mock_ie_event_sink_actions.h" |
| 11 | 12 |
| 12 // Needed for CreateFunctor. | 13 // Needed for CreateFunctor. |
| 13 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING | 14 #define GMOCK_MUTANT_INCLUDE_LATE_OBJECT_BINDING |
| 14 #include "testing/gmock_mutant.h" | 15 #include "testing/gmock_mutant.h" |
| 15 | 16 |
| 16 using testing::_; | 17 using testing::_; |
| 17 using testing::Cardinality; | 18 using testing::Cardinality; |
| 18 using testing::Exactly; | 19 using testing::Exactly; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 134 |
| 134 void MockIEEventSink::ExpectAnyNavigations() { | 135 void MockIEEventSink::ExpectAnyNavigations() { |
| 135 EXPECT_CALL(*this, OnBeforeNavigate2(_, _, _, _, _, _, _)) | 136 EXPECT_CALL(*this, OnBeforeNavigate2(_, _, _, _, _, _, _)) |
| 136 .Times(testing::AnyNumber()); | 137 .Times(testing::AnyNumber()); |
| 137 EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) | 138 EXPECT_CALL(*this, OnFileDownload(VARIANT_TRUE, _)) |
| 138 .Times(testing::AnyNumber()); | 139 .Times(testing::AnyNumber()); |
| 139 EXPECT_CALL(*this, OnNavigateComplete2(_, _)) | 140 EXPECT_CALL(*this, OnNavigateComplete2(_, _)) |
| 140 .Times(testing::AnyNumber()); | 141 .Times(testing::AnyNumber()); |
| 141 } | 142 } |
| 142 | 143 |
| 144 void MockIEEventSink::ExpectDocumentReadystate(int ready_state) { |
| 145 ScopedComPtr<IWebBrowser2> browser(event_sink_->web_browser2()); |
| 146 EXPECT_TRUE(browser != NULL); |
| 147 if (browser) { |
| 148 ScopedComPtr<IDispatch> document; |
| 149 browser->get_Document(document.Receive()); |
| 150 EXPECT_TRUE(document != NULL); |
| 151 if (document) { |
| 152 DISPPARAMS params = { 0 }; |
| 153 ScopedVariant result; |
| 154 EXPECT_HRESULT_SUCCEEDED(document->Invoke(DISPID_READYSTATE, IID_NULL, |
| 155 LOCALE_USER_DEFAULT, DISPATCH_PROPERTYGET, ¶ms, |
| 156 result.Receive(), NULL, NULL)); |
| 157 EXPECT_EQ(VT_I4, result.type()); |
| 158 if (result.type() == VT_I4) { |
| 159 EXPECT_EQ(ready_state, static_cast<int>(V_I4(&result))); |
| 160 } |
| 161 } |
| 162 } |
| 163 } |
| 164 |
| 143 // MockIEEventSinkTest methods | 165 // MockIEEventSinkTest methods |
| 144 MockIEEventSinkTest::MockIEEventSinkTest() : server_mock_(1337, L"127.0.0.1", | 166 MockIEEventSinkTest::MockIEEventSinkTest() : server_mock_(1337, L"127.0.0.1", |
| 145 GetTestDataFolder()) { | 167 GetTestDataFolder()) { |
| 146 EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) | 168 EXPECT_CALL(server_mock_, Get(_, StrCaseEq(L"/favicon.ico"), _)) |
| 147 .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); | 169 .WillRepeatedly(SendFast("HTTP/1.1 404 Not Found", "")); |
| 148 } | 170 } |
| 149 | 171 |
| 150 void MockIEEventSinkTest::LaunchIEAndNavigate(const std::wstring& url) { | 172 void MockIEEventSinkTest::LaunchIEAndNavigate(const std::wstring& url) { |
| 151 LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeoutInSeconds); | 173 LaunchIENavigateAndLoop(url, kChromeFrameLongNavigationTimeoutInSeconds); |
| 152 } | 174 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 164 loop_.RunFor(timeout); | 186 loop_.RunFor(timeout); |
| 165 } | 187 } |
| 166 | 188 |
| 167 std::wstring MockIEEventSinkTest::GetTestUrl( | 189 std::wstring MockIEEventSinkTest::GetTestUrl( |
| 168 const std::wstring& relative_path) { | 190 const std::wstring& relative_path) { |
| 169 return server_mock_.Resolve(relative_path.c_str()); | 191 return server_mock_.Resolve(relative_path.c_str()); |
| 170 } | 192 } |
| 171 | 193 |
| 172 } // namespace chrome_frame_test | 194 } // namespace chrome_frame_test |
| 173 | 195 |
| OLD | NEW |