diff --git a/en/application-dev/notification/common-event.md b/en/application-dev/notification/common-event.md
index 8ea3eaa2d6b2f450f28660ca9f50ad3b99947c8b..f46e565f2a9d203a056e6f9ceed055b81e8dcf08 100644
--- a/en/application-dev/notification/common-event.md
+++ b/en/application-dev/notification/common-event.md
@@ -13,7 +13,7 @@ Each application can subscribe to common events as required. After your applicat
## Common Event Subscription Development
### When to Use
-You can create a subscriber object to subscribe to a common event to obtain the parameters passed in the event. Certain system common events require specific permissions to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEvent.md).
+You can create a subscriber object to subscribe to a common event to obtain the parameters passed in the event. Certain system common events require specific permissions to subscribe to. For details, see [Required Permissions](../reference/apis/js-apis-commonEvent.md#required-permissions).
### Available APIs
| API | Description|
@@ -25,13 +25,13 @@ You can create a subscriber object to subscribe to a common event to obtain the
### How to Develop
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent';
```
2. Create a **subscribeInfo** object. For details about the data types and parameters of the object, see [CommonEventSubscribeInfo](../reference/apis/js-apis-commonEvent.md#commoneventsubscribeinfo).
-```javascript
+```js
private subscriber = null // Used to save the created subscriber object for subsequent subscription and unsubscription.
// Subscriber information
@@ -42,7 +42,7 @@ var subscribeInfo = {
3. Create a subscriber object and save the returned object for subsequent operations such as subscription and unsubscription.
-```javascript
+```js
// Callback for subscriber creation.
commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => {
if (err.code) {
@@ -57,7 +57,7 @@ commonEvent.createSubscriber(subscribeInfo, (err, subscriber) => {
4. Create a subscription callback, which is triggered when an event is received. The data returned by the subscription callback contains information such as the common event name and data carried by the publisher. For details about the data types and parameters of the common event data, see [CommonEventData](../reference/apis/js-apis-commonEvent.md#commoneventdata).
-```javascript
+```js
// Callback for common event subscription.
if (this.subscriber != null) {
commonEvent.subscribe(this.subscriber, (err, data) => {
@@ -74,7 +74,7 @@ if (this.subscriber != null) {
}
```
-## Public Event Publishing Development
+## Common Event Publishing Development
### When to Use
You can use the **publish** APIs to publish a custom common event, which can carry data for subscribers to parse and process.
@@ -89,13 +89,13 @@ You can use the **publish** APIs to publish a custom common event, which can car
#### Development for Publishing a Common Event
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent';
```
2. Pass in the common event name and callback, and publish the event.
-```javascript
+```js
// Publish a common event.
commonEvent.publish("event", (err) => {
if (err.code) {
@@ -109,13 +109,13 @@ commonEvent.publish("event", (err) => {
#### Development for Publishing a Common Event with Given Attributes
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent'
```
2. Define attributes of the common event to publish. For details about the data types and parameters in the data to publish, see [CommonEventPublishData](../reference/apis/js-apis-commonEvent.md#commoneventpublishdata).
-```javascript
+```js
// Attributes of a common event.
var options = {
code: 1, // Result code of the common event
@@ -125,7 +125,7 @@ var options = {
3. Pass in the common event name, attributes of the common event, and callback, and publish the event.
-```javascript
+```js
// Publish a common event.
commonEvent.publish("event", options, (err) => {
if (err.code) {
@@ -149,14 +149,14 @@ You can use the **unsubscribe** API to unsubscribe from a common event.
### How to Develop
1. Import the **commonEvent** module.
-```javascript
+```js
import commonEvent from '@ohos.commonEvent';
```
2. Subscribe to a common event by following instructions in [Common Event Subscription Development](#Common-Event-Subscription-Development).
3. Invoke the **unsubscribe** API in **CommonEvent** to unsubscribe from the common event.
-```javascript
+```js
if (this.subscriber != null) {
commonEvent.unsubscribe(this.subscriber, (err) => {
if (err.code) {
diff --git a/en/application-dev/quick-start/figures/image-20220326064841782.png b/en/application-dev/quick-start/figures/image-20220326064841782.png
index 57ee1a1ca5a7e62893195a296795ffb8eec00bdc..a7811ffe339baceffbfff66f2173b2e5e29a6fc1 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326064841782.png and b/en/application-dev/quick-start/figures/image-20220326064841782.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326064913834.png b/en/application-dev/quick-start/figures/image-20220326064913834.png
index c55df52abc42e8f9a4d0a9d5fc098aa3a3456a0e..9bb845a90c3b80db95c736cc84d2434537cf8522 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326064913834.png and b/en/application-dev/quick-start/figures/image-20220326064913834.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326064955505.png b/en/application-dev/quick-start/figures/image-20220326064955505.png
index db4f6fa370cd5c02b3d2cd98b187e324848e8d99..89a43655a064971b721a5aee4222d7c2d37c9523 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326064955505.png and b/en/application-dev/quick-start/figures/image-20220326064955505.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326065043006.png b/en/application-dev/quick-start/figures/image-20220326065043006.png
index 997acad905475baa43f0debf936508efdcfa2c5f..c8b11931993c83e507dbf7150a5be740430ae42f 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326065043006.png and b/en/application-dev/quick-start/figures/image-20220326065043006.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326065124911.png b/en/application-dev/quick-start/figures/image-20220326065124911.png
index a028e5447476a9d03bcd58285af6fb6dd4aa7d1d..858a8af31bc83367fc4c2f696d0f69e58b36b216 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326065124911.png and b/en/application-dev/quick-start/figures/image-20220326065124911.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326065201867.png b/en/application-dev/quick-start/figures/image-20220326065201867.png
index 5c3b428823d5f044a2857e641ac2465beff39114..e447e34c0a80c472cb2dfd684e1822866b4134d8 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326065201867.png and b/en/application-dev/quick-start/figures/image-20220326065201867.png differ
diff --git a/en/application-dev/quick-start/figures/image-20220326072448840.png b/en/application-dev/quick-start/figures/image-20220326072448840.png
index dac0f9dfe41d8f7667e21f2224563910e3aa9429..861ef6a871ce38d28a1144722ff4d0d327a8bc84 100644
Binary files a/en/application-dev/quick-start/figures/image-20220326072448840.png and b/en/application-dev/quick-start/figures/image-20220326072448840.png differ
diff --git a/en/application-dev/quick-start/syscap.md b/en/application-dev/quick-start/syscap.md
index 41ce7f114359edae353b6fd0783cf55aab8a2adb..e74c958c4df493bd5084ad477b95f78c7893cd48 100644
--- a/en/application-dev/quick-start/syscap.md
+++ b/en/application-dev/quick-start/syscap.md
@@ -4,26 +4,26 @@
### System Capabilities and APIs
-SysCap is short for System Capability. It refers to a standalone feature in the operating system, for example, Bluetooth, Wi-Fi, NFC, or camera. Each system capability corresponds to a set of bound APIs, whose availability depends on the support of the target device. Such a set of APIs can be provided in the IDE for association.
+SysCap is short for System Capability. It refers to a standalone feature in the operating system, for example, Bluetooth, Wi-Fi, NFC, or camera. Each SysCap corresponds to a set of bound APIs, whose availability depends on the support of the target device. Such a set of APIs are provided in DevEco Studio for association.

-### Supported Capability Set, Associated Capability Set, and Required Capability Set
+### Supported SysCap Set, Associated SysCap Set, and Required SysCap Set
-The supported capability set, associated capability set, and required capability set are collections of system capabilities.
-The supported capability set covers the device capabilities, and the required capability set covers the application capabilities. If the capability set required by application A is a subset of the capability set supported by device N, application A can be distributed to device N for installation and running. Otherwise, application A cannot be distributed.
-The associated capability set covers the system capabilities of associated APIs that the IDE offers during application development.
+The supported SysCap set, associated SysCap set, and required SysCap set are collections of SysCaps.
+The supported SysCap set covers the device capabilities, and the required SysCap set covers the application capabilities. If the SysCap set required by application A is a subset of the SysCap set supported by device N, application A can be distributed to device N for installation and running. Otherwise, application A cannot be distributed.
+The associated SysCap set covers the system capabilities of associated APIs that the IDE offers during application development.

-### Devices and Supported Capability Sets
+### Devices and Supported SysCap Sets
-Each device provides a capability set that matches its hardware capability.
-The SDK classifies devices into general devices and custom devices. The general devices' supported capability set is defined by OpenHarmony, and the custom devices' is defined by device vendors.
+Each device provides a SysCap set that matches its hardware capability.
+The SDK classifies devices into general devices and custom devices. The general devices' supported SysCap set is defined by OpenHarmony, and the custom devices' is defined by device vendors.

@@ -31,7 +31,7 @@ The SDK classifies devices into general devices and custom devices. The general
### Mapping Between Devices and SDK Capabilities
-The SDK provides a full set of APIs for the IDE. The IDE identifies the supported capability set based on the devices supported by the project, filters the APIs contained in the capability set, and provides the supported APIs for association (to autocomplete input).
+The SDK provides a full set of APIs for the IDE. DevEco Studio identifies the supported SysCap set based on the devices supported by the project, filters the APIs contained in the SysCap set, and provides the supported APIs for association (to autocomplete input).

@@ -49,11 +49,11 @@ Right-click the project directory and choose **Import Product Compatibility ID**
-### Configuring the Associated Capability Set and Required Capability Set
+### Configuring the Associated SysCap Set and Required SysCap Set
-The IDE automatically configures the associated capability set and required capability set based on the settings supported by the created project. You can modify the capability sets when necessary.
-You can add APIs to the associated capability set in the IDE by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them.
-Exercise caution when modifying the required capability set. Incorrect modifications may cause the application to unable to be distributed to the target device.
+DevEco Studio automatically configures the associated SysCap set and required SysCap set based on the settings supported by the created project. You can modify these SysCap sets when necessary.
+You can add APIs to the associated SysCap set in DevEco Studio by adding system capabilities. However, note that these APIs may not be supported on the device. Therefore, check whether these APIs are supported before using them.
+Exercise caution when modifying the required SysCap set. Incorrect modifications may result in the application being unable to be distributed to the target device.
```
/* syscap.json */
@@ -74,15 +74,15 @@ Exercise caution when modifying the required capability set. Incorrect modificat
...
]
},
- development: { /* The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the associated capability set. */
+ development: { /* The SysCap set in addedSysCaps and the SysCap set supported by each device configured in devices form the associated SysCap set. */
addedSysCaps: [
"SystemCapability.Location.Location.Lite",
...
]
},
production: { /* Used to generate the RPCID. Exercise caution when adding this parameter. Under incorrect settings, applications may fail to be distributed to target devices. */
- addedSysCaps: [], // Intersection of SysCap sets supported by devices configured in devices. It is the required capability set with addedSysCaps set and removedSysCaps set.
- removedSysCaps: [] // When the required capability set is a capability subset of a device, the application can be distributed to the device.
+ addedSysCaps: [], // Intersection of SysCap sets supported by devices configured in devices. It is the required SysCap set with addedSysCaps set and removedSysCaps set.
+ removedSysCaps: [] // When the required SysCap set is a capability subset of a device, the application can be distributed to the device.
}
}
```
@@ -91,7 +91,7 @@ Exercise caution when modifying the required capability set. Incorrect modificat
### Single-Device Application Development
-By default, the association capability set and required system capability set of the application are the same as the supported system capability set of the device. Exercise caution when modifying the required capability set.
+By default, the associated SysCap set and required SysCap set of the application are the same as the supported SysCap set of the device. Exercise caution when modifying the required SysCap set.

@@ -99,7 +99,7 @@ By default, the association capability set and required system capability set of
### Cross-Device Application Development
-By default, the associated capability set of the application is the union of multiple devices' supported capability sets. The capability sets must be the intersection.
+By default, the associated SysCap set of an application is the union of multiple devices' supported SysCap sets, while the required SysCap set is the intersection of the devices' supported SysCap sets.

@@ -133,9 +133,9 @@ if (geolocation) {
-### Checking the Differences Between Devices with the Same Capability
+### Checking the Differences Between Devices with a Specific SysCap
-The performance of a system capability may vary by device type. For example, a tablet is superior to a smart wearable device in terms of the camera capability.
+The performance of a SysCap may vary by device type. For example, a tablet is superior to a smart wearable device in terms of the camera capability.
```
import userAuth from '@ohos.userIAM.userAuth';
@@ -158,11 +158,11 @@ authenticator.execute('FACE_ONLY', 'S1', (err, result) => {
### How Do SysCap Differences Arise Between Devices
-The SysCap of devices varies according to the component combination defined by the product solution vendor. The following figure shows the overall process.
+The device SysCaps in product solutions vary according to the component combination defined by the product solution vendor. The following figure shows the overall process.

-1. A set of OpenHarmony source code consists of optional and mandatory components. Different components have different system capabilities. In other words, different components represent different SysCaps.
+1. A set of OpenHarmony source code consists of optional and mandatory components. Different components represent different SysCaps.
2. In a normalized released SDK, APIs are mapped to SysCap sets.
@@ -170,10 +170,10 @@ The SysCap of devices varies according to the component combination defined by t
4. The components configured for a product can be OpenHarmony components or proprietary components developed by a third party. Since there is mapping between components and SysCap, the SysCap set of the product can be obtained after all components are assembled.
-5. The SysCap set is encoded to generate the PCID. You can import the PCID to the IDE and decode it into SysCap. During development, compatibility processing is performed to mitigate the SysCap differences of devices.
+5. The SysCap set is encoded to generate the PCID. You can import the PCID to DevEco Studio and decode it into SysCaps. During development, compatibility processing is performed to mitigate the SysCap differences of devices.
-6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications to check whether a SysCap set is available.
+6. System parameters deployed on devices contain the SysCap set. The system provides native interfaces and application interfaces for components and applications to check whether a specific SysCap is available.
-7. During application development, the SysCap required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap required by the application and compares it with the SysCap of the device. If the SysCap required by the application is met, the application can be installed.
+7. During application development, the SysCap set required by the application is encoded into the Required Product Compatibility ID (RPCID) and written into the application installation package. During application installation, the package manager decodes the RPCID to obtain the SysCap set required by the application and compares it with the SysCap set supported by the device. If the SysCap set required by the application is met, the application can be installed on the device.
-8. When an application is running, the **canIUse** API can be used to query whether the SysCap is compatible with the device.
+8. When an application is running on a device, the **canIUse** API can be used to query whether the device is compatible with a specific SysCap.
diff --git a/en/application-dev/reference/apis/js-apis-request.md b/en/application-dev/reference/apis/js-apis-request.md
index 0a4b8c5ac6d2570ba34b5567322fef99e6b8bb1f..fec9be3f8e6b9e7cf42f741f357710c99650c2c3 100644
--- a/en/application-dev/reference/apis/js-apis-request.md
+++ b/en/application-dev/reference/apis/js-apis-request.md
@@ -1,8 +1,7 @@
# Upload and Download
->  **NOTE** The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
->
+> **NOTE** The initial APIs of this module are supported since API version 6. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -15,23 +14,23 @@ import request from '@ohos.request';
## Constraints
-- HTTPS is supported by default. To support HTTP, you need to add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**.
-
- ```
- "deviceConfig": {
- "default": {
- "network": {
- "cleartextTraffic": true
- }
- ...
+HTTPS is supported by default. To support HTTP, you need to add **network** to the **config.json** file and set the **cleartextTraffic** attribute to **true**.
+
+```
+ "deviceConfig": {
+ "default": {
+ "network": {
+ "cleartextTraffic": true
}
+ ...
}
- ```
+ }
+```
## Constants
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -65,7 +64,7 @@ upload(config: UploadConfig): Promise<UploadTask>
Uploads files. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -84,11 +83,13 @@ Uploads files. This API uses a promise to return the result.
**Example**
```js
-request.upload({ url: 'https://patch' }).then((data) => {
- uploadTask = data;
-}).catch((err) => {
- console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
-})
+ let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
+ let uploadTask;
+ request.upload({ url: 'https://patch', files: [file1] }).then((data) => {
+ uploadTask = data;
+ }).catch((err) => {
+ console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
+ })
```
@@ -98,7 +99,7 @@ upload(config: UploadConfig, callback: AsyncCallback<UploadTask>): void
Uploads files. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -112,19 +113,21 @@ Uploads files. This API uses an asynchronous callback to return the result.
**Example**
```js
-request.upload({ url: 'https://patch' }, (err, data) => {
- if (err) {
- console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
- return;
- }
- uploadTask = data;
-});
+ let file1 = { filename: "test", name: "test", uri: "internal://cache/test.jpg", type: "jpg" };
+ let uploadTask;
+ request.upload({ url: 'https://patch', files: [file1] }, (err, data) => {
+ if (err) {
+ console.error('Failed to request the upload. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ uploadTask = data;
+ });
```
## UploadTask
-Implements file uploads. Before using a method of this class, you must obtain an **UploadTask** object.
+Implements file uploads. Before using any APIs of this class, you must obtain an **UploadTask** object.
### on('progress')
@@ -133,7 +136,7 @@ on(type: 'progress', callback:(uploadedSize: number, totalSize: number) => vo
Subscribes to the upload progress event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -154,10 +157,10 @@ Parameters of the callback function
**Example**
```js
-uploadTask.on('progress', function callback(uploadedSize, totalSize) {
- console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
-}
-);
+ uploadTask.on('progress', function callback(uploadedSize, totalSize) {
+ console.info("upload totalSize:" + totalSize + " uploadedSize:" + uploadedSize);
+ }
+ );
```
@@ -167,7 +170,7 @@ on(type: 'headerReceive', callback: (header: object) => void): void
Subscribes to the **headerReceive** event, which is triggered when an HTTP response header is received. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -187,10 +190,10 @@ Parameters of the callback function
**Example**
```js
-uploadTask.on('headerReceive', function callback(headers){
- console.info("upOnHeader headers:" + JSON.stringify(headers));
-}
-);
+ uploadTask.on('headerReceive', function callback(headers){
+ console.info("upOnHeader headers:" + JSON.stringify(headers));
+ }
+ );
```
@@ -200,7 +203,7 @@ off(type: 'progress', callback?: (uploadedSize: number, totalSize: number) =&g
Unsubscribes from the upload progress event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -221,10 +224,10 @@ Parameters of the callback function
**Example**
```js
-uploadTask.off('progress', function callback(uploadedSize, totalSize) {
- console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
-}
-);
+ uploadTask.off('progress', function callback(uploadedSize, totalSize) {
+ console.info('uploadedSize: ' + uploadedSize, 'totalSize: ' + totalSize);
+ }
+ );
```
@@ -234,7 +237,7 @@ off(type: 'headerReceive', callback?: (header: object) => void): void
Unsubscribes from the **headerReceive** event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -254,10 +257,10 @@ Parameters of the callback function
**Example**
```js
-uploadTask.off('headerReceive', function callback(headers) {
- console.info("upOnHeader headers:" + JSON.stringify(headers));
-}
-);
+ uploadTask.off('headerReceive', function callback(headers) {
+ console.info("upOnHeader headers:" + JSON.stringify(headers));
+ }
+ );
```
@@ -267,7 +270,7 @@ remove(): Promise<boolean>
Removes this upload task. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -280,15 +283,15 @@ Removes this upload task. This API uses a promise to return the result.
**Example**
```js
-uploadTask.remove().then((result) => {
- if (result) {
- console.info('Upload task removed successfully. ');
- } else {
- console.error('Failed to remove the upload task. ');
- }
-}).catch((err) => {
- console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
-});
+ uploadTask.remove().then((result) => {
+ if (result) {
+ console.info('Upload task removed successfully. ');
+ } else {
+ console.error('Failed to remove the upload task. ');
+ }
+ }).catch((err) => {
+ console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
+ });
```
@@ -298,7 +301,7 @@ remove(callback: AsyncCallback<boolean>): void
Removes this upload task. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Upload
@@ -311,17 +314,17 @@ Removes this upload task. This API uses an asynchronous callback to return the r
**Example**
```js
-uploadTask.remove((err, result) => {
- if (err) {
- console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
- return;
- }
- if (result) {
- console.info('Upload task removed successfully.');
- } else {
- console.error('Failed to remove the upload task.');
- }
-});
+ uploadTask.remove((err, result) => {
+ if (err) {
+ console.error('Failed to remove the upload task. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ if (result) {
+ console.info('Upload task removed successfully.');
+ } else {
+ console.error('Failed to remove the upload task.');
+ }
+ });
```
@@ -366,7 +369,7 @@ download(config: DownloadConfig): Promise<DownloadTask>
Downloads files. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -384,13 +387,14 @@ Downloads files. This API uses a promise to return the result.
**Example**
-```js
-request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
- downloadTask = data;
-}).catch((err) => {
- console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
-})
-```
+ ```js
+ let downloadTask;
+ request.download({ url: 'https://xxxx/xxxx.hap' }).then((data) => {
+ downloadTask = data;
+ }).catch((err) => {
+ console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
+ })
+ ```
## request.download
@@ -399,7 +403,7 @@ download(config: DownloadConfig, callback: AsyncCallback<DownloadTask>): v
Downloads files. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -413,14 +417,15 @@ Downloads files. This API uses an asynchronous callback to return the result.
**Example**
```js
-request.download({ url: 'https://xxxx/xxxxx.hap',
-filePath: 'xxx/xxxxx.hap'}, (err, data) => {
- if (err) {
- console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
- return;
- }
- downloadTask = data;
-});
+ let downloadTask;
+ request.download({ url: 'https://xxxx/xxxxx.hap',
+ filePath: 'xxx/xxxxx.hap'}, (err, data) => {
+ if (err) {
+ console.error('Failed to request the download. Cause: ' + JSON.stringify(err));
+ return;
+ }
+ downloadTask = data;
+ });
```
@@ -435,7 +440,7 @@ on(type: 'progress', callback:(receivedSize: number, totalSize: number) => vo
Subscribes to the download progress event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -456,12 +461,6 @@ Parameters of the callback function
**Example**
```js
- request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask = data;
downloadTask.on('progress', function download_callback(receivedSize, totalSize) {
console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
}
@@ -476,7 +475,7 @@ off(type: 'progress', callback?: (receivedSize: number, totalSize: number) =>
Unsubscribes from the download progress event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -497,17 +496,11 @@ Parameters of the callback function
**Example**
```js
-request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask = data;
- downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
- console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
- }
-);
-});
+ downloadTask .off('progress', function download_callback(receivedSize, totalSize) {
+ console.info("download receivedSize:" + receivedSize + " totalSize:" + totalSize);
+ }
+ );
+ });
```
@@ -517,7 +510,7 @@ on(type: 'complete'|'pause'|'remove', callback:() => void): void
Subscribes to a download event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -531,17 +524,11 @@ Subscribes to a download event. This API uses an asynchronous callback to return
**Example**
```js
-request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask= data;
- downloadTask.on('complete', function callback() {
- console.info('Download task completed.');
- }
-);
-});
+ downloadTask.on('complete', function callback() {
+ console.info('Download task completed.');
+ }
+ );
+ });
```
@@ -551,7 +538,7 @@ off(type: 'complete'|'pause'|'remove', callback?:() => void): void
Unsubscribes from the download event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -565,17 +552,11 @@ Unsubscribes from the download event. This API uses an asynchronous callback to
**Example**
```js
-request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + JSON.stringify(err));
- return;
- }
- downloadTask = data;
- downloadTask.off('complete', function callback() {
- console.info('Download task completed.');
- }
-);
-});
+ downloadTask.off('complete', function callback() {
+ console.info('Download task completed.');
+ }
+ );
+ });
```
@@ -585,7 +566,7 @@ on(type: 'fail', callback: (err: number) => void): void
Subscribes to the download task failure event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -604,18 +585,12 @@ Parameters of the callback function
**Example**
- ```js
-request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask = data;
- downloadTask.on('fail', function callBack(err) {
- console.info('Download task failed. Cause:' + err);
- }
-);
-});
+ ```js
+ downloadTask.on('fail', function callBack(err) {
+ console.info('Download task failed. Cause:' + err);
+ }
+ );
+ });
```
@@ -625,7 +600,7 @@ off(type: 'fail', callback?: (err: number) => void): void
Unsubscribes from the download task failure event. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -645,12 +620,6 @@ Parameters of the callback function
**Example**
```js
- request.download({ url: 'https://xxxx/xxxx.hap' }, (err, data)=> {
- if (err) {
- console.error('Failed to request download. Cause:' + err);
- return;
- }
- downloadTask = data;
downloadTask.off('fail', function callBack(err) {
console.info('Download task failed. Cause:' + err);
}
@@ -665,7 +634,7 @@ remove(): Promise<boolean>
Removes this download task. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -696,7 +665,7 @@ remove(callback: AsyncCallback<boolean>): void
Removes this download task. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -709,17 +678,17 @@ Removes this download task. This API uses an asynchronous callback to return the
**Example**
```js
-downloadTask.remove((err, result)=>{
- if(err) {
- console.error('Failed to remove the download task.');
- return;
- }
- if (result) {
- console.info('Download task removed.');
- } else {
- console.error('Failed to remove the download task.');
- }
-});
+ downloadTask.remove((err, result)=>{
+ if(err) {
+ console.error('Failed to remove the download task.');
+ return;
+ }
+ if (result) {
+ console.info('Download task removed.');
+ } else {
+ console.error('Failed to remove the download task.');
+ }
+ });
```
@@ -729,7 +698,7 @@ query(): Promise<DownloadInfo>
Queries this download task. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -742,11 +711,11 @@ Queries this download task. This API uses a promise to return the result.
**Example**
```js
-downloadTask.query().then((downloadInfo) => {
- console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
-}) .catch((err) => {
- console.error('Failed to query the download task. Cause:' + err)
-});
+ downloadTask.query().then((downloadInfo) => {
+ console.info('Download task queried. Data:' + JSON.stringify(downloadInfo))
+ }) .catch((err) => {
+ console.error('Failed to query the download task. Cause:' + err)
+ });
```
@@ -756,7 +725,7 @@ query(callback: AsyncCallback<DownloadInfo>): void
Queries this download task. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -769,13 +738,13 @@ Queries this download task. This API uses an asynchronous callback to return the
**Example**
```js
-downloadTask.query((err, downloadInfo)=>{
- if(err) {
- console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
- } else {
- console.info('download query success. data:'+ JSON.stringify(downloadInfo));
- }
-});
+ downloadTask.query((err, downloadInfo)=>{
+ if(err) {
+ console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
+ } else {
+ console.info('download query success. data:'+ JSON.stringify(downloadInfo));
+ }
+ });
```
@@ -785,7 +754,7 @@ queryMimeType(): Promise<string>
Queries **MimeType** of this download task. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -798,11 +767,11 @@ Queries **MimeType** of this download task. This API uses a promise to return th
**Example**
```js
-downloadTask.queryMimeType().then((data) => {
- console.info('Download task queried. Data:' + JSON.stringify(data));
-}).catch((err) => {
- console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err))
-});
+ downloadTask.queryMimeType().then((data) => {
+ console.info('Download task queried. Data:' + JSON.stringify(data));
+ }).catch((err) => {
+ console.error('Failed to query the download MimeType. Cause:' + JSON.stringify(err))
+ });
```
@@ -812,7 +781,7 @@ queryMimeType(callback: AsyncCallback<string>): void;
Queries **MimeType** of this download task. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -825,13 +794,13 @@ Queries **MimeType** of this download task. This API uses an asynchronous callba
**Example**
```js
-downloadTask.queryMimeType((err, data)=>{
- if(err) {
- console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
- } else {
- console.info('Download task queried. data:' + JSON.stringify(data));
- }
-});
+ downloadTask.queryMimeType((err, data)=>{
+ if(err) {
+ console.error('Failed to query the download mimeType. Cause:' + JSON.stringify(err));
+ } else {
+ console.info('Download task queried. data:' + JSON.stringify(data));
+ }
+ });
```
@@ -841,7 +810,7 @@ pause(): Promise<void>
Pauses this download task. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -854,15 +823,15 @@ Pauses this download task. This API uses a promise to return the result.
**Example**
```js
-downloadTask.pause().then((result) => {
- if (result) {
- console.info('Download task paused. ');
- } else {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
- }
-}).catch((err) => {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
-});
+ downloadTask.pause().then((result) => {
+ if (result) {
+ console.info('Download task paused. ');
+ } else {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
+ }
+ }).catch((err) => {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
+ });
```
@@ -872,7 +841,7 @@ pause(callback: AsyncCallback<void>): void
Pauses this download task. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -885,17 +854,17 @@ Pauses this download task. This API uses an asynchronous callback to return the
**Example**
```js
-downloadTask.pause((err, result)=>{
- if(err) {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
- return;
- }
- if (result) {
- console.info('Download task paused. ');
- } else {
- console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
- }
-});
+ downloadTask.pause((err, result)=>{
+ if(err) {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(err));
+ return;
+ }
+ if (result) {
+ console.info('Download task paused. ');
+ } else {
+ console.error('Failed to pause the download task. Cause:' + JSON.stringify(result));
+ }
+ });
```
@@ -905,7 +874,7 @@ resume(): Promise<void>
Resumes this download task. This API uses a promise to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -918,16 +887,16 @@ Resumes this download task. This API uses a promise to return the result.
**Example**
```js
-downloadTask.resume().then((result) => {
- if (result) {
- console.info('Download task resumed.')
- } else {
- console.error('Failed to resume the download task. ');
- }
- console.info('Download task resumed.')
-}).catch((err) => {
- console.error('Failed to resume the download task. Cause:' + err);
-});
+ downloadTask.resume().then((result) => {
+ if (result) {
+ console.info('Download task resumed.')
+ } else {
+ console.error('Failed to resume the download task. ');
+ }
+ console.info('Download task resumed.')
+ }).catch((err) => {
+ console.error('Failed to resume the download task. Cause:' + err);
+ });
```
@@ -937,7 +906,7 @@ resume(callback: AsyncCallback<void>): void
Resumes this download task. This API uses an asynchronous callback to return the result.
-**Required permission**: ohos.permission.INTERNET
+**Required permissions**: ohos.permission.INTERNET
**System capability**: SystemCapability.MiscServices.Download
@@ -950,17 +919,17 @@ Resumes this download task. This API uses an asynchronous callback to return the
**Example**
```js
-downloadTask.resume((err, result)=>{
- if (err) {
- console.error('Failed to resume the download task. Cause:' + err);
- return;
- }
- if (result) {
- console.info('Download task resumed.');
- } else {
- console.error('Failed to resume the download task.');
- }
-});
+ downloadTask.resume((err, result)=>{
+ if (err) {
+ console.error('Failed to resume the download task. Cause:' + err);
+ return;
+ }
+ if (result) {
+ console.info('Download task resumed.');
+ } else {
+ console.error('Failed to resume the download task.');
+ }
+ });
```
diff --git a/en/application-dev/reference/apis/js-apis-uitest.md b/en/application-dev/reference/apis/js-apis-uitest.md
index b554e47f481696c48dea31a47315e454a01b9efa..6586d6f0a2c7fc5641a5b49411f67390859e3bfe 100644
--- a/en/application-dev/reference/apis/js-apis-uitest.md
+++ b/en/application-dev/reference/apis/js-apis-uitest.md
@@ -1,8 +1,7 @@
# UiTest
->**NOTE**
+>**NOTE** The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
->The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
@@ -13,46 +12,27 @@ import {UiDriver,BY,MatchPattern} from '@ohos.uitest'
## By
-The UiTest framework provides a wide range of UI component feature description APIs in the **By** class to filter and match components.
-The API capabilities provided by the **By** class exhibit the following features:
+The UiTest framework provides a wide range of UI component feature description APIs in the **By** class to filter and match components.
+The API capabilities provided by the **By** class exhibit the following features: 1. Allow one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component. 2. Provide multiple match patterns for component attributes. 3. Support absolute positioning and relative positioning for components. APIs such as [By.isBefore](#byisbefore) and [By.isAfter](#byisafter) can be used to specify the features of adjacent components to assist positioning. All APIs provided in the **By** class are synchronous. You are advised to use the static constructor **BY** to create a **By** object in chain mode.
-- Allows one or more attributes as the match conditions. For example, you can specify both the **text** and **id** attributes to find the target component.
-
-- Provides multiple match patterns for component attributes.
-
-- Supports absolute positioning and relative positioning for components. APIs such as **isBefore** and **isAfter** can be used to specify the features of adjacent components to assist positioning.
-
-All APIs provided in the **By** class are synchronous. You are advised to use the static constructor **BY** to create a **By** object in chain mode, for example, **BY.text('123').type('button')**.
-
-### enum MatchPattern
-
-Enumerates the match patterns supported for component attributes.
-
-**System capability**: SystemCapability.Test.UiTest
-
-| Name | Value | Description |
-| ----------- | ---- | ------------ |
-| EQUALS | 0 | Equal to the given value. |
-| CONTAINS | 1 | Contain the given value. |
-| STARTS_WITH | 2 | Start with the given value.|
-| ENDS_WITH | 3 | End with the given value.|
+```js
+BY.text('123').type('button')
+```
### By.text
-text(txt:string,pattern?:MatchPattern):By
+text(txt: string, pattern?: MatchPattern): By
Specifies the text attribute of the target component. Multiple match patterns are supported.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------------ | ---- | ---------------------------------- |
-| txt | string | Yes | Component text, used to match the target component.|
-| pattern | MatchPattern | No | Match pattern. The default value is **EQUALS**. |
+| Name | Type | Mandatory| Description |
+| ------- | ------------ | ---- | ------------------------------------------------- |
+| txt | string | Yes | Component text, used to match the target component. |
+| pattern | MatchPattern | No | Match pattern. The default value is [EQUALS](#matchpattern).|
**Return value**
@@ -62,324 +42,382 @@ Specifies the text attribute of the target component. Multiple match patterns ar
**Example**
-```
-let by = BY.text('123') // Use the static constructor BY to create a By object and specify the text attribute
- of the target component.
+```js
+let by = BY.text('123') // Use the static constructor BY to create a By object and specify the text attribute of the target component.
```
### By.key
-key(key:string):By;
+key(key: string): By
Specifies the key attribute of the target component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | --------------- |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ----------------- |
| key | string | Yes | Component key.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.key('123') // Use the static constructor BY to create a By object and specify the key attribute
- of the target component.
+```js
+let by = BY.key('123') // Use the static constructor BY to create a By object and specify the key attribute of the target component.
```
### By.id
-id(id:number):By;
-
-Specifies the ID property of the target component.
+id(id: number): By
-**Required permissions**: none
+Specifies the ID attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------ |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------- |
| id | number | Yes | Component ID.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.id(123) // Use the static constructor BY to create a By object and specify the ID attribute
- of the target component.
+```js
+let by = BY.id(123) // Use the static constructor BY to create a By object and specify the id attribute of the target component.
```
### By.type
-type(tp:string):By;
+type(tp: string): By
-Specifies the type property of the target component.
-
-**Required permissions**: none
+Specifies the type attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------ |
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------- |
| tp | string | Yes | Component type.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.type('button') // Use the static constructor BY to create a By object and specify the type attribute
- of the target component.
+```js
+let by = BY.type('button') // Use the static constructor BY to create a By object and specify the type attribute of the target component.
```
### By.clickable
-clickable(b?:bool):By;
+clickable(b?: bool): By
Specifies the clickable attribute of the target component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------------- |
| b | bool | No | Clickable status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
+```js
+let by = BY.clickable(true) // Use the static constructor BY to create a By object and specify the clickable status attribute of the target component.
```
-let by = BY.clickable(true) // Use the static constructor BY to create a By object and specify the clickable attribute
- of the target component.
+
+### By.longClickable9+
+
+longClickable(b?: bool): By
+
+Specifies the long-clickable status attribute of the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------------------------------ |
+| b | bool | No | Long-clickable status of the target component. The default value is **true**.|
+
+**Return value**
+
+| Type| Description |
+| ---- | ---------------- |
+| By | Returns the **By** object itself.|
+
+**Example**
+
+```js
+let by = BY.longClickable(true) // Use the static constructor BY to create a By object and specify the long-clickable status attribute of the target component.
```
### By.scrollable
-scrollable(b?:bool):By;
+scrollable(b?: bool): By
-Specifies the scrollable attribute of the target component.
-
-**Required permissions**: none
+Specifies the scrollable status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | -------------------------- |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------------------- |
| b | bool | No | Scrollable status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.scrollable(true) // Use the static constructor BY to create a By object and specify the scrollable attribute
- of the target component.
+```js
+let by = BY.scrollable(true) // Use the static constructor BY to create a By object and specify the scrollable status attribute of the target component.
```
### By.enabled
-enabled(b?:bool):By;
-
-Specifies the enable attribute of the target component.
+enabled(b?: bool): By
-**Required permissions**: none
+Specifies the enabled status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ---------------------------- |
-| b | bool | No | Enable status of the target component. The default value is **true**.|
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------------------------ |
+| b | bool | No | Enabled status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the enable attribute
- of the target component.
+```js
+let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the enabled status attribute of the target component.
```
### By.focused
-focused(b?:bool):By;
-
-Specifies the focused attribute of the target component.
+focused(b?: bool): By
-**Required permissions**: none
+Specifies the focused status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------- |
| b | bool | No | Focused status of the target component. The default value is **true**.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.enabled(true) // Use the static constructor BY to create a By object and specify the focused attribute
- of the target component.
+```js
+let by = BY.focused(true) // Use the static constructor BY to create a By object and specify the focused status attribute of the target component.
```
### By.selected
-selected(b?:bool):By;
-
-Specifies the selected attribute of the target component.
+selected(b?: bool): By
-**Required permissions**: none
+Specifies the selected status attribute of the target component.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------------------- |
| b | bool | No | Selected status of the target component. The default value is **true**.|
**Return value**
+| Type| Description |
+| ---- | ---------------- |
+| By | Returns the **By** object itself.|
+
+**Example**
+
+```js
+let by = BY.selected(true) // Use the static constructor BY to create a By object and specify the selected status attribute of the target component.
+```
+
+### By.checked9+
+
+checked(b?: bool): By
+
+Specifies the checked status attribute of the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | --------------------------------- |
+| b | bool | No | Checked status of the target component. The default value is **false**.|
+
+**Return value**
+
| Type| Description |
| ---- | -------------- |
| By | Returns the **By** object itself.|
**Example**
+```js
+let by = BY.checked(true) // Use the static constructor BY to create a By object and specify the checked status attribute of the target component.
```
-let by = BY.selected(true) // Use the static constructor BY to create a By object and specify the selected attribute
- of the target component.
+
+### By.checkable9+
+
+checkable(b?: bool): By
+
+Specifies the checkable status attribute of the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ------------------------------------- |
+| b | bool | No | Checkable status of the target component. The default value is **false**.|
+
+**Return value**
+
+| Type| Description |
+| ---- | ---------------- |
+| By | Returns the **By** object itself.|
+
+**Example**
+
+```js
+let by = BY.checkable(true) // Use the static constructor BY to create a By object and specify the checkable status attribute of the target component.
```
### By.isBefore
-isBefore(by:By):By;
+isBefore(by: By): By
Specifies the attributes of the component before which the target component is located.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | -------------- |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------- |
| by | By | Yes | Attributes of the component before which the target component is located.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.isBefore(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes
- of the component before which the target component is located.
+```js
+let by = BY.isBefore(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes of the component before which the target component is located.
```
### By.isAfter
-isAfter(by:By):By;
+isAfter(by: By): By
Specifies the attributes of the component after which the target component is located.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | -------------- |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | ---------------- |
| by | By | Yes | Attributes of the component before which the target component is located.|
**Return value**
-| Type| Description |
-| ---- | -------------- |
+| Type| Description |
+| ---- | ---------------- |
| By | Returns the **By** object itself.|
**Example**
-```
-let by = BY.isAfter(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes
- of the component after which the target component is located.
+```js
+let by = BY.isAfter(BY.text('123')) // Use the static constructor BY to create a By object and specify the attributes of the component after which the target component is located.
```
## UiComponent
In **UiTest**, the **UiComponent** class represents a component on the UI and provides APIs for obtaining component attributes, clicking a component, scrolling to search for a component, and text injection.
-All APIs provided by this class use a promise to return the result and must be invoked using **await**.
+All APIs provided in this class use a promise to return the result and must be invoked using **await**.
+
+### Rect9+
+
+Provides border information of a component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+| Name | Type| Readable| Writable| Description |
+| ------- | -------- | ---- | ---- | ------------------------- |
+| leftX | number | Yes | No | X coordinate of the upper left corner of the component borders.|
+| topY | number | Yes | No | Y coordinate of the upper left corner of the component borders.|
+| rightX | number | Yes | No | X coordinate of the lower right corner of the component borders.|
+| bottomY | number | Yes | No | Y coordinate of the lower right corner of the component borders.|
### UiComponent.click
-click():Promise;
+click(): Promise\
Clicks this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -389,37 +427,33 @@ async function demo() {
### UiComponent.doubleClick
-doubleClick():Promise;
+doubleClick(): Promise\
Double-clicks this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
- await buttont.doubleClick()
+ await button.doubleClick()
}
```
### UiComponent.longClick
-longClick():Promise;
+longClick(): Promise\
Long-clicks this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -429,23 +463,21 @@ async function demo() {
### UiComponent.getId
-getId():Promise;
+getId(): Promise\
Obtains the ID of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| ---------------- | ------------------------- |
-| Promise; | Promise used to return the component ID.|
+| Type | Description |
+| ---------------- | ------------------------------- |
+| Promise\ | Promise used to return the ID of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -455,23 +487,21 @@ async function demo() {
### UiComponent.getKey
-getKey():Promise;
+getKey(): Promise\
Obtains the key of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| ---------------- | -------------------------- |
-| Promise; | Promise used to return the component key.|
+| Type | Description |
+| ---------------- | ------------------------------ |
+| Promise\ | Promise used to return the key of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -481,23 +511,21 @@ async function demo() {
### UiComponent.getText
-getText():Promise;
+getText(): Promise\
Obtains the text information of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| ---------------- | ------------------------------- |
-| Promise; | Promise used to return the text information of the component.|
+| Type | Description |
+| ---------------- | --------------------------------- |
+| Promise\ | Promise used to return the text information of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -507,23 +535,21 @@ async function demo() {
### UiComponent.getType
-getType():Promise;
+getType(): Promise\
Obtains the type of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| ---------------- | ------------------------------- |
-| Promise; | Promise used to return the component type.|
+| Type | Description |
+| ---------------- | ----------------------------- |
+| Promise\ | Promise used to return the type of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -531,25 +557,47 @@ async function demo() {
}
```
+### UiComponent.getBounds9+
+
+getBounds(): Promise\
+
+Obtains the bounds of this component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Return value**
+
+| Type | Description |
+| -------------- | ------------------------------------- |
+| Promise\ | Promise used to return the bounds of the component.|
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let button = await driver.findComponent(BY.type('button'))
+ let rect = await button.getBounds()
+}
+```
+
### UiComponent.isClickable
-isClickable():Promise;
+isClickable(): Promise\
Obtains the clickable status of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| -------------- | ----------------------------------- |
-| Promise; | Promise used to return the clickable status of the component.|
+| Type | Description |
+| -------------- | ------------------------------------- |
+| Promise\ | Promise used to return the clickable status of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -562,25 +610,110 @@ async function demo() {
}
```
-### UiComponent.isScrollable
+### UiComponent.isLongClickable9+
-isScrollable():Promise;
+isLongClickable(): Promise\
-Obtains the scrollable status of this component.
+Obtains the long clickable status of this component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Return value**
+
+| Type | Description |
+| -------------- | ------------------------------------------- |
+| Promise\ | Promise used to return the long clickable status of the component.|
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let button = await driver.findComponent(BY.type('button'))
+ if(await button.isLongClickable()) {
+ console.info('This button can longClick')
+ }
+ else{
+ console.info('This button can not longClick')
+ }
+}
+```
+
+### UiComponent.isChecked9+
+
+isChecked(): Promise\
-**Required permissions**: none
+Obtains the checked status of this component.
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| -------------- | ----------------------------------- |
-| Promise; | Promise used to return the scrollable status of the component.|
+| Type | Description |
+| -------------- | ------------------------------------- |
+| Promise\ | Promise used to return the checked status of the component.|
**Example**
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let checkBox = await driver.findComponent(BY.type('Checkbox'))
+ if(await checkBox.isChecked) {
+ console.info('This checkBox is checked')
+ }
+ else{
+ console.info('This checkBox is not checked')
+ }
+}
```
+
+### UiComponent.isCheckable9+
+
+isCheckable(): Promise\
+
+Obtains the checked status of this component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Return value**
+
+| Type | Description |
+| -------------- | ------------------------------------------- |
+| Promise\ | Promise used to return the checked status of the component.|
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let checkBox = await driver.findComponent(BY.type('Checkbox'))
+ if(await checkBox.isCheckable) {
+ console.info('This checkBox is checkable')
+ }
+ else{
+ console.info('This checkBox is not checkable')
+ }
+}
+```
+
+### UiComponent.isScrollable
+
+isScrollable(): Promise\
+
+Obtains the scrollable status of this component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Return value**
+
+| Type | Description |
+| -------------- | ------------------------------------- |
+| Promise\ | Promise used to return the scrollable status of the component.|
+
+**Example**
+
+```js
async function demo() {
let driver = UiDriver.create()
let scrollBar = await driver.findComponent(BY.scrollable(true))
@@ -596,23 +729,21 @@ async function demo() {
### UiComponent.isEnabled
-isEnabled():Promise;
+isEnabled(): Promise\
-Obtains the enable status of this component.
-
-**Required permissions**: none
+Obtains the enabled status of this component.
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| -------------- | ----------------------------- |
-| Promise; | Promise used to return the enable status of the component.|
+| Type | Description |
+| -------------- | ------------------------------- |
+| Promise\ | Promise used to return the enabled status of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -628,23 +759,21 @@ async function demo() {
### UiComponent.isFocused
-isFocused():Promise;
+isFocused(): Promise\
Obtains the focused status of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| -------------- | --------------------------------- |
-| Promise; | Promise used to return the focused status of the component.|
+| Type | Description |
+| -------------- | ----------------------------------- |
+| Promise\ | Promise used to return the focused status of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -659,23 +788,21 @@ async function demo() {
### UiComponent.isSelected
-isSelected():Promise;
+isSelected(): Promise\
Obtains the selected status of this component.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| -------------- | ----------------------------------- |
-| Promise; | Promise used to return the selected status of the component.|
+| Type | Description |
+| -------------- | -------------------- |
+| Promise\ | Promise used to return the selected status of the component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.type('button'))
@@ -690,37 +817,51 @@ async function demo() {
### UiComponent.inputText
-inputText(text: string):Promise;
+inputText(text: string): Promise\
Enters text into this component (available for text boxes).
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------ | ---- | ------------------------- |
-| text | string | Yes | Text to be entered to the component.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | ---------------- |
+| text | string | Yes | Text to enter.|
**Example**
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let text = await driver.findComponent(BY.text('hello world'))
+ await text.inputText('123')
+}
```
+
+### UiComponent.clearText9+
+
+clearText(): Promise\
+
+Clears text in this component (available for text boxes).
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Example**
+
+```js
async function demo() {
let driver = UiDriver.create()
- let button = await driver.findComponent(BY.type('button'))
- await button.inputText('next page')
+ let text = await driver.findComponent(BY.text('hello world'))
+ await text.clearText()
}
```
### UiComponent.scrollSearch
-scrollSearch(by:By):Promise;
-
-Scrolls on this component to search for the target component (available for lists).
+scrollSearch(by: By): Promise\
-**Required permissions**: none
+Scrolls on this component to search for the target component (applicable to component that support scrolling, such as **\**).
**System capability**: SystemCapability.Test.UiTest
@@ -732,20 +873,81 @@ Scrolls on this component to search for the target component (available for list
**Return value**
-| Type | Description |
-| --------------------- | ----------------------------------- |
-| Promise; | Promise used to return the target component.|
+| Type | Description |
+| --------------------- | ------------------------------------- |
+| Promise\ | Promise used to return the target component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
- let scrollBar = await driver.findComponent(BY.scrollable(true))
+ let scrollBar = await driver.findComponent(BY.type('Scroll'))
let button = await scrollBar.scrollSearch(BY.text('next page'))
}
```
+### UiComponent.scrollToTop9+
+
+scrollToTop(): Promise\
+
+Scrolls to the top of this a component (applicable to component that support scrolling, such as **\**).
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let scrollBar = await driver.findComponent(BY.type('Scroll'))
+ await scrollBar.scrollToTop()
+}
+```
+
+### UiComponent.scrollToBottom9+
+
+scrollToBottom(): Promise\
+
+Scrolls to the bottom of this a component (applicable to component that support scrolling, such as **\**).
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let scrollBar = await driver.findComponent(BY.type('Scroll'))
+ await scrollBar.scrollToBottom()
+}
+```
+
+### UiComponent.dragTo9+
+
+dragTo(target: UiComponent): Promise\
+
+Drags this component to the target component.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ----------- | ---- | ---------- |
+| target | UiComponent | Yes | Target component.|
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let button = await driver.findComponent(BY.type('button'))
+ let text = await driver.findComponent(BY.text('hello world'))
+ await button.dragTo(text)
+ }
+```
+
## UiDriver
The **UiDriver** class is the main entry to the **uitest** test framework. It provides APIs for features such as component matching/search, key injection, coordinate clicking/sliding, and screenshot.
@@ -753,23 +955,21 @@ All APIs provided by this class, except for **UiDriver.create()**, use a promise
### UiDriver.create
-static create():UiDriver;
+static create(): UiDriver
Creates a **UiDriver** object and returns the object created. This API is a static API.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Return value**
-| Type | Description |
-| ------- | ---------------------- |
+| Type | Description |
+| ------- | ------------------------ |
| UiDrive | Returns the **UiDriver** object created.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
}
@@ -777,23 +977,21 @@ async function demo() {
### UiDriver.delayMs
-delayMs(duration:number):Promise;
+delayMs(duration: number): Promise\
Delays this **UiDriver** object within the specified duration.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------ | ---- | ---------- |
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | ------------ |
| duration | number | Yes | Duration of time.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.delayMs(1000)
@@ -802,29 +1000,27 @@ async function demo() {
### UiDriver.findComponent
-findComponent(by:By):Promise;
-
-Searches this **UiDriver** object for the target component that has the given attributes.
+findComponent(by: By): Promise\
-**Required permissions**: none
+Searches this **UiDriver** object for the target component that matches the given attributes.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------- |
| by | By | Yes | Attributes of the target component.|
**Return value**
-| Type | Description |
-| --------------------- | ------------------------------- |
-| Promise; | Promise used to return the found component.|
+| Type | Description |
+| --------------------- | --------------------------------- |
+| Promise\ | Promise used to return the found component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let button = await driver.findComponent(BY.text('next page'))
@@ -833,54 +1029,80 @@ async function demo() {
### UiDriver.findComponents
-findComponents(by:By):Promise>;
+findComponents(by: By): Promise\>
Searches this **UiDriver** object for all components that match the given attributes.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------- |
| by | By | Yes | Attributes of the target component.|
**Return value**
-| Type | Description |
-| ---------------------------- | ------------------------------------- |
-| Promise>; | Promise used to return a list of found components.|
+| Type | Description |
+| ----------------------------- | --------------------------------------- |
+| Promise\> | Promise used to return a list of found components.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
let buttonList = await driver.findComponents(BY.text('next page'))
}
```
+### UiDriver.waitForComponent9+
+
+waitForComponent(by: By, time: number): Promise\
+
+Searches this **UiDriver** object for the target component that matches the given attributes within the specified duration.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------- |
+| by | By | Yes | Attributes of the target component. |
+| time | number | Yes | Duration for searching for the target component, in ms.|
+
+**Return value**
+
+| Type | Description |
+| --------------------- | --------------------------------- |
+| Promise\ | Promise used to return the found component.|
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ let button = await driver.waitForComponent(BY.text('next page'),500)
+}
+```
+
### UiDriver.assertComponentExist
-assertComponentExist(by:By):Promise;
+assertComponentExist(by: By): Promise\
Asserts that a component that matches the given attributes exists on the current page. If the component does not exist, the API throws a JS exception, causing the current test case to fail.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type| Mandatory| Description |
-| ------ | ---- | ---- | ------------------ |
+| Name| Type| Mandatory| Description |
+| ------ | ---- | ---- | -------------------- |
| by | By | Yes | Attributes of the target component.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.assertComponentExist(BY.text('next page'))
@@ -889,17 +1111,15 @@ async function demo() {
### UiDriver.pressBack
-pressBack():Promise;
+pressBack(): Promise\
Presses the Back button on this **UiDriver** object.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.pressBack()
@@ -908,23 +1128,21 @@ async function demo() {
### UiDriver.triggerKey
-triggerKey(keyCode:number):Promise;
+triggerKey(keyCode: number): Promise\
Triggers the key of this **UiDriver** object that matches the given key code.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------- | ------ | ---- | --------- |
+| Name | Type | Mandatory| Description |
+| ------- | ------ | ---- | ------------- |
| keyCode | number | Yes | Key code.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.triggerKey(123)
@@ -933,23 +1151,22 @@ async function demo() {
### UiDriver.click
-click(x:number,y:number):Promise;
+click(x: number, y: number): Promise\
Clicks a specific point of this **UiDriver** object based on the given coordinates.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------------- | ---- | ------------------------------------------- |
-| x,y | number,number | Yes | Coordinate information of a specific point in the (number,number) format.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------------- |
+| x | number | Yes | X coordinate of the target point.|
+| y | number | Yes | Y coordinate of the target point.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.click(100,100)
@@ -958,23 +1175,22 @@ async function demo() {
### UiDriver.doubleClick
-doubleClick(x:number,y:number):Promise;
+doubleClick(x: number, y: number): Promise\
Double-clicks a specific point of this **UiDriver** object based on the given coordinates.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------------- | ---- | ------------------------------------------- |
-| x,y | number,number | Yes | Coordinate information of a specific point in the (number,number) format.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------------- |
+| x | number | Yes | X coordinate of the target point.|
+| y | number | Yes | Y coordinate of the target point.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.doubleClick(100,100)
@@ -983,23 +1199,22 @@ async function demo() {
### UiDriver.longClick
-longClick(x:number,y:number):Promise;
+longClick(x: number, y: number): Promise\
Long-clicks a specific point of this **UiDriver** object based on the given coordinates.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name| Type | Mandatory| Description |
-| ------ | ------------- | ---- | ------------------------------------------- |
-| x,y | number,number | Yes | Coordinate information of a specific point in the (number,number) format.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------------- |
+| x | number | Yes | X coordinate of the target point.|
+| y | number | Yes | Y coordinate of the target point.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.longClick(100,100)
@@ -1008,51 +1223,96 @@ async function demo() {
### UiDriver.swipe
-swipe(startx:number,starty:number,endx:number,endy:number):Promise;
-
-Swipes from the start point to the end point of this **UiDriver** object based on the given coordinates.
+swipe(startx: number, starty: number, endx: number, endy: number): Promise\
-**Required permissions**: none
+Swipes on this **UiDriver** object from the start point to the end point based on the given coordinates.
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name | Type | Mandatory| Description |
-| ------------- | ------------- | ---- | ------------------------------------------- |
-| startx,starty | number,number | Yes | Coordinate information of the start point in the (number,number) format.|
-| endx,endy | number,number | Yes | Coordinate information of the end point in the (number,number) format.|
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------------- |
+| startx | number | Yes | X coordinate of the start point.|
+| starty | number | Yes | Y coordinate of the start point.|
+| endx | number | Yes | X coordinate of the end point.|
+| endy | number | Yes | Y coordinate of the end point.|
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.swipe(100,100,200,200)
}
```
+### UiDriver.drag9+
+
+drag(startx: number, starty: number, endx: number, endy: number): Promise\
+
+Drags this **UiDriver** object from the given start point to the given end point.
+
+**System capability**: SystemCapability.Test.UiTest
+
+**Parameters**
+
+| Name| Type | Mandatory| Description |
+| ------ | ------ | ---- | -------------------------------------- |
+| startx | number | Yes | X coordinate of the start point.|
+| starty | number | Yes | Y coordinate of the start point.|
+| endx | number | Yes | X coordinate of the end point.|
+| endy | number | Yes | Y coordinate of the end point.|
+
+**Example**
+
+```js
+async function demo() {
+ let driver = UiDriver.create()
+ await driver.drag(100,100,200,200)
+}
+```
+
### UiDriver.screenCap
-screenCap(savePath:string):Promise;
+screenCap(savePath: string): Promise\
Captures the current screen of this **UiDriver** object and saves it as a PNG image to the given save path.
-**Required permissions**: none
-
**System capability**: SystemCapability.Test.UiTest
**Parameters**
-| Name | Type | Mandatory| Description |
-| -------- | ------ | ---- | ------------ |
+| Name | Type | Mandatory| Description |
+| -------- | ------ | ---- | -------------- |
| savePath | string | Yes | File save path.|
+**Return value**
+
+| Type | Description |
+| -------------- | -------------------------------------- |
+| Promise\ | Promise used to return the operation result. The value **true** means that the operation is successful.|
+
**Example**
-```
+```js
async function demo() {
let driver = UiDriver.create()
await driver.screenCap('/local/tmp/')
}
```
+
+## MatchPattern
+
+Enumerates the match patterns supported for component attributes.
+
+**System capability**: SystemCapability.Test.UiTest
+
+| Name | Value | Description |
+| ----------- | ---- | -------------- |
+| EQUALS | 0 | Equal to the given value. |
+| CONTAINS | 1 | Containing the given value. |
+| STARTS_WITH | 2 | Starting from the given value.|
+| ENDS_WITH | 3 | Ending with the given value.|
+
+###
diff --git a/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md b/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md
index de18fea31cc344b2e25091cbb442df29ad87fda9..22126cd74687d1105872e85efa83f26dba71cadd 100644
--- a/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md
+++ b/en/application-dev/reference/arkui-ts/ts-interpolation-calculation.md
@@ -1,13 +1,13 @@
# Interpolation Calculation
->  **NOTE**
+> **NOTE**
> This animation is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
## Modules to Import
-
+
```
import curves from '@ohos.curves'
```
@@ -27,11 +27,12 @@ Implements initialization for the interpolation curve, which is used to create a
- Parameters
- | Name | Type | Mandatory | Default Value | Description |
+ | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
- | curve | Curve | No | Linear | Curve object. |
+ | curve | Curve | No | Linear | Curve object. |
-- Return values
+- Return value
+
Curve object.
@@ -44,12 +45,13 @@ Constructs a step curve object.
- Parameters
- | Name | Type | Mandatory | Default Value | Description |
+ | Name | Type | Mandatory | Default Value | Description |
| -------- | -------- | -------- | -------- | -------- |
- | count | number | Yes | - | Number of steps. Must be a positive integer. |
- | end | boolean | No | true | Step change at the start or end point of each interval. Defaults to **true**, indicating that the step change occurs at the end point. |
+ | count | number | Yes | - | Number of steps. Must be a positive integer. |
+ | end | boolean | Yes | true | Step change at the start or end point of each interval. Defaults to **true**, indicating that the step change occurs at the end point. |
-- Return values
+- Return value
+
Curve object.
@@ -62,14 +64,15 @@ Constructs a third-order Bezier curve object. The curve value must be between 0
- Parameters
- | Name | Type | Mandatory | Description |
+ | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
- | x1 | number | Yes | Horizontal coordinate of the first point on the Bezier curve. |
- | y1 | number | Yes | Vertical coordinate of the first point on the Bezier curve. |
- | x2 | number | Yes | Horizontal coordinate of the second point on the Bezier curve. |
- | y2 | number | Yes | Vertical coordinate of the second point on the Bezier curve. |
+ | x1 | number | Yes | Horizontal coordinate of the first point on the Bezier curve. |
+ | y1 | number | Yes | Vertical coordinate of the first point on the Bezier curve. |
+ | x2 | number | Yes | Horizontal coordinate of the second point on the Bezier curve. |
+ | y2 | number | Yes | Vertical coordinate of the second point on the Bezier curve. |
-- Return values
+- Return value
+
Curve object.
@@ -82,20 +85,21 @@ Constructs a spring curve object.
- Parameters
- | Name | Type | Mandatory | Description |
+ | Name | Type | Mandatory | Description |
| -------- | -------- | -------- | -------- |
- | velocity | number | Yes | Initial velocity. |
- | mass | number | Yes | Mass. |
- | stiffness | number | Yes | Stiffness. |
- | damping | number | Yes | Damping. |
+ | velocity | number | Yes | Initial velocity. |
+ | mass | number | Yes | Mass. |
+ | stiffness | number | Yes | Stiffness. |
+ | damping | number | Yes | Damping. |
-- Return values
+- Return value
+
Curve object.
## Example
-
+
```
import Curves from '@ohos.curves'
let curve1 = Curves.init() // Create a default linear interpolation curve.
@@ -105,14 +109,14 @@ let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezi
```
- Curve objects can be created only by the preceding APIs.
- | API | Description |
+Curve objects can be created only by the preceding APIs.
+| API | Description |
| -------- | -------- |
-| interpolate(time: number): number | Calculation function of the interpolation curve. Passing a normalized time parameter to this function returns the current interpolation. **time**: indicates the current normalized time. The value ranges from 0 to 1. The curve interpolation corresponding to the normalized time point is returned. |
+| interpolate(time: number): number | Calculation function of the interpolation curve. Passing a normalized time parameter to this function returns the current interpolation. **time**: indicates the current normalized time. The value ranges from 0 to 1. The curve interpolation corresponding to the normalized time point is returned. |
- Example
-
+
```
import Curves from '@ohos.curves'
let curve = Curves.init(Curve.EaseIn) // Create an interpolation curve which is slow and then fast by default.
@@ -122,7 +126,7 @@ let curve3 = Curves.cubicBezier(0.1, 0.0, 0.1, 1.0) // Create a third-order Bezi
## Example
-
+
```
import Curves from '@ohos.curves'
@Entry
diff --git a/en/application-dev/ui/js-framework-resource-restriction.md b/en/application-dev/ui/js-framework-resource-restriction.md
index 8636ebfd2197cb2b1a875d522b6d7469816b01c3..ac354320d00180ec887ec33261bd89103d2b68ab 100644
--- a/en/application-dev/ui/js-framework-resource-restriction.md
+++ b/en/application-dev/ui/js-framework-resource-restriction.md
@@ -23,9 +23,9 @@ The name of a resource qualifier consists of one or more qualifiers that represe
Table1 Resource qualifiers
-| Data Type | Description and Value Range |
+| Data Type | Description and Value Range |
| -------- | -------- |
-| Screen density | Indicates the screen density of the device, in dpi. The value can be: - ldpi: low-density screen (~120 dpi) (0.75 x Reference density) - mdpi: medium-density screen (~160 dpi) (reference density) - hdpi: high-density screen (~240 dpi) (1.5 x Reference density) - xhdpi: extra high-density screen (~320 dpi) (2.0 x Reference density) - xxhdpi: extra extra high-density screen (~480 dpi) (3.0 x Reference density) - xxxhdpi: extra extra extra high-density screen (~640 dpi) (4.0 x Reference density) |
+| Screen density | Indicates the screen density of the device, in dpi. The value can be: - ldpi: low-density screen (\~120 dpi) (0.75 x Reference density) - mdpi: medium-density screen (\~160 dpi) (reference density) - hdpi: high-density screen (\~240 dpi) (1.5 x Reference density) - xhdpi: extra high-density screen (\~320 dpi) (2.0 x Reference density) - xxhdpi: extra extra high-density screen (\~480 dpi) (3.0 x Reference density) - xxxhdpi: extra extra extra high-density screen (\~640 dpi) (4.0 x Reference density) |
## Rules for Matching Qualifiers Files and Device Resources
@@ -91,5 +91,5 @@ resources/res-defaults.json:
```
->  **NOTE**:
+>  **NOTE**
> The resource qualifier file does not support color enumeration.
diff --git a/en/application-dev/ui/ts-component-based-styles.md b/en/application-dev/ui/ts-component-based-styles.md
index 33ed37a07a5bb089bcff39f38d4456f6149b646f..a680933d6524893024b09fe4cbdec54a6b43e9f3 100644
--- a/en/application-dev/ui/ts-component-based-styles.md
+++ b/en/application-dev/ui/ts-component-based-styles.md
@@ -1,10 +1,9 @@
# @Styles
-The @Styles decorator adds new attribute functions to basic components, such as <Text>, <Column>, and <Button>. Currently, @Styles supports only universal attributes. You can use the @Styles decorator to quickly define and reuse the custom styles of a component.
+The **@Styles** decorator adds new attribute functions to basic components, such as **\**, **\**, and **\