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