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 "ability_context.h" 20 #include "accessibility_element_operator.h" 21 #include "accessibility_element_operator_stub.h" 22 #include "accessibility_system_ability_client.h" 23 #include "accessible_ability_manager_service_proxy.h" 24 #include "accessible_ability_manager_service_state_stub.h" 25 #include "hilog_wrapper.h" 26 #include "if_system_ability_manager.h" 27 #include "iservice_registry.h" 28 #include "mock_accessible_ability_manager_service_impl.h" 29 #include "system_ability_definition.h" 30 31 using namespace OHOS::AppExecFwk; 32 using namespace testing; 33 using namespace testing::ext; 34 using namespace std; 35 36 namespace OHOS { 37 namespace Accessibility { 38 class ASACClientUnitTest : public ::testing::Test { 39 public: ASACClientUnitTest()40 ASACClientUnitTest() {} ~ASACClientUnitTest()41 ~ASACClientUnitTest() {} 42 SetUpTestCase()43 static void SetUpTestCase() 44 { 45 GTEST_LOG_(INFO) << "ASACClientUnitTest Start"; 46 } TearDownTestCase()47 static void TearDownTestCase() 48 { 49 GTEST_LOG_(INFO) << "ASACClientUnitTest End"; 50 } SetUp()51 void SetUp() 52 { 53 GTEST_LOG_(INFO) << "ASACClientUnitTest SetUp()"; 54 }; TearDown()55 void TearDown() 56 { 57 GTEST_LOG_(INFO) << "ASACClientUnitTest TearDown()"; 58 } 59 }; 60 61 /** 62 * @tc.number: AccessibilityStateEvent_001 63 * @tc.name: Function 64 * @tc.desc: Test function 65 */ 66 HWTEST_F(ASACClientUnitTest, AccessibilityStateEvent_001, TestSize.Level1) 67 { 68 AccessibilityStateEvent stateEvent {}; 69 AccessibilityStateEventType eventType = AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED; 70 GTEST_LOG_(INFO) << "SetEventType start"; 71 stateEvent.SetEventType(eventType); 72 EXPECT_TRUE(stateEvent.GetEventType() == AccessibilityStateEventType::EVENT_ACCESSIBILITY_STATE_CHANGED); 73 GTEST_LOG_(INFO) << "SetEventType start"; 74 75 GTEST_LOG_(INFO) << "SetEventMsg start"; 76 string str = "test"; 77 stateEvent.SetEventMsg(str); 78 EXPECT_TRUE(!strcmp(stateEvent.GetEventMsg().c_str(), "test")); 79 GTEST_LOG_(INFO) << "SetEventMsg start"; 80 81 GTEST_LOG_(INFO) << "SetEventResult start"; 82 stateEvent.SetEventResult(1); 83 EXPECT_TRUE(stateEvent.GetEventResult() == 1); 84 GTEST_LOG_(INFO) << "SetEventResult start"; 85 } 86 } // namespace Accessibility 87 } // namespace OHOS