1 /*
2 * Copyright (c) 2021 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 <memory>
17 #include "kvstore_client_death_observer.h"
18 #include "kvstore_data_service.h"
19 #include "bootstrap.h"
20 #include "gtest/gtest.h"
21 using namespace testing::ext;
22 using namespace OHOS::DistributedKv;
23 using namespace OHOS::DistributedData;
24 using namespace OHOS;
25
26 class KvStoreDataServiceTest : public testing::Test {
27 public:
28 static void SetUpTestCase(void);
29 static void TearDownTestCase(void);
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase(void)34 void KvStoreDataServiceTest::SetUpTestCase(void)
35 {}
36
TearDownTestCase(void)37 void KvStoreDataServiceTest::TearDownTestCase(void)
38 {}
39
SetUp(void)40 void KvStoreDataServiceTest::SetUp(void)
41 {}
42
TearDown(void)43 void KvStoreDataServiceTest::TearDown(void)
44 {}
45
46 /**
47 * @tc.name: RegisterClientDeathObserver001
48 * @tc.desc: register client death observer
49 * @tc.type: FUNC
50 * @tc.require: AR000CQDU2
51 * @tc.author: liuyuhui
52 */
53 HWTEST_F(KvStoreDataServiceTest, RegisterClientDeathObserver001, TestSize.Level1)
54 {
55 AppId appId;
56 appId.appId = "app0";
57 KvStoreDataService kvDataService;
58 Bootstrap::GetInstance().LoadComponents();
59 Bootstrap::GetInstance().LoadCheckers();
60 KvStoreMetaManager::GetInstance().BindExecutor(std::make_shared<ExecutorPool>(12, 5));
61 KvStoreMetaManager::GetInstance().InitMetaParameter();
62 Status status = kvDataService.RegisterClientDeathObserver(appId, new KvStoreClientDeathObserver());
63 EXPECT_EQ(status, Status::SUCCESS) << "RegisterClientDeathObserver failed";
64 }
65