diff --git a/shell/platform/ohos/flutter_embedding/application/.gitignore b/shell/platform/ohos/flutter_embedding/application/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/build-profile.json5 b/shell/platform/ohos/flutter_embedding/application/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..682d223d55956f1d579037598b4bf59a743f03a0 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts b/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c71da0f0404c356f45efa2e7937985e219bf0460 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/hvigorfile.ts @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/shell/platform/ohos/flutter_embedding/application/obfuscation-rules.txt b/shell/platform/ohos/flutter_embedding/application/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/oh-package.json5 b/shell/platform/ohos/flutter_embedding/application/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..9472ce464004acd9f5ecb8eced4e8ec9b0d6f099 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/oh-package.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "name": "application", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "@ohos/flutter_ohos": "file:../flutter", + "@ohos/hypium": "1.0.18" + } +} + diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..11cc563d8fab01c4fe5bc0d083ec1c665986e25d --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationability/ApplicationAbility.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +export default class ApplicationAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); + return; + } + hilog.info(0x0000, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..10ae96d62540755d875f7583986c0db254c34693 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/ets/applicationbackupability/ApplicationBackupAbility.ets @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +export default class ApplicationBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(0x0000, 'testTag', 'onBackup ok'); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(0x0000, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets b/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..81b53999e62d7f257e58d089da9d919c07340712 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/ets/pages/Index.ets @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize(50) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/module.json5 b/shell/platform/ohos/flutter_embedding/application/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8f334feb3a38758d2b7093f6d2170b1448b2a2b6 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "application", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "ApplicationAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "ApplicationAbility", + "srcEntry": "./ets/applicationability/ApplicationAbility.ets", + "description": "$string:ApplicationAbility_desc", + "icon": "$media:layered_image", + "label": "$string:ApplicationAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "ApplicationBackupAbility", + "srcEntry": "./ets/applicationbackupability/ApplicationBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/element/color.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/element/string.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a4969eae868447396d719a863b9ee15c146299f0 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ApplicationAbility_desc", + "value": "description" + }, + { + "name": "ApplicationAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/background.png b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/background.png differ diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/foreground.png b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/foreground.png differ diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/layered_image.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/startIcon.png b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/media/startIcon.png differ diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/profile/backup_config.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/profile/main_pages.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/en_US/element/string.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..a4969eae868447396d719a863b9ee15c146299f0 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "ApplicationAbility_desc", + "value": "description" + }, + { + "name": "ApplicationAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/main/resources/zh_CN/element/string.json b/shell/platform/ohos/flutter_embedding/application/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..9e08d1adfed3a76904517f4f9104d7371cc50a71 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "ApplicationAbility_desc", + "value": "description" + }, + { + "name": "ApplicationAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 b/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..99db04adcdb49dc11ab59844a6b78fc81baace24 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/mock/mock-config.json5 @@ -0,0 +1,17 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ab342916e2b8c1c8c3cd11b7b9e46402c7702c9e --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/FlutterInjector.test.ets @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { FlutterInjector } from "@ohos/flutter_ohos"; + +export default function FlutterInjectorTest() { + describe('FlutterInjectorTest', () => { + it('getInstance', 0, () => { + expect(FlutterInjector.getInstance()).not().assertNull(); + }) + it('getFlutterLoader', 0, () => { + expect(FlutterInjector.getInstance().getFlutterLoader()).not().assertNull(); + }) + it('getFlutterNapi', 0, () => { + expect(FlutterInjector.getInstance().getFlutterNapi()).not().assertNull(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..80151e3685194032e62e448b1c8e45c70ccc0e4b --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the 'License'); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an 'AS IS' BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import FlutterAbilityAndEntryDelegateTest from './embedding/ohos/FlutterAbilityAndEntryDelegateTest.test'; +import FlutterAbilityTest from './embedding/ohos/FlutterAbilityTest.test'; +import FlutterEntryTest from './embedding/ohos/FlutterEntryTest.test'; +import FlutterManagerTest from './embedding/ohos/FlutterManagerTest.test'; +import SettingTest from './embedding/ohos/SettingTest.test'; +import BinaryCodecTest from './plugin/common/BinaryCodecTest.test'; +import PlatformViewRegistryImplTest from './plugin/platform/PlatformViewRegistryImplTest.test'; +import PlatformViewWrapperTest from './plugin/platform/PlatformViewWrapperTest.test'; +import PlatformViewsControllerTest from './plugin/platform/PlatformViewsControllerTest.test'; +import RawPointerCoordTest from './plugin/platform/RawPointerCoordTest.test'; +import RootDvModelManagerTest from './plugin/platform/RootDvModelManagerTest.test'; +import ByteBufferTest from './plugin/util/ByteBufferTest.test'; +import PlatformChannelUnitTest from './embedding/engine/systemchannels/PlatformChannel.test'; +import RestorationChannelUnitTest from './embedding/engine/systemchannels/RestorationChannel.test'; +import SettingsChannelUnitTest from './embedding/engine/systemchannels/SettingsChannel.test'; +import TextInputChannelUnitTest from './embedding/engine/systemchannels/TextInputChannel.test'; +import JSONMethodCodecUnitTest from './plugin/common/JSONMethodCodec.test'; +import MethodCallUnitTest from './plugin/common/MethodCall.test'; +import AccessibilityEventsDelegateUnitTest from './plugin/platform/AccessibilityEventsDelegate.test'; + +import DartMessengerTest from './embedding/engine/dart/DartMessengerTest.test' +import ApplicationInfoTest from './embedding/engine/loader/ApplicationInfoTest.test' +import FlutterApplicationInfoTest from './embedding/engine/loader/FlutterApplicationInfoTest.test' +import FlutterLoaderTest from './embedding/engine/loader/FlutterLoaderTest.test' +import FlutterMutatorViewTest from './embedding/engine/mutatorsstack/FlutterMutatorViewTest.test' +import FlutterMutatorsStackTest from './embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test' +import FlutterRendererTest from './embedding/engine/renderer/FlutterRendererTest.test' +import TouchEventProcessorTest from './embedding/ohos/TouchEventProcessorTest.test'; +import TouchEventTrackerTest from './embedding/ohos/TouchEventTrackerTest.test'; +import WindowInfoRepositoryCallbackAdapterWrapperTest from './embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test'; +import FlutterEngineTest from './embedding/engine/FlutterEngineTest.test'; +import FlutterEngineCacheTest from './embedding/engine/FlutterEngineCacheTest.test'; +import FlutterEngineConnectionRegistryTest from './embedding/engine/FlutterEngineConnectionRegistryTest.test'; +import FlutterEngineGroupCacheTest from './embedding/engine/FlutterEngineGroupCacheTest.test'; +import FlutterEngineGroupTest from './embedding/engine/FlutterEngineGroupTest.test'; +import FlutterNapiTest from './embedding/engine/FlutterNapiTest.test'; +import FlutterOverlaySurfaceTest from './embedding/engine/FlutterOverlaySurfaceTest.test'; +import FlutterShellArgsTest from './embedding/engine/FlutterShellArgsTest.test'; +import BinaryMessengerTest from './plugin/common/BinaryMessengerTest.test'; +import DartExecutorTest from './embedding/engine/dart/DartExecutorTest.test'; + +import PathUtilsTest from './plugin/util/PathUtils.test'; +import StringUtilsTest from './plugin/util/StringUtils.test'; +import ToolUtilsTest from './plugin/util/ToolUtils.test'; +import MessageChannelUtilsTest from './plugin/util/MessageChannelUtils.test'; +import LogTest from './plugin/util/Log.test'; +import TraceSectionTest from './plugin/util/TraceSection.test'; +import FlutterInjectorTest from './FlutterInjector.test'; +import SendableBinaryCodecTest from './plugin/common/SendableBinaryCodec.test'; +import dynamicViewJsonTest from './view/DynamicView/dynamicViewJson.test'; +import PlatformOverlayViewTest from './plugin/platform/PlatformOverlayView.test'; +import PlatformViewTest from './plugin/platform/PlatformView.test'; +import FlutterRunArgumentsTest from './view/FlutterRunArguments.test'; +import LifecycleChannelTest from './embedding/engine/systemchannels/LifecycleChannel.test'; +import FlutterExceptionTest from './plugin/common/FlutterException.test'; +import JSONMessageCodecTest from './plugin/common/JSONMessageCodec.test'; +import SendableJSONMessageCodecTest from './plugin/common/SendableJSONMessageCodec.test'; +import SendableJSONMethodCodecTest from './plugin/common/SendableJSONMethodCodec.test'; +import SendableStringCodecTest from './plugin/common/SendableStringCodec.test'; +import StandardMessageCodecTest from './plugin/common/StandardMessageCodec.test'; +import StandardMethodCodecTest from './plugin/common/StandardMethodCodec.test'; +import StringCodecTest from './plugin/common/StringCodec.test'; +import ListenableEditingStateTest from './plugin/editing/ListenableEditingState.test'; +import TextEditingDeltaTest from './plugin/editing/TextEditingDelta.test'; +import TextInputPluginTest from './plugin/editing/TextInputPlugin.test'; +import LocalizationPluginTest from './plugin/localization/LocalizationPlugin.test'; +import SendableStandardMessageCodecTest from './plugin/common/SendableStandardMessageCodec.test'; +import SendableStandardMethodCodecTest from './plugin/common/SendableStandardMethodCodec.test'; + +export default function testsuite() { + FlutterAbilityAndEntryDelegateTest(); + FlutterAbilityTest(); + FlutterEntryTest(); + FlutterManagerTest(); + SettingTest(); + BinaryCodecTest(); + PlatformViewRegistryImplTest(); + PlatformViewWrapperTest(); + PlatformViewsControllerTest(); + RawPointerCoordTest(); + RootDvModelManagerTest(); + ByteBufferTest(); + PlatformChannelUnitTest(); + RestorationChannelUnitTest(); + SettingsChannelUnitTest(); + TextInputChannelUnitTest(); + JSONMethodCodecUnitTest(); + MethodCallUnitTest(); + AccessibilityEventsDelegateUnitTest(); + DartMessengerTest(); + ApplicationInfoTest(); + FlutterApplicationInfoTest(); + FlutterLoaderTest() + FlutterMutatorViewTest(); + FlutterMutatorsStackTest(); + FlutterRendererTest(); + TouchEventProcessorTest(); + TouchEventTrackerTest(); + WindowInfoRepositoryCallbackAdapterWrapperTest(); + FlutterEngineTest(); + FlutterEngineCacheTest(); + FlutterEngineConnectionRegistryTest(); + FlutterEngineGroupCacheTest(); + FlutterEngineGroupTest(); + FlutterNapiTest(); + FlutterOverlaySurfaceTest(); + FlutterShellArgsTest(); + BinaryMessengerTest(); + DartExecutorTest(); + PathUtilsTest(); + StringUtilsTest(); + ToolUtilsTest(); + MessageChannelUtilsTest(); + LogTest(); + TraceSectionTest(); + FlutterInjectorTest(); + SendableBinaryCodecTest(); + dynamicViewJsonTest(); + PlatformOverlayViewTest(); + PlatformViewTest(); + PlatformViewTest(); + FlutterRunArgumentsTest(); + LifecycleChannelTest(); + FlutterExceptionTest(); + JSONMessageCodecTest(); + SendableJSONMessageCodecTest(); + SendableJSONMethodCodecTest(); + SendableStandardMessageCodecTest(); + SendableStandardMethodCodecTest(); + SendableStringCodecTest(); + StandardMessageCodecTest(); + StandardMethodCodecTest(); + StringCodecTest(); + ListenableEditingStateTest(); + TextEditingDeltaTest(); + TextInputPluginTest(); + LocalizationPluginTest(); +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..73e9ca9573361219b5d2c9e536f9b7abdf76576d --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineCacheTest.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine'; +import FlutterEngineCache from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineCache'; + +export default function FlutterEngineCacheTest() { + const flutterEngineCache: FlutterEngineCache = new FlutterEngineCache(); + + describe('FlutterEngineCacheTest', () => { + + it('getInstance', 0, async (done: Function) => { + console.info("uitest: getInstance begin"); + const getInstance: FlutterEngineCache = FlutterEngineCache.getInstance(); + expect(getInstance).not().assertNull(); + done(); + }) + + it('contains', 0, async (done: Function) => { + console.info("uitest: contains begin"); + const contains: boolean = flutterEngineCache.contains('test'); + expect(contains).not().assertNull(); + done(); + }) + + it('get', 0, async (done: Function) => { + console.info("uitest: contains begin"); + const get: FlutterEngine | null = flutterEngineCache.get('test'); + if(get) { + expect(get).not().assertNull(); + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..01925e7b0ebc20c1dc447303f8bb65d0e707eaf4 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineConnectionRegistryTest.test.ets @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, it, expect } from '@ohos/hypium'; +import { FlutterPlugin, } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin'; +import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine'; +import PlatformViewsController from '@ohos/flutter_ohos/src/main/ets/plugin/platform/PlatformViewsController' +import common from '@ohos.app.ability.common'; +import FlutterEngineConnectionRegistry from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineConnectionRegistry'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; + +export default function FlutterEngineConnectionRegistryTest() { + let flutterEngineConnectionRegistry: FlutterEngineConnectionRegistry; + let flutterEngine: FlutterEngine; + let context: common.UIAbilityContext; + const platformViewsController = new PlatformViewsController(); + const pluginClassName = 'test'; + + describe('FlutterEngineConnectionRegistryTest', () => { + + beforeAll(() => { + context = getContext() as common.UIAbilityContext; + flutterEngine = new FlutterEngine(context, null, null, platformViewsController); + const flutterLoader = flutterEngine.getFlutterLoader(); + flutterEngineConnectionRegistry = new FlutterEngineConnectionRegistry(context, flutterEngine, flutterLoader); + }) + + it('has', 0, async (done: Function) => { + console.info("uitest: has begin"); + if (flutterEngineConnectionRegistry) { + const hasFlag = flutterEngineConnectionRegistry.has(pluginClassName); + expect(hasFlag).not().assertNull(); + } + done(); + }) + + it('get', 0, async (done: Function) => { + console.info("uitest: get begin"); + if (flutterEngineConnectionRegistry) { + const name: FlutterPlugin = flutterEngineConnectionRegistry.get(pluginClassName); + expect(name).not().assertNull(); + } + done(); + }) + + it('onSaveState', 0, async (done: Function) => { + console.info("uitest: onSaveState begin"); + const reason = AbilityConstant.StateType.CONTINUATION; + const wantParam: Record = {}; + if (flutterEngineConnectionRegistry) { + const result: AbilityConstant.OnSaveResult = flutterEngineConnectionRegistry.onSaveState(reason, wantParam); + expect(result).not().assertNull(); + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..647b3e0e8292f03d21e58ad56144f3af5cfd83ce --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupCacheTest.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, expect, it } from '@ohos/hypium'; +import FlutterEngineGroupCache from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroupCache'; +import { FlutterEngineGroup } from '@ohos/flutter_ohos'; + +export default function FlutterEngineGroupCacheTest() { + const flutterEngineGroupCache = new FlutterEngineGroupCache(); + const engineGroupId: string = ''; + + describe('FlutterEngineGroupCacheTest', () => { + + it('instance', 0, async (done: Function) => { + console.info("uitest: instance begin"); + const instance = FlutterEngineGroupCache.instance; + expect(instance).not().assertNull(); + done(); + }) + + it('contains', 0, async (done: Function) => { + console.info("uitest: contains begin"); + const flag = flutterEngineGroupCache.contains(engineGroupId); + expect(flag).not().assertNull(); + done(); + }) + + it('get', 0, async (done: Function) => { + console.info("uitest: get begin"); + const engGroupId: FlutterEngineGroup | null = flutterEngineGroupCache.get(engineGroupId); + if (engGroupId) { + expect(engGroupId).not().assertNull(); + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f0190788bd496bdeefc622de38ef6ccbc1685746 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineGroupTest.test.ets @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, expect, it } from '@ohos/hypium'; +import FlutterEngineGroup, { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; +import { FlutterEngine } from '@ohos/flutter_ohos'; +import PlatformViewsController from '@ohos/flutter_ohos/src/main/ets/plugin/platform/PlatformViewsController' +import common from '@ohos.app.ability.common'; + +export default function FlutterEngineGroupTest() { + const flutterEngineGroup = new FlutterEngineGroup(); + const platformViewsController = new PlatformViewsController(); + const context = getContext() as common.UIAbilityContext; + const args: Array = []; + + describe('FlutterEngineGroupTest', () => { + + it('checkLoader', 0, async (done: Function) => { + console.info("uitest: checkLoader begin"); + const checkLoaderCallBack = flutterEngineGroup.checkLoader(context, args); + expect(checkLoaderCallBack).not().assertNull(); + done(); + }) + + it('createAndRunEngineByOptions', 0, async (done: Function) => { + console.info("uitest: createAndRunEngineByOptions begin"); + const options = new Options(context); + const createAndRunEngineByOptionsCallBack = flutterEngineGroup.createAndRunEngineByOptions(options); + expect(createAndRunEngineByOptionsCallBack).not().assertNull(); + done(); + }) + + it('createEngine', 0, async (done: Function) => { + console.info("uitest: createEngine begin"); + if(context) { + const fng: FlutterEngine = flutterEngineGroup.createEngine(context, platformViewsController); + expect(fng).not().assertNull(); + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc91be86a45e6600bea65db4920ec7b0ed4a2193 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterEngineTest.test.ets @@ -0,0 +1,263 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, it, expect } from '@ohos/hypium'; +import DartExecutor, { DartEntrypoint } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartExecutor'; +import { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; +import { + AccessibilityChannel, + FlutterLoader, + FlutterNapi, + FlutterRenderer, + LifecycleChannel, + LocalizationChannel, + LocalizationPlugin, + MouseCursorChannel, + NavigationChannel, + PlatformChannel, + PluginRegistry, + RestorationChannel, + SettingsChannel, + SystemChannel, + TextInputChannel +} from '@ohos/flutter_ohos'; +import ActivityControlSurface from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/ability/AbilityControlSurface'; +import PlatformViewsController from '@ohos/flutter_ohos/src/main/ets/plugin/platform/PlatformViewsController'; +import FlutterEngine from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine'; +import common from '@ohos.app.ability.common'; + +export default function FlutterEngineTest() { + const platformViewsController = new PlatformViewsController(); + let context: common.UIAbilityContext; + let flutterEngine: FlutterEngine; + + describe('FlutterEngineTest', () => { + + beforeAll(() => { + const context = getContext() as common.UIAbilityContext; + flutterEngine = new FlutterEngine(context, null, null, platformViewsController); + }) + + it('spawn', 0, async (done: Function) => { + console.info("uitest: spawn begin"); + const options = new Options(context); + let dartEntrypoint: DartEntrypoint | null = options.getDartEntrypoint(); + let initialRoute: string = options.getInitialRoute(); + let dartEntrypointArgs: Array = options.getDartEntrypointArgs(); + let eg: FlutterEngine | null = null; + if (dartEntrypoint) { + eg = await flutterEngine.spawn(context, + dartEntrypoint, + initialRoute, + dartEntrypointArgs, + platformViewsController, + false); + if (eg) { + expect(eg).not().assertNull(); + } + } + done(); + }) + + it('getLifecycleChannel', 0, async (done: Function) => { + console.info("uitest: getLifecycleChannel begin"); + if (flutterEngine) { + const lifecycleChannel: LifecycleChannel | null = flutterEngine.getLifecycleChannel(); + if (lifecycleChannel) { + expect(lifecycleChannel).not().assertNull(); + } + } + done(); + }) + + it('getNavigationChannel', 0, async (done: Function) => { + console.info("uitest: getNavigationChannel begin"); + if (flutterEngine) { + const navigationChannel: NavigationChannel | null = flutterEngine.getNavigationChannel(); + if (navigationChannel) { + expect(navigationChannel).not().assertNull(); + } + } + done(); + }) + + it('getTextInputChannel', 0, async (done: Function) => { + console.info("uitest: getTextInputChannel begin"); + if (flutterEngine) { + const textInputChannel: TextInputChannel | null = flutterEngine.getTextInputChannel(); + if (textInputChannel) { + expect(textInputChannel).not().assertNull(); + } + } + done(); + }) + + it('getPlatformChannel', 0, async (done: Function) => { + console.info("uitest: getPlatformChannel begin"); + if (flutterEngine) { + const platformChannel: PlatformChannel | null = flutterEngine.getPlatformChannel(); + if (platformChannel) { + expect(platformChannel).not().assertNull(); + } + } + done(); + }) + + it('getSystemChannel', 0, async (done: Function) => { + console.info("uitest: getSystemChannel begin"); + if (flutterEngine) { + const systemChannel: SystemChannel | null = flutterEngine.getSystemChannel(); + if (systemChannel) { + expect(systemChannel).not().assertNull(); + } + } + done(); + }) + + it('getLocaleChannel', 0, async (done: Function) => { + console.info("uitest: getLocaleChannel begin"); + if (flutterEngine) { + const localizationChannel: LocalizationChannel | null = flutterEngine.getLocaleChannel(); + if (localizationChannel) { + expect(localizationChannel).not().assertNull(); + } + } + done(); + }) + + it('getMouseCursorChannel', 0, async (done: Function) => { + console.info("uitest: getMouseCursorChannel begin"); + if (flutterEngine) { + const mouseCursorChannel: MouseCursorChannel | null = flutterEngine.getMouseCursorChannel(); + if (mouseCursorChannel) { + expect(mouseCursorChannel).not().assertNull(); + } + } + done(); + }) + + it('getFlutterNapi', 0, async (done: Function) => { + console.info("uitest: getFlutterNapi begin"); + if (flutterEngine) { + const flutterNapi: FlutterNapi = flutterEngine.getFlutterNapi(); + expect(flutterNapi).not().assertNull(); + } + done(); + }) + + it('getFlutterRenderer', 0, async (done: Function) => { + console.info("uitest: getFlutterRenderer begin"); + if (flutterEngine) { + const flutterRenderer: FlutterRenderer = flutterEngine.getFlutterRenderer(); + expect(flutterRenderer).not().assertNull(); + } + done(); + }) + + it('getDartExecutor', 0, async (done: Function) => { + console.info("uitest: getDartExecutor begin"); + if (flutterEngine) { + const dartExecutor: DartExecutor = flutterEngine.getDartExecutor(); + expect(dartExecutor).not().assertNull(); + } + done(); + }) + + it('getPlugins', 0, async (done: Function) => { + console.info("uitest: getPlugins begin"); + if (flutterEngine) { + const pluginRegistry: PluginRegistry | null = flutterEngine.getPlugins(); + if (pluginRegistry) { + expect(pluginRegistry).not().assertNull(); + } + } + done(); + }) + + it('getAbilityControlSurface', 0, async (done: Function) => { + console.info("uitest: getAbilityControlSurface begin"); + if (flutterEngine) { + const activityControlSurface: ActivityControlSurface | null = flutterEngine.getAbilityControlSurface(); + if (activityControlSurface) { + expect(activityControlSurface).not().assertNull(); + } + } + done(); + }) + + it('getSettingsChannel', 0, async (done: Function) => { + console.info("uitest: getSettingsChannel begin"); + if (flutterEngine) { + const settingsChannel: SettingsChannel | null = flutterEngine.getSettingsChannel(); + if (settingsChannel) { + expect(settingsChannel).not().assertNull(); + } + } + done(); + }) + + it('getFlutterLoader', 0, async (done: Function) => { + console.info("uitest: getFlutterLoader begin"); + if (flutterEngine) { + const flutterLoader: FlutterLoader = flutterEngine.getFlutterLoader(); + expect(flutterLoader).not().assertNull(); + } + done(); + }) + + it('getRestorationChannel', 0, async (done: Function) => { + console.info("uitest: getRestorationChannel begin"); + if (flutterEngine) { + const restorationChannel: RestorationChannel | null = flutterEngine.getRestorationChannel(); + if (restorationChannel) { + expect(restorationChannel).not().assertNull(); + } + } + done(); + }) + + it('getAccessibilityChannel', 0, async (done: Function) => { + console.info("uitest: getAccessibilityChannel begin"); + if (flutterEngine) { + const accessibilityChannel: AccessibilityChannel | null = flutterEngine.getAccessibilityChannel(); + if (accessibilityChannel) { + expect(accessibilityChannel).not().assertNull(); + } + } + done(); + }) + + it('getLocalizationPlugin', 0, async (done: Function) => { + console.info("uitest: getLocalizationPlugin begin"); + if (flutterEngine) { + const localizationChannel: LocalizationPlugin | null = flutterEngine.getLocalizationPlugin(); + if (localizationChannel) { + expect(localizationChannel).not().assertNull(); + } + } + done(); + }) + + it('getPlatformViewsController', 0, async (done: Function) => { + console.info("uitest: getPlatformViewsController begin"); + if (flutterEngine) { + const platformViewsController: PlatformViewsController | null = flutterEngine.getPlatformViewsController(); + if (platformViewsController) { + expect(platformViewsController).not().assertNull(); + } + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6ee93ce6ad0f9ac77f61cd50671c57f5b52e5bdd --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterNapiTest.test.ets @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import FlutterNapi from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi'; +import ApplicationInfoLoader from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/ApplicationInfoLoader'; +import { FlutterRenderer } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/renderer/FlutterRenderer'; +import { common } from '@kit.AbilityKit'; +import { describe, beforeAll, it, expect } from '@ohos/hypium'; +import { EngineLifecycleListener } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngine' +import { FlutterApplicationInfo, FlutterCallbackInformation } from '@ohos/flutter_ohos'; +import { resourceManager } from '@kit.LocalizationKit'; + +//jit产物默认kenel文件 +const DEFAULT_KERNEL_BLOB = "kernel_blob.bin"; +//文件路径分隔符 +const FILE_SEPARATOR = "/"; + +export default function FlutterNapiTest() { + const flutterNapi = new FlutterNapi(); + const context = getContext() as common.UIAbilityContext; + let textureId = 0; + let initResult: InitResult; + let snapshotAssetPath: string; + let flutterApplicationInfo: FlutterApplicationInfo; + let bundlePath: string; + let event: PanGestureEvent; + let assetManager: resourceManager.ResourceManager; + + describe('FlutterNapiTest', () => { + + beforeAll(() => { + if (context) { + initResult = new InitResult( + `${context.filesDir}/`, + `${context.cacheDir}/`, + `${context.filesDir}`); + snapshotAssetPath = initResult!.dataDirPath + FILE_SEPARATOR + flutterApplicationInfo!.flutterAssetsDir; + bundlePath = snapshotAssetPath + FILE_SEPARATOR + DEFAULT_KERNEL_BLOB; + flutterApplicationInfo = ApplicationInfoLoader.load(context); + assetManager = context.resourceManager; + } + const target: EventTarget = new CustomEventTarget(new CustomArea(0, 0, { + x: 0, y: 0 + }, { + x: 0, y: 0 + })); + const renderer = new FlutterRenderer(flutterNapi); + textureId = renderer.getTextureId(); + event = { + offsetX: 50, + offsetY: 50, + velocityX: 50, + velocityY: 50, + fingerList: [], + velocity: 0, + target: target, + timestamp: 0, + source: SourceType.Unknown, + pressure: 0, + tiltX: 0, + tiltY: 0, + sourceTool: SourceTool.Unknown + } + }) + + it('checkImplemented', 0, async (done: Function) => { + console.info("uitest: checkImplemented begin"); + const methodName = 'test'; + const flag = flutterNapi.checkImplemented(methodName); + expect(flag).not().assertNull(); + done(); + }) + + it('nativeLookupCallbackInformation', 0, async (done: Function) => { + console.info("uitest: nativeLookupCallbackInformation begin"); + try { + const handle = 1; + const flutterCallbackInformation: FlutterCallbackInformation | null = + FlutterNapi.nativeLookupCallbackInformation(handle); + if (flutterCallbackInformation) { + expect(flutterCallbackInformation).not().assertNull(); + } + } catch (e) { + } + done(); + }) + + it('isAttached', 0, async (done: Function) => { + console.info("uitest: isAttached begin"); + const flag: boolean = flutterNapi.isAttached(); + expect(flag).not().assertNull(); + done(); + }) + + it('spawn', 0, async (done: Function) => { + console.info("uitest: spawn begin"); + const entrypointFunctionName = 'test1'; + const pathToEntrypointFunction = 'test2'; + const initialRoute = 'test3'; + const entrypointArgs = ['test4']; + try { + const fnapi: FlutterNapi = + flutterNapi.spawn(entrypointFunctionName, pathToEntrypointFunction, initialRoute, entrypointArgs); + expect(fnapi).not().assertNull(); + } catch (e) { + } + done(); + }) + + it('computePlatformResolvedLocale', 0, async (done: Function) => { + console.info("uitest: computePlatformResolvedLocale begin"); + const strings = []; + const arr = flutterNapi.computePlatformResolvedLocale(strings); + expect(arr).not().assertNull(); + done(); + }) + + it('registerTexture', 0, async (done: Function) => { + console.info("uitest: registerTexture begin"); + const id = flutterNapi.registerTexture(textureId); + expect(id).not().assertNull(); + done(); + }) + }) +} + +class InitResult { + appStoragePath: string; + engineCachesPath: string; + dataDirPath: string; + + constructor(appStoragePath: string, + engineCachesPath: string, + dataDirPath: string) { + this.appStoragePath = appStoragePath; + this.engineCachesPath = engineCachesPath; + this.dataDirPath = dataDirPath; + } +} + +class CurEngineLifecycleListener implements EngineLifecycleListener { + onPreEngineRestart() { + + } + + onEngineWillDestroy() { + + } +} + +class CustomEventTarget implements EventTarget { + area: Area = new CustomArea(0, 0, { x: 0, y: 0 }, { x: 0, y: 0 }); + + constructor(area: Area) { + this.area = area; + } +} + +class CustomArea implements Area { + width: Length = 0; + height: Length = 0; + position: Position = { x: 0, y: 0 }; + globalPosition: Position = { x: 0, y: 0 }; + + constructor(width: Length, height: Length, position: Position, globalPosition: Position) { + this.width = width; + this.height = height; + this.position = position; + this.globalPosition = globalPosition; + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b98eaccdbeee59bb2c66bd0868981ee204bda1d1 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterOverlaySurfaceTest.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, expect, it } from '@ohos/hypium'; +import { FlutterOverlaySurface } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterOverlaySurface'; + +export default function FlutterOverlaySurfaceTest() { + let flutterOverlaySurface: FlutterOverlaySurface; + + describe('FlutterOverlaySurfaceTest', () => { + + beforeAll(() => { + const id = 2356; + flutterOverlaySurface = new FlutterOverlaySurface(id); + }) + + it('getId', 0, async (done: Function) => { + console.info("uitest: getId begin"); + const id = flutterOverlaySurface.getId(); + expect(id).not().assertNull(); + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b92df1429d92e30c588cb5ffbe5d55eeb0090512 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/FlutterShellArgsTest.test.ets @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, expect, it } from '@ohos/hypium'; +import { abilityDelegatorRegistry } from '@kit.TestKit'; +import { Want } from '@kit.AbilityKit'; +import FlutterShellArgs from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterShellArgs'; + +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function FlutterShellArgsTest() { + const flutterShellArgs: FlutterShellArgs = new FlutterShellArgs(); + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + + describe('FlutterShellArgsTest', () => { + + it('fromWant', 0, async (done: Function) => { + console.info("uitest: fromWant begin"); + try { + const flutterShellArgs = FlutterShellArgs.fromWant(want); + if (flutterShellArgs) { + expect(flutterShellArgs).not().assertNull(); + } + } catch (e) { + } + done(); + }) + + it('checkArg', 0, async (done: Function) => { + console.info("uitest: checkArg begin"); + const argKey = 'argKey'; + const argFlag = 'argFlag'; + try { + const flutterShellArgs = FlutterShellArgs.fromWant(want); + FlutterShellArgs.checkArg(argKey, argFlag, want, flutterShellArgs); + } catch (e) { + } + done(); + }) + + it('toArray', 0, async (done: Function) => { + console.info("uitest: toArray begin"); + const toArray = flutterShellArgs.toArray(); + expect(toArray).not().assertNull(); + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6577fa556cb0f9eeffe2c09f6450da5dbdb91d21 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartExecutorTest.test.ets @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, expect, it } from '@ohos/hypium'; +import { common } from '@kit.AbilityKit'; +import { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; +import { DartEntrypoint } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartExecutor'; +import { resourceManager } from '@kit.LocalizationKit'; +import DartExecutor from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartExecutor'; +import FlutterNapi from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi'; + +export default function DartExecutorTest() { + const flutterNapi = new FlutterNapi(); + let context: common.UIAbilityContext; + let dartExecutor: DartExecutor; + let options: Options; + let assetManager: resourceManager.ResourceManager; + let dartEntrypoint: DartEntrypoint | null = null; + let resourceManager: resourceManager.ResourceManager; + + describe('DartExecutorTest', () => { + + beforeAll(() => { + context = getContext() as common.UIAbilityContext; + assetManager = context.resourceManager; + resourceManager = context.resourceManager; + dartExecutor = new DartExecutor(flutterNapi, assetManager); + options = new Options(context); + dartEntrypoint = options.getDartEntrypoint(); + }) + + it('isExecutingDart', 0, async (done: Function) => { + console.info("uitest: isExecutingDart begin"); + if (dartExecutor) { + const isExecutingDart = dartExecutor.isExecutingDart(); + expect(isExecutingDart).not().assertNull(); + } + done(); + }) + + it('getBinaryMessenger', 0, async (done: Function) => { + console.info("uitest: getBinaryMessenger begin"); + if (dartExecutor) { + const binaryMessenger = dartExecutor.getBinaryMessenger(); + expect(binaryMessenger).not().assertNull(); + } + done(); + }) + + it('makeBackgroundTaskQueue', 0, async (done: Function) => { + console.info("uitest: makeBackgroundTaskQueue begin"); + if (dartExecutor) { + const taskQueue = dartExecutor.makeBackgroundTaskQueue(); + expect(taskQueue).not().assertNull(); + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..c48bad263fdf8725e88eaa658ec3acb6a53daf08 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/dart/DartMessengerTest.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DartMessenger} from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartMessenger' +import { describe,it, expect } from '@ohos/hypium'; +import FlutterNapi from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi' +import { + TaskQueue, +} from '@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger' +export default function DartMessengerTest() { + describe('FlutterDartMessengerTest', () => { + it('TestMakeBackgroundTaskQueue', 0, async (done: Function) => { + const flutterNapi: FlutterNapi = new FlutterNapi(); + const dartMessage = new DartMessenger(flutterNapi); + let taskQueue: TaskQueue = dartMessage.makeBackgroundTaskQueue(); + expect(taskQueue).not().assertNull(); + done(); + }) + + it('TestGetPendingChannelResponseCount', 0, async (done: Function) => { + const flutterNapi: FlutterNapi = new FlutterNapi(); + const messenger = new DartMessenger(flutterNapi); + let count: number = messenger.getPendingChannelResponseCount(); + expect(count).assertEqual(0); + done(); + }) + + it('TestAskQueueFactory', 0, async (done: Function) => { + const flutterNapi: FlutterNapi = new FlutterNapi(); + const messenger = new DartMessenger(flutterNapi); + expect(messenger.taskQueueFactory).not().assertNull(); + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..00fe21a0e9ff9560f6e1ea5c669e18c83d20dff4 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/ApplicationInfoTest.test.ets @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import common from '@ohos.app.ability.common'; +import ApplicationInfoLoader from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/ApplicationInfoLoader' +import { describe,it, expect } from '@ohos/hypium'; +export default function ApplicationInfoTest() { + describe('ApplicationInfoTest', () => { + it('TestLoad', 0, async (done: Function) => { + let context: common.Context = getContext(); + let applicationInfo = ApplicationInfoLoader.load(context) + expect(applicationInfo).not().assertNull(); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7556ae740f126c2e0e213045eb25a60b2b33b58f --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterApplicationInfoTest.test.ets @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import FlutterApplicationInfo from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/FlutterApplicationInfo' +import { describe, it, expect } from '@ohos/hypium'; +export default function FlutterApplicationInfoTest() { + describe('FlutterApplicationInfoTest', () => { + it('TestLoad', 0, async (done: Function) => { + let flutterApplicationInfo = new FlutterApplicationInfo("test", "test", "test", "test", "test", "test", false) + expect(flutterApplicationInfo).not().assertNull(); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..52e231dcd95db99780fcc6631a90c7b57e7adcbf --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/loader/FlutterLoaderTest.test.ets @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import common from '@ohos.app.ability.common'; +import FlutterLoader from '@ohos/flutter_ohos/src/main/ets/embedding/engine/loader/FlutterLoader' +import { describe,it, expect } from '@ohos/hypium'; +import FlutterNapi from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi' +export default function FlutterLoaderTest() { + describe('FlutterLoaderTest', () => { + it('initializationTest', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterLoader: FlutterLoader = new FlutterLoader(flutterNapi); + expect(flutterLoader.initialized).assertFalse(); + done(); + }) + + it('initResultTest', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterLoader: FlutterLoader = new FlutterLoader(flutterNapi); + expect(flutterLoader.initResult).assertNull(); + done(); + }) + + it('flutterNapiTest', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterLoader: FlutterLoader = new FlutterLoader(flutterNapi); + expect(flutterLoader.flutterNapi).not().assertNull(); + done(); + }) + + it('startInitializationTest', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterLoader: FlutterLoader = new FlutterLoader(flutterNapi); + let context: common.Context = getContext(); + expect(flutterLoader.initialized).assertFalse(); + flutterLoader.startInitialization(context); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4924e8b78ad3cde41b4c74e0f07a4cb33fab9234 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorViewTest.test.ets @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { FlutterMutatorView } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorView' +import { describe,it, expect } from '@ohos/hypium'; +export default function FlutterMutatorViewTest() { + describe('FlutterMutatorViewTest', () => { + it('TestGetDvModel', 0, async (done: Function) => { + let flutterMutatorView = new FlutterMutatorView(); + let dvModel = flutterMutatorView.getDvModel(); + expect(dvModel).not().assertNull(); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c633425ba780a04fae007d44cc50f759b5787dd --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/mutatorsstack/FlutterMutatorsStackTest.test.ets @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import common from '@ohos.app.ability.common'; +import { + FlutterMutatorsStack, + FlutterMutator +} from '@ohos/flutter_ohos/src/main/ets/embedding/engine/mutatorsstack/FlutterMutatorsStack' +import { describe,it, expect } from '@ohos/hypium'; +import matrix4 from '@ohos.matrix4' +export default function FlutterMutatorsStackTest() { + describe('FlutterMutatorsStackTest', () => { + it('TestPushClipPath', 0, async (done: Function) => { + let flutterMutatorStack = new FlutterMutatorsStack(); + const width = 100; + const height = 200; + const command = 'M 10 10 L 90 90'; + flutterMutatorStack.pushClipPath(width, height, command); + expect(flutterMutatorStack.getMutators().length).assertEqual(1); + expect(flutterMutatorStack.getFinalClippingPaths().length).assertEqual(1); + done(); + }) + + it('TestPushClipRect1', 0, async (done: Function) => { + let flutterMutatorStack = new FlutterMutatorsStack(); + const width = 100; + const height = 200; + const radius = 10; + flutterMutatorStack.pushClipRect(width, height, radius); + expect(flutterMutatorStack.getMutators().length).assertEqual(1); + done(); + }) + + it('TestPushClipRect2', 0, async (done: Function) => { + let flutterMutatorStack = new FlutterMutatorsStack(); + const width = 100; + const height = 200; + const radius = 10; + flutterMutatorStack.pushClipRect(width, height, radius); + expect(flutterMutatorStack.getFinalClippingRects().length).assertEqual(1); + done(); + }) + + it('TestPushTransform1', 0, async (done: Function) => { + const values = [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + let flutterMutatorStack = new FlutterMutatorsStack(); + flutterMutatorStack.pushTransform(values); + expect(flutterMutatorStack.getMutators().length).assertEqual(1); + done(); + }) + + it('TestPushTransform2', 0, async (done: Function) => { + const values = [1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1]; + let flutterMutatorStack = new FlutterMutatorsStack(); + flutterMutatorStack.pushTransform(values); + expect(flutterMutatorStack.getMutators().length).assertEqual(1); + done(); + }) + + it('TestFlutterMutatorsStack1', 0, async (done: Function) => { + let flutterMutatorStack = new FlutterMutatorsStack(); + expect(flutterMutatorStack.getMutators().length).assertEqual(0); + done(); + }) + + it('TestFlutterMutatorsStack2', 0, async (done: Function) => { + let flutterMutatorStack = new FlutterMutatorsStack(); + expect(flutterMutatorStack.getFinalClippingPaths().length).assertEqual(0); + done(); + }) + + it('TestFlutterMutatorsStack3', 0, async (done: Function) => { + let flutterMutatorStack = new FlutterMutatorsStack(); + expect(flutterMutatorStack.getFinalClippingRects().length).assertEqual(0); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..169f510280b480861703ce4c3054f6adaddaf834 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/renderer/FlutterRendererTest.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe,it, expect } from '@ohos/hypium'; +import { FlutterRenderer} from '@ohos/flutter_ohos/src/main/ets/embedding/engine/renderer/FlutterRenderer'; +import FlutterNapi from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterNapi' +export default function FlutterRendererTest() { + describe('FlutterRendererTest', () => { + it('TestCreateSurfaceTexture', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterRenderer = new FlutterRenderer(flutterNapi); + let surfaceTextureEntry = flutterRenderer.createSurfaceTexture(); + expect(surfaceTextureEntry).not().assertNull();; + done(); + }) + + it('TestGetTextureId', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterRenderer = new FlutterRenderer(flutterNapi); + let textureId = flutterRenderer.getTextureId(); + expect(textureId == 0).assertFalse(); + done(); + }) + + it('TestRegisterPixelMap', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterRenderer = new FlutterRenderer(flutterNapi); + const pixelMap = {} as PixelMap; + let textureId = flutterRenderer.registerPixelMap(pixelMap); + expect(textureId).assertEqual(1); + done(); + }) + + it('TestRegisterPixelMapMore', 0, async (done: Function) => { + let flutterNapi: FlutterNapi = new FlutterNapi(); + let flutterRenderer = new FlutterRenderer(flutterNapi); + const pixelMap1 = {} as PixelMap; + const pixelMap2 = {} as PixelMap; + const textureId1 = flutterRenderer.registerPixelMap(pixelMap1); + const textureId2 = flutterRenderer.registerPixelMap(pixelMap2); + expect(textureId1).assertEqual(1); // 第一次调用 + expect(textureId2).assertEqual(2); // 第二次调用 + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..61590d082192e7d588d84d266ad9768c34248ebc --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/LifecycleChannel.test.ets @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeEach, it, expect } from '@ohos/hypium' +import LifecycleChannel from '@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/LifecycleChannel'; +import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; + +export default function LifecycleChannelTest() { + describe('LifecycleChannelTest', () => { + let lifecycleChannel: LifecycleChannel; + let dartExecutorMock: Any; + let basicMessageChannelMock: Any; + beforeEach(() => { + dartExecutorMock = { + send: (channelName: string, message: string) => { + } + }; + basicMessageChannelMock = { + send: (message: string) => { + } + }; + lifecycleChannel = new LifecycleChannel(dartExecutorMock as Any); + (lifecycleChannel as Any).channel = basicMessageChannelMock; + }); + it('should send resumed state with focus', 0, () => { + lifecycleChannel.appIsResumed(); + lifecycleChannel.aWindowIsFocused(); + expect(basicMessageChannelMock.send).not().assertEqual('AppLifecycleState.resumed'); + }) + it('should send inactive state without focus', 0, () => { + lifecycleChannel.appIsResumed(); + lifecycleChannel.noWindowsAreFocused(); + expect(basicMessageChannelMock.send).not().assertEqual('AppLifecycleState.inactive'); + }) + it('should send inactive state when app is inactive', 0, () => { + lifecycleChannel.appIsInactive(); + lifecycleChannel.aWindowIsFocused(); + expect(basicMessageChannelMock.send).not().assertEqual('AppLifecycleState.inactive'); + }) + it('should send paused state when app is paused', 0, () => { + lifecycleChannel.appIsPaused(); + lifecycleChannel.aWindowIsFocused(); + expect(basicMessageChannelMock.send).not().assertEqual('AppLifecycleState.paused'); + }) + it('should send detached state when app is detached', 0, () => { + lifecycleChannel.appIsDetached(); + lifecycleChannel.aWindowIsFocused(); + expect(basicMessageChannelMock.send).not().assertEqual('AppLifecycleState.detached'); + }) + it('should not send duplicate state', 0, () => { + lifecycleChannel.appIsResumed(); + lifecycleChannel.aWindowIsFocused(); + (lifecycleChannel as Any).lastFlutterState = 'AppLifecycleState.resumed'; + + lifecycleChannel.appIsResumed(); + lifecycleChannel.aWindowIsFocused(); + expect(basicMessageChannelMock.send).not().assertEqual(1); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..1b6bb22329b4c9703ffc87264be2b2ae07c0b4cc --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/PlatformChannel.test.ets @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, expect, it, } from "@ohos/hypium"; +import { AsyncCallback as _AsyncCallback } from '@ohos.base'; +import PlatformChannel, { + Brightness, + ClipboardContentFormat, + DeviceOrientation, + HapticFeedbackType, + SystemUiMode, + SystemUiOverlay +} from "@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/PlatformChannel"; +import { Any, DartExecutor, FlutterNapi, MethodResult } from "@ohos/flutter_ohos"; +import { resourceManager } from "@kit.LocalizationKit"; + +export default function PlatformChannelUnitTest() { + describe('PlatformChannelTest', () => { + it('platformChannel_decodeOrientations', 0, decodeOrientations); + + it('platformChannel_getFeedbackTypeFromValue', 0, getFeedbackTypeFromValue); + + it('platformChannel_getClipboardContentFormatFromValue', 0, getClipboardContentFormatFromValue); + + it('platformChannel_getSystemUiOverlayFromValue', 0, getSystemUiOverlayFromValue); + + it('platformChannel_getSystemUiModeFromValue', 0, getSystemUiModeFromValue); + + it('platformChannel_getBrightnessFromValue', 0, getBrightnessFromValue); + + it('platformChannel_getDeviceOrientationFromValue', 0, getDeviceOrientationFromValue); + }) +} + +function decodeOrientations() { + let channel = getPlatformChannel(); + expect(channel.decodeOrientations([DeviceOrientation.PORTRAIT_UP])).assertInstanceOf("Number") +} + +function getFeedbackTypeFromValue() { + let channel = getPlatformChannel(); + let result = channel.getFeedbackTypeFromValue(HapticFeedbackType.STANDARD); + expect(result).assertInstanceOf("String") +} + +function getClipboardContentFormatFromValue() { + let channel = getPlatformChannel(); + let result = channel.getClipboardContentFormatFromValue(ClipboardContentFormat.PLAIN_TEXT); + expect(result).assertInstanceOf("String") +} + +function getSystemUiOverlayFromValue() { + let channel = getPlatformChannel(); + let result = channel.getSystemUiOverlayFromValue(SystemUiOverlay.BOTTOM_OVERLAYS); + expect(result).assertInstanceOf("String") +} + +function getSystemUiModeFromValue() { + let channel = getPlatformChannel(); + let result = channel.getSystemUiModeFromValue(SystemUiMode.IMMERSIVE); + expect(result).assertInstanceOf("String") +} + +function getBrightnessFromValue() { + let channel = getPlatformChannel(); + let result = channel.getBrightnessFromValue(Brightness.LIGHT); + expect(result).assertInstanceOf("String") +} + +function getDeviceOrientationFromValue() { + let channel = getPlatformChannel(); + let result = channel.getDeviceOrientationFromValue(DeviceOrientation.PORTRAIT_UP); + expect(result).assertInstanceOf("String") +} + +function getPlatformChannel(): PlatformChannel { + let flutterNapi = new FlutterNapi(); + let manager: resourceManager.ResourceManager = getContext().resourceManager; + let dartExecutor = new DartExecutor(flutterNapi, manager); + let channel = new PlatformChannel(dartExecutor); + return channel; +} + +export class MethodResultTest implements MethodResult { + success = (result: Any): void => { + }; + error = (errorCode: string, errorMessage: string, errorDetails: Any): void => { + }; + notImplemented = (): void => { + } +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a692e1ad8a4cb8039133306c77e8c75de062f13 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/RestorationChannel.test.ets @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { + DartExecutor, + FlutterNapi, + MethodCall, + MethodCallHandler, + MethodChannel, + MethodResult, + RestorationChannel, + StandardMethodCodec +} from "@ohos/flutter_ohos"; +import { describe, expect, it } from "@ohos/hypium"; +import { resourceManager } from "@kit.LocalizationKit"; +import { util } from "@kit.ArkTS"; + +let TAG = "RestorationChannel"; + +export default function RestorationChannelUnitTest() { + + describe('RestorationChannelTest', () => { + it("RestorationChannel_getRestorationData", 0, getRestorationData); + }) +} + +function getRestorationData() { + let channel = getRestorationChannel(); + expect(channel.getRestorationData()).assertInstanceOf("Uint8Array") +} + +function getRestorationChannel(): RestorationChannel { + let flutterNapi = new FlutterNapi(); + let manager: resourceManager.ResourceManager = getContext().resourceManager; + let dartExecutor = new DartExecutor(flutterNapi, manager); + let rawChannel = new MethodChannel(dartExecutor, "flutter/mousecursor", StandardMethodCodec.INSTANCE); + let restorationChannel = new RestorationChannel(rawChannel, false); + return restorationChannel; +} + +class TestMethodCallHandler implements MethodCallHandler { + onMethodCall(call: MethodCall, result: MethodResult): void { + } +} + +/** + * string转Uint8Array + * @param value + * @returns + */ +export function stringToUint8Array(str: string): Uint8Array { + try { + let textEncoder = new util.TextEncoder("utf-8"); + let array: Uint8Array = textEncoder.encodeInto(str); + return array + } catch (err) { + return new Uint8Array() + } +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..ae6ac3ed607cbaba74fe39bf5fd1582ce7777f13 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/SettingsChannel.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, expect, it } from "@ohos/hypium"; +import { resourceManager } from "@kit.LocalizationKit"; +import { DartExecutor, FlutterNapi, SettingsChannel } from "@ohos/flutter_ohos"; + +export default function SettingsChannelUnitTest() { + describe('SettingsChannelTest', () => { + it("SettingsChannel_startMessage", 0, startMessage); + }) +} + +function startMessage() { + let channel = getSettingsChannel(); + let result = channel.startMessage(); + expect(result).assertInstanceOf("Object"); +} + +function getSettingsChannel(): SettingsChannel { + let flutterNapi = new FlutterNapi(); + let manager: resourceManager.ResourceManager = getContext().resourceManager; + let dartExecutor = new DartExecutor(flutterNapi, manager); + let channel = new SettingsChannel(dartExecutor); + return channel; +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5266cefa3ce4b7bff9e407f60965f64d7d152ea8 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/engine/systemchannels/TextInputChannel.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, expect, it } from "@ohos/hypium"; +import { resourceManager } from "@kit.LocalizationKit"; +import { DartExecutor, FlutterNapi, TextInputChannel } from "@ohos/flutter_ohos"; + +export default function TextInputChannelUnitTest() { + describe('TextInputChannel', () => { + it("TextInputChannel_createEditingStateJSON", 0, createEditingStateJSON); + }) +} + +function createEditingStateJSON() { + let textInputChannel = getTextInputChannel(); + let result = textInputChannel.createEditingStateJSON("test", 0, 1, 0, 2); + expect(result).assertInstanceOf("Object"); +} + +function getTextInputChannel(): TextInputChannel { + let flutterNapi = new FlutterNapi(); + let manager: resourceManager.ResourceManager = getContext().resourceManager; + let dartExecutor = new DartExecutor(flutterNapi, manager); + let channel = new TextInputChannel(dartExecutor); + return channel; +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e13db7bb04a28d455224517e6924231e90fb4cb --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityAndEntryDelegateTest.test.ets @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry } from '@kit.TestKit'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import { FlutterAbilityAndEntryDelegate } from "@ohos/flutter_ohos"; +import { Options } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/FlutterEngineGroup'; +import { Want } from '@kit.AbilityKit'; + +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function FlutterAbilityAndEntryDelegateTest() { + describe('FlutterAbilityAndEntryDelegateTest', () => { + + it('TestAddEntrypointOptions', 0, async (done: Function) => { + const flutterAbilityAndEntryDelegate: FlutterAbilityAndEntryDelegate = new FlutterAbilityAndEntryDelegate(); + const options: Options = new Options(getContext()); + const result = flutterAbilityAndEntryDelegate.addEntrypointOptions(options); + expect(result).not().assertNull(); + done(); + }) + + it('TestShouldDispatchAppLifecycleState', 0, async (done: Function) => { + const flutterAbilityAndEntryDelegate: FlutterAbilityAndEntryDelegate = new FlutterAbilityAndEntryDelegate(); + const result = flutterAbilityAndEntryDelegate.shouldDispatchAppLifecycleState(); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetFlutterNapi', 0, async (done: Function) => { + const flutterAbilityAndEntryDelegate: FlutterAbilityAndEntryDelegate = new FlutterAbilityAndEntryDelegate(); + const result = flutterAbilityAndEntryDelegate.getFlutterNapi(); + expect(result).assertNull(); + done(); + }) + + it('TestOnSaveState', 0, async (done: Function) => { + const flutterAbilityAndEntryDelegate: FlutterAbilityAndEntryDelegate = new FlutterAbilityAndEntryDelegate(); + const reason: AbilityConstant.StateType = AbilityConstant.StateType.CONTINUATION + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + const wantParam: Record = { + "testParams": want + } + const result = flutterAbilityAndEntryDelegate.onSaveState(reason, wantParam); + expect(result).assertEqual(5); + done(); + }) + + it('TestIsFlutterEngineFromHost', 0, async (done: Function) => { + const flutterAbilityAndEntryDelegate: FlutterAbilityAndEntryDelegate = new FlutterAbilityAndEntryDelegate(); + const result = flutterAbilityAndEntryDelegate.isFlutterEngineFromHost(); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetFlutterEngine', 0, async (done: Function) => { + const flutterAbilityAndEntryDelegate: FlutterAbilityAndEntryDelegate = new FlutterAbilityAndEntryDelegate(); + const result = flutterAbilityAndEntryDelegate.getFlutterEngine(); + expect(result).assertNull(); + done(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..949afc3a5016109b96dfd8135c89d7274653ff36 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterAbilityTest.test.ets @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { abilityDelegatorRegistry } from '@kit.TestKit'; +import { Want } from '@kit.AbilityKit'; +import AbilityConstant from '@ohos.app.ability.AbilityConstant'; +import { FlutterView, FlutterAbility, FlutterEngine, FlutterPlugin } from "@ohos/flutter_ohos"; +import { FlutterPluginBinding } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin'; + +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; +const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' +} + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +export default function FlutterAbilityTest() { + describe('FlutterAbilityTest', () => { + it('FlutterAbilityTest', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const flutterView: FlutterView | null = flutterAbility.getFlutterView(); + expect(flutterView).assertNull(); + await sleep(1000); + const pagePath: string = flutterAbility.pagePath(); + expect(pagePath).assertEqual("pages/Index"); + done(); + }) + + it('TestFlutterAbilityOnSaveState', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const reason: AbilityConstant.StateType = AbilityConstant.StateType.CONTINUATION + const wantParam: Record = { + "testParams": want + } + await sleep(1000); + const result = flutterAbility.onSaveState(reason, wantParam); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetWant', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.getWant(); + expect(result).assertUndefined(); + done(); + }) + + it('TestGetFlutterAbilityAndEntryDelegate', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.getFlutterAbilityAndEntryDelegate(); + expect(result).assertNull(); + done(); + }) + + it('TestShouldDispatchAppLifecycleState', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.shouldDispatchAppLifecycleState(); + expect(result).assertTrue(); + done(); + }) + + it('TestProvideFlutterEngine', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.provideFlutterEngine(getContext()); + expect(result).assertNull(); + done(); + }) + + it('TestProvidePlatformPlugin', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const flutterEngine = new FlutterEngine(getContext(), null, null, null); + const result = flutterAbility.providePlatformPlugin(flutterEngine); + expect(result).not().assertNull(); + done(); + }) + + it('TestPopSystemNavigator', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.popSystemNavigator(); + expect(result).assertFalse(); + done(); + }) + + it('TestShouldAttachEngineToAbility', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.shouldAttachEngineToAbility(); + expect(result).assertTrue(); + done(); + }) + + it('TestGetDartEntrypointLibraryUri', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.getDartEntrypointLibraryUri(); + expect(result).assertEqual(""); + done(); + }) + + it('TestGetAppBundlePath', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.getAppBundlePath(); + expect(result).assertEqual(""); + done(); + }) + + it('TestAttachToEngineAutomatically', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.attachToEngineAutomatically(); + expect(result).assertTrue(); + done(); + }) + + it('TestGetExclusiveAppComponent', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.getExclusiveAppComponent(); + expect(result).assertNull(); + done(); + }) + + it('TestGetFlutterEngine', 0, async (done: Function) => { + const flutterAbility: FlutterAbility = new FlutterAbility(); + const result = flutterAbility.getFlutterEngine(); + expect(result).assertNull(); + done(); + }) + }) + +} + + +class TestFlutterPlugin implements FlutterPlugin { + getUniqueClassName(): string { + return "engine test"; + } + + onAttachedToEngine(binding: FlutterPluginBinding): void { + console.info("uitest: onAttachedToEngine"); + } + + onDetachedFromEngine(binding: FlutterPluginBinding): void { + console.info("uitest: onAttachedToEngine"); + } +} + +let plugin: FlutterPlugin = new TestFlutterPlugin(); diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..58ff92f5d4414021b4a473a83370071c6938b988 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterEntryTest.test.ets @@ -0,0 +1,182 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { FlutterEngine, FlutterPlugin, FlutterEntry } from "@ohos/flutter_ohos"; +import { FlutterPluginBinding } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/plugins/FlutterPlugin'; + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +export default function FlutterEntryTest() { + describe('FlutterEntryTest', () => { + + it('TestGetFlutterView', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getFlutterView(); + expect(result).assertNull(); + done(); + }) + + it('TestGetFlutterEngine', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getFlutterEngine(); + expect(result).not().assertNull(); + done(); + }) + + it('TestShouldDispatchAppLifecycleState', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.shouldDispatchAppLifecycleState(); + expect(result).assertTrue(); + done(); + }) + + it('TestProvideFlutterEngine', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.provideFlutterEngine(getContext()); + expect(result).assertNull(); + done(); + }) + + it('TestProvidePlatformPlugin', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const flutterEngine = new FlutterEngine(getContext(), null, null, null); + const result = flutterEntry.providePlatformPlugin(flutterEngine); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetFlutterShellArgs', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getFlutterShellArgs(); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetDartEntrypointArgs', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getDartEntrypointArgs(); + expect(result).not().assertNull(); + done(); + }) + + it('TestPopSystemNavigator', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.popSystemNavigator(); + expect(result).assertFalse(); + done(); + }) + + it('TestShouldAttachEngineToAbility', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.shouldAttachEngineToAbility(); + expect(result).assertUndefined(); + done(); + }) + + it('TestGetDartEntrypointLibraryUri', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getDartEntrypointLibraryUri(); + expect(result).assertEqual(""); + done(); + }) + + it('TestGetAppBundlePath', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getAppBundlePath(); + expect(result).assertEqual(""); + done(); + }) + + it('TestGetDartEntrypointFunctionName', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getDartEntrypointFunctionName(); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetInitialRoute', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getInitialRoute(); + expect(result).not().assertNull(); + done(); + }) + + it('TestAttachToEngineAutomatically', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.attachToEngineAutomatically(); + expect(result).assertTrue(); + done(); + }) + + it('TestShouldRestoreAndSaveState', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.shouldRestoreAndSaveState(); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetExclusiveAppComponent', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getExclusiveAppComponent(); + expect(result).assertNull(); + done(); + }) + + it('TestGetCachedEngineId', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getCachedEngineId(); + expect(result).assertUndefined(); + done(); + }) + + it('TestGetCachedEngineGroupId', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + const result = flutterEntry.getCachedEngineGroupId(); + expect(result).assertUndefined(); + done(); + }) + + it('TestAddPlugin', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + flutterEntry.addPlugin(plugin); + done(); + }) + + it('TestRemovePlugin', 0, async (done: Function) => { + const flutterEntry: FlutterEntry = new FlutterEntry(getContext()); + flutterEntry.removePlugin(plugin); + done(); + }) + }) + +} + +class TestFlutterPlugin implements FlutterPlugin { + getUniqueClassName(): string { + return "engine test"; + } + + onAttachedToEngine(binding: FlutterPluginBinding): void { + console.info("uitest: onAttachedToEngine"); + } + + onDetachedFromEngine(binding: FlutterPluginBinding): void { + console.info("uitest: onAttachedToEngine"); + } +} + +let plugin: FlutterPlugin = new TestFlutterPlugin(); diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..336c41642866334082aac94f75977ccc0ad26cda --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/FlutterManagerTest.test.ets @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect, beforeAll } from '@ohos/hypium'; +import { FlutterManager } from "@ohos/flutter_ohos"; +import { window } from '@kit.ArkUI'; +import { FullScreenListener } from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/FlutterManager'; + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +const flutterManager: FlutterManager = FlutterManager.getInstance(); +const uiAbility = flutterManager.getUIAbility(getContext()); + +export default function FlutterManagerTest() { + describe('FlutterManagerTest', () => { + beforeAll(async () => { + const windowStage = flutterManager.getWindowStage(uiAbility); + await sleep(1000); + flutterManager.pushWindowStage(uiAbility, windowStage); + await sleep(1000); + flutterManager.popWindowStage(uiAbility); + await sleep(1000); + flutterManager.pushUIAbility(uiAbility); + await sleep(1000); + flutterManager.popUIAbility(uiAbility); + + }) + + it('TestGetFlutterViewList', 0, async (done: Function) => { + const result = flutterManager.getFlutterViewList(); + expect(result).not().assertNull(); + done(); + }) + + it('TestSetFullScreenListener', 0, async (done: Function) => { + class MyFullScreenListener implements FullScreenListener { + useFullScreen(): boolean { + return true; + } + + setUseFullScreen(useFullScreen: boolean): void { + console.info("uitest: setUseFullScreen useFullScreen " + useFullScreen); + } + + onScreenStateChanged(data: window.WindowStatusType): void { + console.info("uitest: onScreenStateChanged"); + } + } + + const listener: FullScreenListener = new MyFullScreenListener(); + flutterManager.setFullScreenListener(listener); + await sleep(1000); + const result = flutterManager.getFullScreenListener(); + expect(result).not().assertNull(); + done(); + }) + + it('TestFullScreen', 0, async (done: Function) => { + const result = flutterManager.useFullScreen(); + expect(result).assertTrue(); + flutterManager.setUseFullScreen(result); + flutterManager.clear(); + done(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..76c43cb3fedc2129106905f63979c197a6e34397 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/SettingTest.test.ets @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { Settings } from "@ohos/flutter_ohos"; +import { MediaQuery } from '@kit.ArkUI'; +import { PlatformBrightness } from '@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/SettingsChannel'; + +const settings: Settings = new Settings(null); + +export default function SettingTest() { + describe('SettingTest', () => { + it('TestGetTextScaleFactor', 0, async (done: Function) => { + const result: number = settings.getTextScaleFactor(); + expect(result).not().assertNull(); + done(); + }) + + it('TestGetThemeMode', 0, async (done: Function) => { + const mediaQuery: MediaQuery = new MediaQuery(); + settings.sendSettings(mediaQuery); + const result: PlatformBrightness = settings.getThemeMode(mediaQuery); + expect(result).not().assertNull(); + done(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..dc72a1450d2c27e4f03ed6d48e08d6eb0c04af15 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventProcessorTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import TouchEventProcessor from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/TouchEventProcessor'; +import { CustomTouchEvent } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/CustomTouchEvent'; + +export default function TouchEventProcessorTest() { + const touchEventProcessor: TouchEventProcessor = new TouchEventProcessor(); + + describe('TouchEventProcessorTest', () => { + + it('getInstance', 0, async (done: Function) => { + console.info("uitest: getInstance begin"); + const getInstance: TouchEventProcessor = TouchEventProcessor.getInstance(); + expect(getInstance).not().assertNull(); + done(); + }) + + it('decodeTouchPacket', 0, async (done: Function) => { + console.info("uitest: decodeTouchPacket begin"); + const strings = ['test1', 'test2', 'test3']; + const top = 10; + const left = 10; + const decodeTouchPacket: CustomTouchEvent = touchEventProcessor.constureCustomTouchEvent(strings, top, left); + expect(decodeTouchPacket).not().assertNull(); + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fc93b33e7bf0e95e7b8efab23c6a36d504c92a02 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/TouchEventTrackerTest.test.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { TouchEventId, TouchEventTracker } from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/TouchEventTracker'; +import { TouchEvent } from '@ohos.multimodalInput.touchEvent'; + +export default function TouchEventTrackerTest() { + const touchEventTracker: TouchEventTracker = new TouchEventTracker(); + + describe('TouchEventTrackerTest', () => { + + it('getInstance', 0, async (done: Function) => { + console.info("uitest: getInstance begin"); + const getInstance: TouchEventTracker = TouchEventTracker.getInstance(); + expect(getInstance).not().assertNull(); + done(); + }) + + it('track', 0, async (done: Function) => { + console.info("uitest: decodeTouchPacket begin"); + const event: TouchEvent | null = null; + if(event) { + const decodeTouchPacket: TouchEventId = touchEventTracker.track(event); + expect(decodeTouchPacket).not().assertNull(); + } + done(); + }) + + it('pop', 0, async (done: Function) => { + console.info("uitest: pop begin"); + const eventId: TouchEventId | null = null; + if(eventId) { + const tuchEvent: TouchEvent = touchEventTracker.pop(eventId); + expect(tuchEvent).not().assertNull(); + } + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..92a803725bdb47d4cd8f18837ca9897e8bfab434 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapperTest.test.ets @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import WindowInfoRepositoryCallbackAdapterWrapper from '@ohos/flutter_ohos/src/main/ets/embedding/ohos/WindowInfoRepositoryCallbackAdapterWrapper'; + +export default function WindowInfoRepositoryCallbackAdapterWrapperTest() { + + describe('WindowInfoRepositoryCallbackAdapterWrapper', () => { + + it('WindowInfoRepositoryCallbackAdapterWrapper', 0, async (done: Function) => { + console.info("uitest: WindowInfoRepositoryCallbackAdapterWrapper begin"); + const windowInfoRepositoryCallbackAdapterWrapper: WindowInfoRepositoryCallbackAdapterWrapper = new WindowInfoRepositoryCallbackAdapterWrapper(); + expect(windowInfoRepositoryCallbackAdapterWrapper).not().assertNull(); + done(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b27be52ecfaf833a4d35e400725531baa0e6c4e0 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryCodecTest.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { BinaryCodec } from "@ohos/flutter_ohos"; +import { buffer } from '@kit.ArkTS'; + +const binaryCodec: BinaryCodec = new BinaryCodec(true); + +export default function BinaryCodecTest() { + describe('BinaryCodecTest', () => { + it('TestBinaryCodecEncodeMessageSend', 0, async (done: Function) => { + let blobValue: buffer.Blob = new buffer.Blob(['name', 'age', 'sex']); + let message: ArrayBuffer = await blobValue.arrayBuffer(); + const result: ArrayBuffer = binaryCodec.encodeMessage(message); + expect(result).not().assertNull(); + done(); + }) + + it('TestBinaryCodecDecodeMessage', 0, async (done: Function) => { + const result = binaryCodec.decodeMessage(null); + expect(result).not().assertNull(); + done(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b746c7968235d512006395e13bc835e68f500904 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/BinaryMessengerTest.test.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, expect, it } from '@ohos/hypium'; +import { + BinaryMessageHandler, + BinaryMessenger, + BinaryReply, + TaskQueue, + TaskQueueOptions +} from '@ohos/flutter_ohos/src/main/ets/plugin/common/BinaryMessenger'; + +export default function BinaryMessengerTest() { + let binaryMessenger: CurBinaryMessenger = new CurBinaryMessenger(); + + describe('BinaryMessengerTest', () => { + + it('makeBackgroundTaskQueue', 0, async (done: Function) => { + console.info("uitest: makeBackgroundTaskQueue begin"); + const options = new TaskQueueOptions(); + const taskQueue: TaskQueue = binaryMessenger.makeBackgroundTaskQueue(options); + expect(taskQueue).not().assertNull(); + done(); + }) + }) +} + +class CurBinaryMessenger implements BinaryMessenger { + makeBackgroundTaskQueue(options?: TaskQueueOptions | undefined): TaskQueue { + return {}; + } + + send(channel: String, message: ArrayBuffer, callback?: BinaryReply | null | undefined) { + + } + + setMessageHandler(channel: String, handler: BinaryMessageHandler | BinaryMessageHandler | null, taskQueue?: TaskQueue, + ...args: Object[]) { + } +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..fbdeee4dbff3e606214ea352bc00a90e348587f2 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/FlutterException.test.ets @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import FlutterException from '@ohos/flutter_ohos/src/main/ets/plugin/common/FlutterException'; + +interface keyValue { + key: string; +} + +interface anotherKey { + anotherKey: string; +} + +interface defaultKey { + defaultKey: string; +} + +export default function FlutterExceptionTest() { + describe('FlutterExceptionTest', () => { + it('should initialize with correct values', 0, () => { + const code = 'ERROR_CODE_123'; + const message = 'This is an error message'; + const details:keyValue = { key: 'value' }; + const exception = new FlutterException(code, message, details); + expect(exception.message).assertEqual(message); + expect(exception.code).assertEqual(code); + expect(exception.name).assertEqual(''); + }) + it('should have a stack property if provided', 0, () => { + const code = 'ERROR_CODE_456'; + const message = 'Another error message'; + const details: anotherKey = { anotherKey: 'anotherValue' }; + const stack = 'Error stack trace'; + const exception = new FlutterException(code, message, details); + exception.stack = stack; + expect(exception.stack).assertEqual(stack); + }) + it('should default name to an empty string if not provided', 0, () => { + const code = 'ERROR_CODE_789'; + const message = 'Default name test'; + const details: defaultKey = { defaultKey: 'defaultValue' }; + const exception = new FlutterException(code, message, details); + expect(exception.name).assertEqual(''); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..d7df35e2f0fdaf9c0f29861654acce7bcd01ec2d --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMessageCodec.test.ets @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium' +import JSONMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/JSONMessageCodec'; +import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils'; + +export default function JSONMessageCodecTest() { + describe('JSONMessageCodecTest', () => { + const codec = JSONMessageCodec.INSTANCE; + it('should encode and decode a null message', 0, () => { + const originalMessage = null; + const encodedMessage = codec.encodeMessage(originalMessage); + const decodedMessage = StringUtils.arrayBufferToString(encodedMessage); + expect(decodedMessage).assertEqual(""); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf7519e89861eaca110f470a85d24ef88e55cf1b --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/JSONMethodCodec.test.ets @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { Any, JSONMethodCodec, MethodCall } from "@ohos/flutter_ohos"; +import { describe, expect, it, MockKit, when } from "@ohos/hypium"; + +export default function JSONMethodCodecUnitTest() { + describe('JSONMethodCodec', () => { + it("JSONMethodCodec_encodeMethodCall", 0, encodeMethodCall); + + it("JSONMethodCodec_encodeSuccessEnvelope", 0, encodeSuccessEnvelope); + + it("JSONMethodCodec_decodeEnvelope", 0, decodeEnvelope); + + }) +} + +function encodeMethodCall() { + let mocker = new MockKit(); + let ob = JSONMethodCodec.INSTANCE; + let mockFunc = mocker.mockFunc(ob, ob.encodeMethodCall); + let params = new MethodCall("key", "value"); + let r = new ArrayBuffer(4096); + when(mockFunc)(params).afterReturn(r); + let result = ob.encodeMethodCall(params); + expect(result).assertEqual(r); +} + +function encodeSuccessEnvelope() { + let mocker = new MockKit(); + let ob = JSONMethodCodec.INSTANCE; + let mockFunc = mocker.mockFunc(ob, ob.encodeSuccessEnvelope); + let r = new ArrayBuffer(4096); + when(mockFunc)(null).afterReturn(r); + expect(ob.encodeSuccessEnvelope(null)).assertEqual(r); +} + +function decodeEnvelope() { + let mocker = new MockKit(); + let ob = JSONMethodCodec.INSTANCE; + let mockFunc = mocker.mockFunc(ob, ob.decodeEnvelope); + let r = new ArrayBuffer(4096); + when(mockFunc)(r).afterReturn("any"); + let result: Any = ob.decodeEnvelope(r); + expect(result).assertEqual("any"); +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..905f489199af7bedae951ba2393a27e85d95c057 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/MethodCall.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { MethodCall } from "@ohos/flutter_ohos"; +import { describe, expect, it } from "@ohos/hypium"; + +export default function MethodCallUnitTest() { + describe('MethodCall', () => { + it("MethodCall_argument", 0, argument); + + it("MethodCall_hasArgument", 0, hasArgument); + }) +} + +function argument() { + let ob = new MethodCall("get", null); + expect(ob.argument("key")).assertNull(); +} + +function hasArgument() { + let ob = new MethodCall("get", null); + expect(ob.hasArgument("key")).assertFalse(); +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f8174e51fb2dcf352b0fa49da12a453a7bf5729f --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableBinaryCodec.test.ets @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { SendableBinaryCodec } from '@ohos/flutter_ohos'; +import { buffer } from '@kit.ArkTS'; + +export default function SendableBinaryCodecTest() { + describe('SendableBinaryCodecTest', () => { + it('encodeMessage', 0, async (done: Function) => { + let blobValue: buffer.Blob = new buffer.Blob(['name', 'age', 'sex']); + let message: ArrayBuffer = await blobValue.arrayBuffer(); + expect(SendableBinaryCodec.INSTANCE_DIRECT.encodeMessage(message)) + .not() + .assertNull(); + done(); + }) + + it('decodeMessage', 0, () => { + expect(SendableBinaryCodec.INSTANCE_DIRECT.decodeMessage(null)) + .not() + .assertNull(); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5383bfc399e9f3563f94288d8bf071afc3c968f4 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMessageCodec.test.ets @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import SendableJSONMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableJSONMessageCodec'; +import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils' + +export default function SendableJSONMessageCodecTest() { + describe('SendableJSONMessageCodecTest', () => { + const codec = SendableJSONMessageCodec.INSTANCE; + it('encodeMessage and decodeMessage with a null message', 0, () => { + const originalMessage = null; + const encodedMessage = codec.encodeMessage(originalMessage); + const decodedMessage = StringUtils.arrayBufferToString(encodedMessage); + expect(decodedMessage).assertEqual(""); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b8d2c0e54a4610fa752f368c315e154014b149b3 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableJSONMethodCodec.test.ets @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import SendableJSONMethodCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableJSONMethodCodec'; + +export default function SendableJSONMethodCodecTest() { + describe('SendableJSONMethodCodecTest', () => { + const codec = SendableJSONMethodCodec.INSTANCE; + it('throws an error for invalid JSON', 0, () => { + const invalidJSON = new ArrayBuffer(1); + + try { + codec.decodeMethodCall(invalidJSON); + //fail('Expected an error to be thrown'); + throw new Error('Expected an error to be thrown'); + } catch (e) { + expect(e.message).assertContain('Invalid JSON') + } + + try { + codec.decodeEnvelope(invalidJSON); + //fail('Expected an error to be thrown'); + throw new Error('Expected an error to be thrown'); + } catch (e) { + expect(e.message).assertContain('Invalid JSON') + } + }) + }) +} + diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0a16e5345b4e7b069aa9f76a5ef4f5f4f3e3bb90 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMessageCodec.test.ets @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium' +import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; +import SendableStandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableStandardMessageCodec'; + +export default function SendableStandardMessageCodecTest() { + describe('SendableStandardMessageCodecTest', () => { + const codec = SendableStandardMessageCodec.INSTANCE; + + it('testEncodeDecodeNull', 0, () => { + const encoded = codec.encodeMessage(null); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertNull(); + }) + + it('testEncodeDecodeBoolean', 0, () => { + const encodedTrue = codec.encodeMessage(true); + const decodedTrue:Any = codec.decodeMessage(encodedTrue); + expect(decodedTrue).assertTrue(); + + const encodedFalse = codec.encodeMessage(false); + const decodedFalse:Any = codec.decodeMessage(encodedFalse); + expect(decodedFalse).assertFalse(); + }) + + it('testEncodeDecodeNumber', 0, () => { + const int32Value = 123456; + const encodedInt32 = codec.encodeMessage(int32Value); + const decodedInt32:Any = codec.decodeMessage(encodedInt32); + expect(decodedInt32).assertEqual(int32Value); + + const int64Value = BigInt(9007199254740991); // Max safe integer + const encodedInt64 = codec.encodeMessage(int64Value); + const decodedInt64:Any = codec.decodeMessage(encodedInt64); + expect(decodedInt64).assertEqual(int64Value); + + const float64Value = 3.14159; + const encodedFloat64 = codec.encodeMessage(float64Value); + const decodedFloat64:Any = codec.decodeMessage(encodedFloat64); + expect(decodedFloat64).assertClose(float64Value, 5); + + }) + + it('testEncodeDecodeUint8Array', 0, () => { + const uint8Array = new Uint8Array([1, 2, 3, 4, 5]); + const encodedArray = codec.encodeMessage(uint8Array); + const decodedArray:Any = codec.decodeMessage(encodedArray); + expect(decodedArray).assertDeepEquals(uint8Array); + }) + + it('testEncodeDecodeInt32Array', 0, () => { + const int32Array = new Int32Array([1, 2, 3, 4, 5]); + const encodedArray = codec.encodeMessage(int32Array); + const decodedArray:Any = codec.decodeMessage(encodedArray); + expect(decodedArray).assertDeepEquals(int32Array); + }) + + it('testEncodeDecodeBigInt64Array', 0, () => { + const bigInt64Array = new BigInt64Array([BigInt(1), BigInt(2), BigInt(3), BigInt(4), BigInt(5)]); + const encodedArray = codec.encodeMessage(bigInt64Array); + const decodedArray:Any = codec.decodeMessage(encodedArray); + expect(decodedArray.length).assertEqual(bigInt64Array.length); + for (let i = 0; i < bigInt64Array.length; i++) { + expect(decodedArray[i]).assertEqual(bigInt64Array[i]); + } + }) + + it('testEncodeDecodeFloat64Array', 0, () => { + const float64Array = new Float64Array([1.1, 2.2, 3.3, 4.4, 5.5]); + const encodedArray = codec.encodeMessage(float64Array); + const decodedArray:Any = codec.decodeMessage(encodedArray); + expect(decodedArray).assertDeepEquals(float64Array); + }) + }) +} + + + + diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7257b488ba54ea90442f429e6e53c0411f9686fa --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStandardMethodCodec.test.ets @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import SendableStandardMethodCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableStandardMethodCodec'; + +export default function SendableStandardMethodCodecTest() { + describe('SendableStandardMethodCodecTest', () => { + const codec = SendableStandardMethodCodec.INSTANCE; + it('decodeMethodCall_shouldThrowErrorOnCorruptedMethodCall', 0, () => { + const corruptedBuffer = new ArrayBuffer(2); + const bufferView = new Uint8Array(corruptedBuffer); + bufferView[0] = 0; + bufferView[1] = 1; + + try { + codec.decodeMethodCall(corruptedBuffer); + expect(false).assertEqual(true); + } catch (e) { + expect(e.message).assertEqual('Method call corrupted'); + } + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7a5d4a3b8b0fbeab9018b13e4d91b0b02b7e663a --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/SendableStringCodec.test.ets @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium' +import StringCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/SendableStringCodec' +import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils' + +export default function SendableStringCodecTest() { + describe('SendableStringCodecTest', () => { + const codec = StringCodec.INSTANCE; + it('encodeMessage_emptyString_ReturnEmptyString', 0, () => { + const testString = ""; + const encodedMessage = codec.encodeMessage(testString); + const decodedString = StringUtils.arrayBufferToString(encodedMessage); + expect(decodedString).assertEqual(testString); + }) + it('encodeMessage_null_ReturnEmptyString', 0, () => { + const encodedMessage = codec.encodeMessage(""); + const decodedString = StringUtils.arrayBufferToString(encodedMessage); + expect(decodedString).assertEqual(""); + }) + it('decodeMessage_emptyString_ReturnEmptyString', 0, () => { + const encodedMessage = new ArrayBuffer(0); + const decodedString = codec.decodeMessage(encodedMessage); + expect(decodedString).assertEqual(""); + }) + it('decodeMessage_null_ReturnEmptyString', 0, () => { + const decodedString = codec.decodeMessage(null); + expect(decodedString).assertEqual(""); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf86971696a754f21c07843da892ca865f6764ee --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMessageCodec.test.ets @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium' +import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; +import StandardMessageCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMessageCodec'; + +export default function StandardMessageCodecTest() { + describe('StandardMessageCodecTest', () => { + const codec = StandardMessageCodec.INSTANCE; + it('should encode and decode null', 0, () => { + const encoded = codec.encodeMessage(null); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertNull(); + }) + it('should encode and decode boolean', 0, () => { + const encodedTrue = codec.encodeMessage(true); + const decodedTrue:Any = codec.decodeMessage(encodedTrue); + expect(decodedTrue).assertTrue(); + + const encodedFalse = codec.encodeMessage(false); + const decodedFalse:Any = codec.decodeMessage(encodedFalse); + expect(decodedFalse).assertFalse(); + }) + it('should encode and decode number (int32)', 0, () => { + const number = 123456; + const encoded = codec.encodeMessage(number); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertEqual(number); + }) + it('should encode and decode number (int64)', 0, () => { + const number = BigInt(1234567890123456789); + const encoded = codec.encodeMessage(number); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertEqual(number); + }) + it('should encode and decode number (float64)', 0, ()=> { + const number = 3.14159;; + const encoded = codec.encodeMessage(number); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertClose(number,5) + }) + it('should encode and decode Uint8Array', 0, () => { + const array = new Uint8Array([1, 2, 3, 4, 5]); + const encoded = codec.encodeMessage(array); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertDeepEquals(array); + }) + it('should encode and decode Int32Array', 0, () => { + const array = new Int32Array([1, 2, 3, 4, 5]); + const encoded = codec.encodeMessage(array); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded).assertDeepEquals(array); + }) + it('should encode and decode BigInt64Array', 0, () => { + const array = new BigInt64Array([BigInt(1), BigInt(2), BigInt(3), BigInt(4), BigInt(5)]); + const encoded = codec.encodeMessage(array); + const decoded:Any = codec.decodeMessage(encoded); + expect(decoded.length).assertEqual(array.length); + for (let i = 0; i < array.length; i++) { + expect(decoded[i]).assertEqual(array[i]); + } + }) + it('should encode and decode Float32Array', 0, () => { + const array = new Float32Array([1.1, 2.2, 3.3, 4.4, 5.5]); + const encoded = codec.encodeMessage(array); + const decoded:Any = codec.decodeMessage(encoded); + for (let i = 0; i < array.length; i++) { + expect(decoded[i]).assertEqual(array[i]); + } + }) + it('should encode and decode Float64Array', 0, () => { + const array = new Float64Array([1.1, 2.2, 3.3, 4.4, 5.5]); + const encoded = codec.encodeMessage(array); + const decoded:Any = codec.decodeMessage(encoded); + for (let i = 0; i < array.length; i++) { + expect(decoded[i]).assertEqual(array[i]); + } + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9e19ad054428f3158521cece3b38dc99b2d9f572 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StandardMethodCodec.test.ets @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium' +import StandardMethodCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StandardMethodCodec'; + +export default function StandardMethodCodecTest() { + describe('StandardMethodCodecTest', () => { + const codec = StandardMethodCodec.INSTANCE; + it('should throw an error for a corrupted method call', 0, () => { + const corruptedMethodCall = new ArrayBuffer(2); // Just an invalid ArrayBuffer + try { + codec.decodeMethodCall(corruptedMethodCall); + //fail('Expected an error to be thrown'); + throw new Error('Expected an error to be thrown'); + } catch (e) { + expect(e.message).assertEqual('Method call corrupted'); + } + }); + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..329489ace81bcf28727ba51909e0a8b7978a3bd9 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/common/StringCodec.test.ets @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium' +import StringCodec from '@ohos/flutter_ohos/src/main/ets/plugin/common/StringCodec' +import StringUtils from '@ohos/flutter_ohos/src/main/ets/util/StringUtils' + +export default function StringCodecTest() { + describe('StringCodecTest', () => { + const codec = StringCodec.INSTANCE; + it('encodeMessage_emptyString_ReturnEmptyString', 0, () => { + const testString = ""; + const encodedMessage = codec.encodeMessage(testString); + const decodedString = StringUtils.arrayBufferToString(encodedMessage); + expect(decodedString).assertEqual(testString); + }) + it('decodeMessage_emptyString_ReturnEmptyString', 0, () => { + const encodedMessage = new ArrayBuffer(0); + const decodedString = codec.decodeMessage(encodedMessage); + expect(decodedString).assertEqual(""); + }) + it('decodeMessage_null_ReturnEmptyString', 0, () => { + const decodedString = codec.decodeMessage(null); + expect(decodedString).assertEqual(""); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..6db50566f751aa7806ba3be229c867195864a8a4 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/ListenableEditingState.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { EditingStateWatcher, ListenableEditingState } from '@ohos/flutter_ohos/src/main/ets/plugin/editing/ListenableEditingState'; + +export default function ListenableEditingStateTest() { + describe('ListenableEditingStateTest', () => { + let editingState: ListenableEditingState = new ListenableEditingState(null, 0); + it('should initialize with default values', 0, () => { + expect(editingState.getSelectionStart()).assertEqual(0); + expect(editingState.getSelectionEnd()).assertEqual(0); + expect(editingState.getComposingStart()).assertEqual(-1); + expect(editingState.getComposingEnd()).assertEqual(-1); + expect(editingState.getStringCache()).assertEqual(''); + }) + it('should handle insert text event correctly', 0, () => { + editingState.handleInsertTextEvent('hello'); + expect(editingState.getStringCache()).assertEqual('hello'); + expect(editingState.getSelectionStart()).assertEqual(5); + expect(editingState.getSelectionEnd()).assertEqual(5); + }) + + it('should handle delete event correctly (right)', 0, () => { + editingState.handleDeleteEvent(true, 1); + expect(editingState.getStringCache()).assertEqual('hello'); + expect(editingState.getSelectionStart()).assertEqual(5); + expect(editingState.getSelectionEnd()).assertEqual(5); + }) + it('should handle newline event correctly', 0, () => { + editingState.handleNewlineEvent(); + expect(editingState.getStringCache()).assertEqual('hello\n'); + expect(editingState.getSelectionStart()).assertEqual(6); + expect(editingState.getSelectionEnd()).assertEqual(6); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9d8fb51c7935e87b86aa62c3836803119cdd2cae --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextEditingDelta.test.ets @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { TextEditingDelta } from '@ohos/flutter_ohos/src/main/ets/plugin/editing/TextEditingDelta'; + +export default function TextEditingDeltaTest() { + describe('TextEditingDeltaTest', () => { + it('testToJSON', 0, () => { + const delta = new TextEditingDelta("Old Text", 0, 0, 0, 0, 2, 5, "Delta Text"); + const json = delta.toJSON(); + expect(json.oldText).assertEqual("Old Text"); + expect(json.deltaText).assertEqual("Delta Text"); + expect(json.deltaStart).assertEqual(2); + expect(json.deltaEnd).assertEqual(5); + expect(json.selectionBase).assertEqual(0); + expect(json.selectionExtent).assertEqual(0); + expect(json.composingBase).assertEqual(0); + expect(json.composingExtent).assertEqual(0); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a92aac8ce7ba007f9843690c007ec77d2e4d0bce --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/editing/TextInputPlugin.test.ets @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeEach, it, expect } from '@ohos/hypium' +import TextInputChannel from '@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/TextInputChannel'; +import TextInputPlugin from '@ohos/flutter_ohos/src/main/ets/plugin/editing/TextInputPlugin'; +import TextInputMethodHandlerImpl from '@ohos/flutter_ohos/src/main/ets/plugin/editing/TextInputPlugin'; +import common from '@ohos.app.ability.common'; +import DartExecutor from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartExecutor'; +import FlutterInjector from '@ohos/flutter_ohos/src/main/ets/FlutterInjector'; + +export default function TextInputPluginTest() { + describe('TextInputPluginTest', () => { + let textInputPlugin: TextInputPlugin; + let textInputChannelMock: TextInputChannel; + let textInputMethodHandlerImpl: TextInputMethodHandlerImpl; + let dartExecutor: DartExecutor; + beforeEach(() => { + let context: common.Context = getContext(); + const assetManager = context.resourceManager; + const flutterNapi = FlutterInjector.getInstance().getFlutterNapi(); + dartExecutor = new DartExecutor(flutterNapi, assetManager); + textInputChannelMock = new TextInputChannel(dartExecutor); + textInputPlugin = new TextInputPlugin(textInputChannelMock); + textInputMethodHandlerImpl = new TextInputMethodHandlerImpl(textInputChannelMock); + }) + it('should initialize correctly', 0, ()=> { + expect(textInputMethodHandlerImpl).not().assertNull(); + }) + it('Test clearTextInputClient', 0, () => { + textInputPlugin.clearTextInputClient(); + expect(textInputPlugin).not().assertNull(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a2cbfa0877bc84bb5e68ab317c21048867df6d22 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/localization/LocalizationPlugin.test.ets @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeEach, it, expect } from '@ohos/hypium'; +import LocalizationPlugin from '@ohos/flutter_ohos/src/main/ets/plugin/localization/LocalizationPlugin'; +import common from '@ohos.app.ability.common'; +import LocalizationChannel,{LocalizationMessageHandler} from '@ohos/flutter_ohos/src/main/ets/embedding/engine/systemchannels/LocalizationChannel'; +import intl from '@ohos.intl'; +import DartExecutor from '@ohos/flutter_ohos/src/main/ets/embedding/engine/dart/DartExecutor'; +import FlutterInjector from '@ohos/flutter_ohos/src/main/ets/FlutterInjector'; +import Any from '@ohos/flutter_ohos/src/main/ets/plugin/common/Any'; + +export default function LocalizationPluginTest() { + describe('LocalizationPluginTest', () => { + let localizationChannel: LocalizationChannel; + let localizationPlugin: LocalizationPlugin; + let dartExecutor: DartExecutor; + + beforeEach(() => { + let context: common.Context = getContext(); + const assetManager = context.resourceManager; + const flutterNapi = FlutterInjector.getInstance().getFlutterNapi(); + dartExecutor = new DartExecutor(flutterNapi, assetManager); + localizationChannel = new LocalizationChannel(dartExecutor); // 初始化LocalizationChannel + localizationPlugin = new LocalizationPlugin(context, localizationChannel); + }); + it('test_localeFromString', 0, () => { + let localeString = "zh_CN"; + let expectedLocale = new intl.Locale("zh_CN"); + let actualLocale = localizationPlugin.localeFromString(localeString); + + expect(actualLocale.language).assertEqual(expectedLocale.language); + expect(actualLocale.region).assertEqual(expectedLocale.region); + expect(actualLocale.script).assertEqual(expectedLocale.script); + }) + it('testSendLocaleToFlutter', 0, () => { + let mockSystemLocale = 'zh-Hans-AL'; + (localizationChannel as Any).sendLocales = (locales:Any) => { + expect(locales).assertContain(mockSystemLocale); + }; + localizationPlugin.sendLocaleToFlutter(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9638c016510ea7e22fa132e44d4d36ac8699bff8 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/AccessibilityEventsDelegate.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { AccessibilityBridge, AccessibilityEventsDelegate } from "@ohos/flutter_ohos"; +import { describe, expect, it } from "@ohos/hypium"; + +export default function AccessibilityEventsDelegateUnitTest() { + describe('AccessibilityEventsDelegate', () => { + it("AccessibilityEventsDelegate_requestSendAccessibilityEvent", 0, requestSendAccessibilityEvent); + + it("AccessibilityEventsDelegate_onAccessibilityHoverEvent", 0, onAccessibilityHoverEvent); + }) +} + +function requestSendAccessibilityEvent() { + let delegate = new AccessibilityEventsDelegate(); + let result = delegate.requestSendAccessibilityEvent(new AccessibilityBridge()); + expect(result).assertTrue(); +} + +function onAccessibilityHoverEvent() { + let delegate = new AccessibilityEventsDelegate(); + let result = delegate.onAccessibilityHoverEvent(new AccessibilityBridge()); + expect(result).assertTrue(); +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4ddd8fe65fb3ba510ada07e9ec41f42fa1d9c448 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformOverlayView.test.ets @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { AccessibilityEventsDelegate, PlatformOverlayView } from '@ohos/flutter_ohos'; + +const platformOverlayView: PlatformOverlayView = + new PlatformOverlayView(getContext(), 800, 800, new AccessibilityEventsDelegate()) + +export default function PlatformOverlayViewTest() { + describe('PlatformOverlayViewTest', () => { + it('PlatformOverlayView', 0, () => { + let overlayLayerViews = new Map(); + expect(overlayLayerViews).not().assertNull(); + }); + it('onHoverEvent', 0, () => { + expect(platformOverlayView.onHoverEvent()).assertFalse(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4369f8d25fcc52fcb47d0977c21e6c5428a7bf23 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformView.test.ets @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { PlatformView } from '@ohos/flutter_ohos'; +import { Params } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/PlatformView'; + +export default function PlatformViewTest() { + describe('PlatformViewTest', () => { + class TestPlatformView extends PlatformView { + getView(): WrappedBuilder<[Params]> { + throw new Error('Method not implemented.'); + } + + dispose(): void { + throw new Error('Method not implemented.'); + } + } + + const platformView: PlatformView = new TestPlatformView() + it('getType', 0, () => { + expect(platformView.getType()).assertEqual('default') + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8720501f6465f9fa697968ea64b3e31f5fa1bf79 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewRegistryImplTest.test.ets @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { PlatformViewRegistryImpl, PlatformViewFactory } from "@ohos/flutter_ohos"; + +const platformViewRegistryImpl: PlatformViewRegistryImpl = new PlatformViewRegistryImpl(); + +export default function PlatformViewRegistryImplTest() { + describe('PlatformViewRegistryImplTest', () => { + it('TestPlatformViewRegistryImplGetFactory', 0, async (done: Function) => { + const platformViewFactory: PlatformViewFactory = platformViewRegistryImpl.getFactory('test'); + expect(platformViewFactory).not().assertNull(); + done(); + }) + + it('TestPlatformViewRegistryImplRegisterViewFactory', 0, async (done: Function) => { + const platformViewFactory: PlatformViewFactory = platformViewRegistryImpl.getFactory('test'); + expect(platformViewFactory).not().assertNull(); + const result = platformViewRegistryImpl.registerViewFactory('test', platformViewFactory); + expect(result).assertTrue(); + done(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..2926252aeba5bf4fdc8d2958138dd324b7de7099 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewWrapperTest.test.ets @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { PlatformViewWrapper, OhosTouchProcessor } from "@ohos/flutter_ohos"; +import { DVModel, DVModelParameters } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicView'; + +function sleep(time: number) { + return new Promise((resolve: Function) => setTimeout(resolve, time)); +} + +const platformViewWrapper: PlatformViewWrapper = new PlatformViewWrapper(); + +export default function PlatformViewWrapperTest() { + describe('PlatformViewWrapperTest', () => { + it('TestPlatformViewWrapperDvModel', 0, async (done: Function) => { + const newTouchProcessor: OhosTouchProcessor = new OhosTouchProcessor(); + platformViewWrapper.setTouchProcessor(newTouchProcessor); + await sleep(1000); + const dvModel: DVModel = platformViewWrapper.getDvModel(); + expect(dvModel).not().assertNull(); + await sleep(1000); + platformViewWrapper.addDvModel(dvModel); + await sleep(1000); + const parameters: DVModelParameters = new DVModelParameters(); + platformViewWrapper.setLayoutParams(parameters); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a12b210726702f02e3fd6dc1a6bd5aa81c94e8e3 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/PlatformViewsControllerTest.test.ets @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { + PlatformViewsController, + FlutterOverlaySurface, +} from "@ohos/flutter_ohos"; + +const platformViewsController: PlatformViewsController = new PlatformViewsController(); +const direction: Direction = 100; + +export default function PlatformViewsControllerTest() { + describe('PlatformViewsControllerTest', () => { + + it('TestPlatformViewRegistryImplGetRegistry', 0, async (done: Function) => { + const result = platformViewsController.getRegistry(); + expect(result).not().assertNull(); + done(); + }) + + it('TestCreateOverlaySurface', 0, async (done: Function) => { + const result: FlutterOverlaySurface = platformViewsController.createOverlaySurface(); + expect(result).not().assertNull(); + done(); + }) + it('TestPlatformViewRegistryImplValidateDirection', 0, async (done: Function) => { + const result = platformViewsController.validateDirection(direction); + expect(result).assertFalse(); + done(); + }) + + it('TestPlatformViewRegistryImplGetFlutterView', 0, async (done: Function) => { + const result = platformViewsController.getFlutterView(); + expect(result).assertNull(); + done(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..9443e1467a5be6a8a36f4a16e263c6e38fba855e --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RawPointerCoordTest.test.ets @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { RawPointerCoords } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/RawPointerCoord'; + +const orientation: number = 100; +const pressure: number = 100; +const size: number = 100; +const toolMajor: number = 100; +const toolMinor: number = 100; +const touchMajor: number = 100; +const touchMinor: number = 100; +const x: number = 100; +const y: number = 100; +const rawPointerCoords: RawPointerCoords = + new RawPointerCoords(orientation, pressure, size, toolMajor, toolMinor, touchMajor, touchMinor, x, y); + +export default function RawPointerCoordsTest() { + describe('RawPointerCoordsTest', () => { + it('TestRawPointerCoordsGetX', 0, async (done: Function) => { + const pointX = rawPointerCoords.getX(); + expect(pointX).not().assertNull(); + done(); + }) + + it('TestRawPointerCoordsGetY', 0, async (done: Function) => { + const pointY = rawPointerCoords.getY(); + expect(pointY).not().assertNull(); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e16df0b999c18356fe5cd8b8ccdd9dd8b9ed7c2 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/platform/RootDvModelManagerTest.test.ets @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect } from '@ohos/hypium'; +import { PlatformViewWrapper } from '@ohos/flutter_ohos'; +import { RootDvModeManager } from '@ohos/flutter_ohos/src/main/ets/plugin/platform/RootDvModelManager'; +import { DVModel, DVModelContainer } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicView'; + +export default function DVModelContainerTest() { + describe('DVModelContainerTest', () => { + it('TestDVModelContainerGetRootDvMode', 0, async (done: Function) => { + const dvModel: DVModelContainer = RootDvModeManager.getRootDvMode(); + expect(dvModel).not().assertNull(); + done(); + }) + + it('TestDVModelAddDvModel', 0, async (done: Function) => { + const platformViewWrapper: PlatformViewWrapper = new PlatformViewWrapper(); + const dvModel: DVModel = platformViewWrapper.getDvModel(); + RootDvModeManager.addDvModel(dvModel); + expect(dvModel).not().assertNull(); + done(); + }) + }) +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..536a5aed7110aff664c0a4ed7393874606b97f1d --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ByteBufferTest.test.ets @@ -0,0 +1,317 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, it, expect, afterAll } from '@ohos/hypium'; +import { ByteBuffer } from "@ohos/flutter_ohos"; +import { buffer } from '@kit.ArkTS'; + +let byteBuffer: ByteBuffer; +let byteOffset: number; + +export default function ByteBufferTest() { + describe('ByteBufferTest', () => { + it('TestByteBufferFrom', 0, async (done: Function) => { + const blobValue: buffer.Blob = new buffer.Blob(['name', 'age', 'sex']); + const message: ArrayBuffer = await blobValue.arrayBuffer(); + const result = ByteBuffer.from(message); + expect(result.byteLength).assertEqual(10); + done(); + }) + + it('TestByteBufferByteOffset', 0, async (done: Function) => { + const blobValue: buffer.Blob = new buffer.Blob(['name', 'age', 'sex']); + const message: ArrayBuffer = await blobValue.arrayBuffer(); + byteBuffer = ByteBuffer.from(message); + byteOffset = byteBuffer.byteOffset; + expect(byteOffset).assertEqual(0); + done(); + }) + + it('TestByteBufferByteLength', 0, async (done: Function) => { + const result = byteBuffer.byteLength; + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferBytesRemaining', 0, async (done: Function) => { + const result = byteBuffer.bytesRemaining; + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferBuffer', 0, async (done: Function) => { + const result = byteBuffer.buffer; + expect(result).assertInstanceOf('ArrayBuffer'); + done(); + }) + + it('TestByteBufferHasRemaining', 0, async (done: Function) => { + const result = byteBuffer.hasRemaining(); + expect(result).assertTrue(); + done(); + }) + + it('TestByteBufferSkip', 0, async (done: Function) => { + const result = byteBuffer.byteLength; + expect(result).assertEqual(10); + byteBuffer.skip(result); + byteBuffer.checkWriteCapacity(10); + done(); + }) + + it('TestByteBufferGetBool', 0, async (done: Function) => { + byteBuffer.setBool(byteOffset, true); + let result = byteBuffer.getBool(byteOffset); + expect(result).assertTrue(); + done(); + }) + + it('TestByteBufferReadBool', 0, async (done: Function) => { + byteBuffer.writeBool(false); + let result = byteBuffer.readBool(); + expect(result).assertFalse(); + done(); + }) + + it('TestByteBufferGetInt8', 0, async (done: Function) => { + byteBuffer.setInt8(byteOffset, 10); + let result = byteBuffer.getInt8(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadInt8', 0, async (done: Function) => { + byteBuffer.writeInt8(byteOffset); + let result = byteBuffer.readInt8(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetUint8', 0, async (done: Function) => { + byteBuffer.setUint8(byteOffset, 10); + let result = byteBuffer.getUint8(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadUint8', 0, async (done: Function) => { + byteBuffer.writeUint8(byteOffset); + let result = byteBuffer.readUint8(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetInt16', 0, async (done: Function) => { + byteBuffer.setInt16(byteOffset, 10); + let result = byteBuffer.getInt16(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadInt16', 0, async (done: Function) => { + byteBuffer.writeInt16(byteOffset); + let result = byteBuffer.readInt16(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetUint16', 0, async (done: Function) => { + byteBuffer.setUint16(byteOffset, 10); + let result = byteBuffer.getUint16(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadUint16', 0, async (done: Function) => { + byteBuffer.writeUint16(byteOffset); + let result = byteBuffer.readUint16(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetInt32', 0, async (done: Function) => { + byteBuffer.setInt32(byteOffset, 10); + let result = byteBuffer.getInt32(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadInt32', 0, async (done: Function) => { + byteBuffer.writeInt32(byteOffset); + let result = byteBuffer.readInt32(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetUint32', 0, async (done: Function) => { + byteBuffer.setUint32(byteOffset, 10); + let result = byteBuffer.getUint32(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadUint32', 0, async (done: Function) => { + byteBuffer.writeUint32(byteOffset); + let result = byteBuffer.readUint32(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetFloat32', 0, async (done: Function) => { + byteBuffer.setFloat32(byteOffset, 10); + let result = byteBuffer.getFloat32(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadFloat32', 0, async (done: Function) => { + byteBuffer.writeFloat32(byteOffset); + let result = byteBuffer.readFloat32(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetFloat64', 0, async (done: Function) => { + byteBuffer.setFloat64(byteOffset, 10); + let result = byteBuffer.getFloat64(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadFloat64', 0, async (done: Function) => { + byteBuffer.writeFloat64(byteOffset); + let result = byteBuffer.readFloat64(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetBigInt64', 0, async (done: Function) => { + const value: bigint = BigInt(9223372036854775807); + byteBuffer.setBigInt64(byteOffset, value); + let result = byteBuffer.getBigInt64(byteOffset); + expect(result).not().assertNull(); + done(); + }) + + it('TestByteBufferReadBigInt64', 0, async (done: Function) => { + const value: bigint = BigInt(9223372036854775807); + byteBuffer.writeBigInt64(value); + let result = byteBuffer.readBigInt64(); + expect(result).assertEqual(0n); + done(); + }) + + it('TestByteBufferGetBigUint64', 0, async (done: Function) => { + const value: bigint = BigInt(9223372036854775807); + byteBuffer.setBigUint64(byteOffset, value); + let result = byteBuffer.getBigUint64(byteOffset); + expect(result).not().assertNull(); + done(); + }) + + it('TestByteBufferReadBigUint64', 0, async (done: Function) => { + const value: bigint = BigInt(9223372036854775807); + byteBuffer.writeBigUint64(value); + let result = byteBuffer.readBigUint64(); + expect(result).assertEqual(0n); + done(); + }) + + it('TestByteBufferGetInt64', 0, async (done: Function) => { + byteBuffer.setInt64(byteOffset, 10); + let result = byteBuffer.getInt64(byteOffset); + expect(result).assertEqual(10n); + done(); + }) + + it('TestByteBufferReadInt64', 0, async (done: Function) => { + byteBuffer.writeInt64(10); + let result = byteBuffer.readInt64(); + expect(result).assertEqual(0n); + done(); + }) + + it('TestByteBufferGetUint64', 0, async (done: Function) => { + byteBuffer.setUint64(byteOffset, 10); + let result = byteBuffer.getUint64(byteOffset); + expect(result).assertEqual(10); + done(); + }) + + it('TestByteBufferReadUint64', 0, async (done: Function) => { + byteBuffer.writeUint64(10); + let result = byteBuffer.readUint64(); + expect(result).assertEqual(0); + done(); + }) + + it('TestByteBufferGetUint8Array', 0, async (done: Function) => { + const value: Uint8Array = new Uint8Array(); + byteBuffer.setUint8Array(byteOffset, value); + let result = byteBuffer.getUint8Array(byteOffset); + expect(result).assertInstanceOf('Uint8Array'); + done(); + }) + + it('TestByteBufferReadUint8Array', 0, async (done: Function) => { + const value: Uint8Array = new Uint8Array(); + byteBuffer.writeUint8Array(value); + let result = byteBuffer.readUint8Array(); + expect(result).assertInstanceOf('Uint8Array'); + done(); + }) + + it('TestByteBufferGetUint16Array', 0, async (done: Function) => { + const value: Uint16Array = new Uint16Array(); + byteBuffer.setUint16Array(byteOffset, value); + let result = byteBuffer.getUint16Array(byteOffset); + expect(result).assertInstanceOf('Uint16Array'); + done(); + }) + + it('TestByteBufferReadUint16Array', 0, async (done: Function) => { + const value: Uint16Array = new Uint16Array(); + byteBuffer.writeUint16Array(value); + let result = byteBuffer.readUint16Array(); + expect(result).assertInstanceOf('Uint16Array'); + done(); + }) + + it('TestByteBufferGetString', 0, async (done: Function) => { + byteBuffer.setString(byteOffset, 'test'); + let result = byteBuffer.getString(byteOffset); + expect(result).not().assertNull(); + done(); + }) + + it('TestByteBufferReadString', 0, async (done: Function) => { + byteBuffer.writeString('test'); + let result = byteBuffer.readString(); + expect(result).assertUndefined(); + done(); + }) + + it('TestByteBufferToString', 0, async (done: Function) => { + let result = byteBuffer.toString(); + expect(result).not().assertNull(); + done(); + }) + + afterAll(() => { + byteBuffer.reset(); + byteBuffer.clear(); + }) + }) + +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..5ef0a0618adf56b8a7fe4921de38269c540a02de --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/Log.test.ets @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { Log } from '@ohos/flutter_ohos'; + +export default function LogTest() { + describe('LogTest', () => { + it('Log', 0, () => { + expect(Log.toString()).not().assertNull(); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..60c39c1c12599a1cbfdae18b3a61512fb653b8df --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/MessageChannelUtils.test.ets @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { MessageChannelUtils } from '@ohos/flutter_ohos'; + +export default function MessageChannelUtilsTest() { + describe('MessageChannelUtilsTest', () => { + it('resizeChannelBuffer', 0, () => { + expect(MessageChannelUtils.toString()).not().assertNull(); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8f4283281840e0cc21ce3f9cb3999a9844111a3e --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/PathUtils.test.ets @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { PathUtils } from '@ohos/flutter_ohos'; + +export default function PathUtilsTest() { + describe('PathUtilsTest', () => { + it('getFilesDir', 0, () => { + expect(PathUtils.getFilesDir(getContext())).not().assertNull(); + }); + it('getCacheDirectory', 0, () => { + expect(PathUtils.getCacheDirectory(getContext())).not().assertNull(); + }); + it('getDataDirectory', 0, () => { + const name = "flutter"; + expect(PathUtils.getDataDirectory(getContext())).assertContain(name); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..693d0b188e914694bcd70ec1f73fe1ecdc3efe11 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/StringUtils.test.ets @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { StringUtils } from '@ohos/flutter_ohos'; + +const TAG: string = "stringUtilsTest"; + +export default function StringUtilsTest() { + describe('StringUtilsTest', () => { + it('isNotEmpty', 0, () => { + expect(StringUtils.isNotEmpty(TAG)).assertTrue(); + }); + it('isEmpty', 0, () => { + expect(StringUtils.isEmpty("")).assertTrue(); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..158170ba95c6516332eca4d3779b4a894d2f1ac5 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/ToolUtils.test.ets @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { ToolUtils } from '@ohos/flutter_ohos'; + +export default function ToolUtilsTest() { + describe('ToolUtilsTest', () => { + it('isObj', 0, () => { + const json = JSON.stringify('object'); + expect(ToolUtils.isObj(json)).assertFalse(); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b09b01f10931882f64cfb5b4413633b689e3a848 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/plugin/util/TraceSection.test.ets @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { TraceSection } from '@ohos/flutter_ohos'; + +export default function TraceSectionTest() { + describe('TraceSectionTest', () => { + it('begin', 0, () => { + const sectionName = "DartExecutor"; + expect(TraceSection.begin(sectionName)).assertLarger(0); + }); + it('end', 0, () => { + const sectionName = "DartExecutor"; + TraceSection.end(sectionName); + }); + it('endWithId', 0, () => { + const sectionName = "DartExecutor"; + TraceSection.endWithId(sectionName, 1); + }); + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..610a7f88c6202e029a0a0cdd772ce83e4ef3a0f7 --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/DynamicView/dynamicViewJson.test.ets @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { createDVModelFromJson } from '@ohos/flutter_ohos/src/main/ets/view/DynamicView/dynamicViewJson'; + +const TAG: string = "dynamicViewJsonTest"; + +export default function dynamicViewJsonTest() { + describe('dynamicViewJsonTest', () => { + it('createDVModelFromJson', 0, () => { + let dvModel = createDVModelFromJson(JSON.stringify(TAG)); + expect(dvModel) + .not() + .assertNull(); + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a9d1a0787213b1e610aa61be37059c28328fdf0d --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/ets/test/view/FlutterRunArguments.test.ets @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, it, expect } from '@ohos/hypium' +import { FlutterRunArguments } from '@ohos/flutter_ohos'; + +const TAG: string = "FlutterRunArgumentsTest"; + +export default function FlutterRunArgumentsTest() { + describe('FlutterRunArgumentsTest', () => { + it('flutterRunArguments', 0, () => { + const flutterRunArguments = new FlutterRunArguments(TAG, TAG, TAG) + expect(flutterRunArguments.bundlePath).assertEqual(TAG) + }) + }) +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b4bf32fd9ef07bd62331aa8e09cae3029062b33a --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/ohosTest/module.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "application_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets b/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..312f48fb747c89745bf9671ef83f93eabf0f12bc --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets b/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8ca1b6da13fdc210635bd5e33d64370f1948557e --- /dev/null +++ b/shell/platform/ohos/flutter_embedding/application/src/test/LocalUnit.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/build-profile.json5 b/shell/platform/ohos/flutter_embedding/build-profile.json5 index 4cebb96991c2452fc99cd78dfd665235df58e8f3..87805d1f439f5c5ecd50c5eb400f07f7cf7957ba 100755 --- a/shell/platform/ohos/flutter_embedding/build-profile.json5 +++ b/shell/platform/ohos/flutter_embedding/build-profile.json5 @@ -41,6 +41,18 @@ { "name": "flutter", "srcPath": "./flutter" + }, + { + "name": "application", + "srcPath": "./application", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] } ] -} +} \ No newline at end of file diff --git a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets index 9be47241dc8c077a9e8a39e9fc35869cf54486b2..7216db2888a77ce7e258fb93fd760700b3733c9f 100644 --- a/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets +++ b/shell/platform/ohos/flutter_embedding/flutter/src/main/ets/embedding/engine/FlutterNapi.ets @@ -117,7 +117,7 @@ export default class FlutterNapi { Log.e(TAG, "runBundleAndSnapshotFromLibrary this.nativeShellHolderId:" + this.nativeShellHolderId) return; } - flutter.nativeRunBundleAndSnapshotFromLibrary(this.nativeShellHolderId!, bundlePath, entrypointFunctionName, pathToEntrypointFunction, assetManager, entrypointArgs); + flutter.nativeRunBundleAndSnapshotFromLibrary(this.nativeShellHolderId!, bundlePath, entrypointFunctionName as string, pathToEntrypointFunction as string, assetManager, entrypointArgs); }; /** diff --git a/shell/platform/ohos/flutter_embedding/oh-package.json5 b/shell/platform/ohos/flutter_embedding/oh-package.json5 index 6990a41a16d7d0cedbfca94edf2f197f6d33cdd5..dd166cc567287d35e89516bb40e631c8786e7836 100755 --- a/shell/platform/ohos/flutter_embedding/oh-package.json5 +++ b/shell/platform/ohos/flutter_embedding/oh-package.json5 @@ -24,6 +24,6 @@ "dependencies": { }, "devDependencies": { - "@ohos/hypium": "1.0.6" + "@ohos/hypium": "1.0.18" } }