1 /* 2 * Copyright (C) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include <gtest/gtest.h> 17 #include <memory> 18 19 #include "accessibility_system_ability_client.h" 20 #include "accessible_ability_manager_service_state_proxy.h" 21 #include "accessible_ability_manager_service_state_stub.h" 22 23 using namespace testing; 24 using namespace testing::ext; 25 using namespace std; 26 27 namespace OHOS { 28 namespace Accessibility { 29 class ASACStateProxyUnitTest : public ::testing::Test { 30 public: 31 sptr<AccessibleAbilityManagerServiceStateStub> mockStub_ = nullptr; 32 sptr<AccessibleAbilityManagerServiceStateProxy> mockProxy_ = nullptr; 33 ASACStateProxyUnitTest()34 ASACStateProxyUnitTest() {} ~ASACStateProxyUnitTest()35 ~ASACStateProxyUnitTest() {} 36 SetUpTestCase()37 static void SetUpTestCase() 38 { 39 GTEST_LOG_(INFO) << "ASACStateProxyUnitTest Start"; 40 } TearDownTestCase()41 static void TearDownTestCase() 42 { 43 GTEST_LOG_(INFO) << "ASACStateProxyUnitTest End"; 44 } SetUp()45 void SetUp() 46 { 47 GTEST_LOG_(INFO) << "ASACStateProxyUnitTest SetUp()"; 48 mockStub_ = new AccessibleAbilityManagerServiceStateStub(); 49 mockProxy_ = new AccessibleAbilityManagerServiceStateProxy(mockStub_); 50 }; TearDown()51 void TearDown() 52 { 53 GTEST_LOG_(INFO) << "ASACStateProxyUnitTest TearDown()"; 54 mockStub_ = nullptr; 55 } 56 WriteInterfaceToken(MessageParcel & data)57 void WriteInterfaceToken(MessageParcel &data) 58 { 59 GTEST_LOG_(INFO) << "ASACStateProxyUnitTest WriteInterfaceToken"; 60 data.WriteInterfaceToken(AccessibleAbilityManagerServiceStateStub::GetDescriptor()); 61 } 62 }; 63 64 /** 65 * @tc.number: OnStateChanged_001 66 * @tc.name: OnStateChanged 67 * @tc.desc: Test function OnStateChanged 68 */ 69 HWTEST_F(ASACStateProxyUnitTest, OnStateChanged_001, TestSize.Level1) 70 { 71 GTEST_LOG_(INFO) << "OnStateChanged_001 start"; 72 73 mockProxy_->OnStateChanged(static_cast<uint32_t>(IAccessibleAbilityManagerServiceState::Message::ON_STATE_CHANGED)); 74 75 GTEST_LOG_(INFO) << "OnStateChanged_001 end"; 76 } 77 } // namespace Accessibility 78 } // namespace OHOS