• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# @ohos.application.abilityDelegatorRegistry (AbilityDelegatorRegistry)
2<!--deprecated_code_no_check-->
3
4The **AbilityDelegatorRegistry** module provides APIs for storing global registers of the registered [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) and [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) objects, including obtaining the **AbilityDelegator** and **AbilityDelegatorArgs** objects. The APIs can be used only in the test framework.
5
6> **NOTE**
7>
8> The APIs of this module are supported since API version 8 and deprecated since API version 9. You are advised to use [@ohos.app.ability.abilityDelegatorRegistry](js-apis-app-ability-abilityDelegatorRegistry.md) instead. Newly added APIs will be marked with a superscript to indicate their earliest API version.
9
10## Modules to Import
11
12```ts
13import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
14```
15
16## AbilityLifecycleState
17
18Enumerates the ability lifecycle states.
19
20**System capability**: SystemCapability.Ability.AbilityRuntime.Core
21
22| Name         | Value  | Description                       |
23| ------------- | ---- | --------------------------- |
24| UNINITIALIZED | 0    | The ability is in an invalid state.             |
25| CREATE        | 1    | The ability is created.|
26| FOREGROUND    | 2    | The ability is running in the foreground.  |
27| BACKGROUND    | 3    | The ability is running in the background.  |
28| DESTROY       | 4    | The ability is destroyed.|
29
30## abilityDelegatorRegistry.getAbilityDelegator
31
32getAbilityDelegator(): AbilityDelegator
33
34Obtains the **AbilityDelegator** object of the application.
35
36**System capability**: SystemCapability.Ability.AbilityRuntime.Core
37
38**Return value**
39
40| Type                                                        | Description                                                        |
41| ------------------------------------------------------------ | ------------------------------------------------------------ |
42| [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) | [AbilityDelegator](js-apis-inner-application-abilityDelegator.md) object, which can be used to schedule functions related to the test framework.|
43
44**Example**
45
46```ts
47import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
48
49let abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
50```
51
52## abilityDelegatorRegistry.getArguments
53
54getArguments(): AbilityDelegatorArgs
55
56Obtains the **AbilityDelegatorArgs** object of the application.
57
58**System capability**: SystemCapability.Ability.AbilityRuntime.Core
59
60**Return value**
61
62| Type                                                        | Description                                                        |
63| ------------------------------------------------------------ | ------------------------------------------------------------ |
64| [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) | [AbilityDelegatorArgs](js-apis-inner-application-abilityDelegatorArgs.md) object, which can be used to obtain test parameters.|
65
66**Example**
67
68```ts
69import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
70
71let args = AbilityDelegatorRegistry.getArguments();
72console.info(`getArguments bundleName: ${args.bundleName}`);
73console.info(`getArguments testCaseNames: ${args.testCaseNames}`);
74console.info(`getArguments testRunnerClassName: ${args.testRunnerClassName}`);
75```
76