@react-native-ohos/react-native-system-setting 1.7.7-rc.1 → 1.7.7-rc.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 (62) hide show
  1. package/API.md +57 -57
  2. package/CHANGELOG.md +206 -0
  3. package/COMMITTERS.md +7 -0
  4. package/LICENSE +21 -21
  5. package/LICENSE.md +21 -21
  6. package/OAT.xml +81 -0
  7. package/RCTSystemSetting.podspec +20 -20
  8. package/README.OpenSource +10 -10
  9. package/README.md +15 -15
  10. package/SystemSetting.d.ts +81 -81
  11. package/SystemSetting.js +347 -347
  12. package/Utils.js +11 -11
  13. package/harmony/react_native_system_setting/Index.ets +28 -27
  14. package/harmony/react_native_system_setting/build-profile.json5 +31 -31
  15. package/harmony/react_native_system_setting/hvigorfile.ts +6 -6
  16. package/harmony/react_native_system_setting/obfuscation-rules.txt +17 -17
  17. package/harmony/react_native_system_setting/oh-package.json5 +10 -10
  18. package/harmony/react_native_system_setting/src/main/cpp/CMakeLists.txt +5 -3
  19. package/harmony/react_native_system_setting/src/main/cpp/SystemSettingPackage.h +36 -0
  20. package/harmony/react_native_system_setting/src/main/cpp/{RNSystemSettingPackage.h → generated/RNOH/generated/BaseReactNativeSystemSettingPackage.h} +65 -76
  21. package/harmony/react_native_system_setting/src/main/cpp/{ReactNativeSystemSetting.cpp → generated/RNOH/generated/turbo_modules/ReactNativeSystemSetting.cpp} +47 -54
  22. package/harmony/react_native_system_setting/src/main/cpp/{ReactNativeSystemSetting.h → generated/RNOH/generated/turbo_modules/ReactNativeSystemSetting.h} +16 -21
  23. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/ComponentDescriptors.h +22 -0
  24. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/EventEmitters.cpp +18 -0
  25. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/EventEmitters.h +19 -0
  26. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/Props.cpp +21 -0
  27. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/Props.h +20 -0
  28. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/ShadowNodes.cpp +19 -0
  29. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/ShadowNodes.h +25 -0
  30. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/States.cpp +18 -0
  31. package/harmony/react_native_system_setting/src/main/cpp/generated/react/renderer/components/react_native_system_setting/States.h +23 -0
  32. package/harmony/react_native_system_setting/src/main/ets/Logger.ts +63 -63
  33. package/harmony/react_native_system_setting/src/main/ets/{RNSystemSettingPackage.ts → RNSystemSettingPackage.ets} +52 -51
  34. package/harmony/react_native_system_setting/src/main/ets/RNSystemSettingTurboModule.ts +346 -361
  35. package/harmony/react_native_system_setting/src/main/ets/generated/components/ts.ts +5 -5
  36. package/harmony/react_native_system_setting/src/main/ets/generated/index.ets +5 -8
  37. package/harmony/react_native_system_setting/src/main/ets/generated/ts.ts +6 -9
  38. package/harmony/react_native_system_setting/src/main/ets/generated/turboModules/ReactNativeSystemSetting.ts +78 -86
  39. package/harmony/react_native_system_setting/src/main/ets/generated/turboModules/ts.ts +5 -8
  40. package/harmony/react_native_system_setting/src/main/module.json5 +9 -9
  41. package/harmony/react_native_system_setting/src/main/resources/base/element/string.json +8 -8
  42. package/harmony/react_native_system_setting/src/main/resources/en_US/element/string.json +8 -8
  43. package/harmony/react_native_system_setting/src/main/resources/zh_CN/element/string.json +8 -8
  44. package/harmony/react_native_system_setting/src/mock/mock-config.json5 +2 -0
  45. package/harmony/react_native_system_setting/src/ohosTest/ets/test/Ability.test.ets +35 -0
  46. package/harmony/react_native_system_setting/src/ohosTest/ets/test/List.test.ets +5 -0
  47. package/harmony/react_native_system_setting/src/ohosTest/ets/testability/TestAbility.ets +47 -0
  48. package/harmony/react_native_system_setting/src/ohosTest/ets/testability/pages/Index.ets +17 -0
  49. package/harmony/react_native_system_setting/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ets +90 -0
  50. package/harmony/react_native_system_setting/src/ohosTest/module.json5 +36 -0
  51. package/harmony/react_native_system_setting/src/ohosTest/resources/base/element/color.json +8 -0
  52. package/harmony/react_native_system_setting/src/ohosTest/resources/base/element/string.json +16 -0
  53. package/harmony/react_native_system_setting/src/ohosTest/resources/base/media/icon.png +0 -0
  54. package/harmony/react_native_system_setting/src/ohosTest/resources/base/profile/test_pages.json +5 -0
  55. package/harmony/react_native_system_setting/src/test/List.test.ets +5 -0
  56. package/harmony/react_native_system_setting/src/test/LocalUnit.test.ets +33 -0
  57. package/harmony/react_native_system_setting/{ts.ts → ts.ets} +24 -24
  58. package/harmony/react_native_system_setting.har +0 -0
  59. package/iOS.md +101 -0
  60. package/package.json +48 -46
  61. package/src/ReactRNSystemSetting.ts +108 -112
  62. package/harmony/react_native_system_setting/BuildProfile.ets +0 -6
@@ -1,5 +1,5 @@
1
-
2
- /**
3
- */
4
-
5
- export {}
1
+
2
+ /**
3
+ */
4
+
5
+ export {}
@@ -1,8 +1,5 @@
1
- /**
2
- * This code was generated by "react-native codegen-harmony"
3
- *
4
- * Do not edit this file as changes may cause incorrect behavior and will be
5
- * lost once the code is regenerated.
6
- */
7
-
8
- export * from "./ts"
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * from "./ts"
@@ -1,9 +1,6 @@
1
- /**
2
- * This code was generated by "react-native codegen-harmony"
3
- *
4
- * Do not edit this file as changes may cause incorrect behavior and will be
5
- * lost once the code is regenerated.
6
- */
7
-
8
- export * as RNC from "./components/ts"
9
- export * as TM from "./turboModules/ts"
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * as RNC from "./components/ts"
6
+ export * as TM from "./turboModules/ts"
@@ -1,86 +1,78 @@
1
- /**
2
- * This code was generated by "react-native codegen-harmony"
3
- *
4
- * Do not edit this file as changes may cause incorrect behavior and will be
5
- * lost once the code is regenerated.
6
- *
7
- * @generatorVersion: 1
8
- */
9
-
10
-
11
- export namespace ReactNativeSystemSetting {
12
- export const NAME = 'ReactNativeSystemSetting' as const
13
-
14
- export type EmitterSubscription = {remove: Object, type: unknown}
15
-
16
- export interface Spec {
17
- getBrightness(): Promise<number>;
18
-
19
- setBrightness(val: number): Promise<boolean>;
20
-
21
- setBrightnessForce(val: number): Promise<boolean>;
22
-
23
- getAppBrightness(): Promise<number>;
24
-
25
- setAppBrightness(val: number): Promise<boolean>;
26
-
27
- grantWriteSettingPremission(): void;
28
-
29
- getScreenMode(): Promise<number>;
30
-
31
- setScreenMode(val: number): Promise<boolean>;
32
-
33
- saveBrightness(): Promise<void>;
34
-
35
- restoreBrightness(): number;
36
-
37
- getVolume(type: unknown): Promise<number>;
38
-
39
- setVolume(value: number, config: Object): void;
40
-
41
- addVolumeListener(): void;
42
-
43
- removeVolumeListener(listener: EmitterSubscription): void;
44
-
45
- isWifiEnabled(): Promise<boolean>;
46
-
47
- switchWifiSilence(onComplete: () => void): void;
48
-
49
- switchWifi(onComplete: () => void): void;
50
-
51
- isLocationEnabled(): Promise<boolean>;
52
-
53
- getLocationMode(): Promise<number>;
54
-
55
- switchLocation(onComplete: () => void): void;
56
-
57
- isBluetoothEnabled(): Promise<boolean>;
58
-
59
- switchBluetooth(onComplete: () => void): void;
60
-
61
- switchBluetoothSilence(onComplete: () => void): void;
62
-
63
- isAirplaneEnabled(): Promise<boolean>;
64
-
65
- switchAirplane(onComplete: () => void): void;
66
-
67
- openAppSystemSettings(): void;
68
-
69
- addBluetoothListener(): void;
70
-
71
- addWifiListener(callback: (wifiEnabled: boolean) => void): Promise<null | EmitterSubscription>;
72
-
73
- addLocationListener(callback: (locationEnabled: boolean) => void): Promise<null | EmitterSubscription>;
74
-
75
- addLocationModeListener(callback: (locationMode: number) => void): Promise<null | EmitterSubscription>;
76
-
77
- addAirplaneListener(callback: (airplaneModeEnabled: boolean) => void): Promise<null | EmitterSubscription>;
78
-
79
- removeListener(type: string): void;
80
-
81
- addListener(eventName: string): void;
82
-
83
- removeListeners(count: number): void;
84
-
85
- }
86
- }
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ import { Tag } from "@rnoh/react-native-openharmony/ts"
6
+
7
+ export namespace ReactNativeSystemSetting {
8
+ export const NAME = 'ReactNativeSystemSetting' as const
9
+
10
+ export type EmitterSubscription = {remove: Object, type: string}
11
+
12
+ export interface Spec {
13
+ getBrightness(): Promise<number>;
14
+
15
+ setBrightness(val: number): Promise<boolean>;
16
+
17
+ setBrightnessForce(val: number): Promise<boolean>;
18
+
19
+ getAppBrightness(): Promise<number>;
20
+
21
+ setAppBrightness(val: number): Promise<boolean>;
22
+
23
+ grantWriteSettingPremission(): void;
24
+
25
+ getScreenMode(): Promise<number>;
26
+
27
+ setScreenMode(val: number): Promise<boolean>;
28
+
29
+ saveBrightness(): Promise<void>;
30
+
31
+ restoreBrightness(): number;
32
+
33
+ getVolume(type: string): Promise<number>;
34
+
35
+ setVolume(value: number, config: Object): void;
36
+
37
+ addVolumeListener(): void;
38
+
39
+ removeVolumeListener(listener: EmitterSubscription): void;
40
+
41
+ isWifiEnabled(): Promise<boolean>;
42
+
43
+ switchWifiSilence(onComplete: () => void): void;
44
+
45
+ switchWifi(onComplete: () => void): void;
46
+
47
+ isLocationEnabled(): Promise<boolean>;
48
+
49
+ getLocationMode(): Promise<number>;
50
+
51
+ switchLocation(onComplete: () => void): void;
52
+
53
+ isBluetoothEnabled(): Promise<boolean>;
54
+
55
+ switchBluetooth(onComplete: () => void): void;
56
+
57
+ switchBluetoothSilence(onComplete: () => void): void;
58
+
59
+ isAirplaneEnabled(): Promise<boolean>;
60
+
61
+ switchAirplane(onComplete: () => void): void;
62
+
63
+ openAppSystemSettings(): void;
64
+
65
+ addBluetoothListener(): void;
66
+
67
+ addWifiListener(callback: (wifiEnabled: boolean) => void): Promise<null | EmitterSubscription>;
68
+
69
+ addLocationListener(callback: (locationEnabled: boolean) => void): Promise<null | EmitterSubscription>;
70
+
71
+ addLocationModeListener(callback: (locationMode: number) => void): Promise<null | EmitterSubscription>;
72
+
73
+ addAirplaneListener(callback: (airplaneModeEnabled: boolean) => void): Promise<null | EmitterSubscription>;
74
+
75
+ removeListener(type: string): void;
76
+
77
+ }
78
+ }
@@ -1,8 +1,5 @@
1
- /**
2
- * This code was generated by "react-native codegen-harmony"
3
- *
4
- * Do not edit this file as changes may cause incorrect behavior and will be
5
- * lost once the code is regenerated.
6
- */
7
-
8
- export * from "./ReactNativeSystemSetting"
1
+ /**
2
+ * This code was generated by "react-native codegen-lib-harmony"
3
+ */
4
+
5
+ export * from "./ReactNativeSystemSetting"
@@ -1,9 +1,9 @@
1
- {
2
- "module": {
3
- "name": "react_native_system_setting",
4
- "type": "har",
5
- "deviceTypes": [
6
- "default"
7
- ]
8
- }
9
- }
1
+ {
2
+ "module": {
3
+ "name": "react_native_system_setting",
4
+ "type": "har",
5
+ "deviceTypes": [
6
+ "default"
7
+ ]
8
+ }
9
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
8
- }
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from package"
6
+ }
7
+ ]
8
+ }
@@ -1,8 +1,8 @@
1
- {
2
- "string": [
3
- {
4
- "name": "page_show",
5
- "value": "page from package"
6
- }
7
- ]
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,47 @@
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 testsuite from '../test/List.test';
7
+
8
+ export default class TestAbility extends UIAbility {
9
+ onCreate(want: Want, launchParam: AbilityConstant.LaunchParam) {
10
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate');
11
+ hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? '');
12
+ hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:' + JSON.stringify(launchParam) ?? '');
13
+ let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator;
14
+ abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator();
15
+ let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs;
16
+ abilityDelegatorArguments = abilityDelegatorRegistry.getArguments();
17
+ hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!');
18
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite);
19
+ }
20
+
21
+ onDestroy() {
22
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy');
23
+ }
24
+
25
+ onWindowStageCreate(windowStage: window.WindowStage) {
26
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate');
27
+ windowStage.loadContent('testability/pages/Index', (err) => {
28
+ if (err.code) {
29
+ hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? '');
30
+ return;
31
+ }
32
+ hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.');
33
+ });
34
+ }
35
+
36
+ onWindowStageDestroy() {
37
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy');
38
+ }
39
+
40
+ onForeground() {
41
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground');
42
+ }
43
+
44
+ onBackground() {
45
+ hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground');
46
+ }
47
+ }
@@ -0,0 +1,17 @@
1
+ @Entry
2
+ @Component
3
+ struct Index {
4
+ @State message: string = 'Hello World';
5
+
6
+ build() {
7
+ Row() {
8
+ Column() {
9
+ Text(this.message)
10
+ .fontSize(50)
11
+ .fontWeight(FontWeight.Bold)
12
+ }
13
+ .width('100%')
14
+ }
15
+ .height('100%')
16
+ }
17
+ }
@@ -0,0 +1,90 @@
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
+ import { resourceManager } from '@kit.LocalizationKit';
6
+ import { util } from '@kit.ArkTS';
7
+
8
+ let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator;
9
+ let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs;
10
+ let jsonPath: string = 'mock/mock-config.json';
11
+ let tag: string = 'testTag';
12
+
13
+ async function onAbilityCreateCallback(data: UIAbility) {
14
+ hilog.info(0x0000, 'testTag', 'onAbilityCreateCallback, data: ${}', JSON.stringify(data));
15
+ }
16
+
17
+ async function addAbilityMonitorCallback(err: BusinessError) {
18
+ hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? '');
19
+ }
20
+
21
+ export default class OpenHarmonyTestRunner implements TestRunner {
22
+ constructor() {
23
+ }
24
+
25
+ onPrepare() {
26
+ hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare');
27
+ }
28
+
29
+ async onRun() {
30
+ let tag = 'testTag';
31
+ hilog.info(0x0000, tag, '%{public}s', 'OpenHarmonyTestRunner onRun run');
32
+ abilityDelegatorArguments = abilityDelegatorRegistry.getArguments()
33
+ abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator()
34
+ let moduleName = abilityDelegatorArguments.parameters['-m'];
35
+ let context = abilityDelegator.getAppContext().getApplicationContext().createModuleContext(moduleName);
36
+ let mResourceManager = context.resourceManager;
37
+ await checkMock(abilityDelegator, mResourceManager);
38
+ const bundleName = abilityDelegatorArguments.bundleName;
39
+ const testAbilityName: string = 'TestAbility';
40
+ let lMonitor: abilityDelegatorRegistry.AbilityMonitor = {
41
+ abilityName: testAbilityName,
42
+ onAbilityCreate: onAbilityCreateCallback,
43
+ moduleName: moduleName
44
+ };
45
+ abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
46
+ const want: Want = {
47
+ bundleName: bundleName,
48
+ abilityName: testAbilityName,
49
+ moduleName: moduleName
50
+ };
51
+ abilityDelegator.startAbility(want, (err: BusinessError, data: void) => {
52
+ hilog.info(0x0000, tag, 'startAbility : err : %{public}s', JSON.stringify(err) ?? '');
53
+ hilog.info(0x0000, tag, 'startAbility : data : %{public}s', JSON.stringify(data) ?? '');
54
+ })
55
+ hilog.info(0x0000, tag, '%{public}s', 'OpenHarmonyTestRunner onRun end');
56
+ }
57
+ }
58
+
59
+ async function checkMock(abilityDelegator: abilityDelegatorRegistry.AbilityDelegator, resourceManager: resourceManager.ResourceManager) {
60
+ let rawFile: Uint8Array;
61
+ try {
62
+ rawFile = resourceManager.getRawFileContentSync(jsonPath);
63
+ hilog.info(0x0000, tag, 'MockList file exists');
64
+ let mockStr: string = util.TextDecoder.create('utf-8', { ignoreBOM: true }).decodeWithStream(rawFile);
65
+ let mockMap: Record<string, string> = getMockList(mockStr);
66
+ try {
67
+ abilityDelegator.setMockList(mockMap)
68
+ } catch (error) {
69
+ let code = (error as BusinessError).code;
70
+ let message = (error as BusinessError).message;
71
+ hilog.error(0x0000, tag, `abilityDelegator.setMockList failed, error code: ${code}, message: ${message}.`);
72
+ }
73
+ } catch (error) {
74
+ let code = (error as BusinessError).code;
75
+ let message = (error as BusinessError).message;
76
+ hilog.error(0x0000, tag, `ResourceManager:callback getRawFileContent failed, error code: ${code}, message: ${message}.`);
77
+ }
78
+ }
79
+
80
+ function getMockList(jsonStr: string) {
81
+ let jsonObj: Record<string, Object> = JSON.parse(jsonStr);
82
+ let map: Map<string, object> = new Map<string, object>(Object.entries(jsonObj));
83
+ let mockList: Record<string, string> = {};
84
+ map.forEach((value: object, key: string) => {
85
+ let realValue: string = value['source'].toString();
86
+ mockList[key] = realValue;
87
+ });
88
+ hilog.info(0x0000, tag, '%{public}s', 'mock-json value:' + JSON.stringify(mockList) ?? '');
89
+ return mockList;
90
+ }
@@ -0,0 +1,36 @@
1
+ {
2
+ "module": {
3
+ "name": "react_native_system_setting_test",
4
+ "type": "feature",
5
+ "description": "$string:module_test_desc",
6
+ "mainElement": "TestAbility",
7
+ "deviceTypes": [
8
+ "default"
9
+ ],
10
+ "deliveryWithInstall": true,
11
+ "installationFree": false,
12
+ "pages": "$profile:test_pages",
13
+ "abilities": [
14
+ {
15
+ "name": "TestAbility",
16
+ "srcEntry": "./ets/testability/TestAbility.ets",
17
+ "description": "$string:TestAbility_desc",
18
+ "icon": "$media:icon",
19
+ "label": "$string:TestAbility_label",
20
+ "exported": true,
21
+ "startWindowIcon": "$media:icon",
22
+ "startWindowBackground": "$color:start_window_background",
23
+ "skills": [
24
+ {
25
+ "actions": [
26
+ "action.system.home"
27
+ ],
28
+ "entities": [
29
+ "entity.system.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,16 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "module_test_desc",
5
+ "value": "test ability description"
6
+ },
7
+ {
8
+ "name": "TestAbility_desc",
9
+ "value": "the test ability"
10
+ },
11
+ {
12
+ "name": "TestAbility_label",
13
+ "value": "test label"
14
+ }
15
+ ]
16
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "src": [
3
+ "testability/pages/Index"
4
+ ]
5
+ }
@@ -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
+ }