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 #ifndef OS_ACCOUNT_FRAMEWORKS_DOMAIN_ACCOUNT_TEST_INCLUDE_MOCK_DOMAIN_CREATE_DOMAIN_ACCOUNT_CALLBACK_H
17 #define OS_ACCOUNT_FRAMEWORKS_DOMAIN_ACCOUNT_TEST_INCLUDE_MOCK_DOMAIN_CREATE_DOMAIN_ACCOUNT_CALLBACK_H
18 
19 #include <mutex>
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
22 #include "condition_variable"
23 #include "domain_account_callback.h"
24 #include "os_account_info.h"
25 
26 namespace OHOS {
27 namespace AccountSA {
28 class MockDomainCreateDomainAccountCallback {
29 public:
30     MOCK_METHOD4(OnResult, void(const int32_t errCode, const std::string &accountName, const std::string &domain,
31                                 const std::string &accountId));
32 };
33 
34 class TestCreateDomainAccountCallback : public DomainAccountCallback {
35 public:
36     TestCreateDomainAccountCallback(const std::shared_ptr<MockDomainCreateDomainAccountCallback> &callback);
37     virtual ~TestCreateDomainAccountCallback();
38     void OnResult(const int32_t errCode, Parcel &parcel) override;
39     int32_t GetLocalId();
40     std::condition_variable cv;
41     bool isReady = false;
42     std::mutex mutex;
43 private:
44     int32_t localId_;
45     std::shared_ptr<MockDomainCreateDomainAccountCallback> callback_;
46 };
47 }  // AccountSA
48 }  // OHOS
49 #endif  // OS_ACCOUNT_FRAMEWORKS_DOMAIN_ACCOUNT_TEST_INCLUDE_MOCK_DOMAIN_CREATE_DOMAIN_ACCOUNT_CALLBACK_H