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 "scene_persistent_storage.h"
17 #include <gtest/gtest.h>
18
19 using namespace testing;
20 using namespace testing::ext;
21
22 namespace OHOS {
23 namespace Rosen {
24 class ScenePersistentStorageTest : public testing::Test {
25 public:
26 static void SetUpTestCase();
27 static void TearDownTestCase();
28 void SetUp() override;
29 void TearDown() override;
30 };
31
SetUpTestCase()32 void ScenePersistentStorageTest::SetUpTestCase() {}
33
TearDownTestCase()34 void ScenePersistentStorageTest::TearDownTestCase() {}
35
SetUp()36 void ScenePersistentStorageTest::SetUp() {}
37
TearDown()38 void ScenePersistentStorageTest::TearDown() {}
39
40 namespace {
41 /**
42 * @tc.name: HasKey
43 * @tc.desc: test function : HasKey
44 * @tc.type: FUNC
45 */
46 HWTEST_F(ScenePersistentStorageTest, HasKey, TestSize.Level1)
47 {
48 ScenePersistentStorage scenePersistentStorage_;
49 std::string key = "aspect_ratio";
50 ScenePersistentStorageType storageType = ScenePersistentStorageType::UKNOWN;
51 bool result01 = scenePersistentStorage_.HasKey(key, storageType);
52 ASSERT_FALSE(result01);
53 storageType = ScenePersistentStorageType::ASPECT_RATIO;
54 bool result02 = scenePersistentStorage_.HasKey(key, storageType);
55 ASSERT_FALSE(result02);
56 }
57
58 /**
59 * @tc.name: Delete
60 * @tc.desc: test function : Delete
61 * @tc.type: FUNC
62 */
63 HWTEST_F(ScenePersistentStorageTest, Delete, TestSize.Level1)
64 {
65 ScenePersistentStorage scenePersistentStorage_;
66 std::string key = "aspect_ratio";
67 ScenePersistentStorageType storageType = ScenePersistentStorageType::UKNOWN;
68 scenePersistentStorage_.Delete(key, storageType);
69 storageType = ScenePersistentStorageType::ASPECT_RATIO;
70 scenePersistentStorage_.Delete(key, storageType);
71 ASSERT_FALSE(scenePersistentStorage_.HasKey(key, ScenePersistentStorageType::UKNOWN));
72 }
73
74 /**
75 * @tc.name: InitDir
76 * @tc.desc: test function : InitDir
77 * @tc.type: FUNC
78 */
79 HWTEST_F(ScenePersistentStorageTest, InitDir, TestSize.Level1)
80 {
81 ScenePersistentStorage scenePersistentStorage_;
82 std::string dir_ = "0/Storage/DownLoad";
83 scenePersistentStorage_.InitDir(dir_);
84 ASSERT_FALSE(scenePersistentStorage_.HasKey("maximize_state", ScenePersistentStorageType::MAXIMIZE_STATE));
85 }
86 } // namespace
87 } // namespace Rosen
88 } // namespace OHOS