Update d.ts

Signed-off-by: hanhaibin <hanhaibin@huawei.com>
This commit is contained in:
hanhaibin 2022-01-19 22:38:46 +08:00
parent 2030a97122
commit cd6a8d812d
6 changed files with 394 additions and 0 deletions

View File

@ -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<AbilityDelegator>): void;
function getAbilityDelegator(): Promise<AbilityDelegator>;
/**
* Get unit test parameters stored in the AbilityDelegatorArgs object.
* AbilityDelegatorArgs对象
* @return the previously registered AbilityDelegatorArgs object.
* AbilityDelegatorArgs对象
*/
function getArguments(callback: AsyncCallback<AbilityDelegatorArgs>): void;
function getArguments(): Promise<AbilityDelegatorArgs>;
/**
* Describes all lifecycle states of an ability.
*/
export enum AbilityLifecycleState {
CREATE,
FOREGROUND,
BACKGROUND,
DESTROY,
}
}
export default abilityDelegatorRegistry;

41
api/@ohos.application.testRunner.d.ts vendored Normal file
View File

@ -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;

122
api/application/abilityDelegator.d.ts vendored Normal file
View File

@ -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>): void;
addAbilityMonitor(monitor: AbilityMonitor): Promise<void>;
/**
* Remove a specified AbilityMonitor object from the application memory.
* AbilityMonitor实例
* @param monitor AbilityMonitor实例
*/
removeAbilityMonitor(monitor: AbilityMonitor, callback: AsyncCallback<void>): void;
removeAbilityMonitor(monitor: AbilityMonitor): Promise<void>;
/**
* 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<Ability>): void;
waitAbilityMonitor(monitor: AbilityMonitor, timeout: number, callback: AsyncCallback<Ability>): void;
waitAbilityMonitor(monitor: AbilityMonitor, timeout?: number): Promise<Ability>;
/**
* Obtain the application context.
* ContextContext实例返回
* @return Context
*/
getAppContext(callback: AsyncCallback<Context>): void;
getAppContext(): Promise<Context>;
/**
* Obtain the lifecycle state of a specified ability.
* ability状态
* @param ability Ability对象
* @return Ability对象的状态
*/
getAbilityState(ability: Ability, callback: AsyncCallback<number>): void;
getAbilityState(ability: Ability): Promise<number>;
/**
* Obtain the ability that is currently being displayed.
* ability
* @return ability
*/
getCurrentTopAbility(callback: AsyncCallback<Ability>): void;
getCurrentTopAbility(): Promise<Ability>
/**
* 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<boolean>): void;
doAbilityForeground(ability: Ability): Promise<boolean>;
/**
* 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<boolean>): void;
doAbilityBackground(ability: Ability): Promise<boolean>;
/**
* 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>): void;
print(msg: string): Promise<void>;
/**
* Execute the given command in the aa tools side.
* shell命令
* @param cmd shell命令字符串
* @return shell命令执行结果对象
*/
executeShellCommand(cmd: string, timeoutSecs: number, callback: AsyncCallback<ShellCmdResult>): void;
executeShellCommand(cmd: string, timeoutSecs: number): Promise<ShellCmdResult>;
}
export default AbilityDelegator;

View File

@ -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;

77
api/application/abilityMonitor.d.ts vendored Normal file
View File

@ -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;

40
api/application/shellCmdResult.d.ts vendored Normal file
View File

@ -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;