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 MOCK_METHOD0(GetScheduleCallback, std::shared_ptr<ScheduleNodeCallback>()); 39 MOCK_CONST_METHOD0(GetAuthIntent, int32_t()); 40 MOCK_METHOD0(ClearScheduleCallback, void()); 41 42 MOCK_METHOD1(RegisterScheduleCallback, bool(const std::shared_ptr<ScheduleNodeCallback> &callback)); 43 MOCK_METHOD1(SetExpiredTime, bool(uint32_t ms)); 44 MOCK_METHOD0(StartSchedule, bool()); 45 MOCK_METHOD0(StopSchedule, bool()); 46 MOCK_METHOD1(StopSchedule, bool(ResultCode errorCode)); 47 MOCK_METHOD2(SendMessage, bool(ExecutorRole dstRole, const std::vector<uint8_t> &msg)); 48 MOCK_METHOD2(ContinueSchedule, bool(ResultCode resultCode, const std::shared_ptr<Attributes> &finalResult)); 49 CreateWithScheduleId(uint64_t scheduleId)50 static std::shared_ptr<MockScheduleNode> CreateWithScheduleId(uint64_t scheduleId) 51 { 52 using namespace testing; 53 auto node = std::make_shared<MockScheduleNode>(); 54 EXPECT_CALL(*node, GetScheduleId()).WillRepeatedly(Return(scheduleId)); 55 return node; 56 } 57 }; 58 } // namespace UserAuth 59 } // namespace UserIam 60 } // namespace OHOS 61 #endif // IAM_MOCK_SCHEDULE_NODE_H