1 /* 2 * Copyright (c) 2024 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 INTENTION_SERVICE_TEST_H 17 #define INTENTION_SERVICE_TEST_H 18 19 #include <gtest/gtest.h> 20 #include "nocopyable.h" 21 22 #include "delegate_tasks.h" 23 #include "device_manager.h" 24 #include "devicestatus_define.h" 25 #include "devicestatus_delayed_sp_singleton.h" 26 #include "drag_manager.h" 27 #include "i_context.h" 28 #include "timer_manager.h" 29 30 #include "intention_service.h" 31 #include "socket_session_manager.h" 32 33 namespace OHOS { 34 namespace Msdp { 35 namespace DeviceStatus { 36 class MockDelegateTasks : public IDelegateTasks { 37 public: 38 int32_t PostSyncTask(DTaskCallback callback) override; 39 int32_t PostAsyncTask(DTaskCallback callback) override; 40 }; 41 42 class ContextService final : public IContext { 43 public: 44 ContextService(); 45 ~ContextService() = default; 46 DISALLOW_COPY_AND_MOVE(ContextService); 47 48 IDelegateTasks& GetDelegateTasks() override; 49 IDeviceManager& GetDeviceManager() override; 50 ITimerManager& GetTimerManager() override; 51 IDragManager& GetDragManager() override; 52 IPluginManager& GetPluginManager() override; 53 ISocketSessionManager& GetSocketSessionManager() override; 54 IInputAdapter& GetInput() override; 55 IDSoftbusAdapter& GetDSoftbus() override; 56 static ContextService* GetInstance(); 57 private: 58 MockDelegateTasks delegateTasks_; 59 DeviceManager devMgr_; 60 TimerManager timerMgr_; 61 DragManager dragMgr_; 62 SocketSessionManager socketSessionMgr_; 63 std::unique_ptr<IInputAdapter> input_ { nullptr }; 64 std::unique_ptr<IPluginManager> pluginMgr_ { nullptr }; 65 std::unique_ptr<IDSoftbusAdapter> dsoftbus_ { nullptr }; 66 sptr<IntentionService> intention_ { nullptr }; 67 }; 68 69 class IntentionServiceTest : public testing::Test { 70 public: 71 static void SetUpTestCase(); 72 static void TearDownTestCase(); 73 void SetUp(); 74 void TearDown(); 75 static std::shared_ptr<Media::PixelMap> CreatePixelMap(int32_t width, int32_t height); 76 static std::optional<DragData> CreateDragData(int32_t sourceType, int32_t pointerId, int32_t dragNum, 77 bool hasCoordinateCorrected, int32_t shadowNum); 78 void AssignToAnimation(PreviewAnimation &animation); 79 }; 80 } // namespace DeviceStatus 81 } // namespace Msdp 82 } // namespace OHOS 83 #endif // INTENTION_SERVICE_TEST_H