1885b47fbSopenharmony_ci/* 2885b47fbSopenharmony_ci * Copyright (C) 2022 Huawei Device Co., Ltd. 3885b47fbSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4885b47fbSopenharmony_ci * you may not use this file except in compliance with the License. 5885b47fbSopenharmony_ci * You may obtain a copy of the License at 6885b47fbSopenharmony_ci * 7885b47fbSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8885b47fbSopenharmony_ci * 9885b47fbSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10885b47fbSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11885b47fbSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12885b47fbSopenharmony_ci * See the License for the specific language governing permissions and 13885b47fbSopenharmony_ci * limitations under the License. 14885b47fbSopenharmony_ci */ 15885b47fbSopenharmony_ci 16885b47fbSopenharmony_ci#include <gtest/gtest.h> 17885b47fbSopenharmony_ci#include "common_event_subscriber.h" 18885b47fbSopenharmony_ci 19885b47fbSopenharmony_cinamespace OHOS { 20885b47fbSopenharmony_cinamespace EventFwk { 21885b47fbSopenharmony_ciCommonEventSubscriber::CommonEventSubscriber() : result_(nullptr) 22885b47fbSopenharmony_ci{} 23885b47fbSopenharmony_ci 24885b47fbSopenharmony_ciCommonEventSubscriber::CommonEventSubscriber(const CommonEventSubscribeInfo& subscribeInfo) 25885b47fbSopenharmony_ci : subscribeInfo_(subscribeInfo), result_(nullptr) 26885b47fbSopenharmony_ci{} 27885b47fbSopenharmony_ci 28885b47fbSopenharmony_ciCommonEventSubscriber::~CommonEventSubscriber() 29885b47fbSopenharmony_ci{} 30885b47fbSopenharmony_ci 31885b47fbSopenharmony_ciconst CommonEventSubscribeInfo& CommonEventSubscriber::GetSubscribeInfo() const 32885b47fbSopenharmony_ci{ 33885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber CommonEventSubscriber"; 34885b47fbSopenharmony_ci return subscribeInfo_; 35885b47fbSopenharmony_ci} 36885b47fbSopenharmony_ci 37885b47fbSopenharmony_cibool CommonEventSubscriber::SetCode(const int& code) 38885b47fbSopenharmony_ci{ 39885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber SetCode"; 40885b47fbSopenharmony_ci return result_->SetCode(code); 41885b47fbSopenharmony_ci} 42885b47fbSopenharmony_ci 43885b47fbSopenharmony_ciint CommonEventSubscriber::GetCode() const 44885b47fbSopenharmony_ci{ 45885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber GetCode"; 46885b47fbSopenharmony_ci return result_->GetCode(); 47885b47fbSopenharmony_ci} 48885b47fbSopenharmony_ci 49885b47fbSopenharmony_cibool CommonEventSubscriber::SetData(const std::string& data) 50885b47fbSopenharmony_ci{ 51885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber SetData"; 52885b47fbSopenharmony_ci return result_->SetData(data); 53885b47fbSopenharmony_ci} 54885b47fbSopenharmony_ci 55885b47fbSopenharmony_cistd::string CommonEventSubscriber::GetData() const 56885b47fbSopenharmony_ci{ 57885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber GetData"; 58885b47fbSopenharmony_ci return result_->GetData(); 59885b47fbSopenharmony_ci} 60885b47fbSopenharmony_ci 61885b47fbSopenharmony_cibool CommonEventSubscriber::SetCodeAndData(const int& code, const std::string& data) 62885b47fbSopenharmony_ci{ 63885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber SetCodeAndData"; 64885b47fbSopenharmony_ci return result_->SetCodeAndData(code, data); 65885b47fbSopenharmony_ci} 66885b47fbSopenharmony_ci 67885b47fbSopenharmony_cibool CommonEventSubscriber::AbortCommonEvent() 68885b47fbSopenharmony_ci{ 69885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber AbortCommonEvent"; 70885b47fbSopenharmony_ci return result_->AbortCommonEvent(); 71885b47fbSopenharmony_ci} 72885b47fbSopenharmony_ci 73885b47fbSopenharmony_cibool CommonEventSubscriber::ClearAbortCommonEvent() 74885b47fbSopenharmony_ci{ 75885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber ClearAbortCommonEvent"; 76885b47fbSopenharmony_ci return result_->ClearAbortCommonEvent(); 77885b47fbSopenharmony_ci} 78885b47fbSopenharmony_ci 79885b47fbSopenharmony_cibool CommonEventSubscriber::GetAbortCommonEvent() const 80885b47fbSopenharmony_ci{ 81885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber GetAbortCommonEvent"; 82885b47fbSopenharmony_ci return result_->GetAbortCommonEvent(); 83885b47fbSopenharmony_ci} 84885b47fbSopenharmony_ci 85885b47fbSopenharmony_cistd::shared_ptr<AsyncCommonEventResult> CommonEventSubscriber::GoAsyncCommonEvent() 86885b47fbSopenharmony_ci{ 87885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber GoAsyncCommonEvent"; 88885b47fbSopenharmony_ci std::shared_ptr<AsyncCommonEventResult> res = result_; 89885b47fbSopenharmony_ci result_ = nullptr; 90885b47fbSopenharmony_ci return res; 91885b47fbSopenharmony_ci} 92885b47fbSopenharmony_ci 93885b47fbSopenharmony_cibool CommonEventSubscriber::IsOrderedCommonEvent() const 94885b47fbSopenharmony_ci{ 95885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber IsOrderedCommonEvent"; 96885b47fbSopenharmony_ci return (result_ != nullptr) ? result_->IsOrderedCommonEvent() : false; 97885b47fbSopenharmony_ci} 98885b47fbSopenharmony_ci 99885b47fbSopenharmony_cibool CommonEventSubscriber::IsStickyCommonEvent() const 100885b47fbSopenharmony_ci{ 101885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber IsStickyCommonEvent"; 102885b47fbSopenharmony_ci return (result_ != nullptr) ? result_->IsStickyCommonEvent() : false; 103885b47fbSopenharmony_ci} 104885b47fbSopenharmony_ci 105885b47fbSopenharmony_cibool CommonEventSubscriber::SetAsyncCommonEventResult(const std::shared_ptr<AsyncCommonEventResult>& result) 106885b47fbSopenharmony_ci{ 107885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber SetAsyncCommonEventResult"; 108885b47fbSopenharmony_ci result_ = result; 109885b47fbSopenharmony_ci return true; 110885b47fbSopenharmony_ci} 111885b47fbSopenharmony_ci 112885b47fbSopenharmony_cistd::shared_ptr<AsyncCommonEventResult> CommonEventSubscriber::GetAsyncCommonEventResult() 113885b47fbSopenharmony_ci{ 114885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber GetAsyncCommonEventResult"; 115885b47fbSopenharmony_ci return result_; 116885b47fbSopenharmony_ci} 117885b47fbSopenharmony_ci 118885b47fbSopenharmony_cibool CommonEventSubscriber::CheckSynchronous() const 119885b47fbSopenharmony_ci{ 120885b47fbSopenharmony_ci GTEST_LOG_(INFO) << "MOCK CommonEventSubscriber CheckSynchronous"; 121885b47fbSopenharmony_ci return true; 122885b47fbSopenharmony_ci} 123885b47fbSopenharmony_ci} // namespace EventFwk 124885b47fbSopenharmony_ci} // namespace OHOS