diff --git a/ArkWebKit/ProcessWebPageCont/.gitignore b/ArkWebKit/ProcessWebPageCont/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/AppScope/app.json5 b/ArkWebKit/ProcessWebPageCont/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4b1ce53f111420364c0803811493cd969dc80603 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/AppScope/app.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "app": { + "bundleName": "com.samples.processwebpagecont", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:app_icon", + "label": "$string:app_name" + } +} diff --git a/ArkWebKit/ProcessWebPageCont/AppScope/resources/base/element/string.json b/ArkWebKit/ProcessWebPageCont/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..4779102effef55e6d1414c9166b60b0783cdc210 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ProcessWebPageCont" + } + ] +} diff --git a/ArkWebKit/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png b/ArkWebKit/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..a39445dc87828b76fed6d2ec470dd455c45319e3 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/AppScope/resources/base/media/app_icon.png differ diff --git a/ArkWebKit/ProcessWebPageCont/README.md b/ArkWebKit/ProcessWebPageCont/README.md new file mode 100644 index 0000000000000000000000000000000000000000..8a7bae3d95dda95b45cabd1f819eb1341074ec40 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/README.md @@ -0,0 +1,131 @@ +## 使用Web组件打印前端页面 + +### 介绍 + +2. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-print.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 + +### InitiatePrintW3CAPI + +#### 介绍 + +1. 本示例主要介绍使用Web组件打印前端页面,通过创建打印适配器,拉起打印应用,并对当前Web页面内容进行渲染,渲染后生成的PDF文件信息通过fd传递给打印框架。W3C标准协议接口window.print()方法用于打印当前页面或弹出打印对话框。该方法没有任何参数,只需要在JavaScript中调用即可。 + +#### 效果预览 + +| 主页 | +| ------------------------------------------------------------ | +| | + +使用说明 + +1. 点击print按钮,触发window.print()操作,即可对页面内容进行打印。 + +### InitiatePrintAppAPI + +#### 介绍 + +1. 本示例主要介绍使用Web组件打印前端页面,应用侧通过调用createWebPrintDocumentAdapter创建打印适配器,通过将适配器传入打印的print接口调起打印。 + +#### 效果预览 + +| 主页 | +| ------------------------------------------------------------ | +| | + +使用说明 + +1. 点击createWebPrintDocumentAdapter按钮应用侧会创建打印适配器,并将其传入打印接口,以触发打印操作。 + +## 使用Web组件的PDF文档预览能力 + +### 介绍 + +1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-pdf-preview.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 + +### PreviewPDF + +#### 介绍 + +1. 本示例主要介绍使用Web组件的PDF文档预览能力。Web组件提供了在网页中预览PDF的能力。应用可以通过Web组件的src参数和loadUrl()接口中传入PDF文件,来加载PDF文档。根据PDF文档来源不同,可以分为三种常用场景:加载网络PDF文档、加载本地PDF文档、加载应用内resource资源PDF文档。 + +#### 效果预览 + +| 主页 | +| ------------------------------------------------------- | +| | + +使用说明 + +1. Web组件创建时指定默认加载的网络PDF文档example.com/test.pdf。 + +## 网页中安全区域计算和避让适配 + +### 介绍 + +### CalcAdjustSafeArea + +1. 本工程主要实现了对以下指南文档中 https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/web/web-safe-area-insets.md 示例代码片段的工程化,主要目标是实现指南中示例代码需要与sample工程文件同源。 + +#### 介绍 + +1. 本示例主要介绍网页中安全区域计算和避让适配。Web组件提供了利用W3C CSS进行安全区域计算并避让适配的能力,用来支持异形屏幕设备在沉浸式效果下页面的正常显示。此时,网页开发者想对重叠元素进行避让,就可以该能力。ArkWeb内核将持续监测Web组件及系统安全区域的位置与尺寸,依据两者的重叠部分,计算出当前Web组件的安全区域,以及在各个方向上所需避让的具体距离。 + +#### 效果预览 + +| 主页 | +| ------------------------------------------------------------ | +| | + +使用说明 + +1. 通过expandSafeArea来开启沉浸式效果。Web组件根据实际情况对网页元素进行相应的避让,防止与系统的非安全区域发生重叠遮挡。 + +## 工程目录 + +``` +entry/src/main/ +|---ets +|---|---entryability +|---|---|---EntryAbility.ets +|---|---pages +|---|---|---Index.ets // 首页 +|---|---|---InitiatePrintAppAPI +|---|---|---InitiatePrintW3CAPI +|---|---|---PreviewPDF +|---|---|---CalcAdjustSafeArea +|---resources // 静态资源 +|---ohosTest +|---|---ets +|---|---|---tests +|---|---|---|---Ability.test.ets // 自动化测试用例 +``` + + +## 相关权限 + +[ohos.permission.PRINT](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissionprint) + +[ohos.permission.INTERNET](https://docs.openharmony.cn/pages/v5.0/zh-cn/application-dev/security/AccessToken/permissions-for-all.md#ohospermissioninternet) + +## 依赖 + +不涉及。 + +## 约束与限制 + +1. 本示例仅支持标准系统上运行,支持设备:RK3568。 +2. 本示例支持API14版本SDK,SDK版本号(API Version 14 Release)。 +3. 本示例需要使用DevEco Studio 版本号(5.0.1Release)才可编译运行。 + +## 下载 + +如需单独下载本工程,执行如下命令: + +``` +git init +git config core.sparsecheckout true +echo code/DocsSample/ArkWeb/ProcessWebPageCont > .git/info/sparse-checkout +git remote add origin https://gitee.com/openharmony/applications_app_samples.git +git pull origin master +``` + diff --git a/ArkWebKit/ProcessWebPageCont/build-profile.json5 b/ArkWebKit/ProcessWebPageCont/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a9c78377eb963833422d699676b8fb5b20bae29 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/build-profile.json5 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compileSdkVersion": 14, + "compatibleSdkVersion": 14, + "targetSdkVersion": 14, + "runtimeOS": "OpenHarmony", + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/code-linter.json5 b/ArkWebKit/ProcessWebPageCont/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..28586467ee7a761c737d8654a73aed6fddbc3c71 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/code-linter.json5 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + } +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/.gitignore b/ArkWebKit/ProcessWebPageCont/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/build-profile.json5 b/ArkWebKit/ProcessWebPageCont/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e7569e3056e27af38e9991b7ea73ec10f3ba8a05 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/build-profile.json5 @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2025 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/ArkWebKit/ProcessWebPageCont/entry/hvigorfile.ts b/ArkWebKit/ProcessWebPageCont/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..98d52319cb1dee60511b5716dba03b76e68a6d8b --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/hvigorfile.ts @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2025 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/ArkWebKit/ProcessWebPageCont/entry/obfuscation-rules.txt b/ArkWebKit/ProcessWebPageCont/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/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/ArkWebKit/ProcessWebPageCont/entry/oh-package.json5 b/ArkWebKit/ProcessWebPageCont/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c9cb6c8174858277c9b0d465a51547dcab16d5ff --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..82e98bec44d83d2df03deb52508045cb06cc8604 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2025 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 EntryAbility 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/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..29feaca7669174be5c2b0e2366529ee94ab7e726 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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 EntryBackupAbility 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/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets new file mode 100644 index 0000000000000000000000000000000000000000..e813d66410ad9fd1471e91b9d66567fe4883a46f --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/CalcAdjustSafeArea.ets @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2025 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. + */ +// [Start use_expand_safe_area_to_enable_immersive_effect] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ src: 'www.example.com', controller: this.controller }) + .width('100%').height('100%') + // 扩展至系统默认非安全区域(状态栏、导航栏),并设置只扩展上方区域和下方区域 + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.TOP, SafeAreaEdge.BOTTOM]) + } + } +} +// [End use_expand_safe_area_to_enable_immersive_effect] diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..1def271b5633e957e9dd40c3b9591542f5cae01f --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2025 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 { router } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Column({ space: 10 }) { + Button('InitiatePrintW3CAPI') + .onClick(() => { + router.pushUrl({ url: 'pages/InitiatePrintW3CAPI' }); + }) + Button('InitiatePrintAppAPI') + .onClick(() => { + router.pushUrl({ url: 'pages/InitiatePrintAppAPI' }); + }) + Button('PreviewPDF') + .onClick(() => { + router.pushUrl({ url: 'pages/PreviewPDF' }); + }) + Button('CalcAdjustSafeArea') + .onClick(() => { + router.pushUrl({ url: 'pages/CalcAdjustSafeArea' }); + }) + }.height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets new file mode 100644 index 0000000000000000000000000000000000000000..30eecf7173f0c347787a368ec2b185ff925d4e3d --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintAppAPI.ets @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start create_web_print_document] +import { webview } from '@kit.ArkWeb'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { print } from '@kit.BasicServicesKit'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Button('createWebPrintDocumentAdapter') + .onClick(() => { + try { + let webPrintDocadapter = this.controller.createWebPrintDocumentAdapter('example.pdf'); + print.print('example_jobid', webPrintDocadapter, null, getContext()); + } catch (error) { + console.error(`ErrorCode: ${(error as BusinessError).code}, Message: ${(error as BusinessError).message}`); + } + }) + Web({ src: 'www.example.com', controller: this.controller }); + } + } +} +// [End create_web_print_document] diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets new file mode 100644 index 0000000000000000000000000000000000000000..7d1281e593d6ba6c272dcd97a49da7cc006a16c2 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/InitiatePrintW3CAPI.ets @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start w3c_print_html] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct Index { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Row() { + Column() { + Web({ src: $rawfile('print.html'), controller: this.controller }) + .javaScriptAccess(true) + } + .width('100%') + } + .height('100%') + } +} +// [End w3c_print_html] diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets new file mode 100644 index 0000000000000000000000000000000000000000..74725488de3036aa82a5af0e94132ad567a521ac --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/ets/pages/PreviewPDF.ets @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2025 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. + */ + +// [Start web_module_create_load_pdf] +import { webview } from '@kit.ArkWeb'; + +@Entry +@Component +struct WebComponent { + controller: webview.WebviewController = new webview.WebviewController(); + + build() { + Column() { + Web({ + src: + 'https://www.example.com/test.pdf', // 方式一 加载网络PDF文档 + // this.getUIContext().getHostContext()!.filesDir + '/test.pdf', // 方式二 加载本地应用沙箱内PDF文档 + // 'resource://rawfile/test.pdf', // 方式三 本地PDF文档 (格式一) + // $rawfile('test.pdf'), // 方式三 本地PDF文档 (格式二) + controller: this.controller + }) + .domStorageAccess(true) + } + } +} +// [End web_module_create_load_pdf] diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/module.json5 b/ArkWebKit/ProcessWebPageCont/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c86fd002393d2ddfc6c6bace607995445ec7cf74 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/module.json5 @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2025 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": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + // [Start web_module_print_html] + // [Start web_module_preview_pdf] + "requestPermissions":[ + // [StartExclude web_module_print_html] + { + "name" : "ohos.permission.INTERNET" + } + // [EndExclude web_module_print_html] + ], + // [End web_module_preview_pdf] + // [End web_module_print_html] + } +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/element/color.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/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/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/element/string.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1f758cd41cf67e4c769d7526ee83f962d0d865c6 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/element/string.json @@ -0,0 +1,20 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ProcessWebPageCont" + }, + { + "name": "web_path", + "value": "https://www.example.com/test.pdf" + } + ] +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/background.png b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/background.png differ diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/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/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..ead1e2c5ae06ebd7246b0a4028b9899b3de9574a --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,9 @@ +{ + "src": [ + "pages/Index", + "pages/InitiatePrintW3CAPI", + "pages/InitiatePrintAppAPI", + "pages/PreviewPDF", + "pages/CalcAdjustSafeArea" + ] +} diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..448a2a5210af13626ae587985d80eb8c51800e4d --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/en_US/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ProcessWebPageCont" + } + ] +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html new file mode 100644 index 0000000000000000000000000000000000000000..7225f16ebc840f16091bc9e7c75380f4c1104470 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/rawfile/print.html @@ -0,0 +1,63 @@ + + + + + + + + printTest + + + + +
+

+
This is a test page for printing
+
+
+

+ +

content content content

+
+ + + + + + + + + + + + + + + + + +
ThingChairs
1blue
2green
+
+

content content content

+

content content content

+
+ diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f9dac5633ffc24eea33331035efbdbaffceb0031 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/rawfile/test.pdf differ diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..88de2d38c7e3b4d9017b102162dee18ed9bc4794 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "ProcessWebPageCont" + } + ] +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/mock/mock-config.json5 b/ArkWebKit/ProcessWebPageCont/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b9a78e201535765168a92d3543c690273ecdc019 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/mock/mock-config.json5 @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2025 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/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..328b7bb43ddfe2b41224a082e95263ec212bc34e --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2025 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'; +import { abilityDelegatorRegistry, Driver, ON } from '@kit.TestKit'; +import { UIAbility, Want } from '@kit.AbilityKit'; + +const delegator: abilityDelegatorRegistry.AbilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); +const bundleName = abilityDelegatorRegistry.getArguments().bundleName; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // 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. + }) + + /* + * 打开应用,点击 InitiatePrintW3CAPI 按钮 + * 触发 window.print 操作对页面内容进行打印 + */ + it('InitiatePrintW3CAPI', 0, async (done: Function) => { + console.info('uitest: InitiatePrintW3CAPI begin'); + const want: Want = { + bundleName: bundleName, + abilityName: 'EntryAbility' + } + await delegator.startAbility(want); + const driver = Driver.create(); + await driver.delayMs(1000); + const ability: UIAbility = await delegator.getCurrentTopAbility(); + console.info('get top ability'); + expect(ability.context.abilityInfo.name).assertEqual('EntryAbility'); + await driver.delayMs(3000); + + const button1 = await driver.findComponent(ON.text('InitiatePrintW3CAPI')); + await button1.click(); + await driver.delayMs(1000); + + const button2 = await driver.findComponent(ON.type('button')); + await button2.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let src: string = await web1.getText(); + expect(src).assertContain('print.html'); + + await driver.pressBack(); + console.info('uitest: InitiatePrintW3CAPI end'); + done(); + }); + + /* + * 点击 InitiatePrintAppAPI 按钮 + * 创建打印适配器,将适配器传入打印的print接口调起打印 + */ + it('InitiatePrintAppAPI', 0, async (done: Function) => { + console.info('uitest: InitiatePrintAppAPI begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('InitiatePrintAppAPI')); + await button1.click(); + await driver.delayMs(1000); + + const button2 = await driver.findComponent(ON.type('Button')); + await button2.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let src: string = await web1.getText(); + expect(src).assertContain('example.com'); + + await driver.pressBack(); + console.info('uitest: InitiatePrintAppAPI end'); + done(); + }); + + /* + * 点击 PreviewPDF 按钮 + * 使用Web组件的PDF文档预览能力加载PDF文档 + */ + it('PreviewPDF', 0, async (done: Function) => { + console.info('uitest: PreviewPDF begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('PreviewPDF')); + await button1.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let src: string = await web1.getText(); + expect(src).assertContain('example.com/test.pdf'); + + await driver.pressBack(); + console.info('uitest: PreviewPDF end'); + done(); + }); + + /* + * 点击 CalcAdjustSafeArea 按钮 + * 进行安全区域计算并避让适配支持异形屏幕设备在沉浸式效果下页面的正常显示 + */ + it('CalcAdjustSafeArea', 0, async (done: Function) => { + console.info('uitest: CalcAdjustSafeArea begin'); + const driver = Driver.create(); + await driver.delayMs(1000); + + const button1 = await driver.findComponent(ON.text('CalcAdjustSafeArea')); + await button1.click(); + await driver.delayMs(1000); + + const web1 = await driver.findComponent(ON.type('Web')); + let src: string = await web1.getText(); + expect(src).assertContain('example.com'); + + console.info('uitest: CalcAdjustSafeArea end'); + done(); + }); + }) +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets b/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..f40533d1374f4046f8af1e7df6aa90157cb361d8 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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 abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/module.json5 b/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c3fd9dda3040d888d9d8b0b62bcb5d3b6fbeb614 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/ohosTest/module.json5 @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 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": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkWebKit/ProcessWebPageCont/entry/src/test/List.test.ets b/ArkWebKit/ProcessWebPageCont/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..0ce5a4e436790deecb880ddf871876bd2a7f7b07 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/test/List.test.ets @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2025 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/ArkWebKit/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets b/ArkWebKit/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..b7b035e9b66997b8cac57382753074ff60c3f5ee --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2025 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/ArkWebKit/ProcessWebPageCont/hvigor/hvigor-config.json5 b/ArkWebKit/ProcessWebPageCont/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..43beb743cbd25c3507b1cf8a744bf8197b3bf2fb --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/hvigor/hvigor-config.json5 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "modelVersion": "5.0.0", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/ArkWebKit/ProcessWebPageCont/hvigorfile.ts b/ArkWebKit/ProcessWebPageCont/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..1307c03303328d961439d1f6983b09e728b5e8ce --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/hvigorfile.ts @@ -0,0 +1,21 @@ +/* +* Copyright (c) 2025 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 { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/ArkWebKit/ProcessWebPageCont/oh-package.json5 b/ArkWebKit/ProcessWebPageCont/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..93f097993a458e967d6d5239ea0580e79b5d6998 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/oh-package.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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. + */ + +{ + "modelVersion": "5.0.0", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.19", + "@ohos/hamock": "1.0.0" + } +} diff --git a/ArkWebKit/ProcessWebPageCont/ohosTest.md b/ArkWebKit/ProcessWebPageCont/ohosTest.md new file mode 100644 index 0000000000000000000000000000000000000000..a93a5b8216aaab3fa52497aba5b07499e2460066 --- /dev/null +++ b/ArkWebKit/ProcessWebPageCont/ohosTest.md @@ -0,0 +1,24 @@ +#### InitiatePrintW3CAPI + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------- | ------------ | --------------------------- | ---------------------- | -------- | -------- | +| 使用Web组件打印前端页面 | 设备运转正常 | 应用启动成功,点击print按钮 | 触发window.print()操作 | Yes | Pass | + +#### InitiatePrintAppAPI + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ----------------------- | ------------ | --------------------------------------------------- | ------------ | -------- | -------- | +| 使用Web组件打印前端页面 | 设备运转正常 | 应用启动成功,点击createWebPrintDocumentAdapter按钮 | 触发打印操作 | Yes | Pass | + +#### PreviewPDF + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------- | ------------ | ------------ | -------------------------------------- | -------- | -------- | +| 使用Web组件的PDF文档预览能力 | 设备运转正常 | 应用启动成功 | Web组件创建时指定默认加载的网络PDF文档 | Yes | Pass | + +#### CalcAdjustSafeArea + +| 测试功能 | 预置条件 | 输入 | 预期输出 | 是否自动 | 测试结果 | +| ---------------------------- | ---------------------------- | ------------ | ------------------------------------------- | -------- | -------- | +| 网页中安全区域计算和避让适配 | 设备运转正常,开启沉浸式效果 | 应用启动成功 | Web组件根据实际情况对网页元素进行相应的避让 | Yes | Pass | + diff --git a/ArkWebKit/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png b/ArkWebKit/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png new file mode 100644 index 0000000000000000000000000000000000000000..bacf76e4cca730d6869a641b88c9ab43a1c654c6 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/screenshots/CalcAdjustSafeArea.png differ diff --git a/ArkWebKit/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png b/ArkWebKit/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png new file mode 100644 index 0000000000000000000000000000000000000000..f3e5eb8f67cca636ea0608cd5af117cc0e8f6542 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/screenshots/InitiatePrintAppAPI.png differ diff --git a/ArkWebKit/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png b/ArkWebKit/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png new file mode 100644 index 0000000000000000000000000000000000000000..6e8241f75e8b4701ee18405f97b5b9f7e65efa87 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/screenshots/InitiatePrintW3CAPI.png differ diff --git a/ArkWebKit/ProcessWebPageCont/screenshots/PreviewPDF.png b/ArkWebKit/ProcessWebPageCont/screenshots/PreviewPDF.png new file mode 100644 index 0000000000000000000000000000000000000000..979eb15ac49c64537b600b4fe1e1e4c03b931c52 Binary files /dev/null and b/ArkWebKit/ProcessWebPageCont/screenshots/PreviewPDF.png differ