1 // Copyright (C) 2024 Huawei Device Co., Ltd.
2 // Licensed under the Apache License, Version 2.0 (the "License");
3 // you may not use this file except in compliance with the License.
4 // You may obtain a copy of the License at
5 //
6 // http://www.apache.org/licenses/LICENSE-2.0
7 //
8 // Unless required by applicable law or agreed to in writing, software
9 // distributed under the License is distributed on an "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 // See the License for the specific language governing permissions and
12 // limitations under the License.
13
14 use samgr::manage::SystemAbilityManager;
15 use samgr::DumpFlagPriority;
16
init()17 fn init() {
18 #[cfg(gn_test)]
19 super::init_access_token();
20 }
21
22 #[test]
basic()23 fn basic() {
24 init();
25 let abilities = SystemAbilityManager::list_system_abilities();
26 assert!(!abilities.is_empty());
27
28 let abilities =
29 SystemAbilityManager::list_system_abilities_with_dump_flag(DumpFlagPriority::High);
30 assert!(!abilities.is_empty());
31 let info = SystemAbilityManager::get_system_process_info(3706);
32 assert_eq!("download_server", info.processName);
33 let infos = SystemAbilityManager::get_running_system_process();
34 assert!(!infos.is_empty());
35 }
36
37 #[test]
common_event()38 fn common_event() {
39 init();
40 let obj_j = SystemAbilityManager::check_system_ability(1494);
41 if let Some(obj) = obj_j {
42 let mut id_list:Vec<i64> = vec![];
43 let ret = SystemAbilityManager::get_common_event_extra_data_id_list(1494, &mut id_list, "");
44 assert_eq!(ret, 0);
45 for id in id_list {
46 println!("all extra id is {}", id)
47 }
48
49 let mut id_list:Vec<i64> = vec![];
50 let ret =
51 SystemAbilityManager::get_common_event_extra_data_id_list(1494, &mut id_list, "usual.event.SCREEN_ON");
52 assert_eq!(ret, 0);
53 for id in id_list {
54 println!("usual.event.SCREEN_ON event extra id is {}", id)
55 }
56 }
57 }
58