From 7b5ca4dda00b88d745bc9c73f6ffeb05c32a76c6 Mon Sep 17 00:00:00 2001 From: njupthan Date: Mon, 17 Jan 2022 17:36:12 +0800 Subject: [PATCH 1/7] AMS test framework AbilityDelegator related DTS submission Signed-off-by: njupthan --- api/@ohos.app.abilityDelegatorRegistry.d.ts | 61 ++++++++++ api/app/abilityDelegator.d.ts | 123 ++++++++++++++++++++ api/app/abilityDelegatorArgs.d.ts | 53 +++++++++ api/app/abilityMonitor.d.ts | 77 ++++++++++++ api/app/shellCmdResult.d.ts | 40 +++++++ api/app/testRunner.d.ts | 41 +++++++ 6 files changed, 395 insertions(+) create mode 100644 api/@ohos.app.abilityDelegatorRegistry.d.ts create mode 100644 api/app/abilityDelegator.d.ts create mode 100644 api/app/abilityDelegatorArgs.d.ts create mode 100644 api/app/abilityMonitor.d.ts create mode 100644 api/app/shellCmdResult.d.ts create mode 100644 api/app/testRunner.d.ts diff --git a/api/@ohos.app.abilityDelegatorRegistry.d.ts b/api/@ohos.app.abilityDelegatorRegistry.d.ts new file mode 100644 index 0000000000..7ec09965a6 --- /dev/null +++ b/api/@ohos.app.abilityDelegatorRegistry.d.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from './basic'; +import { AbilityDelegator } from './app/abilityDelegator' +import { AbilityDelegatorArgs } from './app/abilityDelegatorArgs' + +/** + * A global register used to store the AbilityDelegator and AbilityDelegatorArgs objects registered + * during application startup. + * 在应用程序启动期间,保存AbilityDelegator和AbilityDelegatorArgs对象的全局存储器 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import abilityManager from '@ohos.app.abilityManager' + * @permission N/A + */ +declare namespace abilityDelegatorRegistry { + /** + * Get the AbilityDelegator object of the application. + * 异步方式获取应用程序的AbilityDelegator对象 + * @return the AbilityDelegator object initialized when the application is started. + * 应用程序启动时被初始化的AbilityDelegator对象 + */ + function getAbilityDelegator(callback: AsyncCallback): void; + function getAbilityDelegator(): Promise; + + /** + * Get unit test parameters stored in the AbilityDelegatorArgs object. + * 异步的方式获取单元测试参数AbilityDelegatorArgs对象 + * @return the previously registered AbilityDelegatorArgs object. + * 单元测试参数AbilityDelegatorArgs对象 + */ + function getArguments(callback: AsyncCallback): void; + function getArguments(): Promise;​ + + /** + * Describes all lifecycle states of an ability. + */ + export enum AbilityLifecycleState { + CREATE, + FOREGROUND, + BACKGROUND, + DESTROY, + } +} + +export default abilityDelegatorRegistry; \ No newline at end of file diff --git a/api/app/abilityDelegator.d.ts b/api/app/abilityDelegator.d.ts new file mode 100644 index 0000000000..2b5dc8426c --- /dev/null +++ b/api/app/abilityDelegator.d.ts @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from '../basic'; +import { Ability } from '../@ohos.application.Ability' +import { AbilityMonitor } from './abilityMonitor' +import { Context } from './context' +import { ShellCmdResult } from './shellCmdResult' +import { Want } from '../ability/want' + +/** + * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import AbilityDelegator from 'app/abilityDelegator.d' + * @permission N/A + */ +export interface AbilityDelegator { + /** + * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. + * 添加AbilityMonitor实例,用于监听ability生命周期变换 + * @param monitor AbilityMonitor实例 + */ + addAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; + addAbilityMonitor​(monitor: AbilityMonitor): Promise; + + /** + * Remove a specified AbilityMonitor object from the application memory. + * 删除已经添加的AbilityMonitor实例 + * @param monitor AbilityMonitor实例 + */ + removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void;​ + removeAbilityMonitor(monitor: AbilityMonitor): Promise; + + /** + * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. + * 等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例 + * @param monitor AbilityMonitor实例 + * @param timeout 最大等待时间,单位毫秒 + * @return 如果监听到与指定AbilityMonitor实例匹配的Abilityability到达OnCreate生命周期,则返回ability实例;否则返回空 + */ + waitAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; + waitAbilityMonitor​(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; + waitAbilityMonitor​(monitor: AbilityMonitor, timeout?: number): Promise; + + /** + * Obtain the application context. + * 异步方式获取应用Context,通过异步回调将Context实例返回 + * @return 应用Context + */ + getAppContext(callback: AsyncCallback): void; + getAppContext(): Promise; + + /** + * Obtain the lifecycle state of a specified ability. + * 异步方式获取指定ability状态 + * @param ability 指定Ability对象 + * @return 指定Ability对象的状态 + */ + getAbilityState(ability: Ability, callback: AsyncCallback): void; + getAbilityState(ability: Ability): Promise; + + /** + * Obtain the ability that is currently being displayed. + * 异步方式获取当前应用顶部ability + * @return 当前应用顶部ability + */ + getCurrentTopAbility(callback: AsyncCallback): void; + getCurrentTopAbility(): Promise + + /** + * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. + * 异步方式调度指定ability生命周期状态到Foreground状态 + * @param ability 指定Ability对象 + * @return true: 成功 false: 失败 + */ + doAbilityForeground(ability: Ability, callback: AsyncCallback): void; + doAbilityForeground(ability: Ability): Promise; + + /** + * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. + * 异步方式调度指定ability生命周期状态到Background状态 + * @param ability 指定Ability对象 + * @return true: 成功 false: 失败 + */ + doAbilityBackground(ability: Ability, callback: AsyncCallback): void; + doAbilityBackground(ability: Ability): Promise; + + /** + * Prints log information to the unit testing console. + * The total length of the log information to be printed cannot exceed 1000 characters. + * 异步方式打印日志信息到单元测试终端控制台 + * 日志信息字符串长度最大不超过1000个字符 + * @param msg 日志字符串 + */ + print(msg: string, callback: AsyncCallback): void; + print(msg: string): Promise; + + /** + * Execute the given command in the aa tools side. + * 异步方式执行指定的shell命令 + * @param cmd shell命令字符串 + * @return shell命令执行结果对象 + */ + executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void;​ + executeShellCommand(cmd: string, timeoutSecs: number): Promise;​ +} + +export default AbilityDelegator; \ No newline at end of file diff --git a/api/app/abilityDelegatorArgs.d.ts b/api/app/abilityDelegatorArgs.d.ts new file mode 100644 index 0000000000..8b3476cfeb --- /dev/null +++ b/api/app/abilityDelegatorArgs.d.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * Store unit testing-related parameters, including test case names, and test runner name. + * 存储单元测试相关的参数,包括测试用例名称,测试用例执行器名称 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import AbilityDelegatorArgs from 'app/abilityDelegatorArgs.d' + * @permission N/A + */ +export interface AbilityDelegatorArgs { + /** + * the bundle name of the application being tested. + * 表示当前被测试应用的包名 + */ + bundleName: string; + + /** + * the parameters used for unit testing. + * 表示当前启动单元测试的参数 + */ + parameters​: {[key: string]: string}; + + /** + * the class names of all test cases. + * 测试用例名称 + */ + testCaseNames: string; + + /** + * the class name of the test runner used to execute test cases. + * 执行测试用例的测试执行器的名称 + */ + testRunnerClassName: string;​ +} + +export default AbilityDelegatorArgs; \ No newline at end of file diff --git a/api/app/abilityMonitor.d.ts b/api/app/abilityMonitor.d.ts new file mode 100644 index 0000000000..15f68e434a --- /dev/null +++ b/api/app/abilityMonitor.d.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Provide methods for matching monitored Ability objects that meet specified conditions. + * The most recently matched Ability objects will be saved in the AbilityMonitor object. + * 监听指定Ability生命周期状态变化的监听器 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import AbilityMonitor from 'app/abilityMonitor.d' + * @permission N/A + */ +export interface AbilityMonitor { + /** + * The name of the ability to monitor. + * 表示当前AbilityMonitor绑定的ability name + */ + abilityName: string; + + /** + * Called back when the ability is started for initialization. + * ability被启动初始化时的回调函数 + */ + onAbilityCreate?:() => void; + + /** + * Called back when the state of the ability changes to foreground. + * ability状态变成前台时的回调函数 + */ + onAbilityForeground?:() => void; + + /** + * Called back when the state of the ability changes to background. + * ability状态变成后台时的回调函数 + */ + onAbilityBackground?:() => void; + + /** + * Called back before the ability is destroyed. + * ability被销毁前的回调函数 + */ + onAbilityDestroy?:() => void; + + /** + * Called back when an ability window stage is created. + * window stage被创建时的回调函数 + */ + onWindowStageCreate?:() => void; + + /** + * Called back when an ability window stage is restored. + * window stage被重载时的回调函数 + */ + onWindowStageRestore?:() => void; + + /** + * Called back when an ability window stage is destroyed. + * window stage被销毁前的回调函数 + */ + onWindowStageDestroy?:() => void; +} + +export default AbilityMonitor; \ No newline at end of file diff --git a/api/app/shellCmdResult.d.ts b/api/app/shellCmdResult.d.ts new file mode 100644 index 0000000000..d29515c95d --- /dev/null +++ b/api/app/shellCmdResult.d.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A object that records the result of shell command executes. + * 执行shell命令的结果 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import ShellCmdResult from 'app/shellCmdResult.d' + * @permission N/A + */ +export interface ShellCmdResult { + /** + * the cmd standard result. + * shell命令标准输出结果 + */ + stdResult: String; + + /** + * shell cmd exec result. + * shell命令执行的结果 + */ + exitCode: number; +} + +export default ShellCmdResult; \ No newline at end of file diff --git a/api/app/testRunner.d.ts b/api/app/testRunner.d.ts new file mode 100644 index 0000000000..30b3e1c83f --- /dev/null +++ b/api/app/testRunner.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Base class for the test framework. + * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. + * 测试框架的执行器基类 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import TestRunner from 'app/testRunner.d' + * @permission N/A + */ +export interface TestRunner { + /** + * Prepare the unit testing environment for running test cases. + * 为执行器准备单元测试环境 + */ + onPrepare​(): void; + + /** + * Run all test cases. + * 运行所有的测试用例 + */ + onRun​(): void; +} + +export default TestRunner; \ No newline at end of file -- Gitee From cd6a8d812dd31a3c988113e01f76752d79f62e44 Mon Sep 17 00:00:00 2001 From: hanhaibin Date: Wed, 19 Jan 2022 22:38:46 +0800 Subject: [PATCH 2/7] Update d.ts Signed-off-by: hanhaibin --- ....application.abilityDelegatorRegistry.d.ts | 61 +++++++++ api/@ohos.application.testRunner.d.ts | 41 ++++++ api/application/abilityDelegator.d.ts | 122 ++++++++++++++++++ api/application/abilityDelegatorArgs.d.ts | 53 ++++++++ api/application/abilityMonitor.d.ts | 77 +++++++++++ api/application/shellCmdResult.d.ts | 40 ++++++ 6 files changed, 394 insertions(+) create mode 100644 api/@ohos.application.abilityDelegatorRegistry.d.ts create mode 100644 api/@ohos.application.testRunner.d.ts create mode 100644 api/application/abilityDelegator.d.ts create mode 100644 api/application/abilityDelegatorArgs.d.ts create mode 100644 api/application/abilityMonitor.d.ts create mode 100644 api/application/shellCmdResult.d.ts diff --git a/api/@ohos.application.abilityDelegatorRegistry.d.ts b/api/@ohos.application.abilityDelegatorRegistry.d.ts new file mode 100644 index 0000000000..0293d32f0d --- /dev/null +++ b/api/@ohos.application.abilityDelegatorRegistry.d.ts @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from './basic'; +import { AbilityDelegator } from './application/abilityDelegator' +import { AbilityDelegatorArgs } from './application/abilityDelegatorArgs' + +/** + * A global register used to store the AbilityDelegator and AbilityDelegatorArgs objects registered + * during application startup. + * 在应用程序启动期间,保存AbilityDelegator和AbilityDelegatorArgs对象的全局存储器 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import abilityManager from '@ohos.application.abilityManager' + * @permission N/A + */ +declare namespace abilityDelegatorRegistry { + /** + * Get the AbilityDelegator object of the application. + * 异步方式获取应用程序的AbilityDelegator对象 + * @return the AbilityDelegator object initialized when the application is started. + * 应用程序启动时被初始化的AbilityDelegator对象 + */ + function getAbilityDelegator(callback: AsyncCallback): void; + function getAbilityDelegator(): Promise; + + /** + * Get unit test parameters stored in the AbilityDelegatorArgs object. + * 异步的方式获取单元测试参数AbilityDelegatorArgs对象 + * @return the previously registered AbilityDelegatorArgs object. + * 单元测试参数AbilityDelegatorArgs对象 + */ + function getArguments(callback: AsyncCallback): void; + function getArguments(): Promise;​ + + /** + * Describes all lifecycle states of an ability. + */ + export enum AbilityLifecycleState { + CREATE, + FOREGROUND, + BACKGROUND, + DESTROY, + } +} + +export default abilityDelegatorRegistry; \ No newline at end of file diff --git a/api/@ohos.application.testRunner.d.ts b/api/@ohos.application.testRunner.d.ts new file mode 100644 index 0000000000..994bc70efe --- /dev/null +++ b/api/@ohos.application.testRunner.d.ts @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Base class for the test framework. + * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. + * 测试框架的执行器基类 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import TestRunner from '@ohos.application.testRunner' + * @permission N/A + */ +export interface TestRunner { + /** + * Prepare the unit testing environment for running test cases. + * 为执行器准备单元测试环境 + */ + onPrepare​(): void; + + /** + * Run all test cases. + * 运行所有的测试用例 + */ + onRun​(): void; +} + +export default TestRunner; \ No newline at end of file diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts new file mode 100644 index 0000000000..e3a96d55f4 --- /dev/null +++ b/api/application/abilityDelegator.d.ts @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { AsyncCallback } from '../basic'; +import { Ability } from '../@ohos.application.Ability' +import { AbilityMonitor } from './abilityMonitor' +import { Context } from '../app/context' +import { ShellCmdResult } from './shellCmdResult' + +/** + * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import AbilityDelegator from 'application/abilityDelegator.d' + * @permission N/A + */ +export interface AbilityDelegator { + /** + * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. + * 添加AbilityMonitor实例,用于监听ability生命周期变换 + * @param monitor AbilityMonitor实例 + */ + addAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; + addAbilityMonitor​(monitor: AbilityMonitor): Promise; + + /** + * Remove a specified AbilityMonitor object from the application memory. + * 删除已经添加的AbilityMonitor实例 + * @param monitor AbilityMonitor实例 + */ + removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void;​ + removeAbilityMonitor(monitor: AbilityMonitor): Promise; + + /** + * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. + * 等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例 + * @param monitor AbilityMonitor实例 + * @param timeout 最大等待时间,单位毫秒 + * @return 如果监听到与指定AbilityMonitor实例匹配的Abilityability到达OnCreate生命周期,则返回ability实例;否则返回空 + */ + waitAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; + waitAbilityMonitor​(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; + waitAbilityMonitor​(monitor: AbilityMonitor, timeout?: number): Promise; + + /** + * Obtain the application context. + * 异步方式获取应用Context,通过异步回调将Context实例返回 + * @return 应用Context + */ + getAppContext(callback: AsyncCallback): void; + getAppContext(): Promise; + + /** + * Obtain the lifecycle state of a specified ability. + * 异步方式获取指定ability状态 + * @param ability 指定Ability对象 + * @return 指定Ability对象的状态 + */ + getAbilityState(ability: Ability, callback: AsyncCallback): void; + getAbilityState(ability: Ability): Promise; + + /** + * Obtain the ability that is currently being displayed. + * 异步方式获取当前应用顶部ability + * @return 当前应用顶部ability + */ + getCurrentTopAbility(callback: AsyncCallback): void; + getCurrentTopAbility(): Promise + + /** + * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. + * 异步方式调度指定ability生命周期状态到Foreground状态 + * @param ability 指定Ability对象 + * @return true: 成功 false: 失败 + */ + doAbilityForeground(ability: Ability, callback: AsyncCallback): void; + doAbilityForeground(ability: Ability): Promise; + + /** + * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. + * 异步方式调度指定ability生命周期状态到Background状态 + * @param ability 指定Ability对象 + * @return true: 成功 false: 失败 + */ + doAbilityBackground(ability: Ability, callback: AsyncCallback): void; + doAbilityBackground(ability: Ability): Promise; + + /** + * Prints log information to the unit testing console. + * The total length of the log information to be printed cannot exceed 1000 characters. + * 异步方式打印日志信息到单元测试终端控制台 + * 日志信息字符串长度最大不超过1000个字符 + * @param msg 日志字符串 + */ + print(msg: string, callback: AsyncCallback): void; + print(msg: string): Promise; + + /** + * Execute the given command in the aa tools side. + * 异步方式执行指定的shell命令 + * @param cmd shell命令字符串 + * @return shell命令执行结果对象 + */ + executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void;​ + executeShellCommand(cmd: string, timeoutSecs: number): Promise;​ +} + +export default AbilityDelegator; \ No newline at end of file diff --git a/api/application/abilityDelegatorArgs.d.ts b/api/application/abilityDelegatorArgs.d.ts new file mode 100644 index 0000000000..6cad52981b --- /dev/null +++ b/api/application/abilityDelegatorArgs.d.ts @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +/** + * Store unit testing-related parameters, including test case names, and test runner name. + * 存储单元测试相关的参数,包括测试用例名称,测试用例执行器名称 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import AbilityDelegatorArgs from 'application/abilityDelegatorArgs.d' + * @permission N/A + */ +export interface AbilityDelegatorArgs { + /** + * the bundle name of the application being tested. + * 表示当前被测试应用的包名 + */ + bundleName: string; + + /** + * the parameters used for unit testing. + * 表示当前启动单元测试的参数 + */ + parameters​: {[key: string]: string}; + + /** + * the class names of all test cases. + * 测试用例名称 + */ + testCaseNames: string; + + /** + * the class name of the test runner used to execute test cases. + * 执行测试用例的测试执行器的名称 + */ + testRunnerClassName: string;​ +} + +export default AbilityDelegatorArgs; \ No newline at end of file diff --git a/api/application/abilityMonitor.d.ts b/api/application/abilityMonitor.d.ts new file mode 100644 index 0000000000..9bdf341e18 --- /dev/null +++ b/api/application/abilityMonitor.d.ts @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * Provide methods for matching monitored Ability objects that meet specified conditions. + * The most recently matched Ability objects will be saved in the AbilityMonitor object. + * 监听指定Ability生命周期状态变化的监听器 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import AbilityMonitor from 'application/abilityMonitor.d' + * @permission N/A + */ +export interface AbilityMonitor { + /** + * The name of the ability to monitor. + * 表示当前AbilityMonitor绑定的ability name + */ + abilityName: string; + + /** + * Called back when the ability is started for initialization. + * ability被启动初始化时的回调函数 + */ + onAbilityCreate?:() => void; + + /** + * Called back when the state of the ability changes to foreground. + * ability状态变成前台时的回调函数 + */ + onAbilityForeground?:() => void; + + /** + * Called back when the state of the ability changes to background. + * ability状态变成后台时的回调函数 + */ + onAbilityBackground?:() => void; + + /** + * Called back before the ability is destroyed. + * ability被销毁前的回调函数 + */ + onAbilityDestroy?:() => void; + + /** + * Called back when an ability window stage is created. + * window stage被创建时的回调函数 + */ + onWindowStageCreate?:() => void; + + /** + * Called back when an ability window stage is restored. + * window stage被重载时的回调函数 + */ + onWindowStageRestore?:() => void; + + /** + * Called back when an ability window stage is destroyed. + * window stage被销毁前的回调函数 + */ + onWindowStageDestroy?:() => void; +} + +export default AbilityMonitor; \ No newline at end of file diff --git a/api/application/shellCmdResult.d.ts b/api/application/shellCmdResult.d.ts new file mode 100644 index 0000000000..4eebad7cc9 --- /dev/null +++ b/api/application/shellCmdResult.d.ts @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * A object that records the result of shell command executes. + * 执行shell命令的结果 + * + * @since 8 + * @SysCap SystemCapability.Appexecfwk + * @devices phone, tablet, tv, wearable, car + * @import import ShellCmdResult from 'application/shellCmdResult.d' + * @permission N/A + */ +export interface ShellCmdResult { + /** + * the cmd standard result. + * shell命令标准输出结果 + */ + stdResult: String; + + /** + * shell cmd exec result. + * shell命令执行的结果 + */ + exitCode: number; +} + +export default ShellCmdResult; \ No newline at end of file -- Gitee From e3ecfdabba34c9dc2229cc94e8678269b1882909 Mon Sep 17 00:00:00 2001 From: hanhaibin Date: Sun, 23 Jan 2022 00:41:43 +0800 Subject: [PATCH 3/7] Update d.ts Signed-off-by: hanhaibin --- api/application/abilityDelegator.d.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index e3a96d55f4..861e73f172 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -113,10 +113,12 @@ export interface AbilityDelegator { * Execute the given command in the aa tools side. * 异步方式执行指定的shell命令 * @param cmd shell命令字符串 - * @return shell命令执行结果对象 + * @param timeoutSecs 超时时间,单位秒 + * @return shell命令的执行结果ShellCmdResult对象 */ + executeShellCommand(cmd: string, callback: AsyncCallback): void;​ executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void;​ - executeShellCommand(cmd: string, timeoutSecs: number): Promise;​ + executeShellCommand(cmd: string, timeoutSecs?: number): Promise;​ } export default AbilityDelegator; \ No newline at end of file -- Gitee From 6109d29b203a7e811591f4736eeb66e42f8424fb Mon Sep 17 00:00:00 2001 From: njupthan Date: Tue, 22 Feb 2022 19:31:36 +0800 Subject: [PATCH 4/7] Update d.ts Signed-off-by: njupthan --- ....application.abilityDelegatorRegistry.d.ts | 16 ++-- api/@ohos.application.testRunner.d.ts | 9 +-- api/application/abilityDelegator.d.ts | 81 +++++++++---------- api/application/abilityDelegatorArgs.d.ts | 11 +-- api/application/abilityMonitor.d.ts | 11 +-- api/application/shellCmdResult.d.ts | 5 +- 6 files changed, 52 insertions(+), 81 deletions(-) diff --git a/api/@ohos.application.abilityDelegatorRegistry.d.ts b/api/@ohos.application.abilityDelegatorRegistry.d.ts index 0293d32f0d..81de8836d1 100644 --- a/api/@ohos.application.abilityDelegatorRegistry.d.ts +++ b/api/@ohos.application.abilityDelegatorRegistry.d.ts @@ -20,37 +20,31 @@ import { AbilityDelegatorArgs } from './application/abilityDelegatorArgs' /** * A global register used to store the AbilityDelegator and AbilityDelegatorArgs objects registered * during application startup. - * 在应用程序启动期间,保存AbilityDelegator和AbilityDelegatorArgs对象的全局存储器 * - * @since 8 + * @since 9 * @SysCap SystemCapability.Appexecfwk * @devices phone, tablet, tv, wearable, car - * @import import abilityManager from '@ohos.application.abilityManager' + * @import import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' * @permission N/A */ declare namespace abilityDelegatorRegistry { /** * Get the AbilityDelegator object of the application. - * 异步方式获取应用程序的AbilityDelegator对象 * @return the AbilityDelegator object initialized when the application is started. - * 应用程序启动时被初始化的AbilityDelegator对象 */ - function getAbilityDelegator(callback: AsyncCallback): void; - function getAbilityDelegator(): Promise; + function getAbilityDelegator(): AbilityDelegator; /** * Get unit test parameters stored in the AbilityDelegatorArgs object. - * 异步的方式获取单元测试参数AbilityDelegatorArgs对象 * @return the previously registered AbilityDelegatorArgs object. - * 单元测试参数AbilityDelegatorArgs对象 */ - function getArguments(callback: AsyncCallback): void; - function getArguments(): Promise;​ + function getArguments(): AbilityDelegatorArgs; /** * Describes all lifecycle states of an ability. */ export enum AbilityLifecycleState { + UNINITIALIZED, CREATE, FOREGROUND, BACKGROUND, diff --git a/api/@ohos.application.testRunner.d.ts b/api/@ohos.application.testRunner.d.ts index 994bc70efe..41b228c1f5 100644 --- a/api/@ohos.application.testRunner.d.ts +++ b/api/@ohos.application.testRunner.d.ts @@ -16,9 +16,8 @@ /** * Base class for the test framework. * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. - * 测试框架的执行器基类 * - * @since 8 + * @since 9 * @SysCap SystemCapability.Appexecfwk * @devices phone, tablet, tv, wearable, car * @import import TestRunner from '@ohos.application.testRunner' @@ -27,15 +26,13 @@ export interface TestRunner { /** * Prepare the unit testing environment for running test cases. - * 为执行器准备单元测试环境 */ - onPrepare​(): void; + onPrepare(): void; /** * Run all test cases. - * 运行所有的测试用例 */ - onRun​(): void; + onRun(): void; } export default TestRunner; \ No newline at end of file diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index 861e73f172..80cd8ea991 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -22,7 +22,7 @@ import { ShellCmdResult } from './shellCmdResult' /** * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. * - * @since 8 + * @since 9 * @SysCap SystemCapability.Appexecfwk * @devices phone, tablet, tv, wearable, car * @import import AbilityDelegator from 'application/abilityDelegator.d' @@ -31,70 +31,60 @@ import { ShellCmdResult } from './shellCmdResult' export interface AbilityDelegator { /** * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. - * 添加AbilityMonitor实例,用于监听ability生命周期变换 - * @param monitor AbilityMonitor实例 + * @param monitor AbilityMonitor object */ - addAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; - addAbilityMonitor​(monitor: AbilityMonitor): Promise; + addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + addAbilityMonitor(monitor: AbilityMonitor): Promise; /** * Remove a specified AbilityMonitor object from the application memory. - * 删除已经添加的AbilityMonitor实例 - * @param monitor AbilityMonitor实例 + * @param monitor AbilityMonitor object */ - removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void;​ + removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; removeAbilityMonitor(monitor: AbilityMonitor): Promise; /** * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. - * 等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例 - * @param monitor AbilityMonitor实例 - * @param timeout 最大等待时间,单位毫秒 - * @return 如果监听到与指定AbilityMonitor实例匹配的Abilityability到达OnCreate生命周期,则返回ability实例;否则返回空 + * @param monitor AbilityMonitor object + * @param timeout Maximum wait time, in milliseconds + * @return success: return the Ability object, failure: return null */ - waitAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; - waitAbilityMonitor​(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; - waitAbilityMonitor​(monitor: AbilityMonitor, timeout?: number): Promise; + waitAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; + waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; + waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise; /** * Obtain the application context. - * 异步方式获取应用Context,通过异步回调将Context实例返回 - * @return 应用Context + * @return App Context */ - getAppContext(callback: AsyncCallback): void; - getAppContext(): Promise; + getAppContext(): Context; /** * Obtain the lifecycle state of a specified ability. - * 异步方式获取指定ability状态 - * @param ability 指定Ability对象 - * @return 指定Ability对象的状态 + * @param ability The Ability object + * @return The state of the Ability object */ - getAbilityState(ability: Ability, callback: AsyncCallback): void; - getAbilityState(ability: Ability): Promise; + getAbilityState(ability: Ability): number; /** * Obtain the ability that is currently being displayed. - * 异步方式获取当前应用顶部ability - * @return 当前应用顶部ability + * @return The top ability of the current application */ getCurrentTopAbility(callback: AsyncCallback): void; getCurrentTopAbility(): Promise /** * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. - * 异步方式调度指定ability生命周期状态到Foreground状态 - * @param ability 指定Ability对象 - * @return true: 成功 false: 失败 + * @param ability The ability object + * @return true: success false: failure */ doAbilityForeground(ability: Ability, callback: AsyncCallback): void; doAbilityForeground(ability: Ability): Promise; /** * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. - * 异步方式调度指定ability生命周期状态到Background状态 - * @param ability 指定Ability对象 - * @return true: 成功 false: 失败 + * @param ability The ability object + * @return true: success false: failure */ doAbilityBackground(ability: Ability, callback: AsyncCallback): void; doAbilityBackground(ability: Ability): Promise; @@ -102,23 +92,30 @@ export interface AbilityDelegator { /** * Prints log information to the unit testing console. * The total length of the log information to be printed cannot exceed 1000 characters. - * 异步方式打印日志信息到单元测试终端控制台 - * 日志信息字符串长度最大不超过1000个字符 - * @param msg 日志字符串 + * @param msg Log information */ print(msg: string, callback: AsyncCallback): void; print(msg: string): Promise; /** * Execute the given command in the aa tools side. - * 异步方式执行指定的shell命令 - * @param cmd shell命令字符串 - * @param timeoutSecs 超时时间,单位秒 - * @return shell命令的执行结果ShellCmdResult对象 + * @param cmd Shell command + * @param timeoutSecs Timeout, in seconds + * @return ShellCmdResult object */ - executeShellCommand(cmd: string, callback: AsyncCallback): void;​ - executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void;​ - executeShellCommand(cmd: string, timeoutSecs?: number): Promise;​ + executeShellCommand(cmd: string, callback: AsyncCallback): void; + executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void; + executeShellCommand(cmd: string, timeoutSecs?: number): Promise; + + /** + * Prints log information to the unit testing console. + * The total length of the log information to be printed cannot exceed 1000 characters. + * @param msg Log information + * @param code Result code + * @hide + */ + finishTest(msg: string, code: number, callback: AsyncCallback): void; + finishTest(msg: string, code: number): Promise; } export default AbilityDelegator; \ No newline at end of file diff --git a/api/application/abilityDelegatorArgs.d.ts b/api/application/abilityDelegatorArgs.d.ts index 6cad52981b..2f0a508824 100644 --- a/api/application/abilityDelegatorArgs.d.ts +++ b/api/application/abilityDelegatorArgs.d.ts @@ -16,9 +16,8 @@ /** * Store unit testing-related parameters, including test case names, and test runner name. - * 存储单元测试相关的参数,包括测试用例名称,测试用例执行器名称 * - * @since 8 + * @since 9 * @SysCap SystemCapability.Appexecfwk * @devices phone, tablet, tv, wearable, car * @import import AbilityDelegatorArgs from 'application/abilityDelegatorArgs.d' @@ -27,27 +26,23 @@ export interface AbilityDelegatorArgs { /** * the bundle name of the application being tested. - * 表示当前被测试应用的包名 */ bundleName: string; /** * the parameters used for unit testing. - * 表示当前启动单元测试的参数 */ - parameters​: {[key: string]: string}; + parameters: {[key: string]: string}; /** * the class names of all test cases. - * 测试用例名称 */ testCaseNames: string; /** * the class name of the test runner used to execute test cases. - * 执行测试用例的测试执行器的名称 */ - testRunnerClassName: string;​ + testRunnerClassName: string; } export default AbilityDelegatorArgs; \ No newline at end of file diff --git a/api/application/abilityMonitor.d.ts b/api/application/abilityMonitor.d.ts index 9bdf341e18..72705575a0 100644 --- a/api/application/abilityMonitor.d.ts +++ b/api/application/abilityMonitor.d.ts @@ -16,9 +16,8 @@ /** * Provide methods for matching monitored Ability objects that meet specified conditions. * The most recently matched Ability objects will be saved in the AbilityMonitor object. - * 监听指定Ability生命周期状态变化的监听器 * - * @since 8 + * @since 9 * @SysCap SystemCapability.Appexecfwk * @devices phone, tablet, tv, wearable, car * @import import AbilityMonitor from 'application/abilityMonitor.d' @@ -27,49 +26,41 @@ export interface AbilityMonitor { /** * The name of the ability to monitor. - * 表示当前AbilityMonitor绑定的ability name */ abilityName: string; /** * Called back when the ability is started for initialization. - * ability被启动初始化时的回调函数 */ onAbilityCreate?:() => void; /** * Called back when the state of the ability changes to foreground. - * ability状态变成前台时的回调函数 */ onAbilityForeground?:() => void; /** * Called back when the state of the ability changes to background. - * ability状态变成后台时的回调函数 */ onAbilityBackground?:() => void; /** * Called back before the ability is destroyed. - * ability被销毁前的回调函数 */ onAbilityDestroy?:() => void; /** * Called back when an ability window stage is created. - * window stage被创建时的回调函数 */ onWindowStageCreate?:() => void; /** * Called back when an ability window stage is restored. - * window stage被重载时的回调函数 */ onWindowStageRestore?:() => void; /** * Called back when an ability window stage is destroyed. - * window stage被销毁前的回调函数 */ onWindowStageDestroy?:() => void; } diff --git a/api/application/shellCmdResult.d.ts b/api/application/shellCmdResult.d.ts index 4eebad7cc9..3dc6ab2dc5 100644 --- a/api/application/shellCmdResult.d.ts +++ b/api/application/shellCmdResult.d.ts @@ -15,9 +15,8 @@ /** * A object that records the result of shell command executes. - * 执行shell命令的结果 * - * @since 8 + * @since 9 * @SysCap SystemCapability.Appexecfwk * @devices phone, tablet, tv, wearable, car * @import import ShellCmdResult from 'application/shellCmdResult.d' @@ -26,13 +25,11 @@ export interface ShellCmdResult { /** * the cmd standard result. - * shell命令标准输出结果 */ stdResult: String; /** * shell cmd exec result. - * shell命令执行的结果 */ exitCode: number; } -- Gitee From 9713dba6743429ae3f0cc50e15fd2db5168d8287 Mon Sep 17 00:00:00 2001 From: njupthan Date: Wed, 23 Feb 2022 16:26:56 +0800 Subject: [PATCH 5/7] Update d.ts Signed-off-by: njupthan --- ....application.abilityDelegatorRegistry.d.ts | 13 ++++-- api/@ohos.application.testRunner.d.ts | 9 ++++- api/application/abilityDelegator.d.ts | 40 +++++++++++++++++-- api/application/abilityDelegatorArgs.d.ts | 15 ++++++- api/application/abilityMonitor.d.ts | 27 ++++++++++++- api/application/shellCmdResult.d.ts | 9 ++++- 6 files changed, 98 insertions(+), 15 deletions(-) diff --git a/api/@ohos.application.abilityDelegatorRegistry.d.ts b/api/@ohos.application.abilityDelegatorRegistry.d.ts index 81de8836d1..8a8443d4ee 100644 --- a/api/@ohos.application.abilityDelegatorRegistry.d.ts +++ b/api/@ohos.application.abilityDelegatorRegistry.d.ts @@ -13,7 +13,6 @@ * limitations under the License. */ -import { AsyncCallback } from './basic'; import { AbilityDelegator } from './application/abilityDelegator' import { AbilityDelegatorArgs } from './application/abilityDelegatorArgs' @@ -22,26 +21,34 @@ import { AbilityDelegatorArgs } from './application/abilityDelegatorArgs' * during application startup. * * @since 9 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' * @permission N/A */ declare namespace abilityDelegatorRegistry { /** * Get the AbilityDelegator object of the application. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @return the AbilityDelegator object initialized when the application is started. */ function getAbilityDelegator(): AbilityDelegator; /** * Get unit test parameters stored in the AbilityDelegatorArgs object. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @return the previously registered AbilityDelegatorArgs object. */ function getArguments(): AbilityDelegatorArgs; /** * Describes all lifecycle states of an ability. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ export enum AbilityLifecycleState { UNINITIALIZED, diff --git a/api/@ohos.application.testRunner.d.ts b/api/@ohos.application.testRunner.d.ts index 41b228c1f5..6ae4908fcd 100644 --- a/api/@ohos.application.testRunner.d.ts +++ b/api/@ohos.application.testRunner.d.ts @@ -18,19 +18,24 @@ * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. * * @since 9 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @import import TestRunner from '@ohos.application.testRunner' * @permission N/A */ export interface TestRunner { /** * Prepare the unit testing environment for running test cases. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onPrepare(): void; /** * Run all test cases. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onRun(): void; } diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index 80cd8ea991..729694b38f 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -23,14 +23,16 @@ import { ShellCmdResult } from './shellCmdResult' * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. * * @since 9 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegator from 'application/abilityDelegator.d' * @permission N/A */ export interface AbilityDelegator { /** * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param monitor AbilityMonitor object */ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; @@ -38,6 +40,9 @@ export interface AbilityDelegator { /** * Remove a specified AbilityMonitor object from the application memory. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param monitor AbilityMonitor object */ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; @@ -45,6 +50,9 @@ export interface AbilityDelegator { /** * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param monitor AbilityMonitor object * @param timeout Maximum wait time, in milliseconds * @return success: return the Ability object, failure: return null @@ -55,19 +63,28 @@ export interface AbilityDelegator { /** * Obtain the application context. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @return App Context */ getAppContext(): Context; /** * Obtain the lifecycle state of a specified ability. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param ability The Ability object - * @return The state of the Ability object + * @return The state of the Ability object. enum AbilityLifecycleState */ getAbilityState(ability: Ability): number; /** * Obtain the ability that is currently being displayed. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @return The top ability of the current application */ getCurrentTopAbility(callback: AsyncCallback): void; @@ -75,6 +92,9 @@ export interface AbilityDelegator { /** * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param ability The ability object * @return true: success false: failure */ @@ -83,6 +103,9 @@ export interface AbilityDelegator { /** * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param ability The ability object * @return true: success false: failure */ @@ -92,6 +115,9 @@ export interface AbilityDelegator { /** * Prints log information to the unit testing console. * The total length of the log information to be printed cannot exceed 1000 characters. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param msg Log information */ print(msg: string, callback: AsyncCallback): void; @@ -99,6 +125,9 @@ export interface AbilityDelegator { /** * Execute the given command in the aa tools side. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @param cmd Shell command * @param timeoutSecs Timeout, in seconds * @return ShellCmdResult object @@ -110,9 +139,12 @@ export interface AbilityDelegator { /** * Prints log information to the unit testing console. * The total length of the log information to be printed cannot exceed 1000 characters. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @hide * @param msg Log information * @param code Result code - * @hide */ finishTest(msg: string, code: number, callback: AsyncCallback): void; finishTest(msg: string, code: number): Promise; diff --git a/api/application/abilityDelegatorArgs.d.ts b/api/application/abilityDelegatorArgs.d.ts index 2f0a508824..fb9905a667 100644 --- a/api/application/abilityDelegatorArgs.d.ts +++ b/api/application/abilityDelegatorArgs.d.ts @@ -18,29 +18,40 @@ * Store unit testing-related parameters, including test case names, and test runner name. * * @since 9 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegatorArgs from 'application/abilityDelegatorArgs.d' * @permission N/A */ export interface AbilityDelegatorArgs { /** * the bundle name of the application being tested. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ bundleName: string; /** * the parameters used for unit testing. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ parameters: {[key: string]: string}; /** * the class names of all test cases. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ testCaseNames: string; /** * the class name of the test runner used to execute test cases. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ testRunnerClassName: string; } diff --git a/api/application/abilityMonitor.d.ts b/api/application/abilityMonitor.d.ts index 72705575a0..71215ba908 100644 --- a/api/application/abilityMonitor.d.ts +++ b/api/application/abilityMonitor.d.ts @@ -18,49 +18,72 @@ * The most recently matched Ability objects will be saved in the AbilityMonitor object. * * @since 9 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityMonitor from 'application/abilityMonitor.d' * @permission N/A */ export interface AbilityMonitor { /** * The name of the ability to monitor. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ abilityName: string; /** * Called back when the ability is started for initialization. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityCreate?:() => void; /** * Called back when the state of the ability changes to foreground. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityForeground?:() => void; /** * Called back when the state of the ability changes to background. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityBackground?:() => void; /** * Called back before the ability is destroyed. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityDestroy?:() => void; /** * Called back when an ability window stage is created. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onWindowStageCreate?:() => void; /** * Called back when an ability window stage is restored. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onWindowStageRestore?:() => void; /** * Called back when an ability window stage is destroyed. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ onWindowStageDestroy?:() => void; } diff --git a/api/application/shellCmdResult.d.ts b/api/application/shellCmdResult.d.ts index 3dc6ab2dc5..ac951d855c 100644 --- a/api/application/shellCmdResult.d.ts +++ b/api/application/shellCmdResult.d.ts @@ -17,19 +17,24 @@ * A object that records the result of shell command executes. * * @since 9 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car + * @sysCap SystemCapability.Ability.AbilityRuntime.Core * @import import ShellCmdResult from 'application/shellCmdResult.d' * @permission N/A */ export interface ShellCmdResult { /** * the cmd standard result. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ stdResult: String; /** * shell cmd exec result. + * + * @since 9 + * @sysCap SystemCapability.Ability.AbilityRuntime.Core */ exitCode: number; } -- Gitee From ab3e8c1db9fbe5aa32e4f929d49d11d316ffcc0d Mon Sep 17 00:00:00 2001 From: njupthan Date: Mon, 28 Feb 2022 16:32:28 +0800 Subject: [PATCH 6/7] update d.ts file Signed-off-by: njupthan --- ....application.abilityDelegatorRegistry.d.ts | 8 +++---- api/@ohos.application.testRunner.d.ts | 6 ++--- api/application/abilityDelegator.d.ts | 24 +++++++++---------- api/application/abilityDelegatorArgs.d.ts | 10 ++++---- api/application/abilityMonitor.d.ts | 18 +++++++------- api/application/shellCmdResult.d.ts | 6 ++--- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/api/@ohos.application.abilityDelegatorRegistry.d.ts b/api/@ohos.application.abilityDelegatorRegistry.d.ts index 8a8443d4ee..c21a8cc64e 100644 --- a/api/@ohos.application.abilityDelegatorRegistry.d.ts +++ b/api/@ohos.application.abilityDelegatorRegistry.d.ts @@ -21,7 +21,7 @@ import { AbilityDelegatorArgs } from './application/abilityDelegatorArgs' * during application startup. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' * @permission N/A */ @@ -30,7 +30,7 @@ declare namespace abilityDelegatorRegistry { * Get the AbilityDelegator object of the application. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @return the AbilityDelegator object initialized when the application is started. */ function getAbilityDelegator(): AbilityDelegator; @@ -39,7 +39,7 @@ declare namespace abilityDelegatorRegistry { * Get unit test parameters stored in the AbilityDelegatorArgs object. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @return the previously registered AbilityDelegatorArgs object. */ function getArguments(): AbilityDelegatorArgs; @@ -48,7 +48,7 @@ declare namespace abilityDelegatorRegistry { * Describes all lifecycle states of an ability. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ export enum AbilityLifecycleState { UNINITIALIZED, diff --git a/api/@ohos.application.testRunner.d.ts b/api/@ohos.application.testRunner.d.ts index 6ae4908fcd..58593017d0 100644 --- a/api/@ohos.application.testRunner.d.ts +++ b/api/@ohos.application.testRunner.d.ts @@ -18,7 +18,7 @@ * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import TestRunner from '@ohos.application.testRunner' * @permission N/A */ @@ -27,7 +27,7 @@ export interface TestRunner { * Prepare the unit testing environment for running test cases. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onPrepare(): void; @@ -35,7 +35,7 @@ export interface TestRunner { * Run all test cases. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onRun(): void; } diff --git a/api/application/abilityDelegator.d.ts b/api/application/abilityDelegator.d.ts index 729694b38f..8f48ca1ad1 100644 --- a/api/application/abilityDelegator.d.ts +++ b/api/application/abilityDelegator.d.ts @@ -23,7 +23,7 @@ import { ShellCmdResult } from './shellCmdResult' * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegator from 'application/abilityDelegator.d' * @permission N/A */ @@ -32,7 +32,7 @@ export interface AbilityDelegator { * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param monitor AbilityMonitor object */ addAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; @@ -42,7 +42,7 @@ export interface AbilityDelegator { * Remove a specified AbilityMonitor object from the application memory. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param monitor AbilityMonitor object */ removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void; @@ -52,7 +52,7 @@ export interface AbilityDelegator { * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param monitor AbilityMonitor object * @param timeout Maximum wait time, in milliseconds * @return success: return the Ability object, failure: return null @@ -65,7 +65,7 @@ export interface AbilityDelegator { * Obtain the application context. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @return App Context */ getAppContext(): Context; @@ -74,7 +74,7 @@ export interface AbilityDelegator { * Obtain the lifecycle state of a specified ability. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param ability The Ability object * @return The state of the Ability object. enum AbilityLifecycleState */ @@ -84,7 +84,7 @@ export interface AbilityDelegator { * Obtain the ability that is currently being displayed. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @return The top ability of the current application */ getCurrentTopAbility(callback: AsyncCallback): void; @@ -94,7 +94,7 @@ export interface AbilityDelegator { * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param ability The ability object * @return true: success false: failure */ @@ -105,7 +105,7 @@ export interface AbilityDelegator { * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param ability The ability object * @return true: success false: failure */ @@ -117,7 +117,7 @@ export interface AbilityDelegator { * The total length of the log information to be printed cannot exceed 1000 characters. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param msg Log information */ print(msg: string, callback: AsyncCallback): void; @@ -127,7 +127,7 @@ export interface AbilityDelegator { * Execute the given command in the aa tools side. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @param cmd Shell command * @param timeoutSecs Timeout, in seconds * @return ShellCmdResult object @@ -141,7 +141,7 @@ export interface AbilityDelegator { * The total length of the log information to be printed cannot exceed 1000 characters. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @hide * @param msg Log information * @param code Result code diff --git a/api/application/abilityDelegatorArgs.d.ts b/api/application/abilityDelegatorArgs.d.ts index fb9905a667..321a68e0d2 100644 --- a/api/application/abilityDelegatorArgs.d.ts +++ b/api/application/abilityDelegatorArgs.d.ts @@ -18,7 +18,7 @@ * Store unit testing-related parameters, including test case names, and test runner name. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityDelegatorArgs from 'application/abilityDelegatorArgs.d' * @permission N/A */ @@ -27,7 +27,7 @@ export interface AbilityDelegatorArgs { * the bundle name of the application being tested. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ bundleName: string; @@ -35,7 +35,7 @@ export interface AbilityDelegatorArgs { * the parameters used for unit testing. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ parameters: {[key: string]: string}; @@ -43,7 +43,7 @@ export interface AbilityDelegatorArgs { * the class names of all test cases. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ testCaseNames: string; @@ -51,7 +51,7 @@ export interface AbilityDelegatorArgs { * the class name of the test runner used to execute test cases. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ testRunnerClassName: string; } diff --git a/api/application/abilityMonitor.d.ts b/api/application/abilityMonitor.d.ts index 71215ba908..81806c4369 100644 --- a/api/application/abilityMonitor.d.ts +++ b/api/application/abilityMonitor.d.ts @@ -18,7 +18,7 @@ * The most recently matched Ability objects will be saved in the AbilityMonitor object. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import AbilityMonitor from 'application/abilityMonitor.d' * @permission N/A */ @@ -27,7 +27,7 @@ export interface AbilityMonitor { * The name of the ability to monitor. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ abilityName: string; @@ -35,7 +35,7 @@ export interface AbilityMonitor { * Called back when the ability is started for initialization. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityCreate?:() => void; @@ -43,7 +43,7 @@ export interface AbilityMonitor { * Called back when the state of the ability changes to foreground. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityForeground?:() => void; @@ -51,7 +51,7 @@ export interface AbilityMonitor { * Called back when the state of the ability changes to background. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityBackground?:() => void; @@ -59,7 +59,7 @@ export interface AbilityMonitor { * Called back before the ability is destroyed. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onAbilityDestroy?:() => void; @@ -67,7 +67,7 @@ export interface AbilityMonitor { * Called back when an ability window stage is created. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onWindowStageCreate?:() => void; @@ -75,7 +75,7 @@ export interface AbilityMonitor { * Called back when an ability window stage is restored. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onWindowStageRestore?:() => void; @@ -83,7 +83,7 @@ export interface AbilityMonitor { * Called back when an ability window stage is destroyed. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ onWindowStageDestroy?:() => void; } diff --git a/api/application/shellCmdResult.d.ts b/api/application/shellCmdResult.d.ts index ac951d855c..b8cc3f894a 100644 --- a/api/application/shellCmdResult.d.ts +++ b/api/application/shellCmdResult.d.ts @@ -17,7 +17,7 @@ * A object that records the result of shell command executes. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core * @import import ShellCmdResult from 'application/shellCmdResult.d' * @permission N/A */ @@ -26,7 +26,7 @@ export interface ShellCmdResult { * the cmd standard result. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ stdResult: String; @@ -34,7 +34,7 @@ export interface ShellCmdResult { * shell cmd exec result. * * @since 9 - * @sysCap SystemCapability.Ability.AbilityRuntime.Core + * @syscap SystemCapability.Ability.AbilityRuntime.Core */ exitCode: number; } -- Gitee From d702982e63409df805cb10730226e687abf24e62 Mon Sep 17 00:00:00 2001 From: njupthan Date: Mon, 28 Feb 2022 16:43:06 +0800 Subject: [PATCH 7/7] Delete d.ts file Signed-off-by: njupthan --- api/@ohos.app.abilityDelegatorRegistry.d.ts | 61 ---------- api/app/abilityDelegator.d.ts | 123 -------------------- api/app/abilityDelegatorArgs.d.ts | 53 --------- api/app/abilityMonitor.d.ts | 77 ------------ api/app/shellCmdResult.d.ts | 40 ------- api/app/testRunner.d.ts | 41 ------- 6 files changed, 395 deletions(-) delete mode 100644 api/@ohos.app.abilityDelegatorRegistry.d.ts delete mode 100644 api/app/abilityDelegator.d.ts delete mode 100644 api/app/abilityDelegatorArgs.d.ts delete mode 100644 api/app/abilityMonitor.d.ts delete mode 100644 api/app/shellCmdResult.d.ts delete mode 100644 api/app/testRunner.d.ts diff --git a/api/@ohos.app.abilityDelegatorRegistry.d.ts b/api/@ohos.app.abilityDelegatorRegistry.d.ts deleted file mode 100644 index 7ec09965a6..0000000000 --- a/api/@ohos.app.abilityDelegatorRegistry.d.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AsyncCallback } from './basic'; -import { AbilityDelegator } from './app/abilityDelegator' -import { AbilityDelegatorArgs } from './app/abilityDelegatorArgs' - -/** - * A global register used to store the AbilityDelegator and AbilityDelegatorArgs objects registered - * during application startup. - * 在应用程序启动期间,保存AbilityDelegator和AbilityDelegatorArgs对象的全局存储器 - * - * @since 8 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car - * @import import abilityManager from '@ohos.app.abilityManager' - * @permission N/A - */ -declare namespace abilityDelegatorRegistry { - /** - * Get the AbilityDelegator object of the application. - * 异步方式获取应用程序的AbilityDelegator对象 - * @return the AbilityDelegator object initialized when the application is started. - * 应用程序启动时被初始化的AbilityDelegator对象 - */ - function getAbilityDelegator(callback: AsyncCallback): void; - function getAbilityDelegator(): Promise; - - /** - * Get unit test parameters stored in the AbilityDelegatorArgs object. - * 异步的方式获取单元测试参数AbilityDelegatorArgs对象 - * @return the previously registered AbilityDelegatorArgs object. - * 单元测试参数AbilityDelegatorArgs对象 - */ - function getArguments(callback: AsyncCallback): void; - function getArguments(): Promise;​ - - /** - * Describes all lifecycle states of an ability. - */ - export enum AbilityLifecycleState { - CREATE, - FOREGROUND, - BACKGROUND, - DESTROY, - } -} - -export default abilityDelegatorRegistry; \ No newline at end of file diff --git a/api/app/abilityDelegator.d.ts b/api/app/abilityDelegator.d.ts deleted file mode 100644 index 2b5dc8426c..0000000000 --- a/api/app/abilityDelegator.d.ts +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AsyncCallback } from '../basic'; -import { Ability } from '../@ohos.application.Ability' -import { AbilityMonitor } from './abilityMonitor' -import { Context } from './context' -import { ShellCmdResult } from './shellCmdResult' -import { Want } from '../ability/want' - -/** - * A global test utility interface used for adding AbilityMonitor objects and control lifecycle states of abilities. - * - * @since 8 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car - * @import import AbilityDelegator from 'app/abilityDelegator.d' - * @permission N/A - */ -export interface AbilityDelegator { - /** - * Add an AbilityMonitor object for monitoring the lifecycle state changes of the specified ability. - * 添加AbilityMonitor实例,用于监听ability生命周期变换 - * @param monitor AbilityMonitor实例 - */ - addAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; - addAbilityMonitor​(monitor: AbilityMonitor): Promise; - - /** - * Remove a specified AbilityMonitor object from the application memory. - * 删除已经添加的AbilityMonitor实例 - * @param monitor AbilityMonitor实例 - */ - removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback): void;​ - removeAbilityMonitor(monitor: AbilityMonitor): Promise; - - /** - * Wait for and returns the Ability object that matches the conditions set in the given AbilityMonitor. - * 等待与AbilityMonitor实例匹配的ability到达OnCreate生命周期,并返回ability实例 - * @param monitor AbilityMonitor实例 - * @param timeout 最大等待时间,单位毫秒 - * @return 如果监听到与指定AbilityMonitor实例匹配的Abilityability到达OnCreate生命周期,则返回ability实例;否则返回空 - */ - waitAbilityMonitor​(monitor: AbilityMonitor, callback: AsyncCallback): void; - waitAbilityMonitor​(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback): void; - waitAbilityMonitor​(monitor: AbilityMonitor, timeout?: number): Promise; - - /** - * Obtain the application context. - * 异步方式获取应用Context,通过异步回调将Context实例返回 - * @return 应用Context - */ - getAppContext(callback: AsyncCallback): void; - getAppContext(): Promise; - - /** - * Obtain the lifecycle state of a specified ability. - * 异步方式获取指定ability状态 - * @param ability 指定Ability对象 - * @return 指定Ability对象的状态 - */ - getAbilityState(ability: Ability, callback: AsyncCallback): void; - getAbilityState(ability: Ability): Promise; - - /** - * Obtain the ability that is currently being displayed. - * 异步方式获取当前应用顶部ability - * @return 当前应用顶部ability - */ - getCurrentTopAbility(callback: AsyncCallback): void; - getCurrentTopAbility(): Promise - - /** - * Invoke the Ability.onForeground() callback of a specified ability without changing its lifecycle state. - * 异步方式调度指定ability生命周期状态到Foreground状态 - * @param ability 指定Ability对象 - * @return true: 成功 false: 失败 - */ - doAbilityForeground(ability: Ability, callback: AsyncCallback): void; - doAbilityForeground(ability: Ability): Promise; - - /** - * Invoke the Ability.onBackground() callback of a specified ability without changing its lifecycle state. - * 异步方式调度指定ability生命周期状态到Background状态 - * @param ability 指定Ability对象 - * @return true: 成功 false: 失败 - */ - doAbilityBackground(ability: Ability, callback: AsyncCallback): void; - doAbilityBackground(ability: Ability): Promise; - - /** - * Prints log information to the unit testing console. - * The total length of the log information to be printed cannot exceed 1000 characters. - * 异步方式打印日志信息到单元测试终端控制台 - * 日志信息字符串长度最大不超过1000个字符 - * @param msg 日志字符串 - */ - print(msg: string, callback: AsyncCallback): void; - print(msg: string): Promise; - - /** - * Execute the given command in the aa tools side. - * 异步方式执行指定的shell命令 - * @param cmd shell命令字符串 - * @return shell命令执行结果对象 - */ - executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback): void;​ - executeShellCommand(cmd: string, timeoutSecs: number): Promise;​ -} - -export default AbilityDelegator; \ No newline at end of file diff --git a/api/app/abilityDelegatorArgs.d.ts b/api/app/abilityDelegatorArgs.d.ts deleted file mode 100644 index 8b3476cfeb..0000000000 --- a/api/app/abilityDelegatorArgs.d.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -/** - * Store unit testing-related parameters, including test case names, and test runner name. - * 存储单元测试相关的参数,包括测试用例名称,测试用例执行器名称 - * - * @since 8 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car - * @import import AbilityDelegatorArgs from 'app/abilityDelegatorArgs.d' - * @permission N/A - */ -export interface AbilityDelegatorArgs { - /** - * the bundle name of the application being tested. - * 表示当前被测试应用的包名 - */ - bundleName: string; - - /** - * the parameters used for unit testing. - * 表示当前启动单元测试的参数 - */ - parameters​: {[key: string]: string}; - - /** - * the class names of all test cases. - * 测试用例名称 - */ - testCaseNames: string; - - /** - * the class name of the test runner used to execute test cases. - * 执行测试用例的测试执行器的名称 - */ - testRunnerClassName: string;​ -} - -export default AbilityDelegatorArgs; \ No newline at end of file diff --git a/api/app/abilityMonitor.d.ts b/api/app/abilityMonitor.d.ts deleted file mode 100644 index 15f68e434a..0000000000 --- a/api/app/abilityMonitor.d.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Provide methods for matching monitored Ability objects that meet specified conditions. - * The most recently matched Ability objects will be saved in the AbilityMonitor object. - * 监听指定Ability生命周期状态变化的监听器 - * - * @since 8 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car - * @import import AbilityMonitor from 'app/abilityMonitor.d' - * @permission N/A - */ -export interface AbilityMonitor { - /** - * The name of the ability to monitor. - * 表示当前AbilityMonitor绑定的ability name - */ - abilityName: string; - - /** - * Called back when the ability is started for initialization. - * ability被启动初始化时的回调函数 - */ - onAbilityCreate?:() => void; - - /** - * Called back when the state of the ability changes to foreground. - * ability状态变成前台时的回调函数 - */ - onAbilityForeground?:() => void; - - /** - * Called back when the state of the ability changes to background. - * ability状态变成后台时的回调函数 - */ - onAbilityBackground?:() => void; - - /** - * Called back before the ability is destroyed. - * ability被销毁前的回调函数 - */ - onAbilityDestroy?:() => void; - - /** - * Called back when an ability window stage is created. - * window stage被创建时的回调函数 - */ - onWindowStageCreate?:() => void; - - /** - * Called back when an ability window stage is restored. - * window stage被重载时的回调函数 - */ - onWindowStageRestore?:() => void; - - /** - * Called back when an ability window stage is destroyed. - * window stage被销毁前的回调函数 - */ - onWindowStageDestroy?:() => void; -} - -export default AbilityMonitor; \ No newline at end of file diff --git a/api/app/shellCmdResult.d.ts b/api/app/shellCmdResult.d.ts deleted file mode 100644 index d29515c95d..0000000000 --- a/api/app/shellCmdResult.d.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * A object that records the result of shell command executes. - * 执行shell命令的结果 - * - * @since 8 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car - * @import import ShellCmdResult from 'app/shellCmdResult.d' - * @permission N/A - */ -export interface ShellCmdResult { - /** - * the cmd standard result. - * shell命令标准输出结果 - */ - stdResult: String; - - /** - * shell cmd exec result. - * shell命令执行的结果 - */ - exitCode: number; -} - -export default ShellCmdResult; \ No newline at end of file diff --git a/api/app/testRunner.d.ts b/api/app/testRunner.d.ts deleted file mode 100644 index 30b3e1c83f..0000000000 --- a/api/app/testRunner.d.ts +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * Base class for the test framework. - * If you want to implement your own unit test framework, you must inherit this class and overrides all its methods. - * 测试框架的执行器基类 - * - * @since 8 - * @SysCap SystemCapability.Appexecfwk - * @devices phone, tablet, tv, wearable, car - * @import import TestRunner from 'app/testRunner.d' - * @permission N/A - */ -export interface TestRunner { - /** - * Prepare the unit testing environment for running test cases. - * 为执行器准备单元测试环境 - */ - onPrepare​(): void; - - /** - * Run all test cases. - * 运行所有的测试用例 - */ - onRun​(): void; -} - -export default TestRunner; \ No newline at end of file -- Gitee