• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 "app_manager_utils_test.h"
17 
18 #include "app_manager_utils.h"
19 #include "power_log.h"
20 
21 namespace OHOS {
22 namespace PowerMgr {
23 using namespace OHOS::AppExecFwk;
24 using namespace testing;
25 using namespace testing::ext;
26 
27 /**
28  * @tc.name: AppManagerUtilsTest001
29  * @tc.desc: test GetForegroundApplications
30  * @tc.type: FUNC
31  */
32 HWTEST_F(AppManagerUtilsTest, AppManagerUtilsTest001, TestSize.Level0)
33 {
34     POWER_HILOGI(LABEL_TEST, "AppManagerUtilsTest001 function start!");
35     std::vector<AppStateData> testAppsData;
36     AppManagerUtils::GetForegroundApplications(testAppsData);
37     EXPECT_TRUE(testAppsData.size()>=0);
38     POWER_HILOGI(LABEL_TEST, "AppManagerUtilsTest001 function end!");
39 }
40 
41 /**
42  * @tc.name: AppManagerUtilsTest002
43  * @tc.desc: test IsForegroundApplication
44  * @tc.type: FUNC
45  */
46 HWTEST_F(AppManagerUtilsTest, AppManagerUtilsTest002, TestSize.Level0)
47 {
48     POWER_HILOGI(LABEL_TEST, "AppManagerUtilsTest002 function start!");
49     std::string unExistApp = "com.example.UNEXISTED_APP";
50     bool res = AppManagerUtils::IsForegroundApplication(unExistApp);
51     EXPECT_FALSE(res);
52     POWER_HILOGI(LABEL_TEST, "AppManagerUtilsTest002 function end!");
53 }
54 } // PowerMgr
55 } // OHOS