@harmonyos-arkts/droid2hmos 0.0.0-stage → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +249 -3
- package/config/preflight-checklist.json +65 -0
- package/dist/cli.js +8994 -0
- package/dist/cli.js.map +1 -0
- package/package.json +36 -6
- package/templates/ohos/AppScope/app.json5 +10 -0
- package/templates/ohos/AppScope/resources/base/element/string.json +8 -0
- package/templates/ohos/AppScope/resources/base/media/background.png +0 -0
- package/templates/ohos/AppScope/resources/base/media/foreground.png +0 -0
- package/templates/ohos/AppScope/resources/base/media/layered_image.json +7 -0
- package/templates/ohos/build-profile.json5 +42 -0
- package/templates/ohos/code-linter.json5 +32 -0
- package/templates/ohos/entry/build-profile.json5 +33 -0
- package/templates/ohos/entry/hvigorfile.ts +6 -0
- package/templates/ohos/entry/obfuscation-rules.txt +23 -0
- package/templates/ohos/entry/oh-package.json5 +10 -0
- package/templates/ohos/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
- package/templates/ohos/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
- package/templates/ohos/entry/src/main/ets/pages/Index.ets +23 -0
- package/templates/ohos/entry/src/main/module.json5 +50 -0
- package/templates/ohos/entry/src/main/resources/base/element/color.json +8 -0
- package/templates/ohos/entry/src/main/resources/base/element/float.json +8 -0
- package/templates/ohos/entry/src/main/resources/base/element/string.json +16 -0
- package/templates/ohos/entry/src/main/resources/base/media/background.png +0 -0
- package/templates/ohos/entry/src/main/resources/base/media/foreground.png +0 -0
- package/templates/ohos/entry/src/main/resources/base/media/layered_image.json +7 -0
- package/templates/ohos/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/templates/ohos/entry/src/main/resources/base/profile/backup_config.json +3 -0
- package/templates/ohos/entry/src/main/resources/base/profile/main_pages.json +5 -0
- package/templates/ohos/entry/src/main/resources/dark/element/color.json +8 -0
- package/templates/ohos/entry/src/mock/mock-config.json5 +2 -0
- package/templates/ohos/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
- package/templates/ohos/entry/src/ohosTest/ets/test/List.test.ets +5 -0
- package/templates/ohos/entry/src/ohosTest/ets/testability/TestAbility.ets +48 -0
- package/templates/ohos/entry/src/ohosTest/ets/testability/pages/Index.ets +14 -0
- package/templates/ohos/entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +41 -0
- package/templates/ohos/entry/src/ohosTest/module.json5 +25 -0
- package/templates/ohos/entry/src/ohosTest/resources/base/element/color.json +8 -0
- package/templates/ohos/entry/src/ohosTest/resources/base/element/string.json +12 -0
- package/templates/ohos/entry/src/ohosTest/resources/base/media/icon.png +0 -0
- package/templates/ohos/entry/src/ohosTest/resources/base/profile/test_pages.json +5 -0
- package/templates/ohos/entry/src/test/List.test.ets +5 -0
- package/templates/ohos/entry/src/test/LocalUnit.test.ets +33 -0
- package/templates/ohos/hvigor/hvigor-config.json5 +23 -0
- package/templates/ohos/hvigorfile.ts +6 -0
- package/templates/ohos/oh-package-lock.json5 +28 -0
- package/templates/ohos/oh-package.json5 +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,36 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@harmonyos-arkts/droid2hmos",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@harmonyos-arkts/droid2hmos",
|
|
3
|
+
"version": "0.0.8",
|
|
4
|
+
"description": "Report-driven Android to HarmonyOS migration CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"droid2hmos": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist/",
|
|
11
|
+
"config/",
|
|
12
|
+
"templates/",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"typecheck": "tsc --noEmit",
|
|
18
|
+
"build": "tsup",
|
|
19
|
+
"test": "npm run build && tsx --test test/*.test.ts",
|
|
20
|
+
"verify": "npm run typecheck && npm run build && tsx --test test/*.test.ts"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"jpeg-js": "^0.4.4",
|
|
24
|
+
"json5": "^2.2.3"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=20 <25"
|
|
28
|
+
},
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@types/node": "^26.4.0",
|
|
32
|
+
"tsup": "^8.5.1",
|
|
33
|
+
"tsx": "^4.23.13",
|
|
34
|
+
"typescript": "^7.0.2"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"app": {
|
|
3
|
+
"signingConfigs": [],
|
|
4
|
+
"products": [
|
|
5
|
+
{
|
|
6
|
+
"name": "default",
|
|
7
|
+
"signingConfig": "default",
|
|
8
|
+
"targetSdkVersion": "6.0.2(22)",
|
|
9
|
+
"compatibleSdkVersion": "5.0.0(12)",
|
|
10
|
+
"runtimeOS": "HarmonyOS",
|
|
11
|
+
"buildOption": {
|
|
12
|
+
"strictMode": {
|
|
13
|
+
"caseSensitiveCheck": true,
|
|
14
|
+
"useNormalizedOHMUrl": true
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"buildModeSet": [
|
|
20
|
+
{
|
|
21
|
+
"name": "debug",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "release"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
"modules": [
|
|
29
|
+
{
|
|
30
|
+
"name": "entry",
|
|
31
|
+
"srcPath": "./entry",
|
|
32
|
+
"targets": [
|
|
33
|
+
{
|
|
34
|
+
"name": "default",
|
|
35
|
+
"applyToProducts": [
|
|
36
|
+
"default"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
]
|
|
42
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"files": [
|
|
3
|
+
"**/*.ets"
|
|
4
|
+
],
|
|
5
|
+
"ignore": [
|
|
6
|
+
"**/src/ohosTest/**/*",
|
|
7
|
+
"**/src/test/**/*",
|
|
8
|
+
"**/src/mock/**/*",
|
|
9
|
+
"**/node_modules/**/*",
|
|
10
|
+
"**/oh_modules/**/*",
|
|
11
|
+
"**/build/**/*",
|
|
12
|
+
"**/.preview/**/*"
|
|
13
|
+
],
|
|
14
|
+
"ruleSet": [
|
|
15
|
+
"plugin:@performance/recommended",
|
|
16
|
+
"plugin:@typescript-eslint/recommended"
|
|
17
|
+
],
|
|
18
|
+
"rules": {
|
|
19
|
+
"@security/no-unsafe-aes": "error",
|
|
20
|
+
"@security/no-unsafe-hash": "error",
|
|
21
|
+
"@security/no-unsafe-mac": "warn",
|
|
22
|
+
"@security/no-unsafe-dh": "error",
|
|
23
|
+
"@security/no-unsafe-dsa": "error",
|
|
24
|
+
"@security/no-unsafe-ecdsa": "error",
|
|
25
|
+
"@security/no-unsafe-rsa-encrypt": "error",
|
|
26
|
+
"@security/no-unsafe-rsa-sign": "error",
|
|
27
|
+
"@security/no-unsafe-rsa-key": "error",
|
|
28
|
+
"@security/no-unsafe-dsa-key": "error",
|
|
29
|
+
"@security/no-unsafe-dh-key": "error",
|
|
30
|
+
"@security/no-unsafe-3des": "error"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"apiType": "stageMode",
|
|
3
|
+
"buildOption": {
|
|
4
|
+
"resOptions": {
|
|
5
|
+
"copyCodeResource": {
|
|
6
|
+
"enable": false
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
"buildOptionSet": [
|
|
11
|
+
{
|
|
12
|
+
"name": "release",
|
|
13
|
+
"arkOptions": {
|
|
14
|
+
"obfuscation": {
|
|
15
|
+
"ruleOptions": {
|
|
16
|
+
"enable": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"./obfuscation-rules.txt"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
"targets": [
|
|
26
|
+
{
|
|
27
|
+
"name": "default"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"name": "ohosTest",
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Define project specific obfuscation rules here.
|
|
2
|
+
# You can include the obfuscation configuration files in the current module's build-profile.json5.
|
|
3
|
+
#
|
|
4
|
+
# For more details, see
|
|
5
|
+
# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/source-obfuscation
|
|
6
|
+
|
|
7
|
+
# Obfuscation options:
|
|
8
|
+
# -disable-obfuscation: disable all obfuscations
|
|
9
|
+
# -enable-property-obfuscation: obfuscate the property names
|
|
10
|
+
# -enable-toplevel-obfuscation: obfuscate the names in the global scope
|
|
11
|
+
# -compact: remove unnecessary blank spaces and all line feeds
|
|
12
|
+
# -remove-log: remove all console.* statements
|
|
13
|
+
# -print-namecache: print the name cache that contains the mapping from the old names to new names
|
|
14
|
+
# -apply-namecache: reuse the given cache file
|
|
15
|
+
|
|
16
|
+
# Keep options:
|
|
17
|
+
# -keep-property-name: specifies property names that you want to keep
|
|
18
|
+
# -keep-global-name: specifies names that you want to keep in the global scope
|
|
19
|
+
|
|
20
|
+
-enable-property-obfuscation
|
|
21
|
+
-enable-toplevel-obfuscation
|
|
22
|
+
-enable-filename-obfuscation
|
|
23
|
+
-enable-export-obfuscation
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit';
|
|
2
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
3
|
+
import { window } from '@kit.ArkUI';
|
|
4
|
+
|
|
5
|
+
const DOMAIN = 0x0000;
|
|
6
|
+
|
|
7
|
+
export default class EntryAbility extends UIAbility {
|
|
8
|
+
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
9
|
+
try {
|
|
10
|
+
this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET);
|
|
11
|
+
} catch (err) {
|
|
12
|
+
hilog.error(DOMAIN, 'testTag', 'Failed to set colorMode. Cause: %{public}s', JSON.stringify(err));
|
|
13
|
+
}
|
|
14
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
onDestroy(): void {
|
|
18
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
22
|
+
// Main window is created, set main page for this ability
|
|
23
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
|
|
24
|
+
|
|
25
|
+
windowStage.loadContent('pages/Index', (err) => {
|
|
26
|
+
if (err.code) {
|
|
27
|
+
hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
onWindowStageDestroy(): void {
|
|
35
|
+
// Main window is destroyed, release UI related resources
|
|
36
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onForeground(): void {
|
|
40
|
+
// Ability has brought to foreground
|
|
41
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
onBackground(): void {
|
|
45
|
+
// Ability has back to background
|
|
46
|
+
hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
2
|
+
import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit';
|
|
3
|
+
|
|
4
|
+
const DOMAIN = 0x0000;
|
|
5
|
+
|
|
6
|
+
export default class EntryBackupAbility extends BackupExtensionAbility {
|
|
7
|
+
async onBackup() {
|
|
8
|
+
hilog.info(DOMAIN, 'testTag', 'onBackup ok');
|
|
9
|
+
await Promise.resolve();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async onRestore(bundleVersion: BundleVersion) {
|
|
13
|
+
hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion));
|
|
14
|
+
await Promise.resolve();
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@Entry
|
|
2
|
+
@Component
|
|
3
|
+
struct Index {
|
|
4
|
+
@State message: string = 'Hello World';
|
|
5
|
+
|
|
6
|
+
build() {
|
|
7
|
+
RelativeContainer() {
|
|
8
|
+
Text(this.message)
|
|
9
|
+
.id('HelloWorld')
|
|
10
|
+
.fontSize($r('app.float.page_text_font_size'))
|
|
11
|
+
.fontWeight(FontWeight.Bold)
|
|
12
|
+
.alignRules({
|
|
13
|
+
center: { anchor: '__container__', align: VerticalAlign.Center },
|
|
14
|
+
middle: { anchor: '__container__', align: HorizontalAlign.Center }
|
|
15
|
+
})
|
|
16
|
+
.onClick(() => {
|
|
17
|
+
this.message = 'Welcome';
|
|
18
|
+
})
|
|
19
|
+
}
|
|
20
|
+
.height('100%')
|
|
21
|
+
.width('100%')
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"module": {
|
|
3
|
+
"name": "entry",
|
|
4
|
+
"type": "entry",
|
|
5
|
+
"description": "$string:module_desc",
|
|
6
|
+
"mainElement": "EntryAbility",
|
|
7
|
+
"deviceTypes": [
|
|
8
|
+
"phone"
|
|
9
|
+
],
|
|
10
|
+
"deliveryWithInstall": true,
|
|
11
|
+
"installationFree": false,
|
|
12
|
+
"pages": "$profile:main_pages",
|
|
13
|
+
"abilities": [
|
|
14
|
+
{
|
|
15
|
+
"name": "EntryAbility",
|
|
16
|
+
"srcEntry": "./ets/entryability/EntryAbility.ets",
|
|
17
|
+
"description": "$string:EntryAbility_desc",
|
|
18
|
+
"icon": "$media:layered_image",
|
|
19
|
+
"label": "$string:EntryAbility_label",
|
|
20
|
+
"startWindowIcon": "$media:startIcon",
|
|
21
|
+
"startWindowBackground": "$color:start_window_background",
|
|
22
|
+
"exported": true,
|
|
23
|
+
"skills": [
|
|
24
|
+
{
|
|
25
|
+
"entities": [
|
|
26
|
+
"entity.system.home"
|
|
27
|
+
],
|
|
28
|
+
"actions": [
|
|
29
|
+
"ohos.want.action.home"
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
"extensionAbilities": [
|
|
36
|
+
{
|
|
37
|
+
"name": "EntryBackupAbility",
|
|
38
|
+
"srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets",
|
|
39
|
+
"type": "backup",
|
|
40
|
+
"exported": false,
|
|
41
|
+
"metadata": [
|
|
42
|
+
{
|
|
43
|
+
"name": "ohos.extension.backup",
|
|
44
|
+
"resource": "$profile:backup_config"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
}
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
2
|
+
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
|
3
|
+
|
|
4
|
+
export default function abilityTest() {
|
|
5
|
+
describe('ActsAbilityTest', () => {
|
|
6
|
+
// Defines a test suite. Two parameters are supported: test suite name and test suite function.
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
// Presets an action, which is performed only once before all test cases of the test suite start.
|
|
9
|
+
// This API supports only one parameter: preset action function.
|
|
10
|
+
})
|
|
11
|
+
beforeEach(() => {
|
|
12
|
+
// Presets an action, which is performed before each unit test case starts.
|
|
13
|
+
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
14
|
+
// This API supports only one parameter: preset action function.
|
|
15
|
+
})
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
// Presets a clear action, which is performed after each unit test case ends.
|
|
18
|
+
// The number of execution times is the same as the number of test cases defined by **it**.
|
|
19
|
+
// This API supports only one parameter: clear action function.
|
|
20
|
+
})
|
|
21
|
+
afterAll(() => {
|
|
22
|
+
// Presets a clear action, which is performed after all test cases of the test suite end.
|
|
23
|
+
// This API supports only one parameter: clear action function.
|
|
24
|
+
})
|
|
25
|
+
it('assertContain', 0, () => {
|
|
26
|
+
// Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
|
|
27
|
+
hilog.info(0x0000, 'testTag', '%{public}s', 'it begin');
|
|
28
|
+
let a = 'abc';
|
|
29
|
+
let b = 'b';
|
|
30
|
+
// Defines a variety of assertion methods, which are used to declare expected boolean conditions.
|
|
31
|
+
expect(a).assertContain(b);
|
|
32
|
+
expect(a).assertEqual(a);
|
|
33
|
+
})
|
|
34
|
+
})
|
|
35
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit';
|
|
2
|
+
import { abilityDelegatorRegistry } from '@kit.TestKit';
|
|
3
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
4
|
+
import { window } from '@kit.ArkUI';
|
|
5
|
+
import { Hypium } from '@ohos/hypium';
|
|
6
|
+
import tests from '../test/List.test.ets';
|
|
7
|
+
|
|
8
|
+
const DOMAIN = 0x0F00;
|
|
9
|
+
const TAG = 'TestAbility';
|
|
10
|
+
|
|
11
|
+
export default class TestAbility extends UIAbility {
|
|
12
|
+
private abilityDelegator: abilityDelegatorRegistry.AbilityDelegator =
|
|
13
|
+
abilityDelegatorRegistry.getAbilityDelegator();
|
|
14
|
+
|
|
15
|
+
onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {
|
|
16
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'TestAbility onCreate');
|
|
17
|
+
const args = abilityDelegatorRegistry.getArguments();
|
|
18
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'start run testcase!!!');
|
|
19
|
+
Hypium.hypiumTest(this.abilityDelegator, args, tests);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
onDestroy(): void {
|
|
23
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'TestAbility onDestroy');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
onWindowStageCreate(windowStage: window.WindowStage): void {
|
|
27
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'TestAbility onWindowStageCreate');
|
|
28
|
+
windowStage.loadContent('testability/pages/Index', (err) => {
|
|
29
|
+
if (err.code) {
|
|
30
|
+
hilog.error(DOMAIN, TAG, 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
hilog.info(DOMAIN, TAG, 'Succeeded in loading the content.');
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onWindowStageDestroy(): void {
|
|
38
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'TestAbility onWindowStageDestroy');
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
onForeground(): void {
|
|
42
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'TestAbility onForeground');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
onBackground(): void {
|
|
46
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'TestAbility onBackground');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { abilityDelegatorRegistry, TestRunner } from '@kit.TestKit';
|
|
2
|
+
import { UIAbility, Want } from '@kit.AbilityKit';
|
|
3
|
+
import { BusinessError } from '@kit.BasicServicesKit';
|
|
4
|
+
import { hilog } from '@kit.PerformanceAnalysisKit';
|
|
5
|
+
|
|
6
|
+
const DOMAIN = 0x0F00;
|
|
7
|
+
const TAG = 'TestRunner';
|
|
8
|
+
|
|
9
|
+
export default class OpenHarmonyTestRunner implements TestRunner {
|
|
10
|
+
constructor() {
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
onPrepare(): void {
|
|
14
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'OpenHarmonyTestRunner onPrepare');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async onRun(): Promise<void> {
|
|
18
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'OpenHarmonyTestRunner onRun run');
|
|
19
|
+
const abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
|
|
20
|
+
const args = abilityDelegatorRegistry.getArguments();
|
|
21
|
+
const moduleName: string = args.parameters['-m'] as string;
|
|
22
|
+
const bundleName: string = args.bundleName;
|
|
23
|
+
const testAbilityName: string = 'TestAbility';
|
|
24
|
+
const monitor: abilityDelegatorRegistry.AbilityMonitor = {
|
|
25
|
+
abilityName: testAbilityName,
|
|
26
|
+
moduleName: moduleName
|
|
27
|
+
};
|
|
28
|
+
abilityDelegator.addAbilityMonitor(monitor, (err: BusinessError) => {
|
|
29
|
+
hilog.info(DOMAIN, TAG, 'addAbilityMonitor: %{public}s', JSON.stringify(err) ?? '');
|
|
30
|
+
});
|
|
31
|
+
const want: Want = {
|
|
32
|
+
bundleName: bundleName,
|
|
33
|
+
abilityName: testAbilityName,
|
|
34
|
+
moduleName: moduleName
|
|
35
|
+
};
|
|
36
|
+
abilityDelegator.startAbility(want, (err: BusinessError) => {
|
|
37
|
+
hilog.info(DOMAIN, TAG, 'startAbility err: %{public}s', JSON.stringify(err) ?? '');
|
|
38
|
+
});
|
|
39
|
+
hilog.info(DOMAIN, TAG, '%{public}s', 'OpenHarmonyTestRunner onRun end');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"module": {
|
|
3
|
+
"name": "entry_test",
|
|
4
|
+
"type": "feature",
|
|
5
|
+
"deviceTypes": [
|
|
6
|
+
"phone"
|
|
7
|
+
],
|
|
8
|
+
"deliveryWithInstall": true,
|
|
9
|
+
"installationFree": false,
|
|
10
|
+
"mainElement": "TestAbility",
|
|
11
|
+
"pages": "$profile:test_pages",
|
|
12
|
+
"abilities": [
|
|
13
|
+
{
|
|
14
|
+
"name": "TestAbility",
|
|
15
|
+
"srcEntry": "./ets/testability/TestAbility.ets",
|
|
16
|
+
"description": "$string:TestAbility_desc",
|
|
17
|
+
"icon": "$media:icon",
|
|
18
|
+
"label": "$string:TestAbility_label",
|
|
19
|
+
"exported": true,
|
|
20
|
+
"startWindowIcon": "$media:icon",
|
|
21
|
+
"startWindowBackground": "$color:start_window_background"
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
Binary file
|