• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 SetUp();
40     void TearDown();
41     sptr<IDistributedSched> GetDms();
42     sptr<IDistributedSched> proxy_;
43 
44 protected:
45     sptr<IRemoteObject> GetDSchedService() const;
46     int32_t PushAbilityToken();
47     std::shared_ptr<AAFwk::Want> MockWant(const std::string& bundleName, const std::string& ability,
48         int32_t flags);
49     int32_t StartContinuation(int32_t missionId, int32_t flags);
50     int32_t StartRemoteFreeInstall(int32_t flags, const sptr<IRemoteObject>& callback);
51 
52     enum class LoopTime : int32_t {
53         LOOP_TIME = 10,
54         LOOP_PRESSURE_TIME = 100,
55     };
56 
57     std::shared_ptr<DSchedContinuation> dschedContinuation_;
58     std::shared_ptr<DmsCallbackTask> dmsCallbackTask_;
59     bool timeoutFlag_ = false;
60     bool freeInstallTimeoutFlag_ = false;
61 
62     class DeviceInitCallBack : public OHOS::DistributedHardware::DmInitCallback {
63         void OnRemoteDied() override;
64     };
65 };
66 } // namespace DistributedSchedule
67 } // namespace OHOS
68 
69 #endif // DISTRIBUTED_SCHED_CONTINUATION_TEST_H