OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/automation_client_mock.h" | 5 #include "chrome_frame/test/automation_client_mock.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "chrome/common/automation_messages.h" | 9 #include "chrome/common/automation_messages.h" |
10 #include "chrome_frame/custom_sync_call_context.h" | 10 #include "chrome_frame/custom_sync_call_context.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 scoped_refptr<ChromeFrameAutomationClient> client; | 100 scoped_refptr<ChromeFrameAutomationClient> client; |
101 client = new ChromeFrameAutomationClient(); | 101 client = new ChromeFrameAutomationClient(); |
102 | 102 |
103 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(AUTOMATION_TIMEOUT, _)) | 103 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(AUTOMATION_TIMEOUT, _)) |
104 .Times(1) | 104 .Times(1) |
105 .WillOnce(QUIT_LOOP(loop)); | 105 .WillOnce(QUIT_LOOP(loop)); |
106 | 106 |
107 GURL empty; | 107 GURL empty; |
108 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 108 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
109 empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", | 109 empty, empty, profile_path, profile_path.BaseName().value(), L"", |
110 false, false, false)); | 110 false, false, false)); |
111 clp->set_launch_timeout(timeout); | 111 clp->set_launch_timeout(timeout); |
112 clp->set_version_check(false); | 112 clp->set_version_check(false); |
113 EXPECT_TRUE(client->Initialize(&cfd, clp)); | 113 EXPECT_TRUE(client->Initialize(&cfd, clp)); |
114 loop.RunFor(10); | 114 loop.RunFor(10); |
115 client->Uninitialize(); | 115 client->Uninitialize(); |
116 } | 116 } |
117 | 117 |
118 // This test may fail if Chrome take more that 10 seconds (timeout var) to | 118 // This test may fail if Chrome take more that 10 seconds (timeout var) to |
119 // launch. In this case GMock shall print something like "unexpected call to | 119 // launch. In this case GMock shall print something like "unexpected call to |
(...skipping 11 matching lines...) Expand all Loading... |
131 | 131 |
132 EXPECT_CALL(cfd, OnAutomationServerReady()) | 132 EXPECT_CALL(cfd, OnAutomationServerReady()) |
133 .Times(1) | 133 .Times(1) |
134 .WillOnce(QUIT_LOOP(loop)); | 134 .WillOnce(QUIT_LOOP(loop)); |
135 | 135 |
136 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(_, _)) | 136 EXPECT_CALL(cfd, OnAutomationServerLaunchFailed(_, _)) |
137 .Times(0); | 137 .Times(0); |
138 | 138 |
139 GURL empty; | 139 GURL empty; |
140 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 140 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
141 empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", | 141 empty, empty, profile_path, profile_path.BaseName().value(), L"", |
142 false, false, false)); | 142 false, false, false)); |
143 clp->set_launch_timeout(timeout); | 143 clp->set_launch_timeout(timeout); |
144 clp->set_version_check(false); | 144 clp->set_version_check(false); |
145 EXPECT_TRUE(client->Initialize(&cfd, clp)); | 145 EXPECT_TRUE(client->Initialize(&cfd, clp)); |
146 | 146 |
147 loop.RunFor(11); | 147 loop.RunFor(11); |
148 client->Uninitialize(); | 148 client->Uninitialize(); |
149 client = NULL; | 149 client = NULL; |
150 } | 150 } |
151 | 151 |
(...skipping 28 matching lines...) Expand all Loading... |
180 | 180 |
181 EXPECT_CALL(cfd, OnUpdateTargetUrl(_)).Times(testing::AtMost(1)); | 181 EXPECT_CALL(cfd, OnUpdateTargetUrl(_)).Times(testing::AtMost(1)); |
182 | 182 |
183 EXPECT_CALL(cfd, OnLoad(_)) | 183 EXPECT_CALL(cfd, OnLoad(_)) |
184 .Times(1) | 184 .Times(1) |
185 .WillOnce(QUIT_LOOP(loop)); | 185 .WillOnce(QUIT_LOOP(loop)); |
186 } | 186 } |
187 | 187 |
188 GURL empty; | 188 GURL empty; |
189 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 189 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
190 empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", | 190 empty, empty, profile_path, profile_path.BaseName().value(), L"", |
191 false, false, false)); | 191 false, false, false)); |
192 clp->set_launch_timeout(timeout); | 192 clp->set_launch_timeout(timeout); |
193 clp->set_version_check(false); | 193 clp->set_version_check(false); |
194 EXPECT_TRUE(client->Initialize(&cfd, clp)); | 194 EXPECT_TRUE(client->Initialize(&cfd, clp)); |
195 loop.RunFor(10); | 195 loop.RunFor(10); |
196 client->Uninitialize(); | 196 client->Uninitialize(); |
197 client = NULL; | 197 client = NULL; |
198 } | 198 } |
199 | 199 |
200 TEST(CFACWithChrome, NavigateFailed) { | 200 TEST(CFACWithChrome, NavigateFailed) { |
(...skipping 26 matching lines...) Expand all Loading... |
227 | 227 |
228 EXPECT_CALL(cfd, OnUpdateTargetUrl(_)).Times(testing::AnyNumber()); | 228 EXPECT_CALL(cfd, OnUpdateTargetUrl(_)).Times(testing::AnyNumber()); |
229 EXPECT_CALL(cfd, OnLoad(_)).Times(testing::AtMost(1)); | 229 EXPECT_CALL(cfd, OnLoad(_)).Times(testing::AtMost(1)); |
230 | 230 |
231 EXPECT_CALL(cfd, OnNavigationFailed(_, GURL(url))) | 231 EXPECT_CALL(cfd, OnNavigationFailed(_, GURL(url))) |
232 .Times(1) | 232 .Times(1) |
233 .WillOnce(QUIT_LOOP_SOON(loop, 2)); | 233 .WillOnce(QUIT_LOOP_SOON(loop, 2)); |
234 | 234 |
235 GURL empty; | 235 GURL empty; |
236 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 236 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
237 empty, empty, profile_path, profile_path.BaseName().value(), L"", L"", | 237 empty, empty, profile_path, profile_path.BaseName().value(), L"", |
238 false, false, false)); | 238 false, false, false)); |
239 clp->set_launch_timeout(10000); | 239 clp->set_launch_timeout(10000); |
240 clp->set_version_check(false); | 240 clp->set_version_check(false); |
241 EXPECT_TRUE(client->Initialize(&cfd, clp)); | 241 EXPECT_TRUE(client->Initialize(&cfd, clp)); |
242 | 242 |
243 loop.RunFor(10); | 243 loop.RunFor(10); |
244 client->Uninitialize(); | 244 client->Uninitialize(); |
245 client = NULL; | 245 client = NULL; |
246 } | 246 } |
247 | 247 |
(...skipping 17 matching lines...) Expand all Loading... |
265 .WillOnce(Return(tab_)); | 265 .WillOnce(Return(tab_)); |
266 | 266 |
267 EXPECT_CALL(cfd_, OnAutomationServerReady()) | 267 EXPECT_CALL(cfd_, OnAutomationServerReady()) |
268 .WillOnce(QUIT_LOOP(loop_)); | 268 .WillOnce(QUIT_LOOP(loop_)); |
269 | 269 |
270 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); | 270 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); |
271 | 271 |
272 // Here we go! | 272 // Here we go! |
273 GURL empty; | 273 GURL empty; |
274 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 274 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
275 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", | 275 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", |
276 false, false, false)); | 276 false, false, false)); |
277 clp->set_launch_timeout(timeout); | 277 clp->set_launch_timeout(timeout); |
278 clp->set_version_check(false); | 278 clp->set_version_check(false); |
279 EXPECT_TRUE(client_->Initialize(&cfd_, clp)); | 279 EXPECT_TRUE(client_->Initialize(&cfd_, clp)); |
280 loop_.RunFor(10); | 280 loop_.RunFor(10); |
281 | 281 |
282 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); | 282 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); |
283 client_->Uninitialize(); | 283 client_->Uninitialize(); |
284 } | 284 } |
285 | 285 |
(...skipping 12 matching lines...) Expand all Loading... |
298 | 298 |
299 EXPECT_CALL(mock_proxy_, CreateTabProxy(_)).Times(0); | 299 EXPECT_CALL(mock_proxy_, CreateTabProxy(_)).Times(0); |
300 | 300 |
301 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); | 301 EXPECT_CALL(mock_proxy_, CancelAsync(_)).Times(testing::AnyNumber()); |
302 | 302 |
303 Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED); | 303 Set_CFD_LaunchFailed(AUTOMATION_CREATE_TAB_FAILED); |
304 | 304 |
305 // Here we go! | 305 // Here we go! |
306 GURL empty; | 306 GURL empty; |
307 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 307 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
308 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", | 308 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", |
309 false, false, false)); | 309 false, false, false)); |
310 clp->set_launch_timeout(timeout_); | 310 clp->set_launch_timeout(timeout_); |
311 clp->set_version_check(false); | 311 clp->set_version_check(false); |
312 EXPECT_TRUE(client_->Initialize(&cfd_, clp)); | 312 EXPECT_TRUE(client_->Initialize(&cfd_, clp)); |
313 loop_.RunFor(4); | 313 loop_.RunFor(4); |
314 client_->Uninitialize(); | 314 client_->Uninitialize(); |
315 } | 315 } |
316 | 316 |
317 class TestChromeFrameAutomationProxyImpl | 317 class TestChromeFrameAutomationProxyImpl |
318 : public ChromeFrameAutomationProxyImpl { | 318 : public ChromeFrameAutomationProxyImpl { |
(...skipping 20 matching lines...) Expand all Loading... |
339 // No tabs should do nothing yet still not fail either. | 339 // No tabs should do nothing yet still not fail either. |
340 proxy.FakeChannelError(); | 340 proxy.FakeChannelError(); |
341 } | 341 } |
342 | 342 |
343 TEST_F(CFACMockTest, OnChannelError) { | 343 TEST_F(CFACMockTest, OnChannelError) { |
344 TestChromeFrameAutomationProxyImpl proxy; | 344 TestChromeFrameAutomationProxyImpl proxy; |
345 returned_proxy_ = &proxy; | 345 returned_proxy_ = &proxy; |
346 | 346 |
347 GURL empty; | 347 GURL empty; |
348 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( | 348 scoped_refptr<ChromeFrameLaunchParams> clp(new ChromeFrameLaunchParams( |
349 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", L"", | 349 empty, empty, profile_path_, profile_path_.BaseName().value(), L"", |
350 false, false, false)); | 350 false, false, false)); |
351 clp->set_launch_timeout(1); // Unneeded timeout, but can't be 0. | 351 clp->set_launch_timeout(1); // Unneeded timeout, but can't be 0. |
352 clp->set_version_check(false); | 352 clp->set_version_check(false); |
353 | 353 |
354 HWND h1 = ::GetDesktopWindow(); | 354 HWND h1 = ::GetDesktopWindow(); |
355 HWND h2 = ::GetDesktopWindow(); | 355 HWND h2 = ::GetDesktopWindow(); |
356 EXPECT_CALL(proxy, SendAsAsync(testing::Property( | 356 EXPECT_CALL(proxy, SendAsAsync(testing::Property( |
357 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab::ID), | 357 &IPC::SyncMessage::type, AutomationMsg_CreateExternalTab::ID), |
358 testing::NotNull(), _)).Times(3) | 358 testing::NotNull(), _)).Times(3) |
359 .WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)) | 359 .WillOnce(HandleCreateTab(tab_handle_, h1, h2, 99)) |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 .Times(1) | 460 .Times(1) |
461 .WillOnce(Return(true)); | 461 .WillOnce(Return(true)); |
462 | 462 |
463 EXPECT_CALL(cfd_, GetBounds(_)).Times(1); | 463 EXPECT_CALL(cfd_, GetBounds(_)).Times(1); |
464 | 464 |
465 // Here we go! | 465 // Here we go! |
466 GURL empty; | 466 GURL empty; |
467 scoped_refptr<ChromeFrameLaunchParams> launch_params( | 467 scoped_refptr<ChromeFrameLaunchParams> launch_params( |
468 new ChromeFrameLaunchParams( | 468 new ChromeFrameLaunchParams( |
469 GURL("http://www.nonexistent.com"), empty, profile_path_, | 469 GURL("http://www.nonexistent.com"), empty, profile_path_, |
470 profile_path_.BaseName().value(), L"", L"", false, false, false)); | 470 profile_path_.BaseName().value(), L"", false, false, false)); |
471 launch_params->set_launch_timeout(timeout); | 471 launch_params->set_launch_timeout(timeout); |
472 launch_params->set_version_check(false); | 472 launch_params->set_version_check(false); |
473 EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); | 473 EXPECT_TRUE(client_->Initialize(&cfd_, launch_params)); |
474 loop_.RunFor(10); | 474 loop_.RunFor(10); |
475 | 475 |
476 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); | 476 EXPECT_CALL(mock_proxy_, ReleaseTabProxy(testing::Eq(tab_handle_))).Times(1); |
477 client_->Uninitialize(); | 477 client_->Uninitialize(); |
478 } | 478 } |
OLD | NEW |