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 "mock_accessible_ability_listener.h" 17 #include "accessibility_ut_helper.h" 18 #include "key_event.h" 19 20 namespace OHOS { 21 namespace Accessibility { 22 namespace { 23 constexpr int32_t CHANNEL_ID = 1; 24 } // namespace 25 OnAbilityConnected()26void MockAccessibleAbilityListener::OnAbilityConnected() 27 { 28 AccessibilityAbilityHelper::GetInstance().SetTestChannelId(CHANNEL_ID); 29 } 30 OnAbilityDisconnected()31void MockAccessibleAbilityListener::OnAbilityDisconnected() 32 { 33 AccessibilityAbilityHelper::GetInstance().SetTestChannelId(INVALID_CHANNEL_ID); 34 } 35 OnAccessibilityEvent(const AccessibilityEventInfo & eventInfo)36void MockAccessibleAbilityListener::OnAccessibilityEvent(const AccessibilityEventInfo &eventInfo) 37 { 38 AccessibilityAbilityHelper::GetInstance().SetTestEventType(static_cast<EventType>(eventInfo.GetEventType())); 39 } 40 OnKeyPressEvent(const std::shared_ptr<MMI::KeyEvent> & keyEvent)41bool MockAccessibleAbilityListener::OnKeyPressEvent(const std::shared_ptr<MMI::KeyEvent> &keyEvent) 42 { 43 AccessibilityAbilityHelper::GetInstance().SetTestKeyPressEvent(static_cast<int>(keyEvent->GetKeyCode())); 44 return true; 45 } 46 } // namespace Accessibility 47 } // namespace OHOS