/* * 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 "active_key_event_test.h" #include #include #include #include #define private public #define protected public #include "active_key_event.h" #include "log_store_ex.h" #include "hiview_platform.h" #include "sysevent_source.h" using namespace testing::ext; using namespace OHOS::HiviewDFX; namespace OHOS { namespace HiviewDFX { SysEventSource source; void ActiveKeyEventTest::SetUp() { printf("SetUp.\n"); } void ActiveKeyEventTest::TearDown() { printf("TearDown.\n"); } void ActiveKeyEventTest::SetUpTestCase() { HiviewPlatform platform; source.SetHiviewContext(&platform); source.OnLoad(); } void ActiveKeyEventTest::TearDownTestCase() { source.OnUnload(); } /** * @tc.name: ActiveKeyEventTest_001 * @tc.desc: ActiveKeyEventTest CombinationKeyHandle * @tc.type: FUNC */ HWTEST_F(ActiveKeyEventTest, ActiveKeyEventTest_001, TestSize.Level3) { std::string logStorePath = "/data/test/"; std::shared_ptr logStoreEx = std::make_shared(logStorePath, true); auto ret = logStoreEx->Init(); EXPECT_EQ(ret, true); std::shared_ptr activeKeyEvent = std::make_shared(); activeKeyEvent->Init(logStoreEx); activeKeyEvent->triggeringTime_ = 0; auto keyEvent = OHOS::MMI::KeyEvent::Create(); activeKeyEvent->CombinationKeyHandle(keyEvent); } /** * @tc.name: ActiveKeyEventTest_002 * @tc.desc: ActiveKeyEventTest CombinationKeyCallback * @tc.type: FUNC */ HWTEST_F(ActiveKeyEventTest, ActiveKeyEventTest_002, TestSize.Level3) { std::string logStorePath = "/data/test/"; std::shared_ptr logStoreEx = std::make_shared(logStorePath, true); auto ret = logStoreEx->Init(); EXPECT_EQ(ret, true); std::shared_ptr activeKeyEvent = std::make_shared(); activeKeyEvent->Init(logStoreEx); activeKeyEvent->triggeringTime_ = 0; auto keyEvent = OHOS::MMI::KeyEvent::Create(); activeKeyEvent->CombinationKeyCallback(keyEvent); } /** * @tc.name: ActiveKeyEventTest_003 * @tc.desc: ActiveKeyEventTest Init * @tc.type: FUNC */ HWTEST_F(ActiveKeyEventTest, ActiveKeyEventTest_003, TestSize.Level3) { std::string logStorePath = "/data/test/"; std::shared_ptr logStoreEx = std::make_shared(logStorePath, true); auto ret = logStoreEx->Init(); EXPECT_EQ(ret, true); std::shared_ptr activeKeyEvent = std::make_shared(); std::set preKeys; preKeys.insert(OHOS::MMI::KeyEvent::KEYCODE_VOLUME_UP); activeKeyEvent->InitSubscribe(preKeys, OHOS::MMI::KeyEvent::KEYCODE_VOLUME_DOWN, 5, 500); } /** * @tc.name: ActiveKeyEventTest_004 * @tc.desc: ActiveKeyEventTest InitSubscribe * @tc.type: FUNC */ HWTEST_F(ActiveKeyEventTest, ActiveKeyEventTest_004, TestSize.Level3) { std::shared_ptr activeKeyEvent = std::make_shared(); activeKeyEvent->triggeringTime_ = (uint64_t)ActiveKeyEvent::SystemTimeMillisecond(); std::shared_ptr keyEvent = OHOS::MMI::KeyEvent::Create(); activeKeyEvent->CombinationKeyCallback(keyEvent); std::set preKeys; preKeys.insert(OHOS::MMI::KeyEvent::KEYCODE_VOLUME_UP); activeKeyEvent->InitSubscribe(preKeys, OHOS::MMI::KeyEvent::KEYCODE_VOLUME_DOWN, 5, 500); } /** * @tc.name: ActiveKeyEventTest_005 * @tc.desc: ActiveKeyEventTest CombinationKeyCallback * @tc.type: FUNC */ HWTEST_F(ActiveKeyEventTest, ActiveKeyEventTest_005, TestSize.Level3) { std::shared_ptr activeKeyEvent = std::make_shared(); activeKeyEvent->triggeringTime_ = (uint64_t)ActiveKeyEvent::SystemTimeMillisecond(); std::shared_ptr keyEvent = OHOS::MMI::KeyEvent::Create(); activeKeyEvent->CombinationKeyCallback(keyEvent); } /** * @tc.name: ActiveKeyEventTest_006 * @tc.desc: ActiveKeyEventTest CombinationKeyCallback * @tc.type: FUNC */ HWTEST_F(ActiveKeyEventTest, ActiveKeyEventTest_006, TestSize.Level3) { std::shared_ptr activeKeyEvent = std::make_shared(); activeKeyEvent->triggeringTime_ = 0; auto keyEvent = OHOS::MMI::KeyEvent::Create(); activeKeyEvent->CombinationKeyCallback(keyEvent); } } // namespace HiviewDFX } // namespace OHOS