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 <gmock/gmock.h>
17 #include <gtest/gtest.h>
18 
19 #include "database_manager.h"
20 
21 namespace OHOS::FileManagement::CloudDisk::Test {
22 using namespace testing;
23 using namespace testing::ext;
24 using namespace std;
25 
26 class DatabaseManagerTest : public testing::Test {
27 public:
28     static void SetUpTestCase(void);
29     static void TearDownTestCase(void);
30     void SetUp();
31     void TearDown();
32     static inline shared_ptr<DatabaseManager> databaseManager_ = nullptr;
33 };
34 
SetUpTestCase(void)35 void DatabaseManagerTest::SetUpTestCase(void)
36 {
37     GTEST_LOG_(INFO) << "SetUpTestCase";
38     databaseManager_ = make_shared<DatabaseManager>();
39 }
40 
TearDownTestCase(void)41 void DatabaseManagerTest::TearDownTestCase(void)
42 {
43     GTEST_LOG_(INFO) << "TearDownTestCase";
44     databaseManager_ = nullptr;
45 }
46 
SetUp(void)47 void DatabaseManagerTest::SetUp(void)
48 {
49     GTEST_LOG_(INFO) << "SetUp";
50 }
51 
TearDown(void)52 void DatabaseManagerTest::TearDown(void)
53 {
54     GTEST_LOG_(INFO) << "TearDown";
55 }
56 
57 /**
58  * @tc.name: GetRdbStoreTest001
59  * @tc.desc: Verify the GetRdbStore function
60  * @tc.type: FUNC
61  * @tc.require: issuesI92WQP
62  */
63 HWTEST_F(DatabaseManagerTest, GetRdbStoreTest001, TestSize.Level1)
64 {
65     GTEST_LOG_(INFO) << "GetRdbStoreTest001 Start";
66     try {
67         const std::string bundleName = "GetRdbStoreTest";
68         const int32_t userId = 123456789;
69         databaseManager_->GetRdbStore(bundleName, userId);
70         EXPECT_TRUE(true);
71     } catch (...) {
72         EXPECT_TRUE(false);
73         GTEST_LOG_(INFO) << "GetRdbStoreTest001  ERROR";
74     }
75     GTEST_LOG_(INFO) << "GetRdbStoreTest001 End";
76 }
77 
78 } // namespace OHOS::FileManagement::CloudDisk::Test