diff --git a/en/application-dev/application-test/arkxtest-guidelines.md b/en/application-dev/application-test/arkxtest-guidelines.md index 4c0f1f5fd2f6fe56431e5800bfb2228679637c19..955393bf6e5c66c2866418215169a015e7f9c39b 100644 --- a/en/application-dev/application-test/arkxtest-guidelines.md +++ b/en/application-dev/application-test/arkxtest-guidelines.md @@ -92,80 +92,78 @@ export default function abilityTest() {
To write a UI test script to complete the corresponding test activities, simply add the invoking of the UiTest API to a unit test script. For details about the available APIs, see [@ohos.UiTest](..reference/apis-test-kit/js-apis-uitest.md).
In this example, the UI test script is written based on the preceding unit test script. It implements the click operation on the started application page and checks whether the page changes as expected. 1. Write the demo code in the **index.ets**file. - - ```ts - @Entry - @Component - struct Index { - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Text("Next") - .fontSize(50) - .margin({top:20}) - .fontWeight(FontWeight.Bold) - Text("after click") - .fontSize(50) - .margin({top:20}) - .fontWeight(FontWeight.Bold) + ```ts + @Entry + @Component + struct Index { + @State message: string = 'Hello World' + + build() { + Row() { + Column() { + Text(this.message) + .fontSize(50) + .fontWeight(FontWeight.Bold) + Text("Next") + .fontSize(50) + .margin({top:20}) + .fontWeight(FontWeight.Bold) + Text("after click") + .fontSize(50) + .margin({top:20}) + .fontWeight(FontWeight.Bold) + } + .width('100%') } - .width('100%') + .height('100%') } - .height('100%') } - } - ``` + ``` 2. Write test code in the .test.ets file under **ohosTest** > **ets** > **test**. - - ```ts - import { describe, it, expect } from '@ohos/hypium'; - // Import the test dependencies. - import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; - import { UIAbility, Want } from '@kit.AbilityKit'; - - const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() - const bundleName = abilityDelegatorRegistry.getArguments().bundleName; - function sleep(time: number) { - return new Promise((resolve: Function) => setTimeout(resolve, time)); - } - export default function abilityTest() { - describe('ActsAbilityTest', () => { - it('testUiExample',0, async (done: Function) => { - console.info("uitest: TestUiExample begin"); - //start tested ability - const want: Want = { - bundleName: bundleName, - abilityName: 'EntryAbility' - } - await delegator.startAbility(want); - await sleep(1000); - // Check the top display ability. - const ability: UIAbility = await delegator.getCurrentTopAbility(); - console.info("get top ability"); - expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); - // UI test code - // Initialize the driver. - const driver = Driver.create(); - await driver.delayMs(1000); - // Find the button on text 'Next'. - const button = await driver.findComponent(ON.text('Next')); - // Click the button. - await button.click(); - await driver.delayMs(1000); - // Check text. - await driver.assertComponentExist(ON.text('after click')); - await driver.pressBack(); - done(); - }) - }) - } - ``` + ```ts + import { describe, it, expect } from '@ohos/hypium'; + // Import the test dependencies. + import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; + import { UIAbility, Want } from '@kit.AbilityKit'; + + const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator() + const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); + } + export default function abilityTest() { + describe('ActsAbilityTest', () => { + it('testUiExample',0, async (done: Function) => { + console.info("uitest: TestUiExample begin"); + //start tested ability + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + await delegator.startAbility(want); + await sleep(1000); + // Check the top display ability. + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info("get top ability"); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + // UI test code + // Initialize the driver. + const driver = Driver.create(); + await driver.delayMs(1000); + // Find the button on text 'Next'. + const button = await driver.findComponent(ON.text('Next')); + // Click the button. + await button.click(); + await driver.delayMs(1000); + // Check text. + await driver.assertComponentExist(ON.text('after click')); + await driver.pressBack(); + done(); + }) + }) + } + ``` ### Running the Test Script diff --git a/en/application-dev/form/arkts-ui-widget-working-principles.md b/en/application-dev/form/arkts-ui-widget-working-principles.md index e9b58a889eb7d5522cf8ba6da2f4e48eae9d99c0..874a51f0fbacda12f85b06068b2d120a5358b226 100644 --- a/en/application-dev/form/arkts-ui-widget-working-principles.md +++ b/en/application-dev/form/arkts-ui-widget-working-principles.md @@ -66,4 +66,4 @@ In addition, ArkTS widgets do not support the following features: The following samples are provided to help you better understand how to develop an ArkTS widget: -- [Communication Between JS and C++ for Stage Model Widgets (ArkTS, API version 10)] (https://gitee.com/openharmony/applications_app_samples/tree/master/code/SuperFeature/Widget/FormGame) +- [Communication Between JS and C++ for Stage Model Widgets (ArkTS, API version 10)](https://gitee.com/openharmony/applications_app_samples/tree/master/code/SuperFeature/Widget/FormGame) diff --git a/en/application-dev/quick-start/app-clone.md b/en/application-dev/quick-start/app-clone.md index 5dd1eaf2f1a0fc478e62fa9f4fb4832bf1b93592..3da67196a0a30579b04f7b4ecd630f8cef0ddb7e 100644 --- a/en/application-dev/quick-start/app-clone.md +++ b/en/application-dev/quick-start/app-clone.md @@ -17,9 +17,7 @@ The input method application cannot create an application clone. ## How to Develop -1. - - Configure the [multiAppMode](app-configuration-file.md#multiappmode) field in the **AppScope/application.json5** configuration file in the project. The code snippet is as follows: +1. Configure the [multiAppMode](app-configuration-file.md#multiappmode) field in the **AppScope/application.json5** configuration file in the project. The code snippet is as follows: ```json { "app": { @@ -30,9 +28,7 @@ The input method application cannot create an application clone. } } ``` - - - + 2. Create an application clone. - Build and package the configured project and install it on the device. diff --git a/en/application-dev/quick-start/resource-categories-and-access.md b/en/application-dev/quick-start/resource-categories-and-access.md index fd82af40bd95565bddde76c1b74ba5daaea62418..6d4e6ae78d4b378bb2501c81d8bbf79f177095a9 100644 --- a/en/application-dev/quick-start/resource-categories-and-access.md +++ b/en/application-dev/quick-start/resource-categories-and-access.md @@ -65,9 +65,9 @@ Table 2 Requirements for qualifier values | Text | Indicates the script type used by the device. The value starts with one uppercase letter followed by three lowercase letters. For example, **Hans** indicates simplified Chinese, and **Hant** indicates traditional Chinese.
For details about the value range, see [ISO 15924](https://www.iso.org/standard/81905.html) (codes for the representation of names of scripts).| | Country/Region | Indicates the country or region where the user is located. The value consists of two or three uppercase letters or three digits. For example, **CN** indicates China, and **GB** indicates the United Kingdom.
For details about the value range, see [ISO 3166-1](https://www.iso.org/iso-3166-country-codes.html) (codes for the representation of names of countries and their subdivisions).| | Screen orientation | Indicates the screen orientation of the device. The value can be:
- **vertical**: portrait orientation
- **horizontal**: landscape orientation| -| Device type | Indicates the device type. The value can be:
- **car**: a telematics device
- **tablet**: tablet
- **tv**: smart TV
- **wearable**: smart wearable | | Color mode | Indicates the color mode of the device. The value can be:
- **dark**: dark mode
- **light**: light mode| | Screen density | Indicates the screen density of the device, in dpi. The value can be:
- **sdpi**: small-scale DPI. This value is applicable to devices with a DPI range of (0, 120].
- **mdpi**: medium-scale DPI. This value is applicable to devices with a DPI range of (120, 160].
- **ldpi**: large-scale DPI. This value is applicable to devices with a DPI range of (160, 240].
- **xldpi**: extra-large-scale DPI. This value is applicable to devices with a DPI range of (240, 320].
- **xxldpi**: extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (320, 480].
- **xxxldpi**: extra-extra-extra-large-scale DPI. This value is applicable to devices with a DPI range of (480, 640].| +| Device type | Indicates the device type. The value can be:
- **car**: a telematics device
- **tablet**: tablet
- **tv**: smart TV
- **wearable**: smart wearable | #### rawfile Directory @@ -323,38 +323,38 @@ The following shows the **attr** attribute configured in **string**. The **strin ![Alt text](figures/add_dependencies.png) 2. Use *[hsp].type.name*, where **hsp** indicates the HSP module name, **type** indicates the resource type, and **name** indicates the resource name. The following is an example: - - ```ts + ```ts Text($r('[hsp].string.test_string')) .fontSize($r('[hsp].float.font_size')) .fontColor($r('[hsp].color.font_color')) Image($rawfile('[hsp].icon.png')) - ``` - 3. Use variables. The following is an example: + ``` - ```ts - @Entry - @Component - struct Index { - text: string = '[hsp].string.test_string'; - fontSize: string = '[hsp].float.font_size'; - fontColor: string = '[hsp].color.font_color'; - image: string = '[hsp].media.string'; - rawfile: string = '[hsp].icon.png'; - - build() { - Row() { - Text($r(this.text)) - .fontSize($r(this.fontSize)) - .fontColor($r(this.fontColor)) - - Image($r(this.image)) - - Image($rawfile(this.rawfile)) + 3. Use variables. The following is an example: + ```ts + @Entry + @Component + struct Index { + text: string = '[hsp].string.test_string'; + fontSize: string = '[hsp].float.font_size'; + fontColor: string = '[hsp].color.font_color'; + image: string = '[hsp].media.string'; + rawfile: string = '[hsp].icon.png'; + + build() { + Row() { + Text($r(this.text)) + .fontSize($r(this.fontSize)) + .fontColor($r(this.fontColor)) + + Image($r(this.image)) + + Image($rawfile(this.rawfile)) + } } } - } - ``` + ``` + > **NOTE** > > The HSP module name must be placed in the brackets ([]). If the **rawfile** directory contains multiple levels of folders, the path must start from the first level, for example, **$rawfile('[hsp].oneFile/twoFile/icon.png')**. When **$r** or **$rawfile** is used for cross-HSP resource access, resource verification is not available at compile time, and you need to manually check that the target resources exist in the corresponding location.