1 /*
2 * Copyright (c) 2021-2024 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 <gtest/gtest.h>
17
18 #include "app_config_data_manager.h"
19 #include "app_state_callback_host.h"
20 #include "errors.h"
21 #include "hilog_tag_wrapper.h"
22 #include "mock_ability_token.h"
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS {
28 namespace AppExecFwk {
29 class AppConfigDataManagerTest : public testing::Test {
30 public:
31 static void SetUpTestCase();
32 static void TearDownTestCase();
33 void SetUp();
34 void TearDown();
35 public:
36 protected:
GetTestBundleName()37 static const std::string GetTestBundleName()
38 {
39 return "test_bundle_name";
40 }
GetTestAbilityInfoName()41 static const std::string GetTestAbilityInfoName()
42 {
43 return "test_ability_info_name";
44 }
GetTestModuleName()45 static const std::string GetTestModuleName()
46 {
47 return "test_module_name";
48 }
49 };
50
SetUpTestCase()51 void AppConfigDataManagerTest::SetUpTestCase()
52 {}
53
TearDownTestCase()54 void AppConfigDataManagerTest::TearDownTestCase()
55 {}
56
SetUp()57 void AppConfigDataManagerTest::SetUp()
58 {}
59
TearDown()60 void AppConfigDataManagerTest::TearDown()
61 {}
62
63
64 /*
65 * Feature: AppConfigDataManager
66 * Function: SetAppWaitingDebugInfo
67 * SubFunction: NA
68 * FunctionPoints: AppConfigDataManager SetAppWaitingDebugInfo
69 * EnvConditions: NA
70 * CaseDescription: bundle name empty
71 */
72 HWTEST_F(AppConfigDataManagerTest, SetAppWaitingDebugInfo_001, TestSize.Level1)
73 {
74 auto manager = std::make_shared<AbilityRuntime::AppConfigDataManager>();
75 const std::string bundleName;
76 auto iret = manager->SetAppWaitingDebugInfo(bundleName);
77 EXPECT_EQ(iret, ERR_INVALID_VALUE);
78 }
79
80 /*
81 * Feature: AppConfigDataManager
82 * Function: SetAppWaitingDebugInfo
83 * SubFunction: NA
84 * FunctionPoints: AppConfigDataManager SetAppWaitingDebugInfo
85 * EnvConditions: NA
86 * CaseDescription: set ok
87 */
88 HWTEST_F(AppConfigDataManagerTest, SetAppWaitingDebugInfo_002, TestSize.Level1)
89 {
90 auto manager = std::make_shared<AbilityRuntime::AppConfigDataManager>();
91 const std::string bundleName = "bundle";
92 auto iret = manager->SetAppWaitingDebugInfo(bundleName);
93 EXPECT_EQ(iret, ERR_OK);
94 }
95
96 /*
97 * Feature: AppConfigDataManager
98 * Function: ClearAppWaitingDebugInfo
99 * SubFunction: NA
100 * FunctionPoints: AppConfigDataManager ClearAppWaitingDebugInfo
101 * EnvConditions: NA
102 * CaseDescription: clear ok
103 */
104 HWTEST_F(AppConfigDataManagerTest, ClearAppWaitingDebugInfo_001, TestSize.Level1)
105 {
106 auto manager = std::make_shared<AbilityRuntime::AppConfigDataManager>();
107 auto iret = manager->ClearAppWaitingDebugInfo();
108 EXPECT_EQ(iret, ERR_OK);
109 }
110
111 /*
112 * Feature: AppConfigDataManager
113 * Function: GetAppWaitingDebugList
114 * SubFunction: NA
115 * FunctionPoints: AppConfigDataManager GetAppWaitingDebugList
116 * EnvConditions: NA
117 * CaseDescription: get ok
118 */
119 HWTEST_F(AppConfigDataManagerTest, GetAppWaitingDebugList_001, TestSize.Level1)
120 {
121 auto manager = std::make_shared<AbilityRuntime::AppConfigDataManager>();
122 std::vector<std::string> bundleNameList;
123 auto iret = manager->GetAppWaitingDebugList(bundleNameList);
124 EXPECT_EQ(iret, ERR_OK);
125 }
126
127 } // namespace AppExecFwk
128 } // namespace OHOS
129