1 /* 2 * Copyright (c) 2025 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 <gmock/gmock.h> 17 #include <gtest/gtest.h> 18 19 #include "delegate_interface.h" 20 #include "pointer_device_manager.h" 21 22 namespace OHOS { 23 namespace MMI { 24 using namespace testing::ext; 25 26 class PointerDeviceManagerTest : public testing::Test { 27 public: SetUpTestCase(void)28 static void SetUpTestCase(void) {}; TearDownTestCase(void)29 static void TearDownTestCase(void) {}; SetUp(void)30 void SetUp(void) {}; 31 }; 32 33 /** 34 * @tc.name: PointerDeviceManager_001 35 * @tc.desc: Obtain PointerDeviceManager single instance 36 * @tc.type: FUNC 37 * @tc.require: 38 */ 39 HWTEST_F(PointerDeviceManagerTest, PointerDeviceManager_001, TestSize.Level1) 40 { 41 EXPECT_EQ(POINTER_DEV_MGR.isInit, false); 42 } 43 44 #ifdef OHOS_BUILD_ENABLE_POINTER_DRAWING 45 /** 46 * @tc.name: GetDelegateProxy_001 47 * @tc.desc: GetDelegateProxy 48 * @tc.type: FUNC 49 * @tc.require: 50 */ 51 HWTEST_F(PointerDeviceManagerTest, GetDelegateProxy_001, TestSize.Level1) 52 { 53 EXPECT_EQ(POINTER_DEV_MGR.GetDelegateProxy(), nullptr); 54 } 55 56 /** 57 * @tc.name: SetDelegateProxy_001 58 * @tc.desc: SetDelegateProxy 59 * @tc.type: FUNC 60 * @tc.require: 61 */ 62 HWTEST_F(PointerDeviceManagerTest, SetDelegateProxy_001, TestSize.Level1) 63 { 64 DelegateTasks delegateTasks; __anon50374aa90102(DTaskCallback cb) 65 std::function<int32_t(DTaskCallback)> fun = [&](DTaskCallback cb) -> int32_t { 66 return delegateTasks.PostSyncTask(cb); 67 }; __anon50374aa90202(DTaskCallback cb) 68 std::function<int32_t(DTaskCallback)> asyncFun = [&](DTaskCallback cb) -> int32_t { 69 return delegateTasks.PostAsyncTask(cb); 70 }; 71 std::shared_ptr<DelegateInterface> delegateInterface = std::make_shared<DelegateInterface>(fun, asyncFun); 72 73 POINTER_DEV_MGR.SetDelegateProxy(delegateInterface); 74 EXPECT_NE(POINTER_DEV_MGR.GetDelegateProxy(), nullptr); 75 } 76 #endif // OHOS_BUILD_ENABLE_POINTER_DRAWING 77 } // namespace MMI 78 } // namespace OHOS 79