diff --git a/ability/Delegator/README_en.md b/ability/Delegator/README_en.md
new file mode 100644
index 0000000000000000000000000000000000000000..9b59e41c0df50a4d29c02b0278095923fd23fc6d
--- /dev/null
+++ b/ability/Delegator/README_en.md
@@ -0,0 +1,19 @@
+# AbilityDelegator
+
+
+
+##### Introduction
+
+This sample shows how to use the AbilityDelegator to perform operations on the UI of an ability after the ability is developed. In addition, this sample enables test automation by handing over some click and observe operations to the AbilityDelegator.
+
+##### Usage
+
+The procedure for using this sample is as follows:
+
+1. Select an emulator \([instructions](https://developer.harmonyos.com/en/docs/documentation/doc-guides/run_simulator-0000001053303709)\) or connect to a real device \([instructions](https://developer.harmonyos.com/en/docs/documentation/doc-guides/run_phone_tablat-0000001064774652)\).
+2. Select the **MainAbilitySliceTest.java** file in the **ohosTest** directory and run the file.
+
+##### Constraints
+
+This sample can be run only on the standard system.
+
diff --git a/ability/Delegator/README_zh.md b/ability/Delegator/README_zh.md
new file mode 100644
index 0000000000000000000000000000000000000000..339d5b6e1f0e6e43c239c1354add76c1a79cfc29
--- /dev/null
+++ b/ability/Delegator/README_zh.md
@@ -0,0 +1,20 @@
+# Ability测试
+
+
+
+##### 简介
+
+本示例展示了开发者开发完Ability之后,如何通过AbilityDelegator工具,将对元能力界面的操作交给工具
+
+完成,从而实现测试自动化。
+
+##### 使用说明
+
+本示例的使用步骤:
+
+1. 在DevEco Studio配置并选择模拟器([配置链接](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/run_simulator-0000001053303709))或真机设备([配置链接](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/run_phone_tablat-0000001064774652))。
+2. 在DevEco Studio中选择ohosTest目录下的MainAbilitySliceTest.java文件,运行当前文件。
+
+##### 约束与限制
+
+本示例仅支持在标准系统上运行。
\ No newline at end of file
diff --git a/ability/Delegator/build.gradle b/ability/Delegator/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..cb3f5aa02471de2f2a13ca36f611ec70df7bc4e3
--- /dev/null
+++ b/ability/Delegator/build.gradle
@@ -0,0 +1,35 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+}
+buildscript {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.huawei.ohos:hap:2.4.4.2'
+ classpath 'com.huawei.ohos:decctest:1.2.4.0'
+ }
+}
+allprojects {
+ repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
+ }
+}
\ No newline at end of file
diff --git a/ability/Delegator/entry/build.gradle b/ability/Delegator/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..a63c8a42ea812df36c8f14ccbb7442741e499b58
--- /dev/null
+++ b/ability/Delegator/entry/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 4
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+
+}
+
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+}
+decc {
+ supportType = ['html', 'xml']
+}
diff --git a/ability/Delegator/entry/src/main/config.json b/ability/Delegator/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..70a4f9a50e99ca28041446a8748a343a61c0f839
--- /dev/null
+++ b/ability/Delegator/entry/src/main/config.json
@@ -0,0 +1,62 @@
+{
+ "app": {
+ "bundleName": "ohos.samples.delegator",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.samples.delegator",
+ "name": ".MyApplication",
+ "deviceType": [
+ "default"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "ohos.samples.delegator.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "ohos.samples.delegator.FirstAbility",
+ "icon": "$media:icon",
+ "description": "$string:firstability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "ohos.samples.delegator.SecondAbility",
+ "icon": "$media:icon",
+ "description": "$string:secondability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/FirstAbility.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/FirstAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..594ad94f77eb7afd11b1e2705586d938cf2d37ba
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/FirstAbility.java
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.samples.delegator.slice.FirstAbilitySlice;
+
+/**
+ * FirstAbility
+ *
+ * @since 2021-05-19
+ */
+public class FirstAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(FirstAbilitySlice.class.getName());
+ }
+
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/MainAbility.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..144a11fc17437728d63fb430dcd60c370066cbc3
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/MainAbility.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator;
+
+import ohos.samples.delegator.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+/**
+ * MainAbility
+ *
+ * @since 2021-05-19
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/MyApplication.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..4350c68caba167bcb0bc492530dcd28fef105f44
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/MyApplication.java
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * MyApplication
+ *
+ * @since 2021-05-19
+ */
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/SecondAbility.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/SecondAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..32aed30066f5d5db9a30e2cc6ac4dce5e17cff7d
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/SecondAbility.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.samples.delegator.slice.SecondAbilitySlice;
+
+/**
+ * SecondAbility
+ *
+ * @since 2021-05-19
+ */
+public class SecondAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(SecondAbilitySlice.class.getName());
+ }
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/FirstAbilitySlice.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/FirstAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..42c1362f27551a12337419beccfcdb0201cfddad
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/FirstAbilitySlice.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator.slice;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.samples.delegator.ResourceTable;
+
+/**
+ * FirstAbilitySlice
+ *
+ * @since 2021-05-19
+ */
+public class FirstAbilitySlice extends AbilitySlice {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_first);
+ Component setResult = findComponentById(ResourceTable.Id_button_first_to_main);
+ Component receivedTextComponent = findComponentById(ResourceTable.Id_text_main_to_first);
+ if (receivedTextComponent instanceof Text) {
+ Text receivedText = (Text) receivedTextComponent;
+ if (intent != null) {
+ String content = intent.getStringParam("First");
+ receivedText.setText(content);
+ }
+ }
+ setResult.setClickedListener(component -> {
+ terminateAbility();
+ });
+ }
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/MainAbilitySlice.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..d4bff2cb5f897464dc3c3a6b58d46f84aefdc779
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/MainAbilitySlice.java
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator.slice;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.agp.components.TextField;
+import ohos.bundle.ElementName;
+import ohos.samples.delegator.ResourceTable;
+
+import static ohos.samples.delegator.utils.Const.REQUEST_CODE;
+import static ohos.samples.delegator.utils.Const.RESULT_OK;
+
+/**
+ * MainAbilitySlice
+ *
+ * @since 2021-05-19
+ */
+public class MainAbilitySlice extends AbilitySlice {
+ private static final String BUNDLE_NAME = "ohos.samples.delegator";
+ private Button startAbility;
+ private Button startAbilityForResult;
+ private Text displayText;
+ private TextField editText;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+ initView();
+ initEventListener();
+ }
+
+ private void initView() {
+ Component startAbilityComment = findComponentById(ResourceTable.Id_button_startAbility);
+ if (startAbilityComment instanceof Button) {
+ startAbility = (Button) startAbilityComment;
+ }
+ Component startAbilityForResultComponent = findComponentById(ResourceTable.Id_button_startAbilityForResult);
+ if (startAbilityForResultComponent instanceof Button) {
+ startAbilityForResult = (Button) startAbilityForResultComponent;
+ }
+ Component displayTextComponent = findComponentById(ResourceTable.Id_text_displayText);
+ if (displayTextComponent instanceof Text) {
+ displayText = (Text) displayTextComponent;
+ }
+ Component editTextComment = findComponentById(ResourceTable.Id_text_editMain);
+ if (editTextComment instanceof TextField) {
+ editText = (TextField) editTextComment;
+ }
+ }
+
+ private void initEventListener() {
+ startAbility.setClickedListener(component -> {
+ ElementName elementNameFirst = new ElementName();
+ elementNameFirst.setBundleName(BUNDLE_NAME);
+ elementNameFirst.setAbilityName("FirstAbility");
+ Intent intentFirstAbility = new Intent();
+ intentFirstAbility.setElement(elementNameFirst);
+ intentFirstAbility.setParam("First", editText.getText());
+ startAbility(intentFirstAbility);
+
+ });
+ startAbilityForResult.setClickedListener(component -> {
+ ElementName elementNameSecond = new ElementName();
+ elementNameSecond.setBundleName(BUNDLE_NAME);
+ elementNameSecond.setAbilityName("SecondAbility");
+ Intent intentSecondAbility = new Intent();
+ intentSecondAbility.setElement(elementNameSecond);
+ intentSecondAbility.setParam("Second", editText.getText());
+ startAbilityForResult(intentSecondAbility, REQUEST_CODE);
+ });
+ }
+
+ @Override
+ protected void onAbilityResult(int requestCode, int resultCode, Intent resultData) {
+ if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
+ if (resultData != null) {
+ String response = resultData.getStringParam("Main");
+ displayText.setText(response);
+ }
+ }
+ }
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/SecondAbilitySlice.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/SecondAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..a51ad8977454e17ae7ee85c03a950202dac4c06e
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/slice/SecondAbilitySlice.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator.slice;
+
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.agp.components.TextField;
+import ohos.samples.delegator.ResourceTable;
+
+import static ohos.samples.delegator.utils.Const.RESULT_OK;
+
+/**
+ * SecondAbilitySlice
+ *
+ * @since 2021-05-19
+ */
+public class SecondAbilitySlice extends AbilitySlice {
+ private TextField resposeText;
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_second);
+ Component setResult = findComponentById(ResourceTable.Id_button_second_to_main);
+ Component receivedTextComponent = findComponentById(ResourceTable.Id_text_main_to_second);
+ if ( receivedTextComponent instanceof Text) {
+ Text receivedText = (Text) receivedTextComponent;
+ if (intent != null) {
+ String content = intent.getStringParam("Second");
+ receivedText.setText(content);
+ }
+ }
+ Component resposeTextComment = findComponentById(ResourceTable.Id_text_editSecond);
+ if (resposeTextComment instanceof TextField) {
+ resposeText = (TextField) resposeTextComment;
+ }
+ setResult.setClickedListener(component -> {
+ Intent response = new Intent();
+ String res = resposeText.getText();
+ response.setParam("Main", res);
+ getAbility().setResult(RESULT_OK, response);
+ terminateAbility();
+ });
+ }
+}
diff --git a/ability/Delegator/entry/src/main/java/ohos/samples/delegator/utils/Const.java b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/utils/Const.java
new file mode 100644
index 0000000000000000000000000000000000000000..95fc5daff0c1ddb9b7e970ce529ea8729f8686ab
--- /dev/null
+++ b/ability/Delegator/entry/src/main/java/ohos/samples/delegator/utils/Const.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator.utils;
+
+/**
+ * Const
+ *
+ * @since 2021-05-17
+ */
+public class Const {
+ /**
+ * Intent Request Code
+ */
+ public static final int REQUEST_CODE = 0;
+
+ /**
+ * Intent Result Code
+ */
+ public static final int RESULT_OK = 1;
+}
diff --git a/ability/Delegator/entry/src/main/resources/base/element/float.json b/ability/Delegator/entry/src/main/resources/base/element/float.json
new file mode 100644
index 0000000000000000000000000000000000000000..15faa133fc46e30b074f0fa7e03e9ebd91f7a55c
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/element/float.json
@@ -0,0 +1,20 @@
+{
+ "float": [
+ {
+ "name": "top_margin",
+ "value": "20vp"
+ },
+ {
+ "name": "text_size",
+ "value": "20fp"
+ },
+ {
+ "name": "right_padding",
+ "value": "15vp"
+ },
+ {
+ "name": "left_padding",
+ "value": "15vp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/element/string.json b/ability/Delegator/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..4750e8d777f07482b0590baa1a14a9b6da7d6caf
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,44 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "Delegator"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "firstability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "secondability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "hint_message",
+ "value": "Input Your Message"
+ },
+ {
+ "name": "start_ability",
+ "value": "startAbility"
+ },
+ {
+ "name": "start_ability_for_result",
+ "value": "startAbilityForResult"
+ },
+ {
+ "name": "set_result",
+ "value": "setResult"
+ },
+ {
+ "name": "first_text",
+ "value": "This is FirstAbilitySlice"
+ },
+ {
+ "name": "second_text",
+ "value": "This is SecondAbilitySlice"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_first.xml b/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_first.xml
new file mode 100644
index 0000000000000000000000000000000000000000..be1ba89ff3bad27ff85d87e66940e89a64a8192a
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_first.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_main.xml b/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1018ca3426c32c9d7ba832131e1ae9bd4f7ac2c6
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_second.xml b/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_second.xml
new file mode 100644
index 0000000000000000000000000000000000000000..be1ba89ff3bad27ff85d87e66940e89a64a8192a
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/graphic/background_ability_second.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/graphic/capsule_button_element.xml b/ability/Delegator/entry/src/main/resources/base/graphic/capsule_button_element.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6ab9d774ce6788352dbc6cf640822f5561bb663f
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/graphic/capsule_button_element.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/layout/ability_first.xml b/ability/Delegator/entry/src/main/resources/base/layout/ability_first.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d449fbb307b729ba8d53548208040e64ef9b6402
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/layout/ability_first.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/layout/ability_main.xml b/ability/Delegator/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d232c4b176860f240d9b7773b8863a5324c3d592
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/layout/ability_second.xml b/ability/Delegator/entry/src/main/resources/base/layout/ability_second.xml
new file mode 100644
index 0000000000000000000000000000000000000000..59cfe6de56250c49dbb7a4c9da2d83a222d721f7
--- /dev/null
+++ b/ability/Delegator/entry/src/main/resources/base/layout/ability_second.xml
@@ -0,0 +1,62 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/main/resources/base/media/icon.png b/ability/Delegator/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/ability/Delegator/entry/src/main/resources/base/media/icon.png differ
diff --git a/ability/Delegator/entry/src/ohosTest/config.json b/ability/Delegator/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..4a5372c678bd284605deac12821810b85059c50e
--- /dev/null
+++ b/ability/Delegator/entry/src/ohosTest/config.json
@@ -0,0 +1,35 @@
+{
+ "app": {
+ "bundleName": "ohos.samples.delegator",
+ "version": {
+ "code": 1000000,
+ "name": "1.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "ohos.samples.delegator",
+ "name": "testModule",
+ "deviceType": [
+ "default"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/ability/Delegator/entry/src/ohosTest/java/ohos/samples/delegator/slice/MainAbilitySliceTest.java b/ability/Delegator/entry/src/ohosTest/java/ohos/samples/delegator/slice/MainAbilitySliceTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..b1c9a8ba3a0bbefa1fd64b7aa828efd7f67051a3
--- /dev/null
+++ b/ability/Delegator/entry/src/ohosTest/java/ohos/samples/delegator/slice/MainAbilitySliceTest.java
@@ -0,0 +1,215 @@
+/*
+ * 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.
+ */
+
+package ohos.samples.delegator.slice;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import ohos.aafwk.ability.delegation.IAbilityDelegator;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Button;
+import ohos.agp.components.Component;
+import ohos.agp.components.Text;
+import ohos.agp.components.TextField;
+import ohos.bundle.ElementName;
+import ohos.samples.delegator.FirstAbility;
+import ohos.samples.delegator.MainAbility;
+import ohos.samples.delegator.ResourceTable;
+import ohos.samples.delegator.SecondAbility;
+
+/**
+ * MainAbilitySliceTest
+ *
+ * @since 2021-05-17
+ */
+public class MainAbilitySliceTest {
+ private static final String BUNDLE_NAME = "ohos.samples.delegator";
+
+ private static final String SEND_MESSAGE_MAIN = "I am from MainAbility.";
+
+ private static final String SEND_MESSAGE_SECOND = "I am from SecondAbility.";
+
+ private static IAbilityDelegator abilityDelegator;
+
+ private static Intent intentMainAbility = new Intent();
+
+ /**
+ * Global Variable Initialization
+ */
+ @BeforeClass
+ public static void setUp() {
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
+ ElementName elementNameMain = new ElementName();
+ elementNameMain.setBundleName(BUNDLE_NAME);
+ elementNameMain.setAbilityName("MainAbility");
+ intentMainAbility.setElement(elementNameMain);
+ }
+
+ /**
+ * Initialization State
+ */
+ @Before
+ public void jumpBack() {
+ abilityDelegator.startAbilitySync(intentMainAbility);
+ }
+
+ /**
+ * MainAbility StartAbility Test
+ */
+ @Test
+ public void startAbility() {
+ Ability mainAbility = abilityDelegator.getCurrentTopAbility();
+ String mainAbilityName = mainAbility.getAbilityName();
+ Assert.assertEquals(MainAbility.class.getSimpleName(), mainAbilityName);
+ Component editMainTextComponent = mainAbility.findComponentById(ResourceTable.Id_text_editMain);
+ if ( editMainTextComponent instanceof TextField) {
+ TextField editMainText = (TextField) editMainTextComponent;
+ Assert.assertNotNull("editMainText Text is null", editMainText);
+ abilityDelegator.runOnUIThreadSync(() -> {
+ editMainText.setText(SEND_MESSAGE_MAIN);
+ });
+ }
+ Component startAbilityComment = mainAbility.findComponentById(ResourceTable.Id_button_startAbility);
+ if (startAbilityComment instanceof Button) {
+ Button startAbility = (Button) startAbilityComment;
+ Assert.assertNotNull("startAbility button is null", startAbility);
+ boolean okStartAbility = abilityDelegator.triggerClickEvent(mainAbility, startAbility);
+ Assert.assertTrue("startAbility FirstAbility failed", okStartAbility);
+ }
+ // Wait Until The FirstAbility Startup Is Complete
+ synchronized (abilityDelegator) {
+ try {
+ abilityDelegator.wait(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ toFirstAbility();
+ }
+
+ private void toFirstAbility() {
+ Ability firstAbility = abilityDelegator.getCurrentTopAbility();
+ String firstAbilityName = firstAbility.getAbilityName();
+ Assert.assertEquals(FirstAbility.class.getSimpleName(), firstAbilityName);
+ Component firstTextComponent = firstAbility.findComponentById(ResourceTable.Id_text_main_to_first);
+ if (firstTextComponent instanceof Text) {
+ Text firstText = (Text) firstTextComponent;
+ Assert.assertNotNull("toFirstText Text is null", firstText);
+ Assert.assertEquals(SEND_MESSAGE_MAIN, firstText.getText());
+ }
+ Component setResultComponent = firstAbility.findComponentById(ResourceTable.Id_button_first_to_main);
+ if (setResultComponent instanceof Button) {
+ Button setResult = (Button) setResultComponent;
+ Assert.assertNotNull("setResult button is null", setResult);
+ boolean okReturnAbility = abilityDelegator.triggerClickEvent(firstAbility, setResult);
+ Assert.assertTrue("returnAbility MainAbility failed", okReturnAbility);
+ }
+ // Waiting For FirstAbility To Return Completion
+ synchronized (abilityDelegator) {
+ try {
+ abilityDelegator.wait(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ Ability mainAbility = abilityDelegator.getCurrentTopAbility();
+ String mainAbilityName = mainAbility.getAbilityName();
+ Assert.assertEquals(MainAbility.class.getSimpleName(), mainAbilityName);
+ }
+
+ /**
+ * MainAbility StartAbilityForResult Test
+ */
+ @Test
+ public void startAbilityForResult() {
+ Ability mainAbility = abilityDelegator.getCurrentTopAbility();
+ String mainAbilityName = mainAbility.getAbilityName();
+ Assert.assertEquals(MainAbility.class.getSimpleName(), mainAbilityName);
+ Component editMainTextComponent = mainAbility.findComponentById(ResourceTable.Id_text_editMain);
+ if ( editMainTextComponent instanceof TextField) {
+ TextField editMainText = (TextField) editMainTextComponent;
+ Assert.assertNotNull("editMainText Text is null", editMainText);
+ abilityDelegator.runOnUIThreadSync(() -> {
+ editMainText.setText(SEND_MESSAGE_MAIN);
+ });
+ }
+ Component startAbilityForResultComment =
+ mainAbility.findComponentById(ResourceTable.Id_button_startAbilityForResult);
+ if (startAbilityForResultComment instanceof Button) {
+ Button startAbilityForResult = (Button) startAbilityForResultComment;
+ Assert.assertNotNull("startAbilityForResult button is null", startAbilityForResult);
+ boolean okStartAbilityForResult = abilityDelegator.triggerClickEvent(mainAbility, startAbilityForResult);
+ Assert.assertTrue("startAbilityForResult SecondAbility failed", okStartAbilityForResult);
+ }
+ // Wait Until The SecondAbility Startup Is Complete
+ synchronized (abilityDelegator) {
+ try {
+ abilityDelegator.wait(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ toSecondAbility();
+ }
+
+ private void toSecondAbility() {
+ Ability secondAbility = abilityDelegator.getCurrentTopAbility();
+ String secondAbilityName = secondAbility.getAbilityName();
+ Assert.assertEquals(SecondAbility.class.getSimpleName(), secondAbilityName);
+ Component secondTextComponent = secondAbility.findComponentById(ResourceTable.Id_text_main_to_second);
+ if (secondTextComponent instanceof Text) {
+ Text secondText = (Text) secondTextComponent;
+ Assert.assertNotNull("toSecondText Text is null", secondText);
+ Assert.assertEquals(SEND_MESSAGE_MAIN, secondText.getText());
+ }
+ Component editSecondTextComponent = secondAbility.findComponentById(ResourceTable.Id_text_editSecond);
+ if (editSecondTextComponent instanceof TextField) {
+ TextField editSecondText = (TextField) editSecondTextComponent;
+ Assert.assertNotNull("editSecondText Text is null", editSecondText);
+ abilityDelegator.runOnUIThreadSync(() -> {
+ editSecondText.setText(SEND_MESSAGE_SECOND);
+ });
+ }
+ Component setResultComponent = secondAbility.findComponentById(ResourceTable.Id_button_second_to_main);
+ if (setResultComponent instanceof Button) {
+ Button setResult = (Button) setResultComponent;
+ Assert.assertNotNull("setResult button is null", setResult);
+ boolean okReturnAbility = abilityDelegator.triggerClickEvent(secondAbility, setResult);
+ Assert.assertTrue("returnAbility MainAbility failed", okReturnAbility);
+ }
+ // Waiting For SecondAbility To Return Completion
+ synchronized (abilityDelegator) {
+ try {
+ abilityDelegator.wait(2000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+ Ability mainAbility = abilityDelegator.getCurrentTopAbility();
+ String mainAbilityName = mainAbility.getAbilityName();
+ Assert.assertEquals(MainAbility.class.getSimpleName(), mainAbilityName);
+ Component mainTextComponent = mainAbility.findComponentById(ResourceTable.Id_text_displayText);
+ if (mainTextComponent instanceof Text) {
+ Text mainText = (Text) mainTextComponent;
+ Assert.assertNotNull("mainText Text is null", mainText);
+ Assert.assertEquals(SEND_MESSAGE_SECOND, mainText.getText());
+ }
+ }
+}
\ No newline at end of file
diff --git a/ability/Delegator/screenshots/device/MainAbility.png b/ability/Delegator/screenshots/device/MainAbility.png
new file mode 100644
index 0000000000000000000000000000000000000000..382233e7a087a5dd1f4f459013d5e49ddc0e3249
Binary files /dev/null and b/ability/Delegator/screenshots/device/MainAbility.png differ
diff --git a/ability/Delegator/settings.gradle b/ability/Delegator/settings.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..7dc3285c045cc590e49d231a4280ef52ba646d91
--- /dev/null
+++ b/ability/Delegator/settings.gradle
@@ -0,0 +1,15 @@
+/*
+ * 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.
+ */
+include ':entry'