Showing
52 changed files
with
1032 additions
and
3 deletions
1 | buildscript { | 1 | buildscript { |
2 | ext.kotlin_version = '1.6.10' | 2 | ext.kotlin_version = '1.6.10' |
3 | repositories { | 3 | repositories { |
4 | + maven { url 'https://maven.aliyun.com/repository/google/' } | ||
5 | + maven { url 'https://maven.aliyun.com/repository/public' } | ||
6 | + maven { url 'https://maven.aliyun.com/repository/central' } | ||
4 | google() | 7 | google() |
5 | mavenCentral() | 8 | mavenCentral() |
6 | } | 9 | } |
@@ -13,6 +16,9 @@ buildscript { | @@ -13,6 +16,9 @@ buildscript { | ||
13 | 16 | ||
14 | allprojects { | 17 | allprojects { |
15 | repositories { | 18 | repositories { |
19 | + maven { url 'https://maven.aliyun.com/repository/google/' } | ||
20 | + maven { url 'https://maven.aliyun.com/repository/public' } | ||
21 | + maven { url 'https://maven.aliyun.com/repository/central' } | ||
16 | google() | 22 | google() |
17 | mavenCentral() | 23 | mavenCentral() |
18 | } | 24 | } |
@@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME | @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME | ||
2 | distributionPath=wrapper/dists | 2 | distributionPath=wrapper/dists |
3 | zipStoreBase=GRADLE_USER_HOME | 3 | zipStoreBase=GRADLE_USER_HOME |
4 | zipStorePath=wrapper/dists | 4 | zipStorePath=wrapper/dists |
5 | -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip | 5 | +distributionUrl=https\://mirrors.cloud.tencent.com/gradle/gradle-7.5-all.zip |
demo/ohos/.gitignore
0 → 100644
1 | +/node_modules | ||
2 | +/oh_modules | ||
3 | +/local.properties | ||
4 | +/.idea | ||
5 | +**/build | ||
6 | +/.hvigor | ||
7 | +.cxx | ||
8 | +/.clangd | ||
9 | +/.clang-format | ||
10 | +/.clang-tidy | ||
11 | +**/.test | ||
12 | +*.har | ||
13 | +**/BuildProfile.ets | ||
14 | +**/oh-package-lock.json5 | ||
15 | + | ||
16 | +**/src/main/resources/rawfile/flutter_assets/ | ||
17 | +**/libs/arm64-v8a/libapp.so | ||
18 | +**/libs/arm64-v8a/libflutter.so | ||
19 | +**/libs/arm64-v8a/libvmservice_snapshot.so |
demo/ohos/AppScope/app.json5
0 → 100644

6.63 KB
demo/ohos/build-profile.json5
0 → 100644
1 | +{ | ||
2 | + "app": { | ||
3 | + "signingConfigs": [ | ||
4 | + { | ||
5 | + "name": "default", | ||
6 | + "type": "HarmonyOS", | ||
7 | + "material": { | ||
8 | + "certpath": "C:\\Users\\10313468\\.ohos\\config\\default_ohos_pI2tBF_s6xCQykcR2aukxgFD-IyCy-vZzFumXb3K-i8=.cer", | ||
9 | + "storePassword": "0000001B134167378C52AD3E13793C419DE330840C41CA62B0D6FDE887DB5E3C7B0655FDC758AFA1021DD2", | ||
10 | + "keyAlias": "debugKey", | ||
11 | + "keyPassword": "0000001B430FD30082532A99BACBDF1C3FEF99DBF01E067FEF40C9ECFED1BCC41BCF0810C944FAC483D417", | ||
12 | + "profile": "C:\\Users\\10313468\\.ohos\\config\\default_ohos_pI2tBF_s6xCQykcR2aukxgFD-IyCy-vZzFumXb3K-i8=.p7b", | ||
13 | + "signAlg": "SHA256withECDSA", | ||
14 | + "storeFile": "C:\\Users\\10313468\\.ohos\\config\\default_ohos_pI2tBF_s6xCQykcR2aukxgFD-IyCy-vZzFumXb3K-i8=.p12" | ||
15 | + } | ||
16 | + } | ||
17 | + ], | ||
18 | + "products": [ | ||
19 | + { | ||
20 | + "name": "default", | ||
21 | + "signingConfig": "default", | ||
22 | + "compatibleSdkVersion": "5.0.0(12)", | ||
23 | + "runtimeOS": "HarmonyOS" | ||
24 | + } | ||
25 | + ] | ||
26 | + }, | ||
27 | + "modules": [ | ||
28 | + { | ||
29 | + "name": "entry", | ||
30 | + "srcPath": "./entry", | ||
31 | + "targets": [ | ||
32 | + { | ||
33 | + "name": "default", | ||
34 | + "applyToProducts": [ | ||
35 | + "default" | ||
36 | + ] | ||
37 | + } | ||
38 | + ] | ||
39 | + } | ||
40 | + ] | ||
41 | +} |
demo/ohos/entry/.gitignore
0 → 100644
demo/ohos/entry/build-profile.json5
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +{ | ||
17 | + "apiType": 'stageMode', | ||
18 | + "buildOption": { | ||
19 | + }, | ||
20 | + "targets": [ | ||
21 | + { | ||
22 | + "name": "default", | ||
23 | + "runtimeOS": "HarmonyOS" | ||
24 | + }, | ||
25 | + { | ||
26 | + "name": "ohosTest", | ||
27 | + } | ||
28 | + ] | ||
29 | +} |
demo/ohos/entry/hvigorfile.ts
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. | ||
17 | +export { hapTasks } from '@ohos/hvigor-ohos-plugin'; |
demo/ohos/entry/oh-package.json5
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import { FlutterAbility, FlutterEngine } from '@ohos/flutter_ohos'; | ||
17 | +import { GeneratedPluginRegistrant } from '../plugins/GeneratedPluginRegistrant'; | ||
18 | + | ||
19 | +export default class EntryAbility extends FlutterAbility { | ||
20 | + configureFlutterEngine(flutterEngine: FlutterEngine) { | ||
21 | + super.configureFlutterEngine(flutterEngine) | ||
22 | + GeneratedPluginRegistrant.registerWith(flutterEngine) | ||
23 | + } | ||
24 | +} |
demo/ohos/entry/src/main/ets/pages/Index.ets
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import common from '@ohos.app.ability.common'; | ||
17 | +import { FlutterPage } from '@ohos/flutter_ohos' | ||
18 | + | ||
19 | +let storage = LocalStorage.getShared() | ||
20 | +const EVENT_BACK_PRESS = 'EVENT_BACK_PRESS' | ||
21 | + | ||
22 | +@Entry(storage) | ||
23 | +@Component | ||
24 | +struct Index { | ||
25 | + private context = getContext(this) as common.UIAbilityContext | ||
26 | + @LocalStorageLink('viewId') viewId: string = ""; | ||
27 | + | ||
28 | + build() { | ||
29 | + Column() { | ||
30 | + FlutterPage({ viewId: this.viewId }) | ||
31 | + } | ||
32 | + } | ||
33 | + | ||
34 | + onBackPress(): boolean { | ||
35 | + this.context.eventHub.emit(EVENT_BACK_PRESS) | ||
36 | + return true | ||
37 | + } | ||
38 | +} |
demo/ohos/entry/src/main/module.json5
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | +{ | ||
16 | + "module": { | ||
17 | + "name": "entry", | ||
18 | + "type": "entry", | ||
19 | + "description": "$string:module_desc", | ||
20 | + "mainElement": "EntryAbility", | ||
21 | + "deviceTypes": [ | ||
22 | + "phone" | ||
23 | + ], | ||
24 | + "deliveryWithInstall": true, | ||
25 | + "installationFree": false, | ||
26 | + "pages": "$profile:main_pages", | ||
27 | + "abilities": [ | ||
28 | + { | ||
29 | + "name": "EntryAbility", | ||
30 | + "srcEntry": "./ets/entryability/EntryAbility.ets", | ||
31 | + "description": "$string:EntryAbility_desc", | ||
32 | + "icon": "$media:icon", | ||
33 | + "label": "$string:EntryAbility_label", | ||
34 | + "startWindowIcon": "$media:icon", | ||
35 | + "startWindowBackground": "$color:start_window_background", | ||
36 | + "exported": true, | ||
37 | + "skills": [ | ||
38 | + { | ||
39 | + "entities": [ | ||
40 | + "entity.system.home" | ||
41 | + ], | ||
42 | + "actions": [ | ||
43 | + "action.system.home" | ||
44 | + ] | ||
45 | + } | ||
46 | + ] | ||
47 | + } | ||
48 | + ], | ||
49 | + "requestPermissions": [ | ||
50 | + {"name" : "ohos.permission.INTERNET"}, | ||
51 | + ] | ||
52 | + } | ||
53 | +} |

6.63 KB
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import hilog from '@ohos.hilog'; | ||
17 | +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' | ||
18 | + | ||
19 | +export default function abilityTest() { | ||
20 | + describe('ActsAbilityTest', function () { | ||
21 | + // Defines a test suite. Two parameters are supported: test suite name and test suite function. | ||
22 | + beforeAll(function () { | ||
23 | + // Presets an action, which is performed only once before all test cases of the test suite start. | ||
24 | + // This API supports only one parameter: preset action function. | ||
25 | + }) | ||
26 | + beforeEach(function () { | ||
27 | + // Presets an action, which is performed before each unit test case starts. | ||
28 | + // The number of execution times is the same as the number of test cases defined by **it**. | ||
29 | + // This API supports only one parameter: preset action function. | ||
30 | + }) | ||
31 | + afterEach(function () { | ||
32 | + // Presets a clear action, which is performed after each unit test case ends. | ||
33 | + // The number of execution times is the same as the number of test cases defined by **it**. | ||
34 | + // This API supports only one parameter: clear action function. | ||
35 | + }) | ||
36 | + afterAll(function () { | ||
37 | + // Presets a clear action, which is performed after all test cases of the test suite end. | ||
38 | + // This API supports only one parameter: clear action function. | ||
39 | + }) | ||
40 | + it('assertContain',0, function () { | ||
41 | + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. | ||
42 | + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); | ||
43 | + let a = 'abc' | ||
44 | + let b = 'b' | ||
45 | + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. | ||
46 | + expect(a).assertContain(b) | ||
47 | + expect(a).assertEqual(a) | ||
48 | + }) | ||
49 | + }) | ||
50 | +} |
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import abilityTest from './Ability.test' | ||
17 | + | ||
18 | +export default function testsuite() { | ||
19 | + abilityTest() | ||
20 | +} |
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import UIAbility from '@ohos.app.ability.UIAbility'; | ||
17 | +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; | ||
18 | +import hilog from '@ohos.hilog'; | ||
19 | +import { Hypium } from '@ohos/hypium'; | ||
20 | +import testsuite from '../test/List.test'; | ||
21 | +import window from '@ohos.window'; | ||
22 | + | ||
23 | +export default class TestAbility extends UIAbility { | ||
24 | + onCreate(want, launchParam) { | ||
25 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); | ||
26 | + hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); | ||
27 | + hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); | ||
28 | + var abilityDelegator: any | ||
29 | + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() | ||
30 | + var abilityDelegatorArguments: any | ||
31 | + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() | ||
32 | + hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); | ||
33 | + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) | ||
34 | + } | ||
35 | + | ||
36 | + onDestroy() { | ||
37 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); | ||
38 | + } | ||
39 | + | ||
40 | + onWindowStageCreate(windowStage: window.WindowStage) { | ||
41 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); | ||
42 | + windowStage.loadContent('testability/pages/Index', (err, data) => { | ||
43 | + if (err.code) { | ||
44 | + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); | ||
45 | + return; | ||
46 | + } | ||
47 | + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', | ||
48 | + JSON.stringify(data) ?? ''); | ||
49 | + }); | ||
50 | + } | ||
51 | + | ||
52 | + onWindowStageDestroy() { | ||
53 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); | ||
54 | + } | ||
55 | + | ||
56 | + onForeground() { | ||
57 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); | ||
58 | + } | ||
59 | + | ||
60 | + onBackground() { | ||
61 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); | ||
62 | + } | ||
63 | +} |
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import hilog from '@ohos.hilog'; | ||
17 | + | ||
18 | +@Entry | ||
19 | +@Component | ||
20 | +struct Index { | ||
21 | + aboutToAppear() { | ||
22 | + hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); | ||
23 | + } | ||
24 | + @State message: string = 'Hello World' | ||
25 | + build() { | ||
26 | + Row() { | ||
27 | + Column() { | ||
28 | + Text(this.message) | ||
29 | + .fontSize(50) | ||
30 | + .fontWeight(FontWeight.Bold) | ||
31 | + Button() { | ||
32 | + Text('next page') | ||
33 | + .fontSize(20) | ||
34 | + .fontWeight(FontWeight.Bold) | ||
35 | + }.type(ButtonType.Capsule) | ||
36 | + .margin({ | ||
37 | + top: 20 | ||
38 | + }) | ||
39 | + .backgroundColor('#0D9FFB') | ||
40 | + .width('35%') | ||
41 | + .height('5%') | ||
42 | + .onClick(()=>{ | ||
43 | + }) | ||
44 | + } | ||
45 | + .width('100%') | ||
46 | + } | ||
47 | + .height('100%') | ||
48 | + } | ||
49 | + } |
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import hilog from '@ohos.hilog'; | ||
17 | +import TestRunner from '@ohos.application.testRunner'; | ||
18 | +import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; | ||
19 | + | ||
20 | +var abilityDelegator = undefined | ||
21 | +var abilityDelegatorArguments = undefined | ||
22 | + | ||
23 | +async function onAbilityCreateCallback() { | ||
24 | + hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); | ||
25 | +} | ||
26 | + | ||
27 | +async function addAbilityMonitorCallback(err: any) { | ||
28 | + hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); | ||
29 | +} | ||
30 | + | ||
31 | +export default class OpenHarmonyTestRunner implements TestRunner { | ||
32 | + constructor() { | ||
33 | + } | ||
34 | + | ||
35 | + onPrepare() { | ||
36 | + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); | ||
37 | + } | ||
38 | + | ||
39 | + async onRun() { | ||
40 | + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); | ||
41 | + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() | ||
42 | + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() | ||
43 | + var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' | ||
44 | + let lMonitor = { | ||
45 | + abilityName: testAbilityName, | ||
46 | + onAbilityCreate: onAbilityCreateCallback, | ||
47 | + }; | ||
48 | + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) | ||
49 | + var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName | ||
50 | + var debug = abilityDelegatorArguments.parameters['-D'] | ||
51 | + if (debug == 'true') | ||
52 | + { | ||
53 | + cmd += ' -D' | ||
54 | + } | ||
55 | + hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); | ||
56 | + abilityDelegator.executeShellCommand(cmd, | ||
57 | + (err: any, d: any) => { | ||
58 | + hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); | ||
59 | + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); | ||
60 | + hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); | ||
61 | + }) | ||
62 | + hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); | ||
63 | + } | ||
64 | +} |
demo/ohos/entry/src/ohosTest/module.json5
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +{ | ||
17 | + "module": { | ||
18 | + "name": "entry_test", | ||
19 | + "type": "feature", | ||
20 | + "description": "$string:module_test_desc", | ||
21 | + "mainElement": "TestAbility", | ||
22 | + "deviceTypes": [ | ||
23 | + "phone" | ||
24 | + ], | ||
25 | + "deliveryWithInstall": true, | ||
26 | + "installationFree": false, | ||
27 | + "pages": "$profile:test_pages", | ||
28 | + "abilities": [ | ||
29 | + { | ||
30 | + "name": "TestAbility", | ||
31 | + "srcEntry": "./ets/testability/TestAbility.ets", | ||
32 | + "description": "$string:TestAbility_desc", | ||
33 | + "icon": "$media:icon", | ||
34 | + "label": "$string:TestAbility_label", | ||
35 | + "exported": true, | ||
36 | + "startWindowIcon": "$media:icon", | ||
37 | + "startWindowBackground": "$color:start_window_background", | ||
38 | + "skills": [ | ||
39 | + { | ||
40 | + "actions": [ | ||
41 | + "action.system.home" | ||
42 | + ], | ||
43 | + "entities": [ | ||
44 | + "entity.system.home" | ||
45 | + ] | ||
46 | + } | ||
47 | + ] | ||
48 | + } | ||
49 | + ] | ||
50 | + } | ||
51 | +} |

6.63 KB
demo/ohos/hvigor/hvigor-config.json5
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +{ | ||
17 | + "modelVersion": "5.0.0", | ||
18 | + "dependencies": { | ||
19 | + } | ||
20 | +} |
demo/ohos/hvigorfile.ts
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2023 Hunan OpenValley Digital Industry Development Co., Ltd. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | +import { appTasks } from '@ohos/hvigor-ohos-plugin'; | ||
17 | + | ||
18 | +export default { | ||
19 | + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ | ||
20 | + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ | ||
21 | +} |
demo/ohos/oh-package.json5
0 → 100644
1 | +{ | ||
2 | + "modelVersion": "5.0.0", | ||
3 | + "name": "dart_pdf", | ||
4 | + "version": "1.0.0", | ||
5 | + "description": "Please describe the basic information.", | ||
6 | + "main": "", | ||
7 | + "author": "", | ||
8 | + "license": "", | ||
9 | + "dependencies": { | ||
10 | + "@ohos/flutter_ohos": "file:./har/flutter.har" | ||
11 | + }, | ||
12 | + "devDependencies": { | ||
13 | + "@ohos/hypium": "1.0.6" | ||
14 | + }, | ||
15 | + "overrides": { | ||
16 | + "@ohos/flutter_ohos": "file:./har/flutter.har", | ||
17 | + "printing": "file:./har/printing.har", | ||
18 | + "@ohos/flutter_module": "file:./entry" | ||
19 | + } | ||
20 | +} |
@@ -20,7 +20,7 @@ dependencies: | @@ -20,7 +20,7 @@ dependencies: | ||
20 | 20 | ||
21 | dev_dependencies: | 21 | dev_dependencies: |
22 | # flutter_launcher_icons: ^0.10.0 | 22 | # flutter_launcher_icons: ^0.10.0 |
23 | - flutter_lints: ^5.0.0 | 23 | +# flutter_lints: ^5.0.0 |
24 | flutter_test: | 24 | flutter_test: |
25 | sdk: flutter | 25 | sdk: flutter |
26 | test: | 26 | test: |
printing/ohos/.gitignore
0 → 100644
printing/ohos/BuildProfile.ets
0 → 100644
1 | +/** | ||
2 | + * Use these variables when you tailor your ArkTS code. They must be of the const type. | ||
3 | + */ | ||
4 | +export const HAR_VERSION = '1.0.0'; | ||
5 | +export const BUILD_MODE_NAME = 'debug'; | ||
6 | +export const DEBUG = true; | ||
7 | +export const TARGET_NAME = 'default'; | ||
8 | + | ||
9 | +/** | ||
10 | + * BuildProfile Class is used only for compatibility purposes. | ||
11 | + */ | ||
12 | +export default class BuildProfile { | ||
13 | + static readonly HAR_VERSION = HAR_VERSION; | ||
14 | + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; | ||
15 | + static readonly DEBUG = DEBUG; | ||
16 | + static readonly TARGET_NAME = TARGET_NAME; | ||
17 | +} |
printing/ohos/Index.ets
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | + | ||
17 | + | ||
18 | +import PrintingPlugin | ||
19 | + from './src/main/ets/com/ewin/print/PrintingPlugin' | ||
20 | + | ||
21 | +export default PrintingPlugin |
printing/ohos/build-profile.json5
0 → 100644
1 | +{ | ||
2 | + "apiType": "stageMode", | ||
3 | + "buildOption": { | ||
4 | + }, | ||
5 | + "buildOptionSet": [ | ||
6 | + { | ||
7 | + "name": "release", | ||
8 | + "arkOptions": { | ||
9 | + "obfuscation": { | ||
10 | + "ruleOptions": { | ||
11 | + "enable": true, | ||
12 | + "files": [ | ||
13 | + "./obfuscation-rules.txt" | ||
14 | + ] | ||
15 | + }, | ||
16 | + "consumerFiles": [ | ||
17 | + "./consumer-rules.txt" | ||
18 | + ] | ||
19 | + } | ||
20 | + }, | ||
21 | + }, | ||
22 | + ], | ||
23 | + "targets": [ | ||
24 | + { | ||
25 | + "name": "default" | ||
26 | + }, | ||
27 | + { | ||
28 | + "name": "printing" | ||
29 | + } | ||
30 | + ] | ||
31 | +} |
printing/ohos/consumer-rules.txt
0 → 100644
printing/ohos/hvigorfile.ts
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | +export { harTasks } from '@ohos/hvigor-ohos-plugin'; |
printing/ohos/obfuscation-rules.txt
0 → 100644
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://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md | ||
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 |
printing/ohos/oh-package-lock.json5
0 → 100644
1 | +{ | ||
2 | + "meta": { | ||
3 | + "stableOrder": true | ||
4 | + }, | ||
5 | + "lockfileVersion": 3, | ||
6 | + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", | ||
7 | + "specifiers": { | ||
8 | + "@ohos/flutter_ohos@../../demo/ohos/har/flutter.har": "@ohos/flutter_ohos@../../demo/ohos/har/flutter.har" | ||
9 | + }, | ||
10 | + "packages": { | ||
11 | + "@ohos/flutter_ohos@../../demo/ohos/har/flutter.har": { | ||
12 | + "name": "@ohos/flutter_ohos", | ||
13 | + "version": "1.0.0-0e6b4521d4", | ||
14 | + "resolved": "../../demo/ohos/har/flutter.har", | ||
15 | + "registryType": "local" | ||
16 | + } | ||
17 | + } | ||
18 | +} |
printing/ohos/oh-package.json5
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | + | ||
17 | +import { | ||
18 | + EventChannel, | ||
19 | + FlutterPlugin, | ||
20 | + FlutterPluginBinding, | ||
21 | + Log, | ||
22 | + MethodCall, | ||
23 | + MethodCallHandler, | ||
24 | + MethodChannel, | ||
25 | + MethodResult | ||
26 | +} from '@ohos/flutter_ohos' | ||
27 | +import { common } from '@kit.AbilityKit'; | ||
28 | +const TAG: string = "PrintingPlugin"; | ||
29 | +const METHOD_CHANEL: string = "net.nfet.printing"; | ||
30 | + | ||
31 | + | ||
32 | +export default class PrintingPlugin implements FlutterPlugin, MethodCallHandler { | ||
33 | + private context: common.Context | null = null | ||
34 | + private channel: MethodChannel | null = null | ||
35 | + | ||
36 | + getUniqueClassName(): string { | ||
37 | + return TAG; | ||
38 | + } | ||
39 | + | ||
40 | + onAttachedToEngine(binding: FlutterPluginBinding): void { | ||
41 | + this.context = binding.getApplicationContext(); | ||
42 | + this.channel = new MethodChannel(binding.getBinaryMessenger(), METHOD_CHANEL); | ||
43 | + this.channel.setMethodCallHandler(this); | ||
44 | + } | ||
45 | + | ||
46 | + onDetachedFromEngine(binding: FlutterPluginBinding): void { | ||
47 | + this.channel?.setMethodCallHandler(null); | ||
48 | + } | ||
49 | + | ||
50 | + onMethodCall(call: MethodCall, result: MethodResult): void { | ||
51 | + Log.d(TAG, 'onMethodCall step in ' + call.method) | ||
52 | + switch (call.method) { | ||
53 | + case "printingInfo": | ||
54 | + const map:Map<string,Object> =new Map<string,Object>() | ||
55 | + map.set("directPrint", false); | ||
56 | + map.set("dynamicLayout", true); | ||
57 | + map.set("canPrint", true); | ||
58 | + map.set("canShare", true) | ||
59 | + map.set("canRaster", true) | ||
60 | + result.success(map); | ||
61 | + break; | ||
62 | + default: | ||
63 | + result.notImplemented(); | ||
64 | + } | ||
65 | + } | ||
66 | +} |
printing/ohos/src/main/module.json5
0 → 100644
printing/ohos/src/test/List.test.ets
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | + | ||
17 | +import localUnitTest from './LocalUnit.test'; | ||
18 | + | ||
19 | +export default function testsuite() { | ||
20 | + localUnitTest(); | ||
21 | +} |
printing/ohos/src/test/LocalUnit.test.ets
0 → 100644
1 | +/* | ||
2 | +* Copyright (c) 2024 SwanLink (Jiangsu) Technology Development Co., LTD. | ||
3 | +* Licensed under the Apache License, Version 2.0 (the "License"); | ||
4 | +* you may not use this file except in compliance with the License. | ||
5 | +* You may obtain a copy of the License at | ||
6 | +* | ||
7 | +* http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | +* | ||
9 | +* Unless required by applicable law or agreed to in writing, software | ||
10 | +* distributed under the License is distributed on an "AS IS" BASIS, | ||
11 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
12 | +* See the License for the specific language governing permissions and | ||
13 | +* limitations under the License. | ||
14 | +*/ | ||
15 | + | ||
16 | + | ||
17 | +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; | ||
18 | + | ||
19 | +export default function localUnitTest() { | ||
20 | + describe('localUnitTest',() => { | ||
21 | + // Defines a test suite. Two parameters are supported: test suite name and test suite function. | ||
22 | + beforeAll(() => { | ||
23 | + // Presets an action, which is performed only once before all test cases of the test suite start. | ||
24 | + // This API supports only one parameter: preset action function. | ||
25 | + }); | ||
26 | + beforeEach(() => { | ||
27 | + // Presets an action, which is performed before each unit test case starts. | ||
28 | + // The number of execution times is the same as the number of test cases defined by **it**. | ||
29 | + // This API supports only one parameter: preset action function. | ||
30 | + }); | ||
31 | + afterEach(() => { | ||
32 | + // Presets a clear action, which is performed after each unit test case ends. | ||
33 | + // The number of execution times is the same as the number of test cases defined by **it**. | ||
34 | + // This API supports only one parameter: clear action function. | ||
35 | + }); | ||
36 | + afterAll(() => { | ||
37 | + // Presets a clear action, which is performed after all test cases of the test suite end. | ||
38 | + // This API supports only one parameter: clear action function. | ||
39 | + }); | ||
40 | + it('assertContain', 0, () => { | ||
41 | + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. | ||
42 | + let a = 'abc'; | ||
43 | + let b = 'b'; | ||
44 | + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. | ||
45 | + expect(a).assertContain(b); | ||
46 | + expect(a).assertEqual(a); | ||
47 | + }); | ||
48 | + }); | ||
49 | +} |
@@ -36,7 +36,7 @@ dependencies: | @@ -36,7 +36,7 @@ dependencies: | ||
36 | web: ^1.0.0 | 36 | web: ^1.0.0 |
37 | 37 | ||
38 | dev_dependencies: | 38 | dev_dependencies: |
39 | - flutter_lints: ^5.0.0 | 39 | +# flutter_lints: ^5.0.0 |
40 | flutter_test: | 40 | flutter_test: |
41 | sdk: flutter | 41 | sdk: flutter |
42 | mockito: ^5.4.4 | 42 | mockito: ^5.4.4 |
@@ -62,5 +62,8 @@ flutter: | @@ -62,5 +62,8 @@ flutter: | ||
62 | web: | 62 | web: |
63 | fileName: printing_web.dart | 63 | fileName: printing_web.dart |
64 | pluginClass: PrintingPlugin | 64 | pluginClass: PrintingPlugin |
65 | + ohos: | ||
66 | + package: com.ewin.print | ||
67 | + pluginClass: PrintingPlugin | ||
65 | windows: | 68 | windows: |
66 | pluginClass: PrintingPlugin | 69 | pluginClass: PrintingPlugin |
-
Please register or login to post a comment