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 // Cookie API implementation unit tests. | 5 // Cookie API implementation unit tests. |
6 | 6 |
7 // MockWin32 can't be included after ChromeFrameHost because of an include | 7 // MockWin32 can't be included after ChromeFrameHost because of an include |
8 // incompatibility with atlwin.h. | 8 // incompatibility with atlwin.h. |
9 #include "ceee/testing/utils/mock_win32.h" // NOLINT | 9 #include "ceee/testing/utils/mock_win32.h" // NOLINT |
10 | 10 |
11 #include "base/scoped_comptr_win.h" | |
12 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/win/scoped_comptr.h" |
13 #include "ceee/common/process_utils_win.h" | 13 #include "ceee/common/process_utils_win.h" |
14 #include "ceee/ie/broker/api_dispatcher.h" | 14 #include "ceee/ie/broker/api_dispatcher.h" |
15 #include "ceee/ie/broker/api_module_constants.h" | 15 #include "ceee/ie/broker/api_module_constants.h" |
16 #include "ceee/ie/broker/cookie_api_module.h" | 16 #include "ceee/ie/broker/cookie_api_module.h" |
17 #include "ceee/ie/broker/tab_api_module.h" | 17 #include "ceee/ie/broker/tab_api_module.h" |
18 #include "ceee/ie/broker/window_api_module.h" | 18 #include "ceee/ie/broker/window_api_module.h" |
19 #include "ceee/ie/testing/mock_broker_and_friends.h" | 19 #include "ceee/ie/testing/mock_broker_and_friends.h" |
20 #include "ceee/testing/utils/instance_count_mixin.h" | 20 #include "ceee/testing/utils/instance_count_mixin.h" |
21 #include "ceee/testing/utils/mock_window_utils.h" | 21 #include "ceee/testing/utils/mock_window_utils.h" |
22 #include "ceee/testing/utils/test_utils.h" | 22 #include "ceee/testing/utils/test_utils.h" |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // Test failed executor access. | 357 // Test failed executor access. |
358 EXPECT_CALL(result.mock_api_dispatcher_, | 358 EXPECT_CALL(result.mock_api_dispatcher_, |
359 GetExecutor(test_tab_window, _, NotNull())). | 359 GetExecutor(test_tab_window, _, NotNull())). |
360 WillOnce(SetArgumentPointee<2>(static_cast<void*>(NULL))); | 360 WillOnce(SetArgumentPointee<2>(static_cast<void*>(NULL))); |
361 EXPECT_CALL(result, PostError(_)).Times(1); | 361 EXPECT_CALL(result, PostError(_)).Times(1); |
362 EXPECT_HRESULT_FAILED(result.CallGetCookieInfo("helloworld", "foo", | 362 EXPECT_HRESULT_FAILED(result.CallGetCookieInfo("helloworld", "foo", |
363 test_frame_window, false, | 363 test_frame_window, false, |
364 NULL)); | 364 NULL)); |
365 // Test executor. | 365 // Test executor. |
366 testing::MockCookieExecutor* mock_cookie_executor; | 366 testing::MockCookieExecutor* mock_cookie_executor; |
367 ScopedComPtr<ICeeeCookieExecutor> mock_cookie_executor_keeper; | 367 base::win::ScopedComPtr<ICeeeCookieExecutor> mock_cookie_executor_keeper; |
368 EXPECT_HRESULT_SUCCEEDED(testing::MockCookieExecutor::CreateInitialized( | 368 EXPECT_HRESULT_SUCCEEDED(testing::MockCookieExecutor::CreateInitialized( |
369 &mock_cookie_executor, mock_cookie_executor_keeper.Receive())); | 369 &mock_cookie_executor, mock_cookie_executor_keeper.Receive())); |
370 EXPECT_CALL(result.mock_api_dispatcher_, | 370 EXPECT_CALL(result.mock_api_dispatcher_, |
371 GetExecutor(test_tab_window, _, NotNull())). | 371 GetExecutor(test_tab_window, _, NotNull())). |
372 WillRepeatedly(DoAll(SetArgumentPointee<2>( | 372 WillRepeatedly(DoAll(SetArgumentPointee<2>( |
373 mock_cookie_executor_keeper.get()), | 373 mock_cookie_executor_keeper.get()), |
374 AddRef(mock_cookie_executor_keeper.get()))); | 374 AddRef(mock_cookie_executor_keeper.get()))); |
375 // Failing Executor. | 375 // Failing Executor. |
376 // The executor classes are already strict from their base class impl. | 376 // The executor classes are already strict from their base class impl. |
377 EXPECT_CALL(*mock_cookie_executor, GetCookie(_, _, _)). | 377 EXPECT_CALL(*mock_cookie_executor, GetCookie(_, _, _)). |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 scoped_ptr<ListValue> tab_list; | 535 scoped_ptr<ListValue> tab_list; |
536 | 536 |
537 // Test failed executor access. | 537 // Test failed executor access. |
538 EXPECT_CALL(result.mock_api_dispatcher_, | 538 EXPECT_CALL(result.mock_api_dispatcher_, |
539 GetExecutor(test_frame_window, _, NotNull())). | 539 GetExecutor(test_frame_window, _, NotNull())). |
540 WillOnce(SetArgumentPointee<2>(static_cast<void*>(NULL))); | 540 WillOnce(SetArgumentPointee<2>(static_cast<void*>(NULL))); |
541 EXPECT_FALSE(result.CallGetTabListForWindow(test_frame_window, &tab_list)); | 541 EXPECT_FALSE(result.CallGetTabListForWindow(test_frame_window, &tab_list)); |
542 | 542 |
543 // Test executor. | 543 // Test executor. |
544 testing::MockWindowExecutor* mock_window_executor; | 544 testing::MockWindowExecutor* mock_window_executor; |
545 ScopedComPtr<ICeeeWindowExecutor> mock_window_executor_keeper; | 545 base::win::ScopedComPtr<ICeeeWindowExecutor> mock_window_executor_keeper; |
546 EXPECT_HRESULT_SUCCEEDED(testing::MockWindowExecutor::CreateInitialized( | 546 EXPECT_HRESULT_SUCCEEDED(testing::MockWindowExecutor::CreateInitialized( |
547 &mock_window_executor, mock_window_executor_keeper.Receive())); | 547 &mock_window_executor, mock_window_executor_keeper.Receive())); |
548 EXPECT_CALL(result.mock_api_dispatcher_, | 548 EXPECT_CALL(result.mock_api_dispatcher_, |
549 GetExecutor(test_frame_window, _, NotNull())). | 549 GetExecutor(test_frame_window, _, NotNull())). |
550 WillRepeatedly(DoAll(SetArgumentPointee<2>( | 550 WillRepeatedly(DoAll(SetArgumentPointee<2>( |
551 mock_window_executor_keeper.get()), | 551 mock_window_executor_keeper.get()), |
552 AddRef(mock_window_executor_keeper.get()))); | 552 AddRef(mock_window_executor_keeper.get()))); |
553 // Failing Executor. | 553 // Failing Executor. |
554 // The executor classes are already strict from their base class impl. | 554 // The executor classes are already strict from their base class impl. |
555 EXPECT_CALL(*mock_window_executor, GetTabs(NotNull())). | 555 EXPECT_CALL(*mock_window_executor, GetTabs(NotNull())). |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 | 646 |
647 // Test failed executor access. | 647 // Test failed executor access. |
648 EXPECT_CALL(result.mock_api_dispatcher_, | 648 EXPECT_CALL(result.mock_api_dispatcher_, |
649 GetExecutor(test_window, _, NotNull())). | 649 GetExecutor(test_window, _, NotNull())). |
650 WillOnce(SetArgumentPointee<2>(static_cast<void*>(NULL))); | 650 WillOnce(SetArgumentPointee<2>(static_cast<void*>(NULL))); |
651 EXPECT_FALSE(result.CallGetTabProtectedMode(test_window, | 651 EXPECT_FALSE(result.CallGetTabProtectedMode(test_window, |
652 &is_protected_mode)); | 652 &is_protected_mode)); |
653 | 653 |
654 // Test executor. | 654 // Test executor. |
655 testing::MockTabExecutor* mock_tab_executor; | 655 testing::MockTabExecutor* mock_tab_executor; |
656 ScopedComPtr<ICeeeTabExecutor> mock_tab_executor_keeper; | 656 base::win::ScopedComPtr<ICeeeTabExecutor> mock_tab_executor_keeper; |
657 EXPECT_HRESULT_SUCCEEDED(testing::MockTabExecutor::CreateInitialized( | 657 EXPECT_HRESULT_SUCCEEDED(testing::MockTabExecutor::CreateInitialized( |
658 &mock_tab_executor, mock_tab_executor_keeper.Receive())); | 658 &mock_tab_executor, mock_tab_executor_keeper.Receive())); |
659 EXPECT_CALL(result.mock_api_dispatcher_, | 659 EXPECT_CALL(result.mock_api_dispatcher_, |
660 GetExecutor(test_window, _, NotNull())). | 660 GetExecutor(test_window, _, NotNull())). |
661 WillRepeatedly(DoAll( | 661 WillRepeatedly(DoAll( |
662 SetArgumentPointee<2>(mock_tab_executor_keeper.get()), | 662 SetArgumentPointee<2>(mock_tab_executor_keeper.get()), |
663 AddRef(mock_tab_executor_keeper.get()))); | 663 AddRef(mock_tab_executor_keeper.get()))); |
664 // Failing Executor. | 664 // Failing Executor. |
665 // The executor classes are already strict from their base class impl. | 665 // The executor classes are already strict from their base class impl. |
666 EXPECT_CALL(*mock_tab_executor, GetTabInfo(NotNull())). | 666 EXPECT_CALL(*mock_tab_executor, GetTabInfo(NotNull())). |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1022 Return(true))); | 1022 Return(true))); |
1023 EXPECT_CALL(*cookie_changed.api_result_, | 1023 EXPECT_CALL(*cookie_changed.api_result_, |
1024 CookieStoreIsRegistered(HWND(5))).WillOnce(Return(S_FALSE)); | 1024 CookieStoreIsRegistered(HWND(5))).WillOnce(Return(S_FALSE)); |
1025 EXPECT_CALL(*cookie_changed.api_result_, | 1025 EXPECT_CALL(*cookie_changed.api_result_, |
1026 RegisterCookieStore(HWND(5))).WillOnce(Return(S_OK)); | 1026 RegisterCookieStore(HWND(5))).WillOnce(Return(S_OK)); |
1027 EXPECT_EQ(true, | 1027 EXPECT_EQ(true, |
1028 cookie_changed.EventHandlerImpl(input_args, &converted_args)); | 1028 cookie_changed.EventHandlerImpl(input_args, &converted_args)); |
1029 } | 1029 } |
1030 | 1030 |
1031 } // namespace | 1031 } // namespace |
OLD | NEW |