/* * Copyright (c) 2023 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include "key_subscriber_handler.h" #include "switch_subscriber_handler.h" #include "mmi_log.h" #include "uds_server.h" namespace OHOS { namespace MMI { namespace { using namespace testing::ext; } // namespace class KeySubscriberHandlerTest : public testing::Test { public: static void SetUpTestCase(void) {} static void TearDownTestCase(void) {} }; /** * @tc.name: InputWindowsManagerTest_UnsubscribeKeyEvent_001 * @tc.desc: Test UnsubscribeKeyEvent * @tc.type: FUNC * @tc.require: */ HWTEST_F(KeySubscriberHandlerTest, InputWindowsManagerTest_UnsubscribeKeyEvent_001, TestSize.Level1) { KeySubscriberHandler keySubscriberHandler; auto keyEvent = KeyEvent::Create(); keySubscriberHandler.HandleKeyEvent(keyEvent); auto pointerEvent = PointerEvent::Create(); keySubscriberHandler.HandlePointerEvent(pointerEvent); keySubscriberHandler.HandleTouchEvent(pointerEvent); keySubscriberHandler.RemoveSubscriberKeyUpTimer(1); std::vector args = {}; keySubscriberHandler.Dump(1, args); UDSServer udsServer; SessionPtr sess = udsServer.GetSessionByPid(1); std::shared_ptr keyOption = nullptr; ASSERT_EQ(keySubscriberHandler.SubscribeKeyEvent(sess, -1, keyOption), -1); SessionPtr sessPtr = nullptr; ASSERT_EQ(keySubscriberHandler.UnsubscribeKeyEvent(sessPtr, -1), -1); ASSERT_EQ(keySubscriberHandler.UnsubscribeKeyEvent(sess, 1), -1); } } // namespace MMI } // namespace OHOS