• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #ifndef IAM_MOCK_SCHEDULE_NODE_H
16 #define IAM_MOCK_SCHEDULE_NODE_H
17 
18 #include <memory>
19 
20 #include <gmock/gmock.h>
21 
22 #include "schedule_node.h"
23 
24 namespace OHOS {
25 namespace UserIam {
26 namespace UserAuth {
27 class MockScheduleNode final : public ScheduleNode {
28 public:
29     MOCK_CONST_METHOD0(GetScheduleId, uint64_t());
30     MOCK_CONST_METHOD0(GetContextId, uint64_t());
31     MOCK_CONST_METHOD0(GetAuthType, AuthType());
32     MOCK_CONST_METHOD0(GetExecutorMatcher, uint64_t());
33     MOCK_CONST_METHOD0(GetScheduleMode, ScheduleMode());
34     MOCK_CONST_METHOD0(GetCollectorExecutor, std::weak_ptr<ResourceNode>());
35     MOCK_CONST_METHOD0(GetVerifyExecutor, std::weak_ptr<ResourceNode>());
36     MOCK_CONST_METHOD0(GetTemplateIdList, std::optional<std::vector<uint64_t>>());
37     MOCK_CONST_METHOD0(GetCurrentScheduleState, State());
38 
39     MOCK_METHOD1(RegisterScheduleCallback, bool(const std::shared_ptr<ScheduleNodeCallback> &callback));
40     MOCK_METHOD1(SetExpiredTime, bool(uint32_t ms));
41     MOCK_METHOD0(StartSchedule, bool());
42     MOCK_METHOD0(StopSchedule, bool());
43     MOCK_METHOD4(ContinueSchedule,
44         bool(ExecutorRole srcRole, ExecutorRole dstRole, uint64_t transNum, const std::vector<uint8_t> &msg));
45     MOCK_METHOD2(ContinueSchedule, bool(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult));
46 
CreateWithScheduleId(uint64_t scheduleId)47     static std::shared_ptr<MockScheduleNode> CreateWithScheduleId(uint64_t scheduleId)
48     {
49         using namespace testing;
50         auto node = std::make_shared<MockScheduleNode>();
51         EXPECT_CALL(*node, GetScheduleId()).WillRepeatedly(Return(scheduleId));
52         return node;
53     }
54 };
55 } // namespace UserAuth
56 } // namespace UserIam
57 } // namespace OHOS
58 #endif // IAM_MOCK_SCHEDULE_NODE_H