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 {
34 }
35
TearDownTestCase()36 void ScenePersistentStorageTest::TearDownTestCase()
37 {
38 }
39
SetUp()40 void ScenePersistentStorageTest::SetUp()
41 {
42 }
43
TearDown()44 void ScenePersistentStorageTest::TearDown()
45 {
46 }
47
48 namespace {
49 /**
50 * @tc.name: HasKey
51 * @tc.desc: test function : HasKey
52 * @tc.type: FUNC
53 */
54 HWTEST_F(ScenePersistentStorageTest, HasKey, Function | SmallTest | Level1)
55 {
56 ScenePersistentStorage scenePersistentStorage_;
57 std::string key = "aspect_ratio";
58 ScenePersistentStorageType storageType = ScenePersistentStorageType::UKNOWN;
59 bool result01 = scenePersistentStorage_.HasKey(key, storageType);
60 ASSERT_FALSE(result01);
61 storageType = ScenePersistentStorageType::ASPECT_RATIO;
62 bool result02 = scenePersistentStorage_.HasKey(key, storageType);
63 ASSERT_FALSE(result02);
64 }
65
66 /**
67 * @tc.name: Delete
68 * @tc.desc: test function : Delete
69 * @tc.type: FUNC
70 */
71 HWTEST_F(ScenePersistentStorageTest, Delete, Function | SmallTest | Level1)
72 {
73 ScenePersistentStorage scenePersistentStorage_;
74 std::string key = "aspect_ratio";
75 ScenePersistentStorageType storageType = ScenePersistentStorageType::UKNOWN;
76 scenePersistentStorage_.Delete(key, storageType);
77 storageType = ScenePersistentStorageType::ASPECT_RATIO;
78 scenePersistentStorage_.Delete(key, storageType);
79 ASSERT_FALSE(scenePersistentStorage_.HasKey(key, ScenePersistentStorageType::UKNOWN));
80 }
81
82 /**
83 * @tc.name: InitDir
84 * @tc.desc: test function : InitDir
85 * @tc.type: FUNC
86 */
87 HWTEST_F(ScenePersistentStorageTest, InitDir, Function | SmallTest | Level1)
88 {
89 ScenePersistentStorage scenePersistentStorage_;
90 std::string dir_ = "0/Storage/DownLoad";
91 scenePersistentStorage_.InitDir(dir_);
92 ASSERT_FALSE(scenePersistentStorage_.HasKey("maximize_state", ScenePersistentStorageType::MAXIMIZE_STATE));
93 }
94 }
95 }
96 }