1 /*
2  * Copyright (c) 2023 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 #include "mock_domain_has_domain_info_callback.h"
17 
18 #include "account_log_wrapper.h"
19 #include "os_account_manager.h"
20 #include "parcel.h"
21 
22 namespace OHOS {
23 namespace AccountSA {
24 namespace {
25 }
26 
TestHasDomainInfoCallback(const std::shared_ptr<MockDomainHasDomainInfoCallback> & callback)27 TestHasDomainInfoCallback::TestHasDomainInfoCallback(const std::shared_ptr<MockDomainHasDomainInfoCallback> &callback)
28     : callback_(callback)
29 {}
30 
~TestHasDomainInfoCallback()31 TestHasDomainInfoCallback::~TestHasDomainInfoCallback()
32 {}
33 
OnResult(const int32_t errCode,Parcel & parcel)34 void TestHasDomainInfoCallback::OnResult(const int32_t errCode, Parcel &parcel)
35 {
36     if (callback_ == nullptr) {
37         return;
38     }
39     parcel.ReadBool(hasDomainInfo_);
40     callback_->OnResult(errCode, hasDomainInfo_);
41     std::unique_lock<std::mutex> lock(mutex);
42     isReady = true;
43     cv.notify_one();
44     return;
45 }
46 
TestGetDomainAccountInfoCallback(const std::shared_ptr<MockGetDomainAccountInfoCallback> & callback)47 TestGetDomainAccountInfoCallback::TestGetDomainAccountInfoCallback(
48     const std::shared_ptr<MockGetDomainAccountInfoCallback> &callback)
49     : callback_(callback)
50 {}
51 
~TestGetDomainAccountInfoCallback()52 TestGetDomainAccountInfoCallback::~TestGetDomainAccountInfoCallback()
53 {}
54 
OnResult(const int32_t errCode,Parcel & parcel)55 void TestGetDomainAccountInfoCallback::OnResult(const int32_t errCode, Parcel &parcel)
56 {
57     if (callback_ == nullptr) {
58         return;
59     }
60     callback_->OnResult(errCode, parcel);
61     std::unique_lock<std::mutex> lock(mutex);
62     isReady = true;
63     cv.notify_one();
64     return;
65 }
66 }  // AccountSA
67 }  // OHOS