| 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 // IE browser helper object implementation. | 5 // IE browser helper object implementation. |
| 6 #include "ceee/ie/plugin/bho/browser_helper_object.h" | 6 #include "ceee/ie/plugin/bho/browser_helper_object.h" |
| 7 | 7 |
| 8 #include <exdisp.h> | 8 #include <exdisp.h> |
| 9 #include <shlguid.h> | 9 #include <shlguid.h> |
| 10 | 10 |
| 11 #include "ceee/common/initializing_coclass.h" | 11 #include "ceee/common/initializing_coclass.h" |
| 12 #include "ceee/ie/common/constants.h" |
| 12 #include "ceee/ie/common/mock_ceee_module_util.h" | 13 #include "ceee/ie/common/mock_ceee_module_util.h" |
| 13 #include "ceee/ie/testing/mock_broker_and_friends.h" | 14 #include "ceee/ie/testing/mock_broker_and_friends.h" |
| 14 #include "ceee/ie/testing/mock_browser_and_friends.h" | 15 #include "ceee/ie/testing/mock_browser_and_friends.h" |
| 15 #include "ceee/ie/testing/mock_chrome_frame_host.h" | 16 #include "ceee/ie/testing/mock_chrome_frame_host.h" |
| 16 #include "ceee/testing/utils/dispex_mocks.h" | 17 #include "ceee/testing/utils/dispex_mocks.h" |
| 17 #include "ceee/testing/utils/instance_count_mixin.h" | 18 #include "ceee/testing/utils/instance_count_mixin.h" |
| 18 #include "ceee/testing/utils/mock_com.h" | 19 #include "ceee/testing/utils/mock_com.h" |
| 19 #include "ceee/testing/utils/test_utils.h" | 20 #include "ceee/testing/utils/test_utils.h" |
| 20 #include "gmock/gmock.h" | 21 #include "gmock/gmock.h" |
| 21 #include "gtest/gtest.h" | 22 #include "gtest/gtest.h" |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 ExpectFireOnRemovedEvent(0); | 860 ExpectFireOnRemovedEvent(0); |
| 860 ExpectFireOnUnmappedEvent(1); | 861 ExpectFireOnUnmappedEvent(1); |
| 861 ASSERT_HRESULT_SUCCEEDED(bho_with_site_->SetSite(NULL)); | 862 ASSERT_HRESULT_SUCCEEDED(bho_with_site_->SetSite(NULL)); |
| 862 } | 863 } |
| 863 | 864 |
| 864 TEST_F(BrowserHelperObjectTest, SetToolBandSessionId) { | 865 TEST_F(BrowserHelperObjectTest, SetToolBandSessionId) { |
| 865 CreateSite(); | 866 CreateSite(); |
| 866 CreateBrowser(); | 867 CreateBrowser(); |
| 867 | 868 |
| 868 ASSERT_HRESULT_SUCCEEDED(bho_with_site_->SetSite(site_keeper_)); | 869 ASSERT_HRESULT_SUCCEEDED(bho_with_site_->SetSite(site_keeper_)); |
| 869 EXPECT_CALL(*(bho_->broker_), SetTabToolBandIdForHandle(kGoodTabId, | 870 EXPECT_CALL(bho_->mock_broker_rpc_client_, FireEvent( |
| 870 kGoodTabHandle)).WillOnce(Return(S_OK)); | 871 StrEq(ceee_event_names::kCeeeMapToolbandIdToHandle), _)). |
| 872 WillOnce(Return(S_OK)); |
| 871 EXPECT_EQ(S_OK, bho_->SetToolBandSessionId(kGoodTabId)); | 873 EXPECT_EQ(S_OK, bho_->SetToolBandSessionId(kGoodTabId)); |
| 872 | 874 |
| 873 EXPECT_CALL(*(bho_->broker_), SetTabToolBandIdForHandle(kGoodTabId, | 875 EXPECT_CALL(bho_->mock_broker_rpc_client_, FireEvent( |
| 874 kGoodTabHandle)).WillOnce(Return(E_FAIL)); | 876 StrEq(ceee_event_names::kCeeeMapToolbandIdToHandle), _)). |
| 877 WillOnce(Return(E_FAIL)); |
| 875 EXPECT_EQ(E_FAIL, bho_->SetToolBandSessionId(kGoodTabId)); | 878 EXPECT_EQ(E_FAIL, bho_->SetToolBandSessionId(kGoodTabId)); |
| 876 | 879 |
| 877 ExpectFireOnRemovedEvent(0); | 880 ExpectFireOnRemovedEvent(0); |
| 878 ExpectFireOnUnmappedEvent(1); | 881 ExpectFireOnUnmappedEvent(1); |
| 879 ASSERT_HRESULT_SUCCEEDED(bho_with_site_->SetSite(NULL)); | 882 ASSERT_HRESULT_SUCCEEDED(bho_with_site_->SetSite(NULL)); |
| 880 } | 883 } |
| 881 | 884 |
| 882 TEST(BrowserHelperObjectLifeCycleTest, NoBhoForInvisibleToolband) { | 885 TEST(BrowserHelperObjectLifeCycleTest, NoBhoForInvisibleToolband) { |
| 883 StrictMock<testing::MockCeeeModuleUtils> ceee_module_utils; | 886 StrictMock<testing::MockCeeeModuleUtils> ceee_module_utils; |
| 884 EXPECT_CALL(ceee_module_utils, GetOptionToolbandIsHidden()) | 887 EXPECT_CALL(ceee_module_utils, GetOptionToolbandIsHidden()) |
| 885 .WillOnce(Return(false)); | 888 .WillOnce(Return(false)); |
| 886 | 889 |
| 887 TestingBrowserHelperObject* bho; | 890 TestingBrowserHelperObject* bho; |
| 888 base::win::ScopedComPtr<IObjectWithSite> bho_with_site; | 891 base::win::ScopedComPtr<IObjectWithSite> bho_with_site; |
| 889 ASSERT_HRESULT_SUCCEEDED( | 892 ASSERT_HRESULT_SUCCEEDED( |
| 890 TestingBrowserHelperObject::CreateInitialized(&bho, | 893 TestingBrowserHelperObject::CreateInitialized(&bho, |
| 891 bho_with_site.Receive())); | 894 bho_with_site.Receive())); |
| 892 bho_with_site.Release(); | 895 bho_with_site.Release(); |
| 893 bho = NULL; | 896 bho = NULL; |
| 894 | 897 |
| 895 EXPECT_CALL(ceee_module_utils, GetOptionToolbandIsHidden()) | 898 EXPECT_CALL(ceee_module_utils, GetOptionToolbandIsHidden()) |
| 896 .WillOnce(Return(true)); | 899 .WillOnce(Return(true)); |
| 897 ASSERT_HRESULT_FAILED( | 900 ASSERT_HRESULT_FAILED( |
| 898 TestingBrowserHelperObject::CreateInitialized(&bho, | 901 TestingBrowserHelperObject::CreateInitialized(&bho, |
| 899 bho_with_site.Receive())); | 902 bho_with_site.Receive())); |
| 900 ASSERT_EQ(0, testing::InstanceCountMixinBase::all_instance_count()); | 903 ASSERT_EQ(0, testing::InstanceCountMixinBase::all_instance_count()); |
| 901 } | 904 } |
| 902 | 905 |
| 903 } // namespace | 906 } // namespace |
| OLD | NEW |