diff --git a/README.md b/README.md index 1235d649848377c910fae0bb602a8ede45ac4dd1..3e4baaed35683f061733ca72f7fc118f5d719019 100644 --- a/README.md +++ b/README.md @@ -2,58 +2,4 @@ ## 介绍 -本示例通过@kit.ArkUI、@kit.MediaKit等接口,实现了视频播放、手动和自动拉起画中画、画中画窗口控制视频播放和暂停等功能。 - -## 效果预览 - -![](screenshots/devices/WindowPiP.gif) - -## 使用说明 - -1. 在主界面,可以**点击对应视频按钮**进入**视频播放页面**; -2. 视频播放页面**点击开启**,应用**拉起画中画**,点击**关闭**,**关闭画中画**; -3. 视频播放页面**点击自动开启画中画**,在返回桌面时会**自动拉起画中画**; -4. 视频播放页面会显示一些**回调信息**。 - -## 工程目录 - -``` -├──entry/src/main/ets // 代码区 -│ ├──constants -│ │ └──Constants.ets // 常量类 -│ ├──entryability -│ │ └──EntryAbility.ets -│ ├──pages -│ │ ├──AVPlayer.ets // 视频播放 -│ │ ├──Index.ets // 首页 -│ │ └──VideoPlay.ets // 视频播放页面 -│ └──utils -│ └──Logger.ets // 日志工具类 -└──entry/src/main/resources // 应用资源目录 -``` - - -## 具体实现 - -- 整个示例用**Navigation**构建页面,主页面放置五个可点击视频框,点击之后进入视频播放页面。 -- 进入视频播放页面后,有三块区域,最上方的**XComponent**,中间的**画中画控制按钮**以及下方的**回调信息显示框**。 -- 点击**开启**后,应用手动拉起画中画,视频在画中画播放,返回桌面视频依旧画中画播放;点击**关闭**后,画中画播放的视频返回**XComponent**播放,同时返回桌面不会拉起画中画。 -- 点击**自动拉起画中画**后,返回桌面时应用自动拉起画中画,视频画中画播放。 -- 在播放页面进行画中画播放时,XComponent框会提示**当前视频正在以画中画播放**。 -- 回调信息显示框会显示**当前状态**,**错误原因**以及**按钮事件和状态**,参考:[VideoPlay.ets](entry/src/main/ets/pages/VideoPlay.ets)。 - - -## 相关权限 - -不涉及 - -## 依赖 - -不涉及 - -## 约束与限制 - -1. 本示例仅支持标准系统上运行,支持设备:华为手机。 -2. HarmonyOS系统:HarmonyOS NEXT Developer Beta1及以上。 -3. DevEco Studio版本:DevEco Studio NEXT Developer Beta1及以上。 -4. HarmonyOS SDK版本:HarmonyOS NEXT Developer Beta1 SDK及以上。 \ No newline at end of file +此分支仅供HMOS世界集成使用 \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 index c033ce4278fb0641d84107c3c134047ac487368e..6cda1e8dfc61a310a1dad272e61119863c07f5e6 100644 --- a/build-profile.json5 +++ b/build-profile.json5 @@ -30,6 +30,10 @@ ] } ] + }, + { + "name": "windowpipmodule", + "srcPath": "./windowpipmodule", } ] } \ No newline at end of file diff --git a/entry/oh-package.json5 b/entry/oh-package.json5 index 248c3b7541a589682a250f86a6d3ecf7414d2d6a..6aa37e3db94c6154a9ad55161fc52e65ee0b3dc0 100644 --- a/entry/oh-package.json5 +++ b/entry/oh-package.json5 @@ -5,6 +5,8 @@ "main": "", "author": "", "license": "", - "dependencies": {} + "dependencies": { + "@ohos_samples/windowpipmodule": "file:../windowpipmodule" + } } diff --git a/entry/src/main/ets/entryability/EntryAbility.ets b/entry/src/main/ets/entryability/EntryAbility.ets index 26f7915ba58cb086f4cba8138761aa8ade2fc4f3..631333d05052079c193779de35b8a9b062e64f1c 100644 --- a/entry/src/main/ets/entryability/EntryAbility.ets +++ b/entry/src/main/ets/entryability/EntryAbility.ets @@ -30,7 +30,7 @@ export default class EntryAbility extends UIAbility { // Main window is created, set main page for this ability hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); - windowStage.loadContent('pages/WindowPip', (err) => { + windowStage.loadContent('pages/Index', (err) => { if (err.code) { hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); return; diff --git a/entry/src/main/ets/pages/Index.ets b/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..64a3dbac193975d0a2ca3a19db50db3c72f49033 --- /dev/null +++ b/entry/src/main/ets/pages/Index.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 { WindowPip } from '@ohos_samples/windowpipmodule'; + +@Entry +@Component +struct Index { + + build() { + Stack() { + WindowPip() + } + } +} \ No newline at end of file diff --git a/entry/src/main/resources/base/profile/main_pages.json b/entry/src/main/resources/base/profile/main_pages.json index 521b733f03711a7408248c2e58816de7b23ffae6..1898d94f58d6128ab712be2c68acc7c98e9ab9ce 100644 --- a/entry/src/main/resources/base/profile/main_pages.json +++ b/entry/src/main/resources/base/profile/main_pages.json @@ -1,5 +1,5 @@ { "src": [ - "pages/WindowPip" + "pages/Index" ] } diff --git a/windowpipmodule/.gitignore b/windowpipmodule/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/windowpipmodule/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/windowpipmodule/Index.ets b/windowpipmodule/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..bcf1874c34fd6bc6de0f2a95137a1bdd90125000 --- /dev/null +++ b/windowpipmodule/Index.ets @@ -0,0 +1 @@ +export { WindowPip } from './src/main/ets/pages/WindowPip' diff --git a/windowpipmodule/build-profile.json5 b/windowpipmodule/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/windowpipmodule/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/windowpipmodule/consumer-rules.txt b/windowpipmodule/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/windowpipmodule/hvigorfile.ts b/windowpipmodule/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/windowpipmodule/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/windowpipmodule/obfuscation-rules.txt b/windowpipmodule/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/windowpipmodule/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/windowpipmodule/oh-package.json5 b/windowpipmodule/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e3dc6e338d3e4063512ba9f2b9e6603a8190eb34 --- /dev/null +++ b/windowpipmodule/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "@ohos_samples/windowpipmodule", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/entry/src/main/ets/constants/Constants.ets b/windowpipmodule/src/main/ets/constants/Constants.ets similarity index 100% rename from entry/src/main/ets/constants/Constants.ets rename to windowpipmodule/src/main/ets/constants/Constants.ets diff --git a/entry/src/main/ets/pages/AVPlayer.ets b/windowpipmodule/src/main/ets/pages/AVPlayer.ets similarity index 100% rename from entry/src/main/ets/pages/AVPlayer.ets rename to windowpipmodule/src/main/ets/pages/AVPlayer.ets diff --git a/entry/src/main/ets/pages/VideoPlay.ets b/windowpipmodule/src/main/ets/pages/VideoPlay.ets similarity index 100% rename from entry/src/main/ets/pages/VideoPlay.ets rename to windowpipmodule/src/main/ets/pages/VideoPlay.ets diff --git a/entry/src/main/ets/pages/WindowPip.ets b/windowpipmodule/src/main/ets/pages/WindowPip.ets similarity index 99% rename from entry/src/main/ets/pages/WindowPip.ets rename to windowpipmodule/src/main/ets/pages/WindowPip.ets index 67048e28b65e46d7acbc216c0f03fb8beca59f89..5a98589930dc45accd2cbcb36173997665d2ef91 100644 --- a/entry/src/main/ets/pages/WindowPip.ets +++ b/windowpipmodule/src/main/ets/pages/WindowPip.ets @@ -49,7 +49,7 @@ struct ImageWidthTitle { @Entry @Component -struct WindowPip { +export struct WindowPip { @Provide('pageInfos') pageInfos: NavPathStack = new NavPathStack(); @State curState: string = ''; private navigationId: string = 'navId'; diff --git a/entry/src/main/ets/utils/Logger.ets b/windowpipmodule/src/main/ets/utils/Logger.ets similarity index 100% rename from entry/src/main/ets/utils/Logger.ets rename to windowpipmodule/src/main/ets/utils/Logger.ets diff --git a/windowpipmodule/src/main/module.json5 b/windowpipmodule/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c4fcb3740bc66fd5c4a796100f1920c402b92dc5 --- /dev/null +++ b/windowpipmodule/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "windowpipmodule", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/windowpipmodule/src/main/resources/base/element/color.json b/windowpipmodule/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..95fc9b84bcd42de85c4c6fdec9998a7493b4d054 --- /dev/null +++ b/windowpipmodule/src/main/resources/base/element/color.json @@ -0,0 +1,40 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "Play_backgroundColor", + "value": "#F9F9F9" + }, + { + "name": "Toggle_fontColor", + "value": "#182431" + }, + { + "name": "Toggle_selectedColor", + "value": "#317aff" + }, + { + "name": "Callback_message_backgroundColor", + "value": "#FFFFFF" + }, + { + "name": "XComponent_backgroundColor", + "value": "#000000" + }, + { + "name": "Text_color", + "value": "#686868" + }, + { + "name": "Message_color", + "value": "#737373" + }, + { + "name": "XComponent_text_color", + "value": "#686868" + } + ] +} \ No newline at end of file diff --git a/windowpipmodule/src/main/resources/base/element/float.json b/windowpipmodule/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..4a49ef7f00033bdd443ccaf1eb54c21dd2b1ee4c --- /dev/null +++ b/windowpipmodule/src/main/resources/base/element/float.json @@ -0,0 +1,12 @@ +{ + "float": [ + { + "name": "x_component_height", + "value": "800px" + }, + { + "name": "toggle_padding", + "value": "10.75" + } + ] +} \ No newline at end of file diff --git a/windowpipmodule/src/main/resources/base/element/integer.json b/windowpipmodule/src/main/resources/base/element/integer.json new file mode 100644 index 0000000000000000000000000000000000000000..b43b81dd5194b523a36f7c847883bcdbb49e4467 --- /dev/null +++ b/windowpipmodule/src/main/resources/base/element/integer.json @@ -0,0 +1,84 @@ +{ + "integer": [ + { + "name": "Navigation_padding", + "value": 5 + }, + { + "name": "x_component_marg_bottom", + "value": 30 + }, + { + "name": "other_padding", + "value": 14 + }, + { + "name": "auto_pip_height", + "value": 56 + }, + { + "name": "auto_text_width", + "value": 160 + }, + { + "name": "video1_button_height", + "value": 200 + }, + { + "name": "video1_text_padding", + "value": 310 + }, + { + "name": "video_text_padding", + "value": 120 + }, + { + "name": "control_height", + "value": 79 + }, + { + "name": "callback_text_padding", + "value": 273 + }, + { + "name": "text_height", + "value": 60 + }, + { + "name": "control_button_width", + "value": 149 + }, + { + "name": "auto_button_height", + "value": 27 + }, + { + "name": "auto_button_width", + "value": 60 + }, + { + "name": "video_button_height", + "value": 150 + }, + { + "name": "video_button_board_radius", + "value": 10 + }, + { + "name": "auto_button_board_radius", + "value": 15 + }, + { + "name": "x_component_marg_top", + "value": 15 + }, + { + "name": "text_size", + "value": 15 + }, + { + "name": "scroll_height", + "value": 30 + } + ] +} \ No newline at end of file diff --git a/windowpipmodule/src/main/resources/base/element/string.json b/windowpipmodule/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..524d7ae334bc7e7ba6e922fb570c636026e5b2de --- /dev/null +++ b/windowpipmodule/src/main/resources/base/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "WindowPiP" + }, + { + "name": "video1", + "value": "Video1" + }, + { + "name": "video2", + "value": "Video2" + }, + { + "name": "video3", + "value": "Video3" + }, + { + "name": "video4", + "value": "Video4" + }, + { + "name": "video5", + "value": "Video5" + }, + { + "name": "video6", + "value": "Video6" + }, + { + "name": "video7", + "value": "Video7" + }, + { + "name": "pip_demo", + "value": "WindowPiP" + }, + { + "name": "start", + "value": "Start" + }, + { + "name": "stop", + "value": "Stop" + }, + { + "name": "auto", + "value": "Auto" + }, + { + "name": "current_status", + "value": "Current Status" + }, + { + "name": "current_error", + "value": "Current Error" + }, + { + "name": "current_action", + "value": "Current Action" + }, + { + "name": "callback_message", + "value": "Callback Message" + }, + { + "name": "current_video_pip_play", + "value": "Current Video Pip Play" + }, + { + "name": "current_error_hint", + "value": "Without" + } + ] +} \ No newline at end of file diff --git a/windowpipmodule/src/main/resources/base/media/background.png b/windowpipmodule/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..f939c9fa8cc8914832e602198745f592a0dfa34d Binary files /dev/null and b/windowpipmodule/src/main/resources/base/media/background.png differ diff --git a/windowpipmodule/src/main/resources/base/media/btn_ground.PNG b/windowpipmodule/src/main/resources/base/media/btn_ground.PNG new file mode 100644 index 0000000000000000000000000000000000000000..25ce3c2994f68bee7a5fa3ba26f57f9faa707267 Binary files /dev/null and b/windowpipmodule/src/main/resources/base/media/btn_ground.PNG differ diff --git a/windowpipmodule/src/main/resources/base/media/foreground.png b/windowpipmodule/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..4483ddad1f079e1089d685bd204ee1cfe1d01902 Binary files /dev/null and b/windowpipmodule/src/main/resources/base/media/foreground.png differ diff --git a/windowpipmodule/src/main/resources/base/media/layered_image.json b/windowpipmodule/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/windowpipmodule/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/windowpipmodule/src/main/resources/base/media/startIcon.png b/windowpipmodule/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/windowpipmodule/src/main/resources/base/media/startIcon.png differ diff --git a/windowpipmodule/src/main/resources/base/profile/main_pages.json b/windowpipmodule/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..521b733f03711a7408248c2e58816de7b23ffae6 --- /dev/null +++ b/windowpipmodule/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/WindowPip" + ] +} diff --git a/windowpipmodule/src/main/resources/en_US/element/string.json b/windowpipmodule/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..524d7ae334bc7e7ba6e922fb570c636026e5b2de --- /dev/null +++ b/windowpipmodule/src/main/resources/en_US/element/string.json @@ -0,0 +1,84 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "WindowPiP" + }, + { + "name": "video1", + "value": "Video1" + }, + { + "name": "video2", + "value": "Video2" + }, + { + "name": "video3", + "value": "Video3" + }, + { + "name": "video4", + "value": "Video4" + }, + { + "name": "video5", + "value": "Video5" + }, + { + "name": "video6", + "value": "Video6" + }, + { + "name": "video7", + "value": "Video7" + }, + { + "name": "pip_demo", + "value": "WindowPiP" + }, + { + "name": "start", + "value": "Start" + }, + { + "name": "stop", + "value": "Stop" + }, + { + "name": "auto", + "value": "Auto" + }, + { + "name": "current_status", + "value": "Current Status" + }, + { + "name": "current_error", + "value": "Current Error" + }, + { + "name": "current_action", + "value": "Current Action" + }, + { + "name": "callback_message", + "value": "Callback Message" + }, + { + "name": "current_video_pip_play", + "value": "Current Video Pip Play" + }, + { + "name": "current_error_hint", + "value": "Without" + } + ] +} \ No newline at end of file diff --git a/entry/src/main/resources/rawfile/video.mp4 b/windowpipmodule/src/main/resources/rawfile/video.mp4 similarity index 100% rename from entry/src/main/resources/rawfile/video.mp4 rename to windowpipmodule/src/main/resources/rawfile/video.mp4 diff --git a/windowpipmodule/src/main/resources/zh_CN/element/string.json b/windowpipmodule/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..3e368b8b09eadc9d8a6ff0c45ebb76528e846744 --- /dev/null +++ b/windowpipmodule/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,85 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "模块描述" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "WindowPiP" + }, + { + "name": "video1", + "value": "视频1" + }, + { + "name": "video2", + "value": "视频2" + }, + { + "name": "video3", + "value": "视频3" + }, + { + "name": "video4", + "value": "视频4" + }, + { + "name": "video5", + "value": "视频5" + }, + { + "name": "video6", + "value": "视频6" + }, + { + "name": "video7", + "value": "视频7" + }, + + { + "name": "pip_demo", + "value": "画中画示例" + }, + { + "name": "start", + "value": "开启" + }, + { + "name": "stop", + "value": "关闭" + }, + { + "name": "auto", + "value": "自动启动画中画" + }, + { + "name": "current_status", + "value": "当前状态:" + }, + { + "name": "current_error", + "value": "错误原因:" + }, + { + "name": "current_action", + "value": "按钮事件和状态:" + }, + { + "name": "callback_message", + "value": "回调信息" + }, + { + "name": "current_video_pip_play", + "value": "当前视频正在画中画播放" + }, + { + "name": "current_error_hint", + "value": "无" + } + ] +} \ No newline at end of file diff --git a/windowpipmodule/src/ohosTest/ets/test/Ability.test.ets b/windowpipmodule/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/windowpipmodule/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +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. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + 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/windowpipmodule/src/ohosTest/ets/test/List.test.ets b/windowpipmodule/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/windowpipmodule/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/windowpipmodule/src/ohosTest/module.json5 b/windowpipmodule/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..337d2375d50b0763fe67a9fec8158467edc4ea92 --- /dev/null +++ b/windowpipmodule/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "windowpipmodule_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/windowpipmodule/src/test/List.test.ets b/windowpipmodule/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/windowpipmodule/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/windowpipmodule/src/test/LocalUnit.test.ets b/windowpipmodule/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/windowpipmodule/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +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