1 /*
2 * Copyright (c) 2025 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 "bootstrap.h"
17 #include <gtest/gtest.h>
18 #include <memory>
19
20 namespace OHOS::DistributedData {
21 using namespace testing;
22 class BootStrapMockTest : public testing::Test {
23 public:
24 static void SetUpTestCase(void);
25 static void TearDownTestCase(void);
26 void SetUp();
27 void TearDown();
28 private:
29 static constexpr const char *defaultLabel = "distributeddata";
30 static constexpr const char *defaultMeta = "service_meta";
31 };
32
SetUpTestCase(void)33 void BootStrapMockTest::SetUpTestCase(void)
34 {}
35
TearDownTestCase(void)36 void BootStrapMockTest::TearDownTestCase(void)
37 {}
38
SetUp(void)39 void BootStrapMockTest::SetUp(void)
40 {}
41
TearDown(void)42 void BootStrapMockTest::TearDown(void)
43 {}
44
45 /**
46 * @tc.name: GetProcessLabel
47 * @tc.desc: Get process label.
48 * @tc.type: FUNC
49 */
50 HWTEST_F(BootStrapMockTest, GetProcessLabel, testing::ext::TestSize.Level0)
51 {
52 std::string proLabel = Bootstrap::GetInstance().GetProcessLabel();
53 EXPECT_TRUE(proLabel == BootStrapMockTest::defaultLabel);
54 }
55
56 /**
57 * @tc.name: GetMetaDBNameAndLoadMultiItem
58 * @tc.desc: Get meta db name and load other items.
59 * @tc.type: FUNC
60 */
61 HWTEST_F(BootStrapMockTest, GetMetaDBName, testing::ext::TestSize.Level0)
62 {
63 std::string metaDbName = Bootstrap::GetInstance().GetMetaDBName();
64 Bootstrap::GetInstance().LoadComponents();
65 Bootstrap::GetInstance().LoadCheckers();
66 Bootstrap::GetInstance().LoadDirectory();
67 Bootstrap::GetInstance().LoadCloud();
68 Bootstrap::GetInstance().LoadAppIdMappings();
69 std::shared_ptr<ExecutorPool> executors = std::make_shared<ExecutorPool>(0, 1);
70 Bootstrap::GetInstance().LoadBackup(executors);
71 EXPECT_TRUE(metaDbName == BootStrapMockTest::defaultMeta);
72 }
73 }