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 #ifndef INTERACTION_MANAGER_TEST_H 17 #define INTERACTION_MANAGER_TEST_H 18 19 #include <gtest/gtest.h> 20 21 #include "devicestatus_define.h" 22 #include "interaction_manager.h" 23 namespace OHOS { 24 namespace Msdp { 25 namespace DeviceStatus { 26 27 class MockHapToken { 28 public: 29 explicit MockHapToken( 30 const std::string& bundle, const std::vector<std::string>& reqPerm, bool isSystemApp = true); 31 ~MockHapToken(); 32 private: 33 uint64_t selfToken_; 34 uint32_t mockToken_; 35 }; 36 37 class MockNativeToken { 38 public: 39 explicit MockNativeToken(const std::string& process); 40 ~MockNativeToken(); 41 private: 42 uint64_t selfToken_; 43 }; 44 45 class InteractionManagerTest : public testing::Test { 46 public: 47 void SetUp(); 48 void TearDown(); 49 static void SetUpTestCase(); 50 static std::vector<int32_t> GetInputDeviceIds(); 51 static std::shared_ptr<MMI::InputDevice> GetDevice(int32_t deviceId); 52 static std::pair<int32_t, int32_t> GetMouseAndTouch(); 53 static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height); 54 static std::optional<DragData> CreateDragData(const std::pair<int32_t, int32_t> &pixelMapSize, int32_t sourceType, 55 int32_t pointerId, int32_t displayId, const std::pair<int32_t, int32_t> &location); 56 static MMI::PointerEvent::PointerItem CreatePointerItem(int32_t pointerId, 57 int32_t deviceId, const std::pair<int32_t, int32_t> &displayLocation, bool isPressed); 58 static std::shared_ptr<MMI::PointerEvent> SetupPointerEvent(const std::pair<int32_t, int32_t> &displayLocation, 59 int32_t action, int32_t sourceType, int32_t pointerId, bool isPressed); 60 static void SimulateDownPointerEvent( 61 const std::pair<int32_t, int32_t> &location, int32_t sourceType, int32_t pointerId); 62 static void SimulateUpPointerEvent( 63 const std::pair<int32_t, int32_t> &location, int32_t sourceType, int32_t pointerId); 64 static void SimulateMovePointerEvent(const std::pair<int32_t, int32_t> &srcLocation, 65 const std::pair<int32_t, int32_t> &dstLocation, int32_t sourceType, int32_t pointerId, bool isPressed); 66 static int32_t TestAddMonitor(std::shared_ptr<MMI::IInputEventConsumer> consumer); 67 static void TestRemoveMonitor(int32_t monitorId); 68 static void PrintDragData(const DragData &dragData); 69 static void SetupKeyEvent(int32_t action, int32_t key, bool isPressed); 70 static void ClearUpKeyEvent(); 71 static void SimulateDownKeyEvent(int32_t key); 72 static void SimulateUpKeyEvent(int32_t key); 73 static void PrintDragAction(DragAction dragAction); 74 static void AssignToAnimation(PreviewAnimation &animation); 75 static void EnableCooperate(); 76 }; 77 } // namespace DeviceStatus 78 } // namespace Msdp 79 } // namespace OHOS 80 #endif // INTERACTION_MANAGER_TEST_H