@harmonyos-arkts/opencode-plugin 0.0.1 → 0.0.3

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.
Files changed (78) hide show
  1. package/dist/index.js +227 -2767
  2. package/dist/templates/application/AppScope/app.json5 +10 -0
  3. package/dist/templates/application/AppScope/resources/base/element/string.json +8 -0
  4. package/dist/templates/application/AppScope/resources/base/media/background.png +0 -0
  5. package/dist/templates/application/AppScope/resources/base/media/foreground.png +0 -0
  6. package/dist/templates/application/AppScope/resources/base/media/layered_image.json +7 -0
  7. package/dist/templates/application/build-profile.json5 +42 -0
  8. package/dist/templates/application/code-linter.json5 +32 -0
  9. package/dist/templates/application/entry/build-profile.json5 +33 -0
  10. package/dist/templates/application/entry/hvigorfile.ts +6 -0
  11. package/dist/templates/application/entry/obfuscation-rules.txt +23 -0
  12. package/dist/templates/application/entry/oh-package.json5 +10 -0
  13. package/dist/templates/application/entry/src/main/ets/entryability/EntryAbility.ets +48 -0
  14. package/dist/templates/application/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +16 -0
  15. package/dist/templates/application/entry/src/main/ets/pages/Index.ets +23 -0
  16. package/dist/templates/application/entry/src/main/module.json5 +50 -0
  17. package/dist/templates/application/entry/src/main/resources/base/element/color.json +8 -0
  18. package/dist/templates/application/entry/src/main/resources/base/element/float.json +8 -0
  19. package/dist/templates/application/entry/src/main/resources/base/element/string.json +16 -0
  20. package/dist/templates/application/entry/src/main/resources/base/media/background.png +0 -0
  21. package/dist/templates/application/entry/src/main/resources/base/media/foreground.png +0 -0
  22. package/dist/templates/application/entry/src/main/resources/base/media/layered_image.json +7 -0
  23. package/dist/templates/application/entry/src/main/resources/base/media/startIcon.png +0 -0
  24. package/dist/templates/application/entry/src/main/resources/base/profile/backup_config.json +3 -0
  25. package/dist/templates/application/entry/src/main/resources/base/profile/main_pages.json +5 -0
  26. package/dist/templates/application/entry/src/main/resources/dark/element/color.json +8 -0
  27. package/dist/templates/application/entry/src/mock/mock-config.json5 +2 -0
  28. package/dist/templates/application/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  29. package/dist/templates/application/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  30. package/dist/templates/application/entry/src/ohosTest/module.json5 +11 -0
  31. package/dist/templates/application/entry/src/test/List.test.ets +5 -0
  32. package/dist/templates/application/entry/src/test/LocalUnit.test.ets +33 -0
  33. package/dist/templates/application/hvigor/hvigor-config.json5 +23 -0
  34. package/dist/templates/application/hvigorfile.ts +6 -0
  35. package/dist/templates/application/oh-package.json5 +10 -0
  36. package/dist/templates/atomic/AppScope/app.json5 +11 -0
  37. package/dist/templates/atomic/AppScope/resources/base/element/string.json +8 -0
  38. package/dist/templates/atomic/AppScope/resources/base/media/app_icon.png +0 -0
  39. package/dist/templates/atomic/build-profile.json5 +42 -0
  40. package/dist/templates/atomic/code-linter.json5 +32 -0
  41. package/dist/templates/atomic/entry/build-profile.json5 +33 -0
  42. package/dist/templates/atomic/entry/hvigorfile.ts +6 -0
  43. package/dist/templates/atomic/entry/obfuscation-rules.txt +23 -0
  44. package/dist/templates/atomic/entry/oh-package.json5 +10 -0
  45. package/dist/templates/atomic/entry/src/main/ets/entryability/EntryAbility.ets +43 -0
  46. package/dist/templates/atomic/entry/src/main/ets/pages/Index.ets +64 -0
  47. package/dist/templates/atomic/entry/src/main/module.json5 +36 -0
  48. package/dist/templates/atomic/entry/src/main/resources/base/element/color.json +8 -0
  49. package/dist/templates/atomic/entry/src/main/resources/base/element/float.json +8 -0
  50. package/dist/templates/atomic/entry/src/main/resources/base/element/string.json +16 -0
  51. package/dist/templates/atomic/entry/src/main/resources/base/media/icon.png +0 -0
  52. package/dist/templates/atomic/entry/src/main/resources/base/media/startIcon.png +0 -0
  53. package/dist/templates/atomic/entry/src/main/resources/base/profile/main_pages.json +5 -0
  54. package/dist/templates/atomic/entry/src/mock/mock-config.json5 +2 -0
  55. package/dist/templates/atomic/entry/src/ohosTest/ets/test/Ability.test.ets +35 -0
  56. package/dist/templates/atomic/entry/src/ohosTest/ets/test/List.test.ets +5 -0
  57. package/dist/templates/atomic/entry/src/ohosTest/module.json5 +11 -0
  58. package/dist/templates/atomic/entry/src/test/List.test.ets +5 -0
  59. package/dist/templates/atomic/entry/src/test/LocalUnit.test.ets +33 -0
  60. package/dist/templates/atomic/hvigor/hvigor-config.json5 +23 -0
  61. package/dist/templates/atomic/hvigorfile.ts +6 -0
  62. package/dist/templates/atomic/oh-package.json5 +9 -0
  63. package/dist/templates/module/Index.ets +1 -0
  64. package/dist/templates/module/build-profile.json5 +36 -0
  65. package/dist/templates/module/consumer-rules.txt +0 -0
  66. package/dist/templates/module/hvigorfile.ts +6 -0
  67. package/dist/templates/module/obfuscation-rules.txt +23 -0
  68. package/dist/templates/module/oh-package.json5 +9 -0
  69. package/dist/templates/module/src/main/ets/components/MainPage.ets +19 -0
  70. package/dist/templates/module/src/main/module.json5 +9 -0
  71. package/dist/templates/module/src/main/resources/base/element/float.json +8 -0
  72. package/dist/templates/module/src/main/resources/base/element/string.json +8 -0
  73. package/dist/templates/module/src/ohosTest/ets/test/Ability.test.ets +35 -0
  74. package/dist/templates/module/src/ohosTest/ets/test/List.test.ets +5 -0
  75. package/dist/templates/module/src/ohosTest/module.json5 +11 -0
  76. package/dist/templates/module/src/test/List.test.ets +5 -0
  77. package/dist/templates/module/src/test/LocalUnit.test.ets +33 -0
  78. package/package.json +8 -3
@@ -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,6 @@
1
+ import { hapTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -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,10 @@
1
+ {
2
+ "name": "entry",
3
+ "version": "1.0.0",
4
+ "description": "Please describe the basic information.",
5
+ "main": "",
6
+ "author": "",
7
+ "license": "",
8
+ "dependencies": {}
9
+ }
10
+
@@ -0,0 +1,43 @@
1
+ import { AbilityConstant, 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
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
10
+ }
11
+
12
+ onDestroy(): void {
13
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy');
14
+ }
15
+
16
+ onWindowStageCreate(windowStage: window.WindowStage): void {
17
+ // Main window is created, set main page for this ability
18
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate');
19
+
20
+ windowStage.loadContent('pages/Index', (err) => {
21
+ if (err.code) {
22
+ hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err));
23
+ return;
24
+ }
25
+ hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.');
26
+ });
27
+ }
28
+
29
+ onWindowStageDestroy(): void {
30
+ // Main window is destroyed, release UI related resources
31
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy');
32
+ }
33
+
34
+ onForeground(): void {
35
+ // Ability has brought to foreground
36
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground');
37
+ }
38
+
39
+ onBackground(): void {
40
+ // Ability has back to background
41
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground');
42
+ }
43
+ }
@@ -0,0 +1,64 @@
1
+ import { authentication } from '@kit.AccountKit';
2
+ import { BusinessError } from '@kit.BasicServicesKit';
3
+ import { hilog } from '@kit.PerformanceAnalysisKit';
4
+
5
+ const DOMAIN = 0x0000;
6
+
7
+ @Entry
8
+ @Component
9
+ struct Index {
10
+ @State message: string = 'Hello World';
11
+
12
+ build() {
13
+ RelativeContainer() {
14
+ Text(this.message)
15
+ .id('HelloWorld')
16
+ .fontSize($r('app.float.page_text_font_size'))
17
+ .fontWeight(FontWeight.Bold)
18
+ .alignRules({
19
+ center: { anchor: '__container__', align: VerticalAlign.Center },
20
+ middle: { anchor: '__container__', align: HorizontalAlign.Center }
21
+ })
22
+ .onClick(() => {
23
+ this.message = 'Welcome';
24
+ })
25
+
26
+ }
27
+ .height('100%')
28
+ .width('100%')
29
+ }
30
+
31
+ aboutToAppear() {
32
+ hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate');
33
+ this.loginWithHuaweiID();
34
+ }
35
+
36
+ /**
37
+ * Sample code for using HUAWEI ID to log in to atomic service.
38
+ * According to the Atomic Service Review Guide, when a atomic service has an account system,
39
+ * the option to log in with a HUAWEI ID must be provided.
40
+ * The following presets the atomic service to use the HUAWEI ID silent login function.
41
+ * To enable the atomic service to log in successfully using the HUAWEI ID, please refer
42
+ * to the HarmonyOS HUAWEI ID Access Guide to configure the client ID and fingerprint certificate.
43
+ */
44
+ private loginWithHuaweiID() {
45
+ // Create a login request and set parameters
46
+ const loginRequest = new authentication.HuaweiIDProvider().createLoginWithHuaweiIDRequest();
47
+ // Whether to forcibly launch the HUAWEI ID login page when the user is not logged in with the HUAWEI ID
48
+ loginRequest.forceLogin = false;
49
+ // Execute login request
50
+ const controller = new authentication.AuthenticationController();
51
+ controller.executeRequest(loginRequest).then((data) => {
52
+ const loginWithHuaweiIDResponse = data as authentication.LoginWithHuaweiIDResponse;
53
+ const authCode = loginWithHuaweiIDResponse.data?.authorizationCode;
54
+ // Send authCode to the backend in exchange for unionID, session
55
+
56
+ }).catch((error: BusinessError) => {
57
+ hilog.error(DOMAIN, 'testTag', 'error: %{public}s', JSON.stringify(error));
58
+ if (error.code === authentication.AuthenticationErrorCode.ACCOUNT_NOT_LOGGED_IN) {
59
+ // HUAWEI ID is not logged in, it is recommended to jump to the login guide page
60
+
61
+ }
62
+ });
63
+ }
64
+ }
@@ -0,0 +1,36 @@
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": true,
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:icon",
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
+ }
36
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "color": [
3
+ {
4
+ "name": "start_window_background",
5
+ "value": "#FFFFFF"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "float": [
3
+ {
4
+ "name": "page_text_font_size",
5
+ "value": "50fp"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_desc",
5
+ "value": "module description"
6
+ },
7
+ {
8
+ "name": "EntryAbility_desc",
9
+ "value": "description"
10
+ },
11
+ {
12
+ "name": "EntryAbility_label",
13
+ "value": "label"
14
+ }
15
+ ]
16
+ }
@@ -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,5 @@
1
+ import abilityTest from './Ability.test';
2
+
3
+ export default function testsuite() {
4
+ abilityTest();
5
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "module": {
3
+ "name": "entry_test",
4
+ "type": "feature",
5
+ "deviceTypes": [
6
+ "phone"
7
+ ],
8
+ "deliveryWithInstall": true,
9
+ "installationFree": true
10
+ }
11
+ }
@@ -0,0 +1,5 @@
1
+ import localUnitTest from './LocalUnit.test';
2
+
3
+ export default function testsuite() {
4
+ localUnitTest();
5
+ }
@@ -0,0 +1,33 @@
1
+ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2
+
3
+ export default function localUnitTest() {
4
+ describe('localUnitTest', () => {
5
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6
+ beforeAll(() => {
7
+ // Presets an action, which is performed only once before all test cases of the test suite start.
8
+ // This API supports only one parameter: preset action function.
9
+ });
10
+ beforeEach(() => {
11
+ // Presets an action, which is performed before each unit test case starts.
12
+ // The number of execution times is the same as the number of test cases defined by **it**.
13
+ // This API supports only one parameter: preset action function.
14
+ });
15
+ afterEach(() => {
16
+ // Presets a clear action, which is performed after each unit test case ends.
17
+ // The number of execution times is the same as the number of test cases defined by **it**.
18
+ // This API supports only one parameter: clear action function.
19
+ });
20
+ afterAll(() => {
21
+ // Presets a clear action, which is performed after all test cases of the test suite end.
22
+ // This API supports only one parameter: clear action function.
23
+ });
24
+ it('assertContain', 0, () => {
25
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26
+ let a = 'abc';
27
+ let b = 'b';
28
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29
+ expect(a).assertContain(b);
30
+ expect(a).assertEqual(a);
31
+ });
32
+ });
33
+ }
@@ -0,0 +1,23 @@
1
+ {
2
+ "modelVersion": "6.0.1",
3
+ "dependencies": {
4
+ },
5
+ "execution": {
6
+ // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | "ultrafine" | false ]. Default: "normal" */
7
+ // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */
8
+ // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */
9
+ // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */
10
+ // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */
11
+ // "optimizationStrategy": "memory" /* Define the optimization strategy. Value: [ "memory" | "performance" ]. Default: "memory" */
12
+ },
13
+ "logging": {
14
+ // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */
15
+ },
16
+ "debugging": {
17
+ // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */
18
+ },
19
+ "nodeOptions": {
20
+ // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/
21
+ // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/
22
+ }
23
+ }
@@ -0,0 +1,6 @@
1
+ import { appTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "modelVersion": "6.0.1",
3
+ "description": "Please describe the basic information.",
4
+ "dependencies": {
5
+ },
6
+ "devDependencies": {
7
+
8
+ }
9
+ }
@@ -0,0 +1 @@
1
+ export { MainPage } from './src/main/ets/components/MainPage';
@@ -0,0 +1,36 @@
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
+ "consumerFiles": [
22
+ "./consumer-rules.txt"
23
+ ]
24
+ }
25
+ },
26
+ },
27
+ ],
28
+ "targets": [
29
+ {
30
+ "name": "default"
31
+ },
32
+ {
33
+ "name": "ohosTest"
34
+ }
35
+ ]
36
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ import { harTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins: [] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -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,9 @@
1
+ {
2
+ "name": "library",
3
+ "version": "1.0.0",
4
+ "description": "Please describe the basic information.",
5
+ "main": "Index.ets",
6
+ "author": "",
7
+ "license": "Apache-2.0",
8
+ "dependencies": {}
9
+ }
@@ -0,0 +1,19 @@
1
+ @Component
2
+ export struct MainPage {
3
+ @State message: string = 'Hello World';
4
+
5
+ build() {
6
+ Row() {
7
+ Column() {
8
+ Text(this.message)
9
+ .fontSize($r('app.float.page_text_font_size'))
10
+ .fontWeight(FontWeight.Bold)
11
+ .onClick(() => {
12
+ this.message = 'Welcome';
13
+ })
14
+ }
15
+ .width('100%')
16
+ }
17
+ .height('100%')
18
+ }
19
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "module": {
3
+ "name": "library",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "phone"
7
+ ]
8
+ }
9
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "float": [
3
+ {
4
+ "name": "page_text_font_size",
5
+ "value": "50fp"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -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,5 @@
1
+ import abilityTest from './Ability.test';
2
+
3
+ export default function testsuite() {
4
+ abilityTest();
5
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "module": {
3
+ "name": "library_test",
4
+ "type": "feature",
5
+ "deviceTypes": [
6
+ "phone"
7
+ ],
8
+ "deliveryWithInstall": true,
9
+ "installationFree": true
10
+ }
11
+ }
@@ -0,0 +1,5 @@
1
+ import localUnitTest from './LocalUnit.test';
2
+
3
+ export default function testsuite() {
4
+ localUnitTest();
5
+ }
@@ -0,0 +1,33 @@
1
+ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
2
+
3
+ export default function localUnitTest() {
4
+ describe('localUnitTest', () => {
5
+ // Defines a test suite. Two parameters are supported: test suite name and test suite function.
6
+ beforeAll(() => {
7
+ // Presets an action, which is performed only once before all test cases of the test suite start.
8
+ // This API supports only one parameter: preset action function.
9
+ });
10
+ beforeEach(() => {
11
+ // Presets an action, which is performed before each unit test case starts.
12
+ // The number of execution times is the same as the number of test cases defined by **it**.
13
+ // This API supports only one parameter: preset action function.
14
+ });
15
+ afterEach(() => {
16
+ // Presets a clear action, which is performed after each unit test case ends.
17
+ // The number of execution times is the same as the number of test cases defined by **it**.
18
+ // This API supports only one parameter: clear action function.
19
+ });
20
+ afterAll(() => {
21
+ // Presets a clear action, which is performed after all test cases of the test suite end.
22
+ // This API supports only one parameter: clear action function.
23
+ });
24
+ it('assertContain', 0, () => {
25
+ // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function.
26
+ let a = 'abc';
27
+ let b = 'b';
28
+ // Defines a variety of assertion methods, which are used to declare expected boolean conditions.
29
+ expect(a).assertContain(b);
30
+ expect(a).assertEqual(a);
31
+ });
32
+ });
33
+ }