15ba71b47Sopenharmony_ci// Copyright (C) 2024 Huawei Device Co., Ltd.
25ba71b47Sopenharmony_ci// Licensed under the Apache License, Version 2.0 (the "License");
35ba71b47Sopenharmony_ci// you may not use this file except in compliance with the License.
45ba71b47Sopenharmony_ci// You may obtain a copy of the License at
55ba71b47Sopenharmony_ci//
65ba71b47Sopenharmony_ci//     http://www.apache.org/licenses/LICENSE-2.0
75ba71b47Sopenharmony_ci//
85ba71b47Sopenharmony_ci// Unless required by applicable law or agreed to in writing, software
95ba71b47Sopenharmony_ci// distributed under the License is distributed on an "AS IS" BASIS,
105ba71b47Sopenharmony_ci// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
115ba71b47Sopenharmony_ci// See the License for the specific language governing permissions and
125ba71b47Sopenharmony_ci// limitations under the License.
135ba71b47Sopenharmony_ci
145ba71b47Sopenharmony_ciuse samgr::manage::SystemAbilityManager;
155ba71b47Sopenharmony_ciuse samgr::DumpFlagPriority;
165ba71b47Sopenharmony_ci
175ba71b47Sopenharmony_cifn init() {
185ba71b47Sopenharmony_ci    #[cfg(gn_test)]
195ba71b47Sopenharmony_ci    super::init_access_token();
205ba71b47Sopenharmony_ci}
215ba71b47Sopenharmony_ci
225ba71b47Sopenharmony_ci#[test]
235ba71b47Sopenharmony_cifn basic() {
245ba71b47Sopenharmony_ci    init();
255ba71b47Sopenharmony_ci    let abilities = SystemAbilityManager::list_system_abilities();
265ba71b47Sopenharmony_ci    assert!(!abilities.is_empty());
275ba71b47Sopenharmony_ci
285ba71b47Sopenharmony_ci    let abilities =
295ba71b47Sopenharmony_ci        SystemAbilityManager::list_system_abilities_with_dump_flag(DumpFlagPriority::High);
305ba71b47Sopenharmony_ci    assert!(!abilities.is_empty());
315ba71b47Sopenharmony_ci    let info = SystemAbilityManager::get_system_process_info(3706);
325ba71b47Sopenharmony_ci    assert_eq!("download_server", info.processName);
335ba71b47Sopenharmony_ci    let infos = SystemAbilityManager::get_running_system_process();
345ba71b47Sopenharmony_ci    assert!(!infos.is_empty());
355ba71b47Sopenharmony_ci}
365ba71b47Sopenharmony_ci
375ba71b47Sopenharmony_ci#[test]
385ba71b47Sopenharmony_cifn common_event() {
395ba71b47Sopenharmony_ci    init();
405ba71b47Sopenharmony_ci    let obj_j = SystemAbilityManager::check_system_ability(1494);
415ba71b47Sopenharmony_ci    if let Some(obj) = obj_j {
425ba71b47Sopenharmony_ci        let mut id_list:Vec<i64> = vec![];
435ba71b47Sopenharmony_ci        let ret = SystemAbilityManager::get_common_event_extra_data_id_list(1494, &mut id_list, "");
445ba71b47Sopenharmony_ci        assert_eq!(ret, 0);
455ba71b47Sopenharmony_ci        for id in id_list {
465ba71b47Sopenharmony_ci            println!("all extra id is {}", id)
475ba71b47Sopenharmony_ci        }
485ba71b47Sopenharmony_ci
495ba71b47Sopenharmony_ci        let mut id_list:Vec<i64> = vec![];
505ba71b47Sopenharmony_ci        let ret =
515ba71b47Sopenharmony_ci            SystemAbilityManager::get_common_event_extra_data_id_list(1494, &mut id_list, "usual.event.SCREEN_ON");
525ba71b47Sopenharmony_ci        assert_eq!(ret, 0);
535ba71b47Sopenharmony_ci        for id in id_list {
545ba71b47Sopenharmony_ci            println!("usual.event.SCREEN_ON event extra id is {}", id)
555ba71b47Sopenharmony_ci        }
565ba71b47Sopenharmony_ci    }
575ba71b47Sopenharmony_ci}
58