• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 UI_APPEARANCE_MOCK_DATASHARE_HELPER_H
17 #define UI_APPEARANCE_MOCK_DATASHARE_HELPER_H
18 
19 #include <vector>
20 #include <gmock/gmock.h>
21 
22 #include "datashare_errno.h"
23 #include "datashare_result_set.h"
24 #include "datashare_predicates.h"
25 #include "datashare_values_bucket.h"
26 #include "data_ability_observer_stub.h"
27 #include "iremote_object.h"
28 #include "refbase.h"
29 #include "uri.h"
30 
31 namespace OHOS::DataShare {
32 class DataShareHelper : public std::enable_shared_from_this<DataShareHelper> {
33 public:
GetInstance()34     static DataShareHelper &GetInstance()
35     {
36         static DataShareHelper instance_;
37         return instance_;
38     }
39 
40     DataShareHelper() = default;
41 
42     ~DataShareHelper() = default;
43 
44     static std::pair<int, std::shared_ptr<DataShareHelper>> Create(const sptr<IRemoteObject>& token,
45         const std::string& strUri, const std::string& extUri, const int waitTime = 2)
46     {
47         return GetInstance().MockCreate(token, strUri, extUri, waitTime);
48     }
49 
50     MOCK_METHOD((std::pair<int, std::shared_ptr<DataShareHelper>>), MockCreate,
51         (const sptr<IRemoteObject>&, const std::string&, const std::string&, const int));
52     MOCK_METHOD(std::shared_ptr<DataShareResultSet>, Query,
53         (Uri&, const DataSharePredicates&, std::vector<std::string>&));
54     MOCK_METHOD(int, Insert, (Uri&, const DataShareValuesBucket&));
55     MOCK_METHOD(int, Update, (Uri&, const DataSharePredicates&, const DataShareValuesBucket &));
56     MOCK_METHOD(bool, Release, ());
57     MOCK_METHOD(void, NotifyChange, (const Uri&));
58     MOCK_METHOD(void, RegisterObserver, (const Uri&, const sptr<AAFwk::IDataAbilityObserver>&));
59     MOCK_METHOD(void, UnregisterObserver, (const Uri&, const sptr<AAFwk::IDataAbilityObserver>&));
60 };
61 } // namespace OHOS::DataShare
62 #endif // UI_APPEARANCE_MOCK_DATASHARE_HELPER_H
63