1 /* 2 * Copyright (c) 2021 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 DISTRIBUTED_SCHED_CONTINUATION_TEST_H 17 #define DISTRIBUTED_SCHED_CONTINUATION_TEST_H 18 19 #include "distributed_sched_proxy.h" 20 #define private public 21 #include "distributed_sched_continuation.h" 22 #include "distributed_sched_service.h" 23 #undef private 24 #include "gtest/gtest.h" 25 #include "device_manager.h" 26 #include "dtbschedmgr_log.h" 27 #include "if_system_ability_manager.h" 28 #include "iservice_registry.h" 29 #include "system_ability_definition.h" 30 #include "test_log.h" 31 #include "want.h" 32 33 namespace OHOS { 34 namespace DistributedSchedule { 35 class DSchedContinuationTest : public testing::Test { 36 public: 37 static void SetUpTestCase(); 38 static void TearDownTestCase(); 39 void MockOnStart(); 40 void SetUp(); 41 void TearDown(); 42 sptr<IDistributedSched> GetDms(); 43 sptr<IDistributedSched> proxy_; 44 45 protected: 46 sptr<IRemoteObject> GetDSchedService() const; 47 int32_t PushAbilityToken(); 48 std::shared_ptr<AAFwk::Want> MockWant(const std::string& bundleName, const std::string& ability, 49 int32_t flags); 50 int32_t StartContinuation(int32_t missionId, int32_t flags); 51 int32_t StartRemoteFreeInstall(int32_t flags, const sptr<IRemoteObject>& callback); 52 53 enum class LoopTime : int32_t { 54 LOOP_TIME = 10, 55 LOOP_PRESSURE_TIME = 100, 56 }; 57 58 std::shared_ptr<DSchedContinuation> dschedContinuation_; 59 std::shared_ptr<DmsCallbackTask> dmsCallbackTask_; 60 bool timeoutFlag_ = false; 61 bool freeInstallTimeoutFlag_ = false; 62 63 class DeviceInitCallBack : public OHOS::DistributedHardware::DmInitCallback { 64 void OnRemoteDied() override; 65 }; 66 }; 67 } // namespace DistributedSchedule 68 } // namespace OHOS 69 70 #endif // DISTRIBUTED_SCHED_CONTINUATION_TEST_H