├── screenshot ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png └── 8.png ├── entry ├── .gitignore ├── src │ ├── main │ │ ├── ets │ │ │ ├── model │ │ │ │ ├── IStatus.ets │ │ │ │ ├── MeListBean.ets │ │ │ │ ├── BottomTabsItem.ets │ │ │ │ ├── BottomTabsModel.ets │ │ │ │ ├── ITreeBean.ets │ │ │ │ └── HomeEntity.ets │ │ │ ├── pages │ │ │ │ ├── DetailsWeb.ets │ │ │ │ ├── Launch.ets │ │ │ │ ├── Index.ets │ │ │ │ └── Login.ets │ │ │ ├── component │ │ │ │ ├── HomeComponent.ets │ │ │ │ ├── refresh │ │ │ │ │ ├── NoMoreLayout.ets │ │ │ │ │ ├── LoadMoreLayout.ets │ │ │ │ │ ├── RefreshLayout.ets │ │ │ │ │ ├── RefreshModel.ets │ │ │ │ │ └── RefreshConst.ets │ │ │ │ ├── SquareComponent.ets │ │ │ │ ├── NavigationList.ets │ │ │ │ ├── SquareList.ets │ │ │ │ └── MeComponent.ets │ │ │ ├── http │ │ │ │ ├── Response.ets │ │ │ │ └── API.ets │ │ │ ├── request │ │ │ │ ├── Login.ets │ │ │ │ ├── SquareReq.ets │ │ │ │ └── Home.ets │ │ │ ├── view │ │ │ │ └── Banner.ets │ │ │ ├── entryability │ │ │ │ └── EntryAbility.ts │ │ │ └── utils │ │ │ │ └── Constants.ets │ │ ├── resources │ │ │ ├── base │ │ │ │ ├── media │ │ │ │ │ ├── icon.png │ │ │ │ │ ├── about.png │ │ │ │ │ ├── ic_me.png │ │ │ │ │ ├── image1.png │ │ │ │ │ ├── image2.png │ │ │ │ │ ├── image3.png │ │ │ │ │ ├── right.png │ │ │ │ │ ├── score.png │ │ │ │ │ ├── share.png │ │ │ │ │ ├── system.png │ │ │ │ │ ├── ic_avatar.png │ │ │ │ │ ├── ic_down.png │ │ │ │ │ ├── ic_home.png │ │ │ │ │ ├── ic_square.png │ │ │ │ │ ├── collection.png │ │ │ │ │ ├── read_record.png │ │ │ │ │ ├── ic_me_selected.png │ │ │ │ │ ├── loading_icon.gif │ │ │ │ │ ├── ic_fail_refresh.png │ │ │ │ │ ├── ic_home_selected.png │ │ │ │ │ ├── ic_pull_up_load.gif │ │ │ │ │ ├── ic_pull_up_refresh.png │ │ │ │ │ ├── ic_square_selected.png │ │ │ │ │ ├── ic_succeed_refresh.png │ │ │ │ │ └── ic_pull_down_refresh.png │ │ │ │ ├── profile │ │ │ │ │ └── main_pages.json │ │ │ │ └── element │ │ │ │ │ ├── color.json │ │ │ │ │ └── string.json │ │ │ ├── zh_CN │ │ │ │ └── element │ │ │ │ │ └── string.json │ │ │ └── en_US │ │ │ │ └── element │ │ │ │ └── string.json │ │ └── module.json5 │ └── ohosTest │ │ ├── resources │ │ └── base │ │ │ ├── profile │ │ │ └── test_pages.json │ │ │ ├── media │ │ │ └── icon.png │ │ │ └── element │ │ │ ├── color.json │ │ │ └── string.json │ │ ├── ets │ │ ├── test │ │ │ ├── List.test.ets │ │ │ └── Ability.test.ets │ │ ├── testability │ │ │ ├── pages │ │ │ │ └── Index.ets │ │ │ └── TestAbility.ets │ │ └── testrunner │ │ │ └── OpenHarmonyTestRunner.ts │ │ └── module.json5 ├── hvigorfile.ts ├── build-profile.json5 └── oh-package.json5 ├── AppScope ├── resources │ └── base │ │ ├── media │ │ └── app_icon.png │ │ └── element │ │ └── string.json └── app.json5 ├── hvigor └── hvigor-config.json5 ├── hvigorfile.ts ├── oh-package.json5 ├── oh_modules ├── @ohos │ └── hypium │ │ ├── oh-package.json5 │ │ ├── CHANGELOG.md │ │ └── src │ │ └── main │ │ ├── module │ │ ├── assert │ │ │ ├── assertFail.js │ │ │ ├── assertNaN.js │ │ │ ├── assertNull.js │ │ │ ├── assertFalse.js │ │ │ ├── assertLess.js │ │ │ ├── assertUndefined.js │ │ │ ├── assertLarger.js │ │ │ ├── assertLessOrEqual.js │ │ │ ├── assertLargerOrEqual.js │ │ │ ├── assertNegUnlimited.js │ │ │ ├── assertPosUnlimited.js │ │ │ ├── isPromiseLike.js │ │ │ ├── assertInstanceOf.js │ │ │ ├── assertContain.js │ │ │ ├── assertThrowError.js │ │ │ ├── assertPromiseIsRejected.js │ │ │ ├── assertClose.js │ │ │ ├── assertPromiseIsPending.js │ │ │ ├── assertPromiseIsResolved.js │ │ │ ├── assertPromiseIsRejectedWith.js │ │ │ └── assertPromiseIsResolvedWith.js │ │ ├── coverage │ │ │ └── coverageCollect.js │ │ ├── mock │ │ │ ├── VerificationMode.js │ │ │ └── ExtendInterface.js │ │ ├── config │ │ │ └── Filter.js │ │ └── kit │ │ │ └── SysTestKit.js │ │ ├── Constant.js │ │ ├── interface.js │ │ └── event.js └── .ohpm │ ├── oh_modules │ └── @ohos │ │ └── hypium │ │ ├── oh-package.json5 │ │ ├── CHANGELOG.md │ │ └── src │ │ └── main │ │ ├── module │ │ ├── assert │ │ │ ├── assertFail.js │ │ │ ├── assertNaN.js │ │ │ ├── assertFalse.js │ │ │ ├── assertNull.js │ │ │ ├── assertLess.js │ │ │ ├── assertLarger.js │ │ │ ├── assertUndefined.js │ │ │ ├── assertLessOrEqual.js │ │ │ ├── assertLargerOrEqual.js │ │ │ ├── assertNegUnlimited.js │ │ │ ├── assertPosUnlimited.js │ │ │ ├── isPromiseLike.js │ │ │ ├── assertInstanceOf.js │ │ │ ├── assertContain.js │ │ │ ├── assertThrowError.js │ │ │ ├── assertPromiseIsRejected.js │ │ │ ├── assertClose.js │ │ │ ├── assertPromiseIsPending.js │ │ │ ├── assertPromiseIsResolved.js │ │ │ ├── assertPromiseIsRejectedWith.js │ │ │ └── assertPromiseIsResolvedWith.js │ │ ├── coverage │ │ │ └── coverageCollect.js │ │ ├── mock │ │ │ ├── VerificationMode.js │ │ │ └── ExtendInterface.js │ │ ├── config │ │ │ └── Filter.js │ │ └── kit │ │ │ └── SysTestKit.js │ │ ├── Constant.js │ │ ├── interface.js │ │ └── event.js │ └── @ohos+hypium@1.0.6 │ └── oh_modules │ └── @ohos │ └── hypium │ ├── oh-package.json5 │ ├── CHANGELOG.md │ └── src │ └── main │ ├── module │ ├── assert │ │ ├── assertFail.js │ │ ├── assertNaN.js │ │ ├── assertNull.js │ │ ├── assertFalse.js │ │ ├── assertLess.js │ │ ├── assertUndefined.js │ │ ├── assertLarger.js │ │ ├── assertLessOrEqual.js │ │ ├── assertLargerOrEqual.js │ │ ├── assertNegUnlimited.js │ │ ├── assertPosUnlimited.js │ │ ├── isPromiseLike.js │ │ ├── assertInstanceOf.js │ │ ├── assertContain.js │ │ ├── assertThrowError.js │ │ ├── assertPromiseIsRejected.js │ │ ├── assertClose.js │ │ ├── assertPromiseIsPending.js │ │ ├── assertPromiseIsResolved.js │ │ ├── assertPromiseIsRejectedWith.js │ │ └── assertPromiseIsResolvedWith.js │ ├── coverage │ │ └── coverageCollect.js │ ├── mock │ │ ├── VerificationMode.js │ │ └── ExtendInterface.js │ ├── config │ │ └── Filter.js │ └── kit │ │ └── SysTestKit.js │ ├── Constant.js │ ├── interface.js │ └── event.js ├── .hvigor └── outputs │ └── logs │ └── details │ └── details.json ├── oh-package-lock.json5 ├── .gitignore ├── README.md ├── hvigorw └── hvigorw.bat /screenshot/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/1.png -------------------------------------------------------------------------------- /screenshot/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/2.png -------------------------------------------------------------------------------- /screenshot/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/3.png -------------------------------------------------------------------------------- /screenshot/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/4.png -------------------------------------------------------------------------------- /screenshot/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/5.png -------------------------------------------------------------------------------- /screenshot/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/6.png -------------------------------------------------------------------------------- /screenshot/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/7.png -------------------------------------------------------------------------------- /screenshot/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/screenshot/8.png -------------------------------------------------------------------------------- /entry/.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | /oh_modules 3 | /.preview 4 | /build 5 | /.cxx 6 | /.test -------------------------------------------------------------------------------- /entry/src/main/ets/model/IStatus.ets: -------------------------------------------------------------------------------- 1 | export const enum IState { 2 | Loading = 0, 3 | Success = 1, 4 | Fail = 2 5 | } -------------------------------------------------------------------------------- /entry/src/main/ets/model/MeListBean.ets: -------------------------------------------------------------------------------- 1 | export class MeListBean { 2 | id: number 3 | name: string 4 | img: Resource 5 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/profile/test_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "testability/pages/Index" 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /AppScope/resources/base/media/app_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/AppScope/resources/base/media/app_icon.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/icon.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/about.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_me.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_me.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/image1.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/image2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/image2.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/image3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/image3.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/right.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/score.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/score.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/share.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/share.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/system.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/system.png -------------------------------------------------------------------------------- /hvigor/hvigor-config.json5: -------------------------------------------------------------------------------- 1 | { 2 | "hvigorVersion": "2.4.2", 3 | "dependencies": { 4 | "@ohos/hvigor-ohos-plugin": "2.4.2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_avatar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_avatar.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_down.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_home.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_home.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_square.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_square.png -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/media/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/ohosTest/resources/base/media/icon.png -------------------------------------------------------------------------------- /entry/src/main/ets/model/BottomTabsItem.ets: -------------------------------------------------------------------------------- 1 | export interface BottomTabsItem { 2 | icon: Resource; 3 | iconSelected: Resource; 4 | text: Resource; 5 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/collection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/collection.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/read_record.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/read_record.png -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/List.test.ets: -------------------------------------------------------------------------------- 1 | import abilityTest from './Ability.test' 2 | 3 | export default function testsuite() { 4 | abilityTest() 5 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_me_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_me_selected.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/loading_icon.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/loading_icon.gif -------------------------------------------------------------------------------- /AppScope/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "app_name", 5 | "value": "玩Android鸿蒙版" 6 | } 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_fail_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_fail_refresh.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_home_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_home_selected.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_pull_up_load.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_pull_up_load.gif -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_pull_up_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_pull_up_refresh.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_square_selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_square_selected.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_succeed_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_succeed_refresh.png -------------------------------------------------------------------------------- /entry/src/main/resources/base/media/ic_pull_down_refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zqf-dev/WAndroidHOS/HEAD/entry/src/main/resources/base/media/ic_pull_down_refresh.png -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { appTasks } from '@ohos/hvigor-ohos-plugin'; -------------------------------------------------------------------------------- /entry/src/main/resources/base/profile/main_pages.json: -------------------------------------------------------------------------------- 1 | { 2 | "src": [ 3 | "pages/Index", 4 | "pages/Login", 5 | "pages/Launch", 6 | "pages/DetailsWeb" 7 | ] 8 | } -------------------------------------------------------------------------------- /entry/hvigorfile.ts: -------------------------------------------------------------------------------- 1 | // Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. 2 | export { hapTasks } from '@ohos/hvigor-ohos-plugin'; 3 | -------------------------------------------------------------------------------- /entry/build-profile.json5: -------------------------------------------------------------------------------- 1 | { 2 | "apiType": 'stageMode', 3 | "buildOption": { 4 | }, 5 | "targets": [ 6 | { 7 | "name": "default", 8 | "runtimeOS": "HarmonyOS" 9 | }, 10 | { 11 | "name": "ohosTest", 12 | } 13 | ] 14 | } -------------------------------------------------------------------------------- /entry/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "license": "", 3 | "devDependencies": {}, 4 | "author": "", 5 | "name": "entry", 6 | "description": "Please describe the basic information.", 7 | "main": "", 8 | "version": "1.0.0", 9 | "dependencies": {} 10 | } 11 | -------------------------------------------------------------------------------- /AppScope/app.json5: -------------------------------------------------------------------------------- 1 | { 2 | "app": { 3 | "bundleName": "com.zqf.wandroidhos", 4 | "vendor": "example", 5 | "versionCode": 1000000, 6 | "versionName": "1.0.0", 7 | "icon": "$media:app_icon", 8 | "label": "$string:app_name", 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "license": "", 3 | "devDependencies": { 4 | "@ohos/hypium": "1.0.6" 5 | }, 6 | "author": "", 7 | "name": "wandroidhos", 8 | "description": "Please describe the basic information.", 9 | "main": "", 10 | "version": "1.0.0", 11 | "dependencies": {} 12 | } 13 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ohos/hypium", 3 | "version": "1.0.6", 4 | "description": "A unit test framework for OpenHarmony application", 5 | "main": "index.js", 6 | "keywords": [], 7 | "author": "huawei", 8 | "license": "Apache-2.0", 9 | "dependencies": { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ohos/hypium", 3 | "version": "1.0.6", 4 | "description": "A unit test framework for OpenHarmony application", 5 | "main": "index.js", 6 | "keywords": [], 7 | "author": "huawei", 8 | "license": "Apache-2.0", 9 | "dependencies": { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/oh-package.json5: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@ohos/hypium", 3 | "version": "1.0.6", 4 | "description": "A unit test framework for OpenHarmony application", 5 | "main": "index.js", 6 | "keywords": [], 7 | "author": "huawei", 8 | "license": "Apache-2.0", 9 | "dependencies": { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /.hvigor/outputs/logs/details/details.json: -------------------------------------------------------------------------------- 1 | { 2 | "totalTime": 4900285400, 3 | "moduleNum": 1, 4 | "taskTime": { 5 | "compileArkTS": 4144990000, 6 | "compileJS": 4627600, 7 | "compileResource": 0, 8 | "packageHap": 511450400, 9 | "signHap": 844700 10 | }, 11 | "isIncremental": true, 12 | "hasIncremental": true, 13 | "isParallel": true 14 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_test_desc", 5 | "value": "test ability description" 6 | }, 7 | { 8 | "name": "TestAbility_desc", 9 | "value": "the test ability" 10 | }, 11 | { 12 | "name": "TestAbility_label", 13 | "value": "test label" 14 | } 15 | ] 16 | } -------------------------------------------------------------------------------- /entry/src/main/ets/pages/DetailsWeb.ets: -------------------------------------------------------------------------------- 1 | import webview from '@ohos.web.webview' 2 | import router from '@ohos.router' 3 | import { Constants } from '../utils/Constants' 4 | 5 | @Entry 6 | @Component 7 | struct DetailsWeb { 8 | webController: WebviewController = new webview.WebviewController() 9 | @State url: string = router.getParams()?.['url'] 10 | 11 | build() { 12 | Column(){ 13 | Web({ src: this.url, controller: this.webController }) 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /oh-package-lock.json5: -------------------------------------------------------------------------------- 1 | { 2 | "lockfileVersion": 1, 3 | "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", 4 | "specifiers": { 5 | "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6" 6 | }, 7 | "packages": { 8 | "@ohos/hypium@1.0.6": { 9 | "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", 10 | "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /entry/src/main/ets/component/HomeComponent.ets: -------------------------------------------------------------------------------- 1 | import { Constants } from '../utils/Constants'; 2 | import { ArticleList } from '../view/ArticleList'; 3 | import { Banner } from '../view/Banner'; 4 | 5 | @Component 6 | export struct Home { 7 | build() { 8 | Scroll() { 9 | Column() { 10 | //广告页面 11 | Banner() 12 | //文章列表 13 | ArticleList() 14 | } 15 | .width(Constants.FULL_SIZE) 16 | } 17 | .scrollable(ScrollDirection.Vertical).scrollBar(BarState.Off) 18 | } 19 | } -------------------------------------------------------------------------------- /entry/src/main/ets/http/Response.ets: -------------------------------------------------------------------------------- 1 | 2 | export class Response { 3 | /** 4 | * Code returned by the network request: success, fail. 5 | */ 6 | errorCode: number; 7 | 8 | /** 9 | * Message returned by the network request. 10 | */ 11 | errorMsg: string | Resource; 12 | 13 | /** 14 | * Data returned by the network request. 15 | */ 16 | data: string | Object | ArrayBuffer; 17 | 18 | constructor() { 19 | this.errorCode = 0; 20 | this.errorMsg = ''; 21 | this.data = ''; 22 | } 23 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Gradle files 2 | .gradle/ 3 | build/ 4 | 5 | # Local configuration file (sdk path, etc) 6 | local.properties 7 | 8 | # Log/OS Files 9 | *.log 10 | 11 | # Android Studio generated files and folders 12 | captures/ 13 | .externalNativeBuild/ 14 | .cxx/ 15 | *.apk 16 | output.json 17 | 18 | # IntelliJ 19 | *.iml 20 | .idea/ 21 | misc.xml 22 | deploymentTargetDropDown.xml 23 | render.experimental.xml 24 | 25 | # Keystore files 26 | *.jks 27 | *.keystore 28 | 29 | # Google Services (e.g. APIs or Firebase) 30 | google-services.json 31 | 32 | # Android Profiling 33 | *.hprof 34 | -------------------------------------------------------------------------------- /entry/src/main/ets/component/refresh/NoMoreLayout.ets: -------------------------------------------------------------------------------- 1 | import { RefreshConst } from './RefreshConst' 2 | import { Constants } from '../../utils/Constants' 3 | 4 | @Component 5 | export default struct NoMoreLayout { 6 | build() { 7 | Row() { 8 | Text($r('app.string.prompt_message')) 9 | .margin({ left: RefreshConst.NoMoreLayoutConstant_NORMAL_PADDING }) 10 | .fontSize(RefreshConst.NoMoreLayoutConstant_TITLE_FONT) 11 | .textAlign(TextAlign.Center) 12 | } 13 | .width(Constants.FULL_SIZE) 14 | .justifyContent(FlexAlign.Center) 15 | .height(RefreshConst.CUSTOM_LAYOUT_HEIGHT) 16 | } 17 | } -------------------------------------------------------------------------------- /entry/src/main/ets/model/BottomTabsModel.ets: -------------------------------------------------------------------------------- 1 | import { BottomTabsItem } from './BottomTabsItem'; 2 | 3 | export const BottomTabsList: Array = [ 4 | { 5 | icon: $r('app.media.ic_home'), 6 | iconSelected: $r('app.media.ic_home_selected'), 7 | text: $r('app.string.bottom_text_home') 8 | }, 9 | { 10 | icon: $r('app.media.ic_square'), 11 | iconSelected: $r('app.media.ic_square_selected'), 12 | text: $r('app.string.bottom_text_square') 13 | }, 14 | { 15 | icon: $r('app.media.ic_me'), 16 | iconSelected: $r('app.media.ic_me_selected'), 17 | text: $r('app.string.bottom_text_me') 18 | } 19 | ] -------------------------------------------------------------------------------- /entry/src/main/ets/model/ITreeBean.ets: -------------------------------------------------------------------------------- 1 | //体系 2 | export class ITree { 3 | children: Array 4 | name: string 5 | id: string 6 | parentChapterId: number 7 | courseId: number 8 | order: number 9 | type: number 10 | userControlSetTop: boolean 11 | } 12 | 13 | export class ITreeChildren { 14 | name: string 15 | id: string 16 | parentChapterId: number 17 | courseId: number 18 | order: number 19 | type: number 20 | userControlSetTop: boolean 21 | } 22 | 23 | //导航 24 | export class INav { 25 | articles: Array 26 | name: string 27 | cid: string 28 | } 29 | 30 | export class INavChildren { 31 | title: string 32 | link: string 33 | } -------------------------------------------------------------------------------- /entry/src/main/ets/request/Login.ets: -------------------------------------------------------------------------------- 1 | import HashMap from '@ohos.util.HashMap'; 2 | import { API } from '../http/API'; 3 | import { get, post, postForm } from '../http/Request'; 4 | import { Response } from '../http/Response'; 5 | /** 6 | * 登录 7 | */ 8 | export function userLogin(params: HashMap): Promise { 9 | return new Promise((resolve, reject) => { 10 | postForm(API.login, params).then((data: Response) => { 11 | if (data.data && data.errorCode === API.SERVER_CODE_SUCCESS) { 12 | resolve(data.data); 13 | } else { 14 | reject(data.errorMsg); 15 | } 16 | }).catch((err: Error) => { 17 | reject($r('app.string.http_error_message')); 18 | }); 19 | }); 20 | } -------------------------------------------------------------------------------- /entry/src/main/ets/http/API.ets: -------------------------------------------------------------------------------- 1 | export class API { 2 | //服务器地址 3 | static readonly Url = 'https://www.wanandroid.com' 4 | //广告页 5 | static readonly banner = API.Url + '/banner/json' 6 | //文章 7 | static readonly article = API.Url + '/article/list/' 8 | //体系 9 | static readonly tree = API.Url + '/tree/json' 10 | //导航 11 | static readonly nav = API.Url + '/navi/json' 12 | //登录 13 | static readonly login = API.Url + "/user/login" 14 | 15 | //读取超时 16 | static readonly HTTP_READ_TIMEOUT = 10 * 1000 17 | /** 18 | * Http请求成功的code. 19 | */ 20 | static readonly HTTP_CODE_200: number = 200; 21 | /** 22 | * wanAndroid 接口返回的成功的code. 23 | */ 24 | static readonly SERVER_CODE_SUCCESS: number = 0; 25 | } 26 | 27 | export const enum ContentType { 28 | JSON = 'application/json', 29 | formUrlencoded = 'application/x-www-form-urlencoded ' 30 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.6 2 | 3 | - 适配模块化编译 4 | - 适配IDE覆盖率数据输出 5 | 6 | ## 1.0.5 7 | 8 | - 优化接口异常场景处理能力 9 | - 修复大规模压力测试下内存溢出问题 10 | - 修复测试脚本定义扩展原型方法与框架的兼容性问题 11 | - 异步promise状态判断断言与取反断言兼容 12 | 13 | ## 1.0.4 14 | 15 | - 新增异步promise状态判断断言 16 | - 新增基础数据判断断言 17 | - 新增断言异常信息描述 18 | - 优化用例计时逻辑,采用相对时间计时 19 | - 修改用例执行过程,异步执行 20 | - 修复用例结果偶现的乱序问题 21 | 22 | ## 1.0.3 23 | 24 | - 新增mock对象的能力,支持mock无参数函数 25 | - 新增测试套、测试用例随机执行功能 26 | - 解决测试套声明不规范,导致用例加载异常的问题 27 | - 修复命令行窗口输出乱序的问题 28 | 29 | ## 1.0.2 30 | 31 | - 新增mock接口,判断当前mock方法状态、使用次数 32 | - 修复用例耗时统计问题 33 | - 修改断言功能,断言失败后,会抛出异常 34 | 35 | ## 1.0.1 36 | - 新增mock基础能力 37 | - 修复部分断言失败后,消息提示异常问题 38 | 39 | ## 1.0.0 40 | - 新增应用日志关键字查询接口,查询hilog日志中是否包含指定字符串 41 | - 支持用例筛选功能,用于指定测试用例的执行。可按用例名称、类型、规模、级别与测试套名称筛选 42 | - 支持新SDK下单元测试 43 | - 支持dry run 功能,通过命令行传参数,返回当前测试套用例名称全集 44 | - 新增框架接口声明文件,用于deveco联想 45 | - 修复用例状态统计问题 -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.6 2 | 3 | - 适配模块化编译 4 | - 适配IDE覆盖率数据输出 5 | 6 | ## 1.0.5 7 | 8 | - 优化接口异常场景处理能力 9 | - 修复大规模压力测试下内存溢出问题 10 | - 修复测试脚本定义扩展原型方法与框架的兼容性问题 11 | - 异步promise状态判断断言与取反断言兼容 12 | 13 | ## 1.0.4 14 | 15 | - 新增异步promise状态判断断言 16 | - 新增基础数据判断断言 17 | - 新增断言异常信息描述 18 | - 优化用例计时逻辑,采用相对时间计时 19 | - 修改用例执行过程,异步执行 20 | - 修复用例结果偶现的乱序问题 21 | 22 | ## 1.0.3 23 | 24 | - 新增mock对象的能力,支持mock无参数函数 25 | - 新增测试套、测试用例随机执行功能 26 | - 解决测试套声明不规范,导致用例加载异常的问题 27 | - 修复命令行窗口输出乱序的问题 28 | 29 | ## 1.0.2 30 | 31 | - 新增mock接口,判断当前mock方法状态、使用次数 32 | - 修复用例耗时统计问题 33 | - 修改断言功能,断言失败后,会抛出异常 34 | 35 | ## 1.0.1 36 | - 新增mock基础能力 37 | - 修复部分断言失败后,消息提示异常问题 38 | 39 | ## 1.0.0 40 | - 新增应用日志关键字查询接口,查询hilog日志中是否包含指定字符串 41 | - 支持用例筛选功能,用于指定测试用例的执行。可按用例名称、类型、规模、级别与测试套名称筛选 42 | - 支持新SDK下单元测试 43 | - 支持dry run 功能,通过命令行传参数,返回当前测试套用例名称全集 44 | - 新增框架接口声明文件,用于deveco联想 45 | - 修复用例状态统计问题 -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFail() { 17 | return { 18 | pass: false, 19 | message: 'fail ' 20 | }; 21 | } 22 | 23 | export default assertFail; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFail() { 17 | return { 18 | pass: false, 19 | message: 'fail ' 20 | }; 21 | } 22 | 23 | export default assertFail; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.6 2 | 3 | - 适配模块化编译 4 | - 适配IDE覆盖率数据输出 5 | 6 | ## 1.0.5 7 | 8 | - 优化接口异常场景处理能力 9 | - 修复大规模压力测试下内存溢出问题 10 | - 修复测试脚本定义扩展原型方法与框架的兼容性问题 11 | - 异步promise状态判断断言与取反断言兼容 12 | 13 | ## 1.0.4 14 | 15 | - 新增异步promise状态判断断言 16 | - 新增基础数据判断断言 17 | - 新增断言异常信息描述 18 | - 优化用例计时逻辑,采用相对时间计时 19 | - 修改用例执行过程,异步执行 20 | - 修复用例结果偶现的乱序问题 21 | 22 | ## 1.0.3 23 | 24 | - 新增mock对象的能力,支持mock无参数函数 25 | - 新增测试套、测试用例随机执行功能 26 | - 解决测试套声明不规范,导致用例加载异常的问题 27 | - 修复命令行窗口输出乱序的问题 28 | 29 | ## 1.0.2 30 | 31 | - 新增mock接口,判断当前mock方法状态、使用次数 32 | - 修复用例耗时统计问题 33 | - 修改断言功能,断言失败后,会抛出异常 34 | 35 | ## 1.0.1 36 | - 新增mock基础能力 37 | - 修复部分断言失败后,消息提示异常问题 38 | 39 | ## 1.0.0 40 | - 新增应用日志关键字查询接口,查询hilog日志中是否包含指定字符串 41 | - 支持用例筛选功能,用于指定测试用例的执行。可按用例名称、类型、规模、级别与测试套名称筛选 42 | - 支持新SDK下单元测试 43 | - 支持dry run 功能,通过命令行传参数,返回当前测试套用例名称全集 44 | - 新增框架接口声明文件,用于deveco联想 45 | - 修复用例状态统计问题 -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFail() { 17 | return { 18 | pass: false, 19 | message: 'fail ' 20 | }; 21 | } 22 | 23 | export default assertFail; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNaN(actualValue) { 17 | return { 18 | pass: actualValue !== actualValue, 19 | message: 'expect NaN, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNaN; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNull(actualValue) { 17 | return { 18 | pass: (actualValue) === null, 19 | message: 'expect null, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertNull; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFalse(actualValue) { 17 | return { 18 | pass: (actualValue) === false, 19 | message: 'expect false, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertFalse; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNaN(actualValue) { 17 | return { 18 | pass: actualValue !== actualValue, 19 | message: 'expect NaN, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNaN; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFalse(actualValue) { 17 | return { 18 | pass: (actualValue) === false, 19 | message: 'expect false, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertFalse; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNull(actualValue) { 17 | return { 18 | pass: (actualValue) === null, 19 | message: 'expect null, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertNull; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLess(actualValue, expected) { 17 | return { 18 | pass: (actualValue) < expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLess; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertUndefined(actualValue) { 17 | return { 18 | pass: undefined === (actualValue), 19 | message: 'expect Undefined, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertUndefined; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNaN(actualValue) { 17 | return { 18 | pass: actualValue !== actualValue, 19 | message: 'expect NaN, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNaN; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLarger(actualValue, expected) { 17 | return { 18 | pass: (actualValue) > expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLarger; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNull(actualValue) { 17 | return { 18 | pass: (actualValue) === null, 19 | message: 'expect null, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertNull; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLess(actualValue, expected) { 17 | return { 18 | pass: (actualValue) < expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLess; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLessOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) <= expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLessOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertFalse(actualValue) { 17 | return { 18 | pass: (actualValue) === false, 19 | message: 'expect false, actualValue is ' + actualValue 20 | }; 21 | } 22 | 23 | export default assertFalse; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLarger(actualValue, expected) { 17 | return { 18 | pass: (actualValue) > expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLarger; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertUndefined(actualValue) { 17 | return { 18 | pass: undefined === (actualValue), 19 | message: 'expect Undefined, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertUndefined; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLargerOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) >= expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLargerOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLess(actualValue, expected) { 17 | return { 18 | pass: (actualValue) < expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLess; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLessOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) <= expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLessOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNegUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.NEGATIVE_INFINITY, 19 | message: 'Expected actualValue not to be -Infinity. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNegUnlimited; 24 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertPosUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.POSITIVE_INFINITY, 19 | message: 'Expected actualValue is POSITIVE_INFINITY. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertPosUnlimited; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertUndefined(actualValue) { 17 | return { 18 | pass: undefined === (actualValue), 19 | message: 'expect Undefined, actualValue is ' + (actualValue) 20 | }; 21 | } 22 | 23 | export default assertUndefined; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLargerOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) >= expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLargerOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLarger(actualValue, expected) { 17 | return { 18 | pass: (actualValue) > expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLarger; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNegUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.NEGATIVE_INFINITY, 19 | message: 'Expected actualValue not to be -Infinity. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNegUnlimited; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertPosUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.POSITIVE_INFINITY, 19 | message: 'Expected actualValue is POSITIVE_INFINITY. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertPosUnlimited; 24 | -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testability/pages/Index.ets: -------------------------------------------------------------------------------- 1 | import hilog from '@ohos.hilog'; 2 | 3 | @Entry 4 | @Component 5 | struct Index { 6 | aboutToAppear() { 7 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility index aboutToAppear'); 8 | } 9 | @State message: string = 'Hello World' 10 | build() { 11 | Row() { 12 | Column() { 13 | Text(this.message) 14 | .fontSize(50) 15 | .fontWeight(FontWeight.Bold) 16 | Button() { 17 | Text('next page') 18 | .fontSize(20) 19 | .fontWeight(FontWeight.Bold) 20 | }.type(ButtonType.Capsule) 21 | .margin({ 22 | top: 20 23 | }) 24 | .backgroundColor('#0D9FFB') 25 | .width('35%') 26 | .height('5%') 27 | .onClick(()=>{ 28 | }) 29 | } 30 | .width('100%') 31 | } 32 | .height('100%') 33 | } 34 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLessOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) <= expected[0], 19 | message: (actualValue) + ' is not less than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLessOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertLargerOrEqual(actualValue, expected) { 17 | return { 18 | pass: (actualValue) >= expected[0], 19 | message: (actualValue) + ' is not larger than ' + expected[0] 20 | }; 21 | } 22 | 23 | export default assertLargerOrEqual; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertNegUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.NEGATIVE_INFINITY, 19 | message: 'Expected actualValue not to be -Infinity. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertNegUnlimited; 24 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertPosUnlimited(actualValue) { 17 | return { 18 | pass: actualValue === Number.POSITIVE_INFINITY, 19 | message: 'Expected actualValue is POSITIVE_INFINITY. actualValue is,' + actualValue 20 | }; 21 | } 22 | 23 | export default assertPosUnlimited; 24 | -------------------------------------------------------------------------------- /entry/src/ohosTest/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry_test", 4 | "type": "feature", 5 | "description": "$string:module_test_desc", 6 | "mainElement": "TestAbility", 7 | "deviceTypes": [ 8 | "phone", 9 | "tablet" 10 | ], 11 | "deliveryWithInstall": true, 12 | "installationFree": false, 13 | "pages": "$profile:test_pages", 14 | "abilities": [ 15 | { 16 | "name": "TestAbility", 17 | "srcEntry": "./ets/testability/TestAbility.ets", 18 | "description": "$string:TestAbility_desc", 19 | "icon": "$media:icon", 20 | "label": "$string:TestAbility_label", 21 | "exported": true, 22 | "startWindowIcon": "$media:icon", 23 | "startWindowBackground": "$color:start_window_background", 24 | "skills": [ 25 | { 26 | "actions": [ 27 | "action.system.home" 28 | ], 29 | "entities": [ 30 | "entity.system.home" 31 | ] 32 | } 33 | ] 34 | } 35 | ] 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /entry/src/main/ets/component/refresh/LoadMoreLayout.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * 加载更多组件 3 | */ 4 | import { RefreshConst } from './RefreshConst'; 5 | import { Constants } from '../../utils/Constants'; 6 | import { RefreshLoadLayoutClass } from './RefreshModel'; 7 | 8 | @Component 9 | export default struct LoadMoreLayout { 10 | @ObjectLink rlc: RefreshLoadLayoutClass; 11 | 12 | build() { 13 | Column() { 14 | Row() { 15 | Image(this.rlc.imageSrc) 16 | .width(RefreshConst.RefreshLayout_IMAGE_WIDTH) 17 | .height(RefreshConst.RefreshLayout_IMAGE_HEIGHT) 18 | Text(this.rlc.textValue) 19 | .margin({ 20 | left: RefreshConst.RefreshLayout_TEXT_MARGIN_LEFT, 21 | bottom: RefreshConst.RefreshLayout_TEXT_MARGIN_BOTTOM 22 | }) 23 | .fontSize(RefreshConst.RefreshLayout_TEXT_FONT_SIZE) 24 | .textAlign(TextAlign.Center) 25 | } 26 | .clip(true) 27 | .width(Constants.FULL_SIZE) 28 | .justifyContent(FlexAlign.Center) 29 | .height(this.rlc.isVisible ? this.rlc.heightValue : 0) 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /entry/src/main/ets/component/refresh/RefreshLayout.ets: -------------------------------------------------------------------------------- 1 | import { Constants } from '../../utils/Constants'; 2 | import { RefreshConst } from './RefreshConst'; 3 | import { RefreshLoadLayoutClass } from './RefreshModel'; 4 | 5 | @Component 6 | export default struct RefreshLayout { 7 | @ObjectLink rlc: RefreshLoadLayoutClass; 8 | 9 | build() { 10 | Column() { 11 | if (this.rlc.isVisible) { 12 | Row() { 13 | Image(this.rlc.imageSrc) 14 | .width(RefreshConst.RefreshLayout_IMAGE_WIDTH) 15 | .height(RefreshConst.RefreshLayout_IMAGE_HEIGHT) 16 | 17 | Text(this.rlc.textValue) 18 | .margin({ 19 | left: RefreshConst.RefreshLayout_TEXT_MARGIN_LEFT, 20 | bottom: RefreshConst.RefreshLayout_TEXT_MARGIN_BOTTOM 21 | }) 22 | .fontSize(RefreshConst.RefreshLayout_TEXT_FONT_SIZE) 23 | .textAlign(TextAlign.Center) 24 | } 25 | .clip(true) 26 | .width(Constants.FULL_PERCENT) 27 | .justifyContent(FlexAlign.Center) 28 | .height(this.rlc.heightValue) 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function isPromiseLike(obj) { 17 | return !!obj && isFunction_(obj.then); 18 | } 19 | 20 | function isFunction_(value) { 21 | return isA_('Function', value); 22 | } 23 | 24 | function isA_(typeName, value) { 25 | return getType_(value) === '[object ' + typeName + ']'; 26 | } 27 | 28 | function getType_(value) { 29 | return Object.prototype.toString.apply(value); 30 | } 31 | 32 | export default isPromiseLike; 33 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function isPromiseLike(obj) { 17 | return !!obj && isFunction_(obj.then); 18 | } 19 | 20 | function isFunction_(value) { 21 | return isA_('Function', value); 22 | } 23 | 24 | function isA_(typeName, value) { 25 | return getType_(value) === '[object ' + typeName + ']'; 26 | } 27 | 28 | function getType_(value) { 29 | return Object.prototype.toString.apply(value); 30 | } 31 | 32 | export default isPromiseLike; 33 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function isPromiseLike(obj) { 17 | return !!obj && isFunction_(obj.then); 18 | } 19 | 20 | function isFunction_(value) { 21 | return isA_('Function', value); 22 | } 23 | 24 | function isA_(typeName, value) { 25 | return getType_(value) === '[object ' + typeName + ']'; 26 | } 27 | 28 | function getType_(value) { 29 | return Object.prototype.toString.apply(value); 30 | } 31 | 32 | export default isPromiseLike; 33 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertInstanceOf(actualValue, expected) { 17 | if (Object.prototype.toString.call(actualValue) == '[object ' + expected[0] + ']') { 18 | return { 19 | pass: true 20 | }; 21 | } else { 22 | return { 23 | pass: false, 24 | message: actualValue + ' is ' + Object.prototype.toString.call(actualValue) + 'not ' + expected[0] 25 | }; 26 | } 27 | } 28 | 29 | export default assertInstanceOf; 30 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertInstanceOf(actualValue, expected) { 17 | if (Object.prototype.toString.call(actualValue) == '[object ' + expected[0] + ']') { 18 | return { 19 | pass: true 20 | }; 21 | } else { 22 | return { 23 | pass: false, 24 | message: actualValue + ' is ' + Object.prototype.toString.call(actualValue) + 'not ' + expected[0] 25 | }; 26 | } 27 | } 28 | 29 | export default assertInstanceOf; 30 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertInstanceOf(actualValue, expected) { 17 | if (Object.prototype.toString.call(actualValue) == '[object ' + expected[0] + ']') { 18 | return { 19 | pass: true 20 | }; 21 | } else { 22 | return { 23 | pass: false, 24 | message: actualValue + ' is ' + Object.prototype.toString.call(actualValue) + 'not ' + expected[0] 25 | }; 26 | } 27 | } 28 | 29 | export default assertInstanceOf; 30 | -------------------------------------------------------------------------------- /entry/src/main/module.json5: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "name": "entry", 4 | "type": "entry", 5 | "description": "$string:module_desc", 6 | "mainElement": "EntryAbility", 7 | "deviceTypes": [ 8 | "phone", 9 | "tablet" 10 | ], 11 | "deliveryWithInstall": true, 12 | "installationFree": false, 13 | "pages": "$profile:main_pages", 14 | "abilities": [ 15 | { 16 | "name": "EntryAbility", 17 | "srcEntry": "./ets/entryability/EntryAbility.ts", 18 | "description": "$string:EntryAbility_desc", 19 | "icon": "$media:icon", 20 | "label": "$string:EntryAbility_label", 21 | "startWindowIcon": "$media:icon", 22 | "startWindowBackground": "$color:start_window_background", 23 | "exported": true, 24 | "skills": [ 25 | { 26 | "entities": [ 27 | "entity.system.home" 28 | ], 29 | "actions": [ 30 | "action.system.home" 31 | ] 32 | } 33 | ] 34 | } 35 | ], 36 | "requestPermissions": [ 37 | { 38 | "name": 'ohos.permission.INTERNET', 39 | "usedScene": { 40 | "abilities": [ 41 | "FormAbility" 42 | ], 43 | "when":"always" 44 | } 45 | } 46 | ] 47 | } 48 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import SysTestKit from "../kit/SysTestKit"; 17 | 18 | export async function collectCoverageData() { 19 | if (globalThis.__coverage__ === undefined) { 20 | return; 21 | } 22 | const strJson = JSON.stringify(globalThis.__coverage__); 23 | const strLen = strJson.length; 24 | const maxLen = 500; 25 | const maxCount = Math.floor(strLen / maxLen); 26 | const OHOS_REPORT_COVERAGE_DATA = 'OHOS_REPORT_COVERAGE_DATA:'; 27 | for (let count = 0; count <= maxCount; count++) { 28 | await SysTestKit.print(`${OHOS_REPORT_COVERAGE_DATA} ${strJson.substring(count * maxLen, (count + 1) * maxLen)}`); 29 | } 30 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import SysTestKit from "../kit/SysTestKit"; 17 | 18 | export async function collectCoverageData() { 19 | if (globalThis.__coverage__ === undefined) { 20 | return; 21 | } 22 | const strJson = JSON.stringify(globalThis.__coverage__); 23 | const strLen = strJson.length; 24 | const maxLen = 500; 25 | const maxCount = Math.floor(strLen / maxLen); 26 | const OHOS_REPORT_COVERAGE_DATA = 'OHOS_REPORT_COVERAGE_DATA:'; 27 | for (let count = 0; count <= maxCount; count++) { 28 | await SysTestKit.print(`${OHOS_REPORT_COVERAGE_DATA} ${strJson.substring(count * maxLen, (count + 1) * maxLen)}`); 29 | } 30 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import SysTestKit from "../kit/SysTestKit"; 17 | 18 | export async function collectCoverageData() { 19 | if (globalThis.__coverage__ === undefined) { 20 | return; 21 | } 22 | const strJson = JSON.stringify(globalThis.__coverage__); 23 | const strLen = strJson.length; 24 | const maxLen = 500; 25 | const maxCount = Math.floor(strLen / maxLen); 26 | const OHOS_REPORT_COVERAGE_DATA = 'OHOS_REPORT_COVERAGE_DATA:'; 27 | for (let count = 0; count <= maxCount; count++) { 28 | await SysTestKit.print(`${OHOS_REPORT_COVERAGE_DATA} ${strJson.substring(count * maxLen, (count + 1) * maxLen)}`); 29 | } 30 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertContain(actualValue, expect) { 17 | let result = false; 18 | if (Object.prototype.toString.call(actualValue).indexOf('Array')) { 19 | for (let i in actualValue) { 20 | if (actualValue[i] == expect[0]) { 21 | result = true; 22 | } 23 | } 24 | } 25 | let type = Object.prototype.toString.call(actualValue); 26 | if (type === '[object String]') { 27 | result = actualValue.indexOf(expect[0]) >= 0; 28 | } 29 | return { 30 | pass: result, 31 | message: 'expect false, ' + actualValue + ' do not have ' + expect[0] 32 | }; 33 | } 34 | 35 | export default assertContain; 36 | -------------------------------------------------------------------------------- /entry/src/main/ets/component/refresh/RefreshModel.ets: -------------------------------------------------------------------------------- 1 | import { RefreshConst } from './RefreshConst'; 2 | 3 | export default class RefreshModel { 4 | pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text'); 5 | pullDownRefreshImage: Resource = $r('app.media.ic_pull_down_refresh'); 6 | pullDownRefreshHeight: number = RefreshConst.CUSTOM_LAYOUT_HEIGHT; 7 | isVisiblePullDown: boolean = false; 8 | pullUpLoadText: Resource = $r('app.string.pull_up_load_text'); 9 | pullUpLoadImage: Resource = $r('app.media.ic_pull_up_load'); 10 | pullUpLoadHeight: number = RefreshConst.CUSTOM_LAYOUT_HEIGHT; 11 | isVisiblePullUpLoad: boolean = false; 12 | offsetY: number = 0; 13 | hasMore: boolean = true; 14 | startIndex = 0; 15 | endIndex = 0; 16 | downY = 0; 17 | lastMoveY = 0; 18 | isRefreshing: boolean = false; 19 | isCanRefresh = false; 20 | isPullRefreshOperation = false; 21 | isLoading: boolean = false; 22 | isCanLoadMore: boolean = false; 23 | } 24 | 25 | @Observed 26 | export class RefreshLoadLayoutClass { 27 | isVisible: boolean; 28 | imageSrc: Resource; 29 | textValue: Resource; 30 | heightValue: number; 31 | 32 | constructor(isVisible: boolean, imageSrc: Resource, textValue: Resource, heightValue: number) { 33 | this.isVisible = isVisible; 34 | this.imageSrc = imageSrc; 35 | this.textValue = textValue; 36 | this.heightValue = heightValue; 37 | } 38 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertContain(actualValue, expect) { 17 | let result = false; 18 | if (Object.prototype.toString.call(actualValue).indexOf('Array')) { 19 | for (let i in actualValue) { 20 | if (actualValue[i] == expect[0]) { 21 | result = true; 22 | } 23 | } 24 | } 25 | let type = Object.prototype.toString.call(actualValue); 26 | if (type === '[object String]') { 27 | result = actualValue.indexOf(expect[0]) >= 0; 28 | } 29 | return { 30 | pass: result, 31 | message: 'expect false, ' + actualValue + ' do not have ' + expect[0] 32 | }; 33 | } 34 | 35 | export default assertContain; 36 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertContain(actualValue, expect) { 17 | let result = false; 18 | if (Object.prototype.toString.call(actualValue).indexOf('Array')) { 19 | for (let i in actualValue) { 20 | if (actualValue[i] == expect[0]) { 21 | result = true; 22 | } 23 | } 24 | } 25 | let type = Object.prototype.toString.call(actualValue); 26 | if (type === '[object String]') { 27 | result = actualValue.indexOf(expect[0]) >= 0; 28 | } 29 | return { 30 | pass: result, 31 | message: 'expect false, ' + actualValue + ' do not have ' + expect[0] 32 | }; 33 | } 34 | 35 | export default assertContain; 36 | -------------------------------------------------------------------------------- /entry/src/main/ets/request/SquareReq.ets: -------------------------------------------------------------------------------- 1 | import { API } from '../http/API'; 2 | import { get } from '../http/Request'; 3 | import { Response } from '../http/Response'; 4 | import { INav, ITree } from '../model/ITreeBean'; 5 | /** 6 | * 请求体系数据 7 | */ 8 | export function getTree(): Promise { 9 | return new Promise((resolve: Function, reject: Function) => { 10 | get(API.tree).then((data: Response) => { 11 | if (data.errorCode === API.SERVER_CODE_SUCCESS) { 12 | resolve(data.data); 13 | } else { 14 | console.log('getTree failed', JSON.stringify(data)); 15 | reject($r('app.string.page_none_msg')); 16 | } 17 | }).catch((err: Error) => { 18 | console.log('getTree failed', JSON.stringify(err)); 19 | reject($r('app.string.http_error_message')); 20 | }); 21 | }); 22 | } 23 | 24 | /** 25 | * 导航数据 26 | * @returns 27 | */ 28 | export function getNav(): Promise { 29 | return new Promise((resolve: Function, reject: Function) => { 30 | get(API.nav).then((data: Response) => { 31 | if (data.errorCode === API.SERVER_CODE_SUCCESS) { 32 | resolve(data.data); 33 | } else { 34 | console.log('getTree failed', JSON.stringify(data)); 35 | reject($r('app.string.page_none_msg')); 36 | } 37 | }).catch((err: Error) => { 38 | console.log('getTree failed', JSON.stringify(err)); 39 | reject($r('app.string.http_error_message')); 40 | }); 41 | }); 42 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/color.json: -------------------------------------------------------------------------------- 1 | { 2 | "color": [ 3 | { 4 | "name": "start_window_background", 5 | "value": "#FFFFFF" 6 | }, 7 | { 8 | "name": "bottom_tabs_background_color", 9 | "value": "#F1F3F5" 10 | }, 11 | { 12 | "name": "bottom_tabs_font_color", 13 | "value": "#000000" 14 | }, 15 | { 16 | "name": "bottom_tabs_font_color_selected", 17 | "value": "#007DFF" 18 | }, 19 | { 20 | "name": "transparent", 21 | "value": "#00000000" 22 | }, 23 | { 24 | "name": "common_background_color", 25 | "value": "#F1F3F5" 26 | }, 27 | { 28 | "name": "custom_panel_background", 29 | "value": "#FAFAFA" 30 | }, 31 | { 32 | "name": "font_color_black", 33 | "value": "#000000" 34 | }, 35 | { 36 | "name": "introduction_page_color", 37 | "value": "#F1F3F5" 38 | }, 39 | { 40 | "name": "font_color_white", 41 | "value": "#FFFFFF" 42 | }, 43 | { 44 | "name": "swiper_dot_color", 45 | "value": "#99FFFFFF" 46 | }, 47 | { 48 | "name": "swiper_jump_bg_color", 49 | "value": "#4d182431" 50 | }, 51 | { 52 | "name": "train_station_color", 53 | "value": "#F5AC00" 54 | }, 55 | { 56 | "name": "launch_bg_color", 57 | "value": "#55C7FB" 58 | }, 59 | { 60 | "name": "line_color", 61 | "value": "#E2E2E2" 62 | } 63 | ] 64 | } -------------------------------------------------------------------------------- /entry/src/main/resources/zh_CN/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "模块描述" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "description" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "鸿蒙玩Android" 14 | }, 15 | { 16 | "name": "bottom_text_home", 17 | "value": "首页" 18 | }, 19 | { 20 | "name": "bottom_text_square", 21 | "value": "发现" 22 | }, 23 | { 24 | "name": "bottom_text_me", 25 | "value": "我的" 26 | }, 27 | { 28 | "name": "pull_up_load_text", 29 | "value": "加载中..." 30 | }, 31 | { 32 | "name": "pull_down_refresh_text", 33 | "value": "下拉刷新" 34 | }, 35 | { 36 | "name": "release_refresh_text", 37 | "value": "松开刷新" 38 | }, 39 | { 40 | "name": "refreshing_text", 41 | "value": "正在刷新" 42 | }, 43 | { 44 | "name": "refresh_success_text", 45 | "value": "刷新成功" 46 | }, 47 | { 48 | "name": "refresh_fail_text", 49 | "value": "刷新失败" 50 | }, 51 | { 52 | "name": "http_error_message", 53 | "value": "网络请求失败,请重试!" 54 | }, 55 | { 56 | "name": "page_none_msg", 57 | "value": "网络加载失败" 58 | }, 59 | { 60 | "name": "prompt_message", 61 | "value": "没有更多数据了" 62 | }, 63 | { 64 | "name": "dependency_reason", 65 | "value": "用于发起网络数据请求" 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /entry/src/main/ets/component/refresh/RefreshConst.ets: -------------------------------------------------------------------------------- 1 | export class RefreshConst { 2 | static CUSTOM_LAYOUT_HEIGHT: number = 70; 3 | static pullDownRefreshText: Resource = $r('app.string.pull_down_refresh_text'); 4 | static pullDownRefreshImage: Resource = $r('app.media.ic_pull_down_refresh'); 5 | static pullDownRefreshHeight: number = 70; 6 | static readonly RefreshLayout_MARGIN_LEFT: string = '40%'; 7 | static readonly RefreshLayout_TEXT_MARGIN_BOTTOM: number = 1; 8 | static readonly RefreshLayout_TEXT_MARGIN_LEFT: number = 7; 9 | static readonly RefreshLayout_TEXT_FONT_SIZE: number = 17; 10 | static readonly RefreshLayout_IMAGE_WIDTH: number = 18; 11 | static readonly RefreshLayout_IMAGE_HEIGHT: number = 18; 12 | static readonly Y_OFF_SET_COEFFICIENT: number = 0.1; 13 | static readonly ANIMATION_DURATION: number = 2000; 14 | static readonly DELAY_ANIMATION_DURATION: number = 300; 15 | static readonly DELAY_TIME: number = 1000; 16 | static readonly RefreshConstant_DELAY_PULL_DOWN_REFRESH: number = 50; 17 | static readonly RefreshConstant_CLOSE_PULL_DOWN_REFRESH_TIME: number = 150; 18 | static readonly RefreshConstant_DELAY_SHRINK_ANIMATION_TIME: number = 500; 19 | static readonly NoMoreLayoutConstant_NORMAL_PADDING: number = 8; 20 | static readonly NoMoreLayoutConstant_TITLE_FONT: string = '16fp'; 21 | static readonly LIST_OFFSET_UNIT: string = 'px'; 22 | } 23 | 24 | export const enum RefreshState { 25 | DropDown = 0, 26 | Release = 1, 27 | Refreshing = 2, 28 | Success = 3, 29 | Fail = 4 30 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WAndroidHOS 2 | 鸿蒙版本的玩Android,ArkTS版本、hap包、带注释等新手实战入门最佳助手,ArkTSUI框架、布局、权限、网络等实用技巧 3 | 4 | ## 项目介绍 5 | 6 | ​ 项目使用DevEco Studio 3.1.1 Release,ArkTS API 9最新版本开发,都是ArkTS UI的组件,比较纯粹。主要是为巩固理论知识 7 | 8 | 借鉴了Android开发和前端的代码结构思路。照者技术文档一顿输出。拿之前开发过的**玩Android**写一个鸿蒙版本出来,涉及到UI的 9 | 10 | 布局、http网络请求数据、渲染数据、Banner广告、下拉刷新组件、Flex组件布局、数据保存、Web组件加载网页、JS调用等。 11 | 12 | ## 部分截图 13 | 14 | | ![](screenshot/1.png) | ![](screenshot/2.png) | ![](screenshot/3.png) | 15 | | --------------------- | --------------------- | --------------------- | 16 | | ![](screenshot/7.png) | ![](screenshot/4.png) | ![](screenshot/5.png) | 17 | | ![](screenshot/6.png) | | | 18 | 19 | 20 | 21 | ## 更新日志 22 | 23 | 预计更新: 24 | 25 | - web和JS之间交互; 26 | - JS Bridge使用; 27 | - Camera的使用; 28 | - 完善我的等等部分二级页面; 29 | - 临时增加一些功能; 30 | - ... 31 | - ... 32 | 33 | v1.0.1 2024.01.06 34 | 35 | 此次更新优点仓促,中间由于工作和身体的原因耽搁了很多事情。后面会慢慢更新优化代码 36 | 37 | - 下拉刷新上拉加载更多组件; 38 | - 增加数据保存AppStorage、持久化Preferences使用; 39 | - 完成发现页面UI增加流式布局 40 | - 完善http网络请求 41 | - 完成登录接口 42 | 43 | v1.0.0 2023.11.26 44 | 45 | - 完成我的页面UI 46 | 47 | - 启动页的UI增加渐变用法 48 | 49 | - 登录页面容器布局**Row**和**Column**细化用法 50 | 51 | - 页面传值**@State**父子组件用法 52 | 53 | - 增加**Web**组件页面加载使用 54 | 55 | - 增加**Toast**的用法 56 | 57 | - **Navigation**的用法 58 | 59 | - 已反馈开放平台记录发现的bug: 60 | 61 | Text组件内使用Span子组件不能控制Span的visibility状态 62 | 63 | TextInput组件在外部改变ype的InputType.Password后会将text值清空 64 | 65 | 66 | 67 | ## 后续跟进计划 68 | 69 | 数据保存 70 | 71 | web 72 | 73 | Camera 74 | 75 | 音视频 76 | 77 | 数据库 78 | 79 | ... 80 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertThrowError(actualValue, expected) { 17 | let result = false; 18 | let err; 19 | if (typeof actualValue !== 'function') { 20 | throw new Error('actualValue is not a function'); 21 | } 22 | try { 23 | actualValue(); 24 | return { 25 | pass: result, 26 | message: ' An error is not thrown while it is expected!' 27 | }; 28 | } catch (e) { 29 | err = e; 30 | } 31 | 32 | if (err instanceof Error) { 33 | console.log(err.message); 34 | if (err.message == expected[0]) { 35 | result = true; 36 | } 37 | } 38 | return { 39 | pass: result, 40 | message: 'expected throw failed , ' + err.message + ' is not ' + expected[0] 41 | }; 42 | } 43 | 44 | export default assertThrowError; 45 | -------------------------------------------------------------------------------- /entry/src/main/ets/pages/Launch.ets: -------------------------------------------------------------------------------- 1 | import router from '@ohos.router' 2 | import hilog from '@ohos.hilog' 3 | import { Constants } from '../utils/Constants' 4 | 5 | 6 | @Entry 7 | @Component 8 | struct Launch { 9 | @State message: string = '玩Android\nHarmonyOS版' 10 | 11 | jumpToMain() { 12 | setTimeout(() => { 13 | router.replaceUrl({ url: 'pages/Index' }) 14 | }, 2000) 15 | } 16 | 17 | aboutToAppear() { 18 | AppStorage.SetOrCreate("isLogin", false) 19 | this.jumpToMain() 20 | hilog.info(0x011, 'Tag', 'aboutToAppear') 21 | } 22 | 23 | onPageShow() { 24 | hilog.info(0x011, 'splash', 'onPageShow') 25 | } 26 | 27 | build() { 28 | Flex({ 29 | alignItems: ItemAlign.Center, 30 | direction: FlexDirection.Column 31 | }) { 32 | Stack() { 33 | Text(this.message) 34 | .fontSize(30) 35 | .width(200) 36 | .textAlign(TextAlign.Center) 37 | .margin({ top: px2vp(300) }) 38 | .fontColor($r('app.color.font_color_white')) 39 | .lineHeight(40) 40 | }.height('97%').alignContent(Alignment.TopStart) 41 | 42 | Text('https://github.com/zqf-dev') 43 | .fontColor($r('app.color.font_color_white')) 44 | .width('100%') 45 | .fontSize(px2vp(30)) 46 | .textAlign(TextAlign.Center) 47 | } 48 | .linearGradient({ 49 | direction: 180, 50 | repeating: false, 51 | colors: [['#FF03DAC5', 0.0], ['#55C7FB', 1]] 52 | }) 53 | .width(Constants.FULL_PERCENT) 54 | .height(Constants.FULL_PERCENT) 55 | } 56 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertThrowError(actualValue, expected) { 17 | let result = false; 18 | let err; 19 | if (typeof actualValue !== 'function') { 20 | throw new Error('actualValue is not a function'); 21 | } 22 | try { 23 | actualValue(); 24 | return { 25 | pass: result, 26 | message: ' An error is not thrown while it is expected!' 27 | }; 28 | } catch (e) { 29 | err = e; 30 | } 31 | 32 | if (err instanceof Error) { 33 | console.log(err.message); 34 | if (err.message == expected[0]) { 35 | result = true; 36 | } 37 | } 38 | return { 39 | pass: result, 40 | message: 'expected throw failed , ' + err.message + ' is not ' + expected[0] 41 | }; 42 | } 43 | 44 | export default assertThrowError; 45 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertThrowError(actualValue, expected) { 17 | let result = false; 18 | let err; 19 | if (typeof actualValue !== 'function') { 20 | throw new Error('actualValue is not a function'); 21 | } 22 | try { 23 | actualValue(); 24 | return { 25 | pass: result, 26 | message: ' An error is not thrown while it is expected!' 27 | }; 28 | } catch (e) { 29 | err = e; 30 | } 31 | 32 | if (err instanceof Error) { 33 | console.log(err.message); 34 | if (err.message == expected[0]) { 35 | result = true; 36 | } 37 | } 38 | return { 39 | pass: result, 40 | message: 'expected throw failed , ' + err.message + ' is not ' + expected[0] 41 | }; 42 | } 43 | 44 | export default assertThrowError; 45 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import {expect} from '../../interface'; 17 | 18 | class VerificationMode { 19 | constructor(times) { 20 | this.doTimes = times; 21 | } 22 | 23 | times(count) { 24 | expect(count).assertEqual(this.doTimes); 25 | } 26 | 27 | never() { 28 | console.log(this.doTimes); 29 | expect(0).assertEqual(this.doTimes); 30 | } 31 | 32 | once() { 33 | expect(1).assertEqual(this.doTimes); 34 | } 35 | 36 | atLeast(count) { 37 | if (count > this.doTimes) { 38 | throw Error('failed ' + count + ' greater than the actual execution times of method'); 39 | } 40 | } 41 | 42 | atMost(count) { 43 | if (count < this.doTimes) { 44 | throw Error('failed ' + count + ' less than the actual execution times of method'); 45 | } 46 | } 47 | } 48 | 49 | export default VerificationMode; -------------------------------------------------------------------------------- /hvigorw: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # ---------------------------------------------------------------------------- 4 | # Hvigor startup script, version 1.0.0 5 | # 6 | # Required ENV vars: 7 | # ------------------ 8 | # NODE_HOME - location of a Node home dir 9 | # or 10 | # Add /usr/local/nodejs/bin to the PATH environment variable 11 | # ---------------------------------------------------------------------------- 12 | 13 | HVIGOR_APP_HOME=$(dirname $(readlink -f $0)) 14 | HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js 15 | warn() { 16 | echo "" 17 | echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 18 | } 19 | 20 | error() { 21 | echo "" 22 | echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" 23 | } 24 | 25 | fail() { 26 | error "$@" 27 | exit 1 28 | } 29 | 30 | # Determine node to start hvigor wrapper script 31 | if [ -n "${NODE_HOME}" ];then 32 | EXECUTABLE_NODE="${NODE_HOME}/bin/node" 33 | if [ ! -x "$EXECUTABLE_NODE" ];then 34 | fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" 35 | fi 36 | else 37 | EXECUTABLE_NODE="node" 38 | which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" 39 | fi 40 | 41 | # Check hvigor wrapper script 42 | if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then 43 | fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" 44 | fi 45 | 46 | # start hvigor-wrapper script 47 | exec "${EXECUTABLE_NODE}" \ 48 | "${HVIGOR_WRAPPER_SCRIPT}" "$@" 49 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/Constant.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | /** 17 | * define the testcase type : TestType, Size , Level 18 | */ 19 | export const DEFAULT = 0B0000; 20 | 21 | export class TestType { 22 | static FUNCTION = 0B1; 23 | static PERFORMANCE = 0B1 << 1; 24 | static POWER = 0B1 << 2; 25 | static RELIABILITY = 0B1 << 3; 26 | static SECURITY = 0B1 << 4; 27 | static GLOBAL = 0B1 << 5; 28 | static COMPATIBILITY = 0B1 << 6; 29 | static USER = 0B1 << 7; 30 | static STANDARD = 0B1 << 8; 31 | static SAFETY = 0B1 << 9; 32 | static RESILIENCE = 0B1 << 10; 33 | } 34 | 35 | export class Size { 36 | static SMALLTEST = 0B1 << 16; 37 | static MEDIUMTEST = 0B1 << 17; 38 | static LARGETEST = 0B1 << 18; 39 | } 40 | 41 | export class Level { 42 | static LEVEL0 = 0B1 << 24; 43 | static LEVEL1 = 0B1 << 25; 44 | static LEVEL2 = 0B1 << 26; 45 | static LEVEL3 = 0B1 << 27; 46 | static LEVEL4 = 0B1 << 28; 47 | } 48 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejected(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return { 29 | pass: false, 30 | message: 'expect isRejected, but actualValue is ' 31 | + (helper === got ? 'isPending' : 'resolve') 32 | }; 33 | }, 34 | function () { 35 | return {pass: true, message: 'actualValue is isRejected'}; 36 | } 37 | ); 38 | } 39 | 40 | export default assertPromiseIsRejected; -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import {expect} from '../../interface'; 17 | 18 | class VerificationMode { 19 | constructor(times) { 20 | this.doTimes = times; 21 | } 22 | 23 | times(count) { 24 | expect(count).assertEqual(this.doTimes); 25 | } 26 | 27 | never() { 28 | console.log(this.doTimes); 29 | expect(0).assertEqual(this.doTimes); 30 | } 31 | 32 | once() { 33 | expect(1).assertEqual(this.doTimes); 34 | } 35 | 36 | atLeast(count) { 37 | if (count > this.doTimes) { 38 | throw Error('failed ' + count + ' greater than the actual execution times of method'); 39 | } 40 | } 41 | 42 | atMost(count) { 43 | if (count < this.doTimes) { 44 | throw Error('failed ' + count + ' less than the actual execution times of method'); 45 | } 46 | } 47 | } 48 | 49 | export default VerificationMode; -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/Constant.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | /** 17 | * define the testcase type : TestType, Size , Level 18 | */ 19 | export const DEFAULT = 0B0000; 20 | 21 | export class TestType { 22 | static FUNCTION = 0B1; 23 | static PERFORMANCE = 0B1 << 1; 24 | static POWER = 0B1 << 2; 25 | static RELIABILITY = 0B1 << 3; 26 | static SECURITY = 0B1 << 4; 27 | static GLOBAL = 0B1 << 5; 28 | static COMPATIBILITY = 0B1 << 6; 29 | static USER = 0B1 << 7; 30 | static STANDARD = 0B1 << 8; 31 | static SAFETY = 0B1 << 9; 32 | static RESILIENCE = 0B1 << 10; 33 | } 34 | 35 | export class Size { 36 | static SMALLTEST = 0B1 << 16; 37 | static MEDIUMTEST = 0B1 << 17; 38 | static LARGETEST = 0B1 << 18; 39 | } 40 | 41 | export class Level { 42 | static LEVEL0 = 0B1 << 24; 43 | static LEVEL1 = 0B1 << 25; 44 | static LEVEL2 = 0B1 << 26; 45 | static LEVEL3 = 0B1 << 27; 46 | static LEVEL4 = 0B1 << 28; 47 | } 48 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejected(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return { 29 | pass: false, 30 | message: 'expect isRejected, but actualValue is ' 31 | + (helper === got ? 'isPending' : 'resolve') 32 | }; 33 | }, 34 | function () { 35 | return {pass: true, message: 'actualValue is isRejected'}; 36 | } 37 | ); 38 | } 39 | 40 | export default assertPromiseIsRejected; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import {expect} from '../../interface'; 17 | 18 | class VerificationMode { 19 | constructor(times) { 20 | this.doTimes = times; 21 | } 22 | 23 | times(count) { 24 | expect(count).assertEqual(this.doTimes); 25 | } 26 | 27 | never() { 28 | console.log(this.doTimes); 29 | expect(0).assertEqual(this.doTimes); 30 | } 31 | 32 | once() { 33 | expect(1).assertEqual(this.doTimes); 34 | } 35 | 36 | atLeast(count) { 37 | if (count > this.doTimes) { 38 | throw Error('failed ' + count + ' greater than the actual execution times of method'); 39 | } 40 | } 41 | 42 | atMost(count) { 43 | if (count < this.doTimes) { 44 | throw Error('failed ' + count + ' less than the actual execution times of method'); 45 | } 46 | } 47 | } 48 | 49 | export default VerificationMode; -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertClose(actualValue, expected) { 17 | console.log('expected:' + expected[0] + ',precision:' + expected[1]); 18 | if (actualValue === null && expected[0] === null) { 19 | throw new Error('actualValue and expected can not be both null!!!'); 20 | } 21 | let result; 22 | let diff = Math.abs(expected[0] - actualValue); 23 | let actualAbs = Math.abs(actualValue); 24 | if ((actualAbs - 0) === 0) { 25 | if ((diff - 0) === 0) { 26 | result = true; 27 | } else { 28 | result = false; 29 | } 30 | } else if (diff / actualAbs < expected[1]) { 31 | result = true; 32 | } else { 33 | result = false; 34 | } 35 | return { 36 | pass: result, 37 | message: '|' + actualValue + ' - ' + expected[0] + '|/' + actualValue + ' is not less than ' + expected[1] 38 | }; 39 | } 40 | 41 | export default assertClose; 42 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/Constant.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | /** 17 | * define the testcase type : TestType, Size , Level 18 | */ 19 | export const DEFAULT = 0B0000; 20 | 21 | export class TestType { 22 | static FUNCTION = 0B1; 23 | static PERFORMANCE = 0B1 << 1; 24 | static POWER = 0B1 << 2; 25 | static RELIABILITY = 0B1 << 3; 26 | static SECURITY = 0B1 << 4; 27 | static GLOBAL = 0B1 << 5; 28 | static COMPATIBILITY = 0B1 << 6; 29 | static USER = 0B1 << 7; 30 | static STANDARD = 0B1 << 8; 31 | static SAFETY = 0B1 << 9; 32 | static RESILIENCE = 0B1 << 10; 33 | } 34 | 35 | export class Size { 36 | static SMALLTEST = 0B1 << 16; 37 | static MEDIUMTEST = 0B1 << 17; 38 | static LARGETEST = 0B1 << 18; 39 | } 40 | 41 | export class Level { 42 | static LEVEL0 = 0B1 << 24; 43 | static LEVEL1 = 0B1 << 25; 44 | static LEVEL2 = 0B1 << 26; 45 | static LEVEL3 = 0B1 << 27; 46 | static LEVEL4 = 0B1 << 28; 47 | } 48 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejected(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return { 29 | pass: false, 30 | message: 'expect isRejected, but actualValue is ' 31 | + (helper === got ? 'isPending' : 'resolve') 32 | }; 33 | }, 34 | function () { 35 | return {pass: true, message: 'actualValue is isRejected'}; 36 | } 37 | ); 38 | } 39 | 40 | export default assertPromiseIsRejected; -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ExtendInterface { 17 | constructor(mocker) { 18 | this.mocker = mocker; 19 | } 20 | 21 | stub() { 22 | this.params = arguments; 23 | return this; 24 | } 25 | 26 | stubMockedCall(returnInfo) { 27 | this.mocker.stubApply(this, this.params, returnInfo); 28 | } 29 | 30 | afterReturn(value) { 31 | this.stubMockedCall(function () { 32 | return value; 33 | }); 34 | } 35 | 36 | afterReturnNothing() { 37 | this.stubMockedCall(function () { 38 | return undefined; 39 | }); 40 | } 41 | 42 | afterAction(action) { 43 | this.stubMockedCall(action); 44 | } 45 | 46 | afterThrow(msg) { 47 | this.stubMockedCall(function () { 48 | throw msg; 49 | }); 50 | } 51 | 52 | clear() { 53 | this.mocker.clear(); 54 | } 55 | } 56 | 57 | export default ExtendInterface; -------------------------------------------------------------------------------- /entry/src/main/ets/request/Home.ets: -------------------------------------------------------------------------------- 1 | import { API } from '../http/API'; 2 | import { get } from '../http/Request'; 3 | import { Response } from '../http/Response'; 4 | import { Article, HomeModel, IBannerModel } from '../model/HomeEntity'; 5 | import { Constants } from '../utils/Constants'; 6 | 7 | /** 8 | * 请求Banner数据 9 | * @returns 10 | */ 11 | export function getBanner(): Promise { 12 | return new Promise((resolve: Function, reject: Function) => { 13 | get(API.banner).then((data: Response) => { 14 | console.log("Tag", "data " + data) 15 | if (data.data && data.errorCode === API.SERVER_CODE_SUCCESS) { 16 | resolve(data.data); 17 | } else { 18 | console.log('getBannerList failed', JSON.stringify(data)); 19 | reject($r('app.string.page_none_msg')); 20 | } 21 | }).catch((err: Error) => { 22 | console.log('getBannerList failed', JSON.stringify(err)); 23 | reject($r('app.string.http_error_message')); 24 | }); 25 | }); 26 | } 27 | 28 | /** 29 | * 请求文章数据 30 | */ 31 | export function getArticle(page: number): Promise
{ 32 | return new Promise((resolve: Function, reject: Function) => { 33 | get(API.article + page + '/json').then((data: Response) => { 34 | if (data.errorCode === API.SERVER_CODE_SUCCESS) { 35 | resolve(data.data); 36 | } else { 37 | console.log('request failed', JSON.stringify(data)); 38 | reject($r('app.string.page_none_msg')); 39 | } 40 | }).catch((err: Error) => { 41 | console.log('request failed', JSON.stringify(err)); 42 | reject($r('app.string.http_error_message')); 43 | }); 44 | }); 45 | } -------------------------------------------------------------------------------- /entry/src/main/resources/base/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "module description" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "description" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "label" 14 | }, 15 | { 16 | "name": "bottom_text_home", 17 | "value": "Home" 18 | }, 19 | { 20 | "name": "bottom_text_square", 21 | "value": "Find" 22 | }, 23 | { 24 | "name": "bottom_text_me", 25 | "value": "Me" 26 | }, 27 | { 28 | "name": "pull_up_load_text", 29 | "value": "Loading in..." 30 | }, 31 | { 32 | "name": "pull_down_refresh_text", 33 | "value": "The drop-down refresh" 34 | }, 35 | { 36 | "name": "release_refresh_text", 37 | "value": "Loosen the refresh" 38 | }, 39 | { 40 | "name": "refreshing_text", 41 | "value": "Is refreshing" 42 | }, 43 | { 44 | "name": "refresh_success_text", 45 | "value": "Refresh the success" 46 | }, 47 | { 48 | "name": "refresh_fail_text", 49 | "value": "Refresh the failure" 50 | }, 51 | { 52 | "name": "http_error_message", 53 | "value": "Network request failed, please try later!" 54 | }, 55 | { 56 | "name": "page_none_msg", 57 | "value": "Network loading failure" 58 | }, 59 | { 60 | "name": "prompt_message", 61 | "value": "No more data" 62 | }, 63 | { 64 | "name": "dependency_reason", 65 | "value": "Used to initiate network data requests." 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertClose(actualValue, expected) { 17 | console.log('expected:' + expected[0] + ',precision:' + expected[1]); 18 | if (actualValue === null && expected[0] === null) { 19 | throw new Error('actualValue and expected can not be both null!!!'); 20 | } 21 | let result; 22 | let diff = Math.abs(expected[0] - actualValue); 23 | let actualAbs = Math.abs(actualValue); 24 | if ((actualAbs - 0) === 0) { 25 | if ((diff - 0) === 0) { 26 | result = true; 27 | } else { 28 | result = false; 29 | } 30 | } else if (diff / actualAbs < expected[1]) { 31 | result = true; 32 | } else { 33 | result = false; 34 | } 35 | return { 36 | pass: result, 37 | message: '|' + actualValue + ' - ' + expected[0] + '|/' + actualValue + ' is not less than ' + expected[1] 38 | }; 39 | } 40 | 41 | export default assertClose; 42 | -------------------------------------------------------------------------------- /entry/src/main/resources/en_US/element/string.json: -------------------------------------------------------------------------------- 1 | { 2 | "string": [ 3 | { 4 | "name": "module_desc", 5 | "value": "module description" 6 | }, 7 | { 8 | "name": "EntryAbility_desc", 9 | "value": "description" 10 | }, 11 | { 12 | "name": "EntryAbility_label", 13 | "value": "label" 14 | }, 15 | { 16 | "name": "bottom_text_home", 17 | "value": "Home" 18 | }, 19 | { 20 | "name": "bottom_text_square", 21 | "value": "Find" 22 | }, 23 | { 24 | "name": "bottom_text_me", 25 | "value": "Me" 26 | }, 27 | { 28 | "name": "pull_up_load_text", 29 | "value": "Loading in..." 30 | }, 31 | { 32 | "name": "pull_down_refresh_text", 33 | "value": "The drop-down refresh" 34 | }, 35 | { 36 | "name": "release_refresh_text", 37 | "value": "Loosen the refresh" 38 | }, 39 | { 40 | "name": "refreshing_text", 41 | "value": "Is refreshing" 42 | }, 43 | { 44 | "name": "refresh_success_text", 45 | "value": "Refresh the success" 46 | }, 47 | { 48 | "name": "refresh_fail_text", 49 | "value": "Refresh the failure" 50 | }, 51 | { 52 | "name": "http_error_message", 53 | "value": "Network request failed, please try later!" 54 | }, 55 | { 56 | "name": "page_none_msg", 57 | "value": "Network loading failure" 58 | }, 59 | { 60 | "name": "prompt_message", 61 | "value": "No more data" 62 | }, 63 | { 64 | "name": "dependency_reason", 65 | "value": "Used to initiate network data requests." 66 | } 67 | ] 68 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ExtendInterface { 17 | constructor(mocker) { 18 | this.mocker = mocker; 19 | } 20 | 21 | stub() { 22 | this.params = arguments; 23 | return this; 24 | } 25 | 26 | stubMockedCall(returnInfo) { 27 | this.mocker.stubApply(this, this.params, returnInfo); 28 | } 29 | 30 | afterReturn(value) { 31 | this.stubMockedCall(function () { 32 | return value; 33 | }); 34 | } 35 | 36 | afterReturnNothing() { 37 | this.stubMockedCall(function () { 38 | return undefined; 39 | }); 40 | } 41 | 42 | afterAction(action) { 43 | this.stubMockedCall(action); 44 | } 45 | 46 | afterThrow(msg) { 47 | this.stubMockedCall(function () { 48 | throw msg; 49 | }); 50 | } 51 | 52 | clear() { 53 | this.mocker.clear(); 54 | } 55 | } 56 | 57 | export default ExtendInterface; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | function assertClose(actualValue, expected) { 17 | console.log('expected:' + expected[0] + ',precision:' + expected[1]); 18 | if (actualValue === null && expected[0] === null) { 19 | throw new Error('actualValue and expected can not be both null!!!'); 20 | } 21 | let result; 22 | let diff = Math.abs(expected[0] - actualValue); 23 | let actualAbs = Math.abs(actualValue); 24 | if ((actualAbs - 0) === 0) { 25 | if ((diff - 0) === 0) { 26 | result = true; 27 | } else { 28 | result = false; 29 | } 30 | } else if (diff / actualAbs < expected[1]) { 31 | result = true; 32 | } else { 33 | result = false; 34 | } 35 | return { 36 | pass: result, 37 | message: '|' + actualValue + ' - ' + expected[0] + '|/' + actualValue + ' is not less than ' + expected[1] 38 | }; 39 | } 40 | 41 | export default assertClose; 42 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ExtendInterface { 17 | constructor(mocker) { 18 | this.mocker = mocker; 19 | } 20 | 21 | stub() { 22 | this.params = arguments; 23 | return this; 24 | } 25 | 26 | stubMockedCall(returnInfo) { 27 | this.mocker.stubApply(this, this.params, returnInfo); 28 | } 29 | 30 | afterReturn(value) { 31 | this.stubMockedCall(function () { 32 | return value; 33 | }); 34 | } 35 | 36 | afterReturnNothing() { 37 | this.stubMockedCall(function () { 38 | return undefined; 39 | }); 40 | } 41 | 42 | afterAction(action) { 43 | this.stubMockedCall(action); 44 | } 45 | 46 | afterThrow(msg) { 47 | this.stubMockedCall(function () { 48 | throw msg; 49 | }); 50 | } 51 | 52 | clear() { 53 | this.mocker.clear(); 54 | } 55 | } 56 | 57 | export default ExtendInterface; -------------------------------------------------------------------------------- /entry/src/main/ets/component/SquareComponent.ets: -------------------------------------------------------------------------------- 1 | import { Constants } from '../utils/Constants'; 2 | import { NavigationList } from './NavigationList'; 3 | import { SquareList } from './SquareList'; 4 | 5 | @Component 6 | export struct Square { 7 | @Provide tabSquareArray: string[] = ['体系', '导航'] 8 | @State currentIndex: number = 0; 9 | 10 | @Builder TabBuilder(index: number) { 11 | Column() { 12 | Text(this.tabSquareArray[index]) 13 | .height(Constants.FULL_PERCENT) 14 | .fontSize(this.currentIndex === index ? Constants.SELECT_TEXT_FONT_SIZE : Constants.UN_SELECT_TEXT_FONT_SIZE) 15 | .fontColor(this.currentIndex === index ? $r('app.color.font_color_white') : $r('app.color.font_color_black')) 16 | } 17 | .width(Constants.FULL_PERCENT) 18 | .backgroundColor($r('app.color.launch_bg_color')) 19 | } 20 | 21 | build() { 22 | Tabs() { 23 | ForEach(this.tabSquareArray, (_: string, index: number) => { 24 | TabContent() { 25 | Column() { 26 | if (this.currentIndex === 0) { 27 | SquareList({ currentIndex: $currentIndex }) 28 | } else if (this.currentIndex === 1) { 29 | NavigationList() 30 | } 31 | } 32 | } 33 | .backgroundColor($r('app.color.font_color_white')) 34 | .tabBar(this.TabBuilder(index)) 35 | }, (item: string) => JSON.stringify(item)); 36 | } 37 | .barHeight(Constants.SQUARE_TABS_HEIGHT) 38 | .barMode(BarMode.Fixed) 39 | .barWidth(Constants.FULL_PERCENT) 40 | .onChange((index: number) => { 41 | console.log("Tag", "====" + index); 42 | this.currentIndex = index; 43 | }) 44 | } 45 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsPending(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return helper === got ? {pass: true, message: 'actualValue is isPending'} 29 | : { 30 | pass: false, 31 | message: 'expect isPending, actualValue is resolve' 32 | }; 33 | }, 34 | function () { 35 | return { 36 | pass: false 37 | , message: 'expect isPending, actualValue is reject' 38 | }; 39 | }); 40 | } 41 | 42 | export default assertPromiseIsPending; -------------------------------------------------------------------------------- /entry/src/main/ets/model/HomeEntity.ets: -------------------------------------------------------------------------------- 1 | /** 2 | * Banners实体类 3 | */ 4 | import { IState } from './IStatus'; 5 | 6 | export class HomeModel { 7 | bannerData: Array 8 | status: number = IState.Loading 9 | } 10 | 11 | export class IBannerModel { 12 | desc?: string = ''; 13 | id?: number = 0; 14 | title?: string = ''; 15 | imagePath?: string = ''; 16 | url?: string = ''; 17 | type?: number = 0; 18 | } 19 | 20 | export class Article { 21 | offset: number = 0 22 | over: boolean = false 23 | pageCount: number = 0 24 | size: number = 0 25 | total: number = 0 26 | curPage: number = 1 27 | datas: Array 28 | } 29 | 30 | export class IArticle { 31 | title: string = ''; 32 | superChapterName: string = '' 33 | niceDate: string = '' 34 | niceShareDate: string = '' 35 | shareUser: string = '' 36 | adminAdd: boolean 37 | apkLink: string = '' 38 | audit: number = 1 39 | author: string = '' 40 | canEdit: boolean 41 | chapterId: number = 0 42 | chapterName: string = '' 43 | collect: boolean 44 | courseId: number = 0 45 | desc: string = '' 46 | descMd: string = '' 47 | envelopePic: string = '' 48 | fresh: boolean 49 | host: string = '' 50 | id: number = 0 51 | isAdminAdd: boolean 52 | link: string = '' 53 | origin: string = '' 54 | prefix: string = '' 55 | projectLink: string = '' 56 | publishTime: number = 0 57 | realSuperChapterId: number = 0 58 | selfVisible: number = 0 59 | shareDate: number = 0 60 | superChapterId: number = 0 61 | tags: Array 62 | type: number = 0 63 | userId: number = 0 64 | visible: number = 1 65 | zan: number = 0 66 | } 67 | 68 | export class ITags { 69 | name: string = '' 70 | url: string = '' 71 | } 72 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsPending(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return helper === got ? {pass: true, message: 'actualValue is isPending'} 29 | : { 30 | pass: false, 31 | message: 'expect isPending, actualValue is resolve' 32 | }; 33 | }, 34 | function () { 35 | return { 36 | pass: false 37 | , message: 'expect isPending, actualValue is reject' 38 | }; 39 | }); 40 | } 41 | 42 | export default assertPromiseIsPending; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsPending(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | const helper = {}; 26 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 27 | function (got) { 28 | return helper === got ? {pass: true, message: 'actualValue is isPending'} 29 | : { 30 | pass: false, 31 | message: 'expect isPending, actualValue is resolve' 32 | }; 33 | }, 34 | function () { 35 | return { 36 | pass: false 37 | , message: 'expect isPending, actualValue is reject' 38 | }; 39 | }); 40 | } 41 | 42 | export default assertPromiseIsPending; -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolved(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | const helper = {}; 27 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 28 | function (got) { 29 | return helper === got ? { 30 | pass: false, 31 | message: 'expect resolve, actualValue is isPending' 32 | } 33 | : {pass: true, message: 'actualValue is isResolved'}; 34 | }, 35 | function (rej) { 36 | return { 37 | pass: false, 38 | message: 'Expected a promise to be resolved but it was ' + 39 | 'rejected with ' + JSON.stringify(rej) + '.' 40 | }; 41 | } 42 | ); 43 | } 44 | 45 | export default assertPromiseIsResolved; -------------------------------------------------------------------------------- /hvigorw.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Hvigor startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 17 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 18 | 19 | set WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js 20 | set NODE_EXE=node.exe 21 | 22 | goto start 23 | 24 | :start 25 | @rem Find node.exe 26 | if defined NODE_HOME goto findNodeFromNodeHome 27 | 28 | %NODE_EXE% --version >NUL 2>&1 29 | if "%ERRORLEVEL%" == "0" goto execute 30 | 31 | echo. 32 | echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. 33 | echo. 34 | echo Please set the NODE_HOME variable in your environment to match the 35 | echo location of your NodeJs installation. 36 | 37 | goto fail 38 | 39 | :findNodeFromNodeHome 40 | set NODE_HOME=%NODE_HOME:"=% 41 | set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE% 42 | 43 | if exist "%NODE_EXE_PATH%" goto execute 44 | echo. 45 | echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH. 46 | echo. 47 | echo Please set the NODE_HOME variable in your environment to match the 48 | echo location of your NodeJs installation. 49 | 50 | goto fail 51 | 52 | :execute 53 | @rem Execute hvigor 54 | "%NODE_EXE%" %WRAPPER_MODULE_PATH% %* 55 | 56 | if "%ERRORLEVEL%" == "0" goto hvigorwEnd 57 | 58 | :fail 59 | exit /b 1 60 | 61 | :hvigorwEnd 62 | if "%OS%" == "Windows_NT" endlocal 63 | 64 | :end 65 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolved(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | const helper = {}; 27 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 28 | function (got) { 29 | return helper === got ? { 30 | pass: false, 31 | message: 'expect resolve, actualValue is isPending' 32 | } 33 | : {pass: true, message: 'actualValue is isResolved'}; 34 | }, 35 | function (rej) { 36 | return { 37 | pass: false, 38 | message: 'Expected a promise to be resolved but it was ' + 39 | 'rejected with ' + JSON.stringify(rej) + '.' 40 | }; 41 | } 42 | ); 43 | } 44 | 45 | export default assertPromiseIsResolved; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolved(actualPromise) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | const helper = {}; 27 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 28 | function (got) { 29 | return helper === got ? { 30 | pass: false, 31 | message: 'expect resolve, actualValue is isPending' 32 | } 33 | : {pass: true, message: 'actualValue is isResolved'}; 34 | }, 35 | function (rej) { 36 | return { 37 | pass: false, 38 | message: 'Expected a promise to be resolved but it was ' + 39 | 'rejected with ' + JSON.stringify(rej) + '.' 40 | }; 41 | } 42 | ); 43 | } 44 | 45 | export default assertPromiseIsResolved; -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/interface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import Core from './core'; 17 | 18 | const core = Core.getInstance(); 19 | 20 | const describe = function (desc, func) { 21 | return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { }; 22 | }; 23 | const it = function (desc, filter, func) { 24 | return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { }; 25 | }; 26 | const beforeEach = function (func) { 27 | return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { }; 28 | }; 29 | const afterEach = function (func) { 30 | return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { }; 31 | }; 32 | const beforeAll = function (func) { 33 | return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { }; 34 | }; 35 | const afterAll = function (func) { 36 | return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { }; 37 | }; 38 | const expect = function (actualValue) { 39 | return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { }; 40 | }; 41 | 42 | export { 43 | describe, it, beforeAll, beforeEach, afterEach, afterAll, expect 44 | }; 45 | -------------------------------------------------------------------------------- /entry/src/main/ets/view/Banner.ets: -------------------------------------------------------------------------------- 1 | import { IBannerModel, HomeModel } from '../model/HomeEntity'; 2 | import { IState } from '../model/IStatus'; 3 | import { getBanner } from '../request/Home'; 4 | import { Constants } from '../utils/Constants'; 5 | 6 | 7 | @Component 8 | export struct Banner { 9 | private controller: SwiperController = new SwiperController(); 10 | @State list: HomeModel = new HomeModel() 11 | 12 | requestBanner() { 13 | getBanner().then((data: IBannerModel[]) => { 14 | this.list.bannerData = [...data] 15 | this.list.status = IState.Success 16 | }).catch((err: string | Resource) => { 17 | this.list.status = IState.Fail 18 | }) 19 | } 20 | 21 | aboutToAppear() { 22 | this.requestBanner() 23 | } 24 | 25 | @Builder LoadingLayout() { 26 | Text('加载中...').width('100%').height('100%').textAlign(TextAlign.Center) 27 | } 28 | 29 | @Builder ShowData() { 30 | Swiper(this.controller) { 31 | ForEach(this.list.bannerData, (item: IBannerModel) => { 32 | Image(item.imagePath) 33 | .objectFit(ImageFit.Fill) 34 | .height(Constants.FULL_SIZE) 35 | .width(Constants.FULL_SIZE) 36 | .borderRadius(Constants.fs_6) 37 | .align(Alignment.Center) 38 | .onClick(() => { 39 | }) 40 | }, (item: IBannerModel, index?: number) => JSON.stringify(item) + index) 41 | } 42 | .width(Constants.PAGE_WIDTH) 43 | .height(Constants.HEIGHT_BANNER) 44 | .indicatorStyle({ selectedColor: $r('app.color.start_window_background') }) 45 | .indicator(true) 46 | .loop(true) 47 | .margin({ top: 5 }) 48 | .autoPlay(true) 49 | .duration(Constants.DURATION_ADS) 50 | } 51 | 52 | build() { 53 | if (this.list.status === IState.Loading) { 54 | this.LoadingLayout() 55 | } else { 56 | this.ShowData() 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/interface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import Core from './core'; 17 | 18 | const core = Core.getInstance(); 19 | 20 | const describe = function (desc, func) { 21 | return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { }; 22 | }; 23 | const it = function (desc, filter, func) { 24 | return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { }; 25 | }; 26 | const beforeEach = function (func) { 27 | return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { }; 28 | }; 29 | const afterEach = function (func) { 30 | return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { }; 31 | }; 32 | const beforeAll = function (func) { 33 | return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { }; 34 | }; 35 | const afterAll = function (func) { 36 | return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { }; 37 | }; 38 | const expect = function (actualValue) { 39 | return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { }; 40 | }; 41 | 42 | export { 43 | describe, it, beforeAll, beforeEach, afterEach, afterAll, expect 44 | }; 45 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/interface.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import Core from './core'; 17 | 18 | const core = Core.getInstance(); 19 | 20 | const describe = function (desc, func) { 21 | return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { }; 22 | }; 23 | const it = function (desc, filter, func) { 24 | return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { }; 25 | }; 26 | const beforeEach = function (func) { 27 | return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { }; 28 | }; 29 | const afterEach = function (func) { 30 | return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { }; 31 | }; 32 | const beforeAll = function (func) { 33 | return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { }; 34 | }; 35 | const afterAll = function (func) { 36 | return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { }; 37 | }; 38 | const expect = function (actualValue) { 39 | return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { }; 40 | }; 41 | 42 | export { 43 | describe, it, beforeAll, beforeEach, afterEach, afterAll, expect 44 | }; 45 | -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/test/Ability.test.ets: -------------------------------------------------------------------------------- 1 | import hilog from '@ohos.hilog'; 2 | import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' 3 | 4 | export default function abilityTest() { 5 | describe('ActsAbilityTest', function () { 6 | // Defines a test suite. Two parameters are supported: test suite name and test suite function. 7 | beforeAll(function () { 8 | // Presets an action, which is performed only once before all test cases of the test suite start. 9 | // This API supports only one parameter: preset action function. 10 | }) 11 | beforeEach(function () { 12 | // Presets an action, which is performed before each unit test case starts. 13 | // The number of execution times is the same as the number of test cases defined by **it**. 14 | // This API supports only one parameter: preset action function. 15 | }) 16 | afterEach(function () { 17 | // Presets a clear action, which is performed after each unit test case ends. 18 | // The number of execution times is the same as the number of test cases defined by **it**. 19 | // This API supports only one parameter: clear action function. 20 | }) 21 | afterAll(function () { 22 | // Presets a clear action, which is performed after all test cases of the test suite end. 23 | // This API supports only one parameter: clear action function. 24 | }) 25 | it('assertContain',0, function () { 26 | // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. 27 | hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); 28 | let a = 'abc' 29 | let b = 'b' 30 | // Defines a variety of assertion methods, which are used to declare expected boolean conditions. 31 | expect(a).assertContain(b) 32 | expect(a).assertEqual(a) 33 | }) 34 | }) 35 | } -------------------------------------------------------------------------------- /entry/src/main/ets/component/NavigationList.ets: -------------------------------------------------------------------------------- 1 | import { IState } from '../model/IStatus'; 2 | import { INav, INavChildren, ITree, ITreeChildren } from '../model/ITreeBean'; 3 | import { getNav } from '../request/SquareReq'; 4 | import { Constants } from '../utils/Constants'; 5 | 6 | @Component 7 | export struct NavigationList { 8 | @State status: IState = IState.Loading 9 | scroll: Scroller = new Scroller() 10 | @State mListNav: INav[] = new Array() 11 | 12 | category() { 13 | console.log("Tag"); 14 | getNav().then((data: INav[]) => { 15 | this.mListNav = [...data]; 16 | this.status = IState.Success; 17 | }).catch((err: string | Resource) => { 18 | console.log('getNav failed', err); 19 | }) 20 | } 21 | 22 | aboutToAppear() { 23 | this.category(); 24 | } 25 | 26 | @Builder LoadingLayout() { 27 | Text('加载中...').width('100%').height('100%').textAlign(TextAlign.Center) 28 | } 29 | 30 | @Builder showNav() { 31 | Scroll(this.scroll) { 32 | Column() { 33 | ForEach(this.mListNav, (item: INav, index) => { 34 | Column() { 35 | Text(item.name) 36 | .width(Constants.FULL_PERCENT) 37 | .textAlign(TextAlign.Start) 38 | .margin(10) 39 | .fontSize(20) 40 | Flex({ 41 | wrap: FlexWrap.Wrap 42 | }) { 43 | ForEach(item.articles, (itemChild: INavChildren, item) => { 44 | Button(itemChild.title) 45 | .backgroundColor('#EEEEEE') 46 | .borderRadius(30) 47 | .fontColor(Color.Black) 48 | .margin(5) 49 | .padding({ left: 8, right: 8 }) 50 | }, (item: ITreeChildren, index?: number) => JSON.stringify(item) + index) 51 | } 52 | }.padding({ left: 10, right: 10 }) 53 | }, (item: ITree, index?: number) => JSON.stringify(item) + index) 54 | } 55 | .width(Constants.FULL_PERCENT) 56 | } 57 | .scrollable(ScrollDirection.Vertical) 58 | .edgeEffect(EdgeEffect.Spring) 59 | } 60 | 61 | build() { 62 | if (this.status === IState.Loading) { 63 | this.LoadingLayout() 64 | } else { 65 | this.showNav() 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testability/TestAbility.ets: -------------------------------------------------------------------------------- 1 | import UIAbility from '@ohos.app.ability.UIAbility'; 2 | import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 3 | import hilog from '@ohos.hilog'; 4 | import { Hypium } from '@ohos/hypium'; 5 | import testsuite from '../test/List.test'; 6 | import window from '@ohos.window'; 7 | 8 | export default class TestAbility extends UIAbility { 9 | onCreate(want, launchParam) { 10 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); 11 | hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); 12 | hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); 13 | var abilityDelegator: any 14 | abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() 15 | var abilityDelegatorArguments: any 16 | abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() 17 | hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); 18 | Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) 19 | } 20 | 21 | onDestroy() { 22 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); 23 | } 24 | 25 | onWindowStageCreate(windowStage: window.WindowStage) { 26 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); 27 | windowStage.loadContent('testability/pages/Index', (err, data) => { 28 | if (err.code) { 29 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 30 | return; 31 | } 32 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', 33 | JSON.stringify(data) ?? ''); 34 | }); 35 | } 36 | 37 | onWindowStageDestroy() { 38 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); 39 | } 40 | 41 | onForeground() { 42 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); 43 | } 44 | 45 | onBackground() { 46 | hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); 47 | } 48 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejectedWith(actualPromise, expectedValue) { 19 | 20 | if (!isPromiseLike(actualPromise)) { 21 | return Promise.reject().then(function () { 22 | }, function () { 23 | return {pass: false, message: 'Expected not be called on a promise.'}; 24 | }); 25 | } 26 | 27 | function tips(passed) { 28 | return ('Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be rejected with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | return { 36 | pass: false, 37 | message: tips(false) + ' but actualValue is ' 38 | + (helper === got ? 'isPending' : 'resolve') 39 | }; 40 | }, 41 | function (actualValue) { 42 | if (JSON.stringify(actualValue) == JSON.stringify(expectedValue[0])) { 43 | return { 44 | pass: true, 45 | message: 'actualValue was rejected with ' + JSON.stringify(actualValue) + '.' 46 | }; 47 | } else { 48 | return { 49 | pass: false, 50 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(actualValue) + '.' 51 | }; 52 | } 53 | } 54 | ); 55 | } 56 | 57 | export default assertPromiseIsRejectedWith; -------------------------------------------------------------------------------- /entry/src/main/ets/pages/Index.ets: -------------------------------------------------------------------------------- 1 | import { Square } from '../component/SquareComponent'; 2 | import { Home } from '../component/HomeComponent'; 3 | import { Me } from '../component/MeComponent'; 4 | import { BottomTabsList } from '../model/BottomTabsModel'; 5 | import { Constants } from '../utils/Constants'; 6 | 7 | @Entry 8 | @Component 9 | struct Index { 10 | @Provide data: string[] = ['Home', 'Square', 'Me'] 11 | @State @Watch('onIndexChange') bottomTabIndex: number = 0; 12 | private controller: TabsController = new TabsController() 13 | 14 | @Builder TabBuild(index: number) { 15 | Column() { 16 | Image(this.bottomTabIndex === index ? BottomTabsList[index].iconSelected : BottomTabsList[index].icon) 17 | .width(Constants.ICON_SIZE) 18 | .height(Constants.ICON_SIZE) 19 | .objectFit(ImageFit.Contain) 20 | 21 | Text(BottomTabsList[index].text) 22 | .fontSize($r('app.float.bottom_font_size')) 23 | .opacity(Constants.OPACITY) 24 | .fontColor(this.bottomTabIndex === index ? 25 | $r('app.color.bottom_tabs_font_color_selected') : $r('app.color.bottom_tabs_font_color')) 26 | } 27 | .width(Constants.FULL_PERCENT) 28 | .height(Constants.FULL_PERCENT) 29 | .justifyContent(FlexAlign.Center) 30 | .backgroundColor('#FFF') 31 | } 32 | 33 | //切换改变的监听 34 | onIndexChange() { 35 | this.controller.changeIndex(this.bottomTabIndex); 36 | } 37 | 38 | build() { 39 | Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.End, justifyContent: FlexAlign.End }) { 40 | Tabs({ barPosition: BarPosition.End, index: 0, controller: this.controller }) { 41 | ForEach(this.data, (_, index) => { 42 | TabContent() { 43 | if (index === 0) { 44 | Home() 45 | } else if (index === 1) { 46 | Square() 47 | } else if (index === 2) { 48 | Me() 49 | } 50 | }.tabBar(this.TabBuild(index)) 51 | }) 52 | } 53 | .width(Constants.FULL_PERCENT) 54 | .height(Constants.FULL_PERCENT) 55 | .vertical(false) 56 | .scrollable(false) 57 | .barHeight(Constants.BAR_HEIGHT) 58 | .onChange((index: number) => { 59 | this.bottomTabIndex = index; 60 | }) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejectedWith(actualPromise, expectedValue) { 19 | 20 | if (!isPromiseLike(actualPromise)) { 21 | return Promise.reject().then(function () { 22 | }, function () { 23 | return {pass: false, message: 'Expected not be called on a promise.'}; 24 | }); 25 | } 26 | 27 | function tips(passed) { 28 | return ('Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be rejected with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | return { 36 | pass: false, 37 | message: tips(false) + ' but actualValue is ' 38 | + (helper === got ? 'isPending' : 'resolve') 39 | }; 40 | }, 41 | function (actualValue) { 42 | if (JSON.stringify(actualValue) == JSON.stringify(expectedValue[0])) { 43 | return { 44 | pass: true, 45 | message: 'actualValue was rejected with ' + JSON.stringify(actualValue) + '.' 46 | }; 47 | } else { 48 | return { 49 | pass: false, 50 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(actualValue) + '.' 51 | }; 52 | } 53 | } 54 | ); 55 | } 56 | 57 | export default assertPromiseIsRejectedWith; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsRejectedWith(actualPromise, expectedValue) { 19 | 20 | if (!isPromiseLike(actualPromise)) { 21 | return Promise.reject().then(function () { 22 | }, function () { 23 | return {pass: false, message: 'Expected not be called on a promise.'}; 24 | }); 25 | } 26 | 27 | function tips(passed) { 28 | return ('Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be rejected with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | return { 36 | pass: false, 37 | message: tips(false) + ' but actualValue is ' 38 | + (helper === got ? 'isPending' : 'resolve') 39 | }; 40 | }, 41 | function (actualValue) { 42 | if (JSON.stringify(actualValue) == JSON.stringify(expectedValue[0])) { 43 | return { 44 | pass: true, 45 | message: 'actualValue was rejected with ' + JSON.stringify(actualValue) + '.' 46 | }; 47 | } else { 48 | return { 49 | pass: false, 50 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(actualValue) + '.' 51 | }; 52 | } 53 | } 54 | ); 55 | } 56 | 57 | export default assertPromiseIsRejectedWith; -------------------------------------------------------------------------------- /entry/src/ohosTest/ets/testrunner/OpenHarmonyTestRunner.ts: -------------------------------------------------------------------------------- 1 | import hilog from '@ohos.hilog'; 2 | import TestRunner from '@ohos.application.testRunner'; 3 | import AbilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry'; 4 | 5 | var abilityDelegator = undefined 6 | var abilityDelegatorArguments = undefined 7 | 8 | async function onAbilityCreateCallback() { 9 | hilog.info(0x0000, 'testTag', '%{public}s', 'onAbilityCreateCallback'); 10 | } 11 | 12 | async function addAbilityMonitorCallback(err: any) { 13 | hilog.info(0x0000, 'testTag', 'addAbilityMonitorCallback : %{public}s', JSON.stringify(err) ?? ''); 14 | } 15 | 16 | export default class OpenHarmonyTestRunner implements TestRunner { 17 | constructor() { 18 | } 19 | 20 | onPrepare() { 21 | hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner OnPrepare '); 22 | } 23 | 24 | async onRun() { 25 | hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun run'); 26 | abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() 27 | abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() 28 | var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' 29 | let lMonitor = { 30 | abilityName: testAbilityName, 31 | onAbilityCreate: onAbilityCreateCallback, 32 | }; 33 | abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) 34 | var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName 35 | var debug = abilityDelegatorArguments.parameters['-D'] 36 | if (debug == 'true') 37 | { 38 | cmd += ' -D' 39 | } 40 | hilog.info(0x0000, 'testTag', 'cmd : %{public}s', cmd); 41 | abilityDelegator.executeShellCommand(cmd, 42 | (err: any, d: any) => { 43 | hilog.info(0x0000, 'testTag', 'executeShellCommand : err : %{public}s', JSON.stringify(err) ?? ''); 44 | hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.stdResult ?? ''); 45 | hilog.info(0x0000, 'testTag', 'executeShellCommand : data : %{public}s', d.exitCode ?? ''); 46 | }) 47 | hilog.info(0x0000, 'testTag', '%{public}s', 'OpenHarmonyTestRunner onRun end'); 48 | } 49 | } -------------------------------------------------------------------------------- /entry/src/main/ets/entryability/EntryAbility.ts: -------------------------------------------------------------------------------- 1 | import UIAbility from '@ohos.app.ability.UIAbility'; 2 | import hilog from '@ohos.hilog'; 3 | import window from '@ohos.window'; 4 | import data_preferences from '@ohos.data.preferences'; 5 | 6 | export var preferences: data_preferences.Preferences = null; 7 | 8 | export default class EntryAbility extends UIAbility { 9 | onCreate(want, launchParam) { 10 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onCreate'); 11 | } 12 | 13 | onDestroy() { 14 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onDestroy'); 15 | } 16 | 17 | onWindowStageCreate(windowStage: window.WindowStage) { 18 | // 主窗口已创建,为此功能设置主页面 19 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); 20 | try { 21 | data_preferences.getPreferences(this.context, 'myStore', function (err, val) { 22 | if (err) { 23 | console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message); 24 | return; 25 | } 26 | preferences = val; 27 | console.info("Succeeded in getting preferences."); 28 | preferences.get('token', '456', (value) => { 29 | console.info("token" + value) 30 | }) 31 | }) 32 | } catch (err) { 33 | console.error("Failed to get preferences. code =" + err.code + ", message =" + err.message); 34 | } 35 | try { 36 | // TODO 加载页面的入口 37 | windowStage.loadContent('pages/Launch', (err, data) => { 38 | if (err.code) { 39 | hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); 40 | return; 41 | } 42 | hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', JSON.stringify(data) ?? ''); 43 | }); 44 | } catch (err) { 45 | hilog.info(0x0000, 'testTag', 'Failed loadContent' + err); 46 | } 47 | } 48 | 49 | onWindowStageDestroy() { 50 | // 主窗口被破坏,释放UI相关资源 51 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); 52 | } 53 | 54 | onForeground() { 55 | // Ability 处于前台 56 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onForeground'); 57 | } 58 | 59 | onBackground() { 60 | // Ability 处于后台 61 | hilog.info(0x0000, 'testTag', '%{public}s', 'Ability onBackground'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolvedWith(actualPromise, expectedValue) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | function tips(passed) { 27 | return ( 28 | 'Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be resolved with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | if (helper === got) { 36 | return {pass: false, message: 'expect resolve, actualValue is isPending'}; 37 | } 38 | if (JSON.stringify(got) == JSON.stringify(expectedValue[0])) { 39 | return { 40 | pass: true, 41 | message: 'actualValue was resolved with ' + JSON.stringify(got) + '.' 42 | }; 43 | } 44 | return { 45 | pass: false, 46 | message: tips(false) + ' but it was resolved with ' + 47 | JSON.stringify(got) + '.' 48 | }; 49 | }, 50 | function (rej) { 51 | return { 52 | pass: false, 53 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(rej) + '.' 54 | }; 55 | } 56 | ); 57 | } 58 | 59 | export default assertPromiseIsResolvedWith; -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolvedWith(actualPromise, expectedValue) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | function tips(passed) { 27 | return ( 28 | 'Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be resolved with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | if (helper === got) { 36 | return {pass: false, message: 'expect resolve, actualValue is isPending'}; 37 | } 38 | if (JSON.stringify(got) == JSON.stringify(expectedValue[0])) { 39 | return { 40 | pass: true, 41 | message: 'actualValue was resolved with ' + JSON.stringify(got) + '.' 42 | }; 43 | } 44 | return { 45 | pass: false, 46 | message: tips(false) + ' but it was resolved with ' + 47 | JSON.stringify(got) + '.' 48 | }; 49 | }, 50 | function (rej) { 51 | return { 52 | pass: false, 53 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(rej) + '.' 54 | }; 55 | } 56 | ); 57 | } 58 | 59 | export default assertPromiseIsResolvedWith; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | import isPromiseLike from './isPromiseLike'; 17 | 18 | function assertPromiseIsResolvedWith(actualPromise, expectedValue) { 19 | if (!isPromiseLike(actualPromise)) { 20 | return Promise.reject().then(function () { 21 | }, function () { 22 | return {pass: false, message: 'Expected not be called on a promise.'}; 23 | }); 24 | } 25 | 26 | function tips(passed) { 27 | return ( 28 | 'Expected a promise ' + (passed ? 'not ' : '') + 29 | 'to be resolved with ' + JSON.stringify(expectedValue[0])); 30 | } 31 | 32 | const helper = {}; 33 | return Promise.race([actualPromise, Promise.resolve(helper)]).then( 34 | function (got) { 35 | if (helper === got) { 36 | return {pass: false, message: 'expect resolve, actualValue is isPending'}; 37 | } 38 | if (JSON.stringify(got) == JSON.stringify(expectedValue[0])) { 39 | return { 40 | pass: true, 41 | message: 'actualValue was resolved with ' + JSON.stringify(got) + '.' 42 | }; 43 | } 44 | return { 45 | pass: false, 46 | message: tips(false) + ' but it was resolved with ' + 47 | JSON.stringify(got) + '.' 48 | }; 49 | }, 50 | function (rej) { 51 | return { 52 | pass: false, 53 | message: tips(false) + ' but it was rejected with ' + JSON.stringify(rej) + '.' 54 | }; 55 | } 56 | ); 57 | } 58 | 59 | export default assertPromiseIsResolvedWith; -------------------------------------------------------------------------------- /entry/src/main/ets/component/SquareList.ets: -------------------------------------------------------------------------------- 1 | import Prompt from '@system.prompt'; 2 | import { IState } from '../model/IStatus'; 3 | import { ITree, ITreeChildren } from '../model/ITreeBean'; 4 | import { getTree } from '../request/SquareReq'; 5 | import { Constants } from '../utils/Constants'; 6 | 7 | @Component 8 | export struct SquareList { 9 | @Watch('category') @Link currentIndex: number; 10 | @State list: ITree[] = new Array() 11 | @State status: IState = IState.Loading 12 | scroll: Scroller = new Scroller() 13 | 14 | category() { 15 | if (this.currentIndex === 0) { 16 | getTree().then((data: ITree[]) => { 17 | this.list = [...data]; 18 | this.status = IState.Success 19 | }).catch((err: string | Resource) => { 20 | console.log('getTree failed', err); 21 | }) 22 | } 23 | } 24 | 25 | aboutToAppear() { 26 | this.category(); 27 | } 28 | 29 | @Builder LoadingLayout() { 30 | Text('加载中...').width('100%').height('100%').textAlign(TextAlign.Center) 31 | } 32 | 33 | @Builder showTree() { 34 | Scroll(this.scroll) { 35 | Column() { 36 | ForEach(this.list, (item: ITree, index) => { 37 | Column() { 38 | Text(item.name) 39 | .width(Constants.FULL_PERCENT) 40 | .textAlign(TextAlign.Start) 41 | .margin(10) 42 | .fontSize(20) 43 | Flex({ 44 | wrap: FlexWrap.Wrap 45 | }) { 46 | ForEach(item.children, (itemChild: ITreeChildren, item) => { 47 | Button(itemChild.name) 48 | .backgroundColor('#EEEEEE') 49 | .borderRadius(30) 50 | .fontColor(Color.Black) 51 | .margin(5) 52 | .padding({ left: 8, right: 8 }) 53 | .onClick(() => { 54 | Prompt.showToast({ message: '点击了' + itemChild.name }) 55 | }) 56 | }, (item: ITreeChildren, index?: number) => JSON.stringify(item) + index) 57 | } 58 | }.padding({ left: 10, right: 10 }) 59 | }, (item: ITree, index?: number) => JSON.stringify(item) + index) 60 | } 61 | .width(Constants.FULL_PERCENT) 62 | } 63 | .scrollable(ScrollDirection.Vertical) 64 | .edgeEffect(EdgeEffect.Spring) 65 | } 66 | 67 | build() { 68 | if (this.status === IState.Loading) { 69 | this.LoadingLayout() 70 | } else { 71 | this.showTree() 72 | } 73 | } 74 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/event.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SpecEvent { 17 | constructor(attr) { 18 | this.id = attr.id; 19 | this.coreContext = attr.context; 20 | this.eventMonitors = []; 21 | } 22 | 23 | subscribeEvent(service) { 24 | this.eventMonitors.push(service); 25 | } 26 | 27 | async specStart() { 28 | for (const monitor of this.eventMonitors) { 29 | await monitor['specStart'](); 30 | } 31 | } 32 | 33 | async specDone() { 34 | for (const monitor of this.eventMonitors) { 35 | await monitor['specDone'](); 36 | } 37 | } 38 | } 39 | 40 | class SuiteEvent { 41 | constructor(attr) { 42 | this.id = attr.id; 43 | this.suiteContext = attr.coreContext; 44 | this.eventMonitors = []; 45 | } 46 | 47 | subscribeEvent(service) { 48 | this.eventMonitors.push(service); 49 | } 50 | 51 | async suiteStart() { 52 | for (const monitor of this.eventMonitors) { 53 | await monitor['suiteStart'](); 54 | } 55 | } 56 | 57 | async suiteDone() { 58 | for (const monitor of this.eventMonitors) { 59 | await monitor['suiteDone'](); 60 | } 61 | } 62 | } 63 | 64 | class TaskEvent { 65 | constructor(attr) { 66 | this.id = attr.id; 67 | this.coreContext = attr.coreContext; 68 | this.eventMonitors = []; 69 | } 70 | 71 | subscribeEvent(service) { 72 | this.eventMonitors.push(service); 73 | } 74 | 75 | async taskStart() { 76 | for (const monitor of this.eventMonitors) { 77 | await monitor['taskStart'](); 78 | } 79 | } 80 | 81 | async taskDone() { 82 | for (const monitor of this.eventMonitors) { 83 | await monitor['taskDone'](); 84 | } 85 | } 86 | 87 | incorrectFormat() { 88 | for (const monitor of this.eventMonitors) { 89 | monitor['incorrectFormat'](); 90 | } 91 | } 92 | } 93 | 94 | export {SpecEvent, TaskEvent, SuiteEvent}; 95 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/event.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SpecEvent { 17 | constructor(attr) { 18 | this.id = attr.id; 19 | this.coreContext = attr.context; 20 | this.eventMonitors = []; 21 | } 22 | 23 | subscribeEvent(service) { 24 | this.eventMonitors.push(service); 25 | } 26 | 27 | async specStart() { 28 | for (const monitor of this.eventMonitors) { 29 | await monitor['specStart'](); 30 | } 31 | } 32 | 33 | async specDone() { 34 | for (const monitor of this.eventMonitors) { 35 | await monitor['specDone'](); 36 | } 37 | } 38 | } 39 | 40 | class SuiteEvent { 41 | constructor(attr) { 42 | this.id = attr.id; 43 | this.suiteContext = attr.coreContext; 44 | this.eventMonitors = []; 45 | } 46 | 47 | subscribeEvent(service) { 48 | this.eventMonitors.push(service); 49 | } 50 | 51 | async suiteStart() { 52 | for (const monitor of this.eventMonitors) { 53 | await monitor['suiteStart'](); 54 | } 55 | } 56 | 57 | async suiteDone() { 58 | for (const monitor of this.eventMonitors) { 59 | await monitor['suiteDone'](); 60 | } 61 | } 62 | } 63 | 64 | class TaskEvent { 65 | constructor(attr) { 66 | this.id = attr.id; 67 | this.coreContext = attr.coreContext; 68 | this.eventMonitors = []; 69 | } 70 | 71 | subscribeEvent(service) { 72 | this.eventMonitors.push(service); 73 | } 74 | 75 | async taskStart() { 76 | for (const monitor of this.eventMonitors) { 77 | await monitor['taskStart'](); 78 | } 79 | } 80 | 81 | async taskDone() { 82 | for (const monitor of this.eventMonitors) { 83 | await monitor['taskDone'](); 84 | } 85 | } 86 | 87 | incorrectFormat() { 88 | for (const monitor of this.eventMonitors) { 89 | monitor['incorrectFormat'](); 90 | } 91 | } 92 | } 93 | 94 | export {SpecEvent, TaskEvent, SuiteEvent}; 95 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/event.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SpecEvent { 17 | constructor(attr) { 18 | this.id = attr.id; 19 | this.coreContext = attr.context; 20 | this.eventMonitors = []; 21 | } 22 | 23 | subscribeEvent(service) { 24 | this.eventMonitors.push(service); 25 | } 26 | 27 | async specStart() { 28 | for (const monitor of this.eventMonitors) { 29 | await monitor['specStart'](); 30 | } 31 | } 32 | 33 | async specDone() { 34 | for (const monitor of this.eventMonitors) { 35 | await monitor['specDone'](); 36 | } 37 | } 38 | } 39 | 40 | class SuiteEvent { 41 | constructor(attr) { 42 | this.id = attr.id; 43 | this.suiteContext = attr.coreContext; 44 | this.eventMonitors = []; 45 | } 46 | 47 | subscribeEvent(service) { 48 | this.eventMonitors.push(service); 49 | } 50 | 51 | async suiteStart() { 52 | for (const monitor of this.eventMonitors) { 53 | await monitor['suiteStart'](); 54 | } 55 | } 56 | 57 | async suiteDone() { 58 | for (const monitor of this.eventMonitors) { 59 | await monitor['suiteDone'](); 60 | } 61 | } 62 | } 63 | 64 | class TaskEvent { 65 | constructor(attr) { 66 | this.id = attr.id; 67 | this.coreContext = attr.coreContext; 68 | this.eventMonitors = []; 69 | } 70 | 71 | subscribeEvent(service) { 72 | this.eventMonitors.push(service); 73 | } 74 | 75 | async taskStart() { 76 | for (const monitor of this.eventMonitors) { 77 | await monitor['taskStart'](); 78 | } 79 | } 80 | 81 | async taskDone() { 82 | for (const monitor of this.eventMonitors) { 83 | await monitor['taskDone'](); 84 | } 85 | } 86 | 87 | incorrectFormat() { 88 | for (const monitor of this.eventMonitors) { 89 | monitor['incorrectFormat'](); 90 | } 91 | } 92 | } 93 | 94 | export {SpecEvent, TaskEvent, SuiteEvent}; 95 | -------------------------------------------------------------------------------- /entry/src/main/ets/utils/Constants.ets: -------------------------------------------------------------------------------- 1 | import { MeListBean } from '../model/MeListBean'; 2 | 3 | export class Constants { 4 | static readonly SWIPER_DEFAULT_WIDTH: string = '66%'; 5 | static readonly FULL_PERCENT: string = '100%'; 6 | static readonly HALF_PERCENT: string = '50%'; 7 | static readonly IMAGE_CONTAINER_HEIGHT: string = '42%'; 8 | static readonly FULL_SIZE: string = '100%'; 9 | static readonly ICON_SIZE: string = '40%'; 10 | static readonly BAR_HEIGHT: string = '50'; 11 | static readonly CONTENT_WIDTH_PERCENT: string = '87%'; 12 | static readonly SEARCHBAR_WIDTH: string = '91.1%' 13 | static readonly IMAGE_HEIGHT_MIN: string = '78%'; 14 | static readonly LIST_HEIGHT: string = '90%'; 15 | 16 | //TabItem 17 | static readonly HOME_TITLE: string = '首页'; 18 | static readonly SQUARE_TITLE: string = '广场'; 19 | static readonly ME_TITLE: string = "我的"; 20 | static readonly OPACITY: number = 0.6; 21 | static readonly BORDER_WIDTH: number = 0.5; 22 | static readonly COUNTDOWN: number = 5; 23 | 24 | //圆角的RADIUS 25 | static readonly BORDER_RADIUS = 12; 26 | //tab页的宽 27 | static readonly PAGE_WIDTH = '94.4%'; 28 | //banner的高 29 | static readonly HEIGHT_BANNER = '27%'; 30 | //动画执行的时间. 31 | static readonly DURATION_ADS = 200; 32 | //滚动持续时间 33 | static readonly SWIPER_TIME = 1500; 34 | //TAG日志 35 | static readonly TAG = 'Tag'; 36 | static readonly Article_LIST_WIDTH: string = '93.3%'; 37 | static readonly Article_LIST_MARGIN_LEFT: string = '3.3%'; 38 | static readonly Article_LIST_MARGIN_RIGHT: string = '3.3%'; 39 | static readonly Article_LIST_DIVIDER_STROKE_WIDTH: number = 0.5; 40 | static readonly ten_percent = '10%' 41 | static readonly twenty_percent = '20%' 42 | static readonly twenty_five_percent = '25%' 43 | static readonly thirty_percent = '30%' 44 | static readonly forth_percent = '40%' 45 | static readonly fifth_percent = '50%' 46 | static readonly fs_5 = 5 47 | static readonly fs_6 = 6 48 | static readonly fs_8 = 10 49 | static readonly fs_10 = 10 50 | static readonly fs_11 = 11 51 | static readonly fs_12 = 12 52 | static readonly fs_16 = 16 53 | static readonly fs_18 = 18 54 | static readonly SELECT_TEXT_FONT_SIZE = 20 55 | static readonly UN_SELECT_TEXT_FONT_SIZE = 16 56 | static readonly SQUARE_TABS_HEIGHT: string = '7.2%'; 57 | 58 | 59 | static readonly MeListData: MeListBean[] = [ 60 | { id: 1, name: '我的积分', img: $r('app.media.score') }, 61 | { id: 2, name: '我的分享', img: $r('app.media.share') }, 62 | { id: 3, name: '我的收藏', img: $r('app.media.collection') }, 63 | { id: 4, name: '阅读历史', img: $r('app.media.read_record') }, 64 | { id: 5, name: '关于作者', img: $r('app.media.about') }, 65 | { id: 6, name: '系统设置', img: $r('app.media.system') }, 66 | ] 67 | // Key-Value键值型的数据处理 68 | static preferences: any = null 69 | 70 | static storage: LocalStorage; 71 | 72 | } 73 | -------------------------------------------------------------------------------- /entry/src/main/ets/pages/Login.ets: -------------------------------------------------------------------------------- 1 | import HashMap from '@ohos.util.HashMap' 2 | import Prompt from '@system.prompt' 3 | import router from '@ohos.router' 4 | import { userLogin } from '../request/Login' 5 | import { preferences } from '../entryability/EntryAbility' 6 | import { Constants } from '../utils/Constants' 7 | 8 | @Entry 9 | @Component 10 | struct Login { 11 | @State acc: string = "" 12 | @State pwd: string = "" 13 | params: HashMap = new HashMap(); 14 | 15 | login() { 16 | this.params.set('username', this.acc) 17 | this.params.set('password', this.pwd) 18 | userLogin(this.params).then((data: any) => { 19 | if (data) { 20 | try { 21 | //用户id 22 | preferences.put("id", data.id) 23 | //用户名 24 | preferences.put("username", data.username) 25 | //昵称 26 | preferences.put("nickname", data.nickname) 27 | //等级 28 | preferences.put("coinCount", data.coinCount) 29 | //用户信息 30 | preferences.put("userinfo", JSON.stringify(data)) 31 | let promise = preferences.flush() 32 | promise.then(() => { 33 | console.log(Constants.TAG, "Succeeded in flushing."); 34 | }).catch((err) => { 35 | console.log(Constants.TAG, "Failed to flush. code =" + err.code + ", message =" + err.message); 36 | }) 37 | } catch (e) { 38 | e.message 39 | } 40 | Prompt.showToast({ message: '登录成功' }) 41 | router.back() 42 | } 43 | }).catch((err: string | Resource) => { 44 | Prompt.showToast({ message: err.toString() }) 45 | }) 46 | } 47 | 48 | build() { 49 | Navigation() { 50 | Flex({ 51 | direction: FlexDirection.Row, 52 | wrap: FlexWrap.Wrap, 53 | }) { 54 | Flex({ 55 | justifyContent: FlexAlign.SpaceBetween, 56 | alignItems: ItemAlign.Center 57 | }) { 58 | Text('账号:').width('20%') 59 | TextInput({ placeholder: '请输入账号' 60 | }).type(InputType.Normal).onChange((value) => { 61 | this.acc = value; 62 | }) 63 | } 64 | 65 | Flex({ 66 | justifyContent: FlexAlign.SpaceBetween, 67 | alignItems: ItemAlign.Center 68 | }) { 69 | Text('密码:').width('20%') 70 | TextInput({ 71 | placeholder: '请输入密码' 72 | }).type(InputType.Password) 73 | .onChange((value) => { 74 | this.pwd = value; 75 | }) 76 | }.margin({ top: 20 }) 77 | 78 | Button('登录').width('100%').margin({ top: 30 }) 79 | .onClick(() => { 80 | //点击 81 | this.login() 82 | }) 83 | } 84 | .padding(20) 85 | .width('100%') 86 | .height('100%') 87 | } 88 | .title('登录') 89 | .hideToolBar(false) 90 | .titleMode(NavigationTitleMode.Mini) 91 | } 92 | } -------------------------------------------------------------------------------- /entry/src/main/ets/component/MeComponent.ets: -------------------------------------------------------------------------------- 1 | import Prompt from '@system.prompt'; 2 | import router from '@ohos.router'; 3 | import { MeListBean } from '../model/MeListBean'; 4 | import { Constants } from '../utils/Constants'; 5 | import { preferences } from '../entryability/EntryAbility' 6 | import picker from '@ohos.file.picker'; 7 | 8 | @Component 9 | export struct Me { 10 | @State name: string = '' 11 | @State avatar: string[] = [] 12 | 13 | aboutToAppear() { 14 | let pf = preferences.get('username', ''); 15 | pf.then((data) => { 16 | this.name = data.toString() 17 | }).catch((err) => { 18 | console.log(Constants.TAG, err) 19 | }) 20 | } 21 | 22 | build() { 23 | Column() { 24 | Column() { 25 | Image(this.avatar.length > 0 ? this.avatar[0] : $r('app.media.ic_avatar')).width(80) 26 | .margin({ top: 60, bottom: 10 }) 27 | .borderRadius(100) 28 | .onClick(() => { 29 | //选择器使用 30 | let selectOptions = new picker.PhotoSelectOptions() 31 | //选择的类型 IMAGE_TYPE:图片 VIDEO_TYPE:视频 IMAGE_VIDEO_TYPE:所有 32 | selectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE 33 | selectOptions.maxSelectNumber = 1 34 | let photoView = new picker.PhotoViewPicker() 35 | photoView.select(selectOptions, (err, result) => { 36 | if (err) { 37 | console.log("err: " + err); 38 | return 39 | } 40 | this.avatar = [...result.photoUris] 41 | }) 42 | }) 43 | Text(this.name ? this.name : '去登录').fontSize(18).fontColor($r('app.color.font_color_white')) 44 | } 45 | .onClick(() => { 46 | if (this.name) return 47 | router.pushUrl({ 48 | url: 'pages/Login' 49 | }) 50 | }) 51 | .backgroundColor($r('app.color.launch_bg_color')) 52 | .width(Constants.FULL_PERCENT) 53 | .height(200) 54 | 55 | List() { 56 | ForEach(Constants.MeListData, (item: MeListBean, index) => { 57 | ListItem() { 58 | Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) { 59 | Row() { 60 | Image(item.img).width(28) 61 | Text(item.name).margin({ left: 10 }) 62 | } 63 | 64 | Image($r('app.media.right')).width(30) 65 | } 66 | } 67 | .padding({ left: 20, right: 20 }) 68 | .width(Constants.FULL_PERCENT) 69 | .height(55) 70 | .onClick(() => { 71 | Prompt.showToast({ message: '点击了' + item.name }) 72 | }) 73 | }) 74 | } 75 | .width(Constants.FULL_PERCENT) 76 | .height(Constants.FULL_PERCENT) 77 | .divider({ 78 | color: $r('app.color.line_color'), 79 | strokeWidth: Constants.Article_LIST_DIVIDER_STROKE_WIDTH, 80 | endMargin: Constants.Article_LIST_MARGIN_RIGHT 81 | }) 82 | } 83 | .height(Constants.FULL_PERCENT) 84 | } 85 | } -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/config/Filter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ClassFilter { 17 | constructor(suiteName, itName, params) { 18 | this.suiteName = suiteName; 19 | this.itName = itName; 20 | this.params = params; 21 | } 22 | 23 | filterSuite() { 24 | return !this.params.split(',').map(item => item.split('#')[0]).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 25 | } 26 | 27 | filterIt() { 28 | let classArray = this.params.split(',') || []; 29 | let suiteFilterResult = classArray.filter(item => !item.includes('#')).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 30 | let itFilterResult = classArray.filter(item => item.includes('#')).map(item => item == (this.suiteName + '#' + this.itName)).reduce((pre, cur) => pre || cur, false); 31 | return !(suiteFilterResult || itFilterResult); 32 | } 33 | } 34 | 35 | class NotClassFilter { 36 | constructor(suiteName, itName, params) { 37 | this.suiteName = suiteName; 38 | this.itName = itName; 39 | this.params = params; 40 | } 41 | 42 | filterSuite() { 43 | return this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 44 | } 45 | 46 | filterIt() { 47 | return this.params.split(',').some(item => item == (this.suiteName + '#' + this.itName)); 48 | } 49 | } 50 | 51 | class SuiteAndItNameFilter { 52 | constructor(suiteName, itName, params) { 53 | this.suiteName = suiteName; 54 | this.itName = itName; 55 | this.params = params; 56 | } 57 | 58 | filterSuite() { 59 | return !this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 60 | } 61 | 62 | filterIt() { 63 | return !this.params.split(',').map(item => item == this.itName).reduce((pre, cur) => pre || cur, false); 64 | } 65 | } 66 | 67 | 68 | class TestTypesFilter { 69 | constructor(suiteName, itName, fi, params) { 70 | this.suiteName = suiteName; 71 | this.itName = itName; 72 | this.params = params; 73 | this.fi = fi; 74 | } 75 | 76 | filterIt() { 77 | return !((this.params === (this.fi & this.params)) || this.fi === 0); 78 | } 79 | } 80 | 81 | export {ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter}; 82 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/config/Filter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ClassFilter { 17 | constructor(suiteName, itName, params) { 18 | this.suiteName = suiteName; 19 | this.itName = itName; 20 | this.params = params; 21 | } 22 | 23 | filterSuite() { 24 | return !this.params.split(',').map(item => item.split('#')[0]).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 25 | } 26 | 27 | filterIt() { 28 | let classArray = this.params.split(',') || []; 29 | let suiteFilterResult = classArray.filter(item => !item.includes('#')).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 30 | let itFilterResult = classArray.filter(item => item.includes('#')).map(item => item == (this.suiteName + '#' + this.itName)).reduce((pre, cur) => pre || cur, false); 31 | return !(suiteFilterResult || itFilterResult); 32 | } 33 | } 34 | 35 | class NotClassFilter { 36 | constructor(suiteName, itName, params) { 37 | this.suiteName = suiteName; 38 | this.itName = itName; 39 | this.params = params; 40 | } 41 | 42 | filterSuite() { 43 | return this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 44 | } 45 | 46 | filterIt() { 47 | return this.params.split(',').some(item => item == (this.suiteName + '#' + this.itName)); 48 | } 49 | } 50 | 51 | class SuiteAndItNameFilter { 52 | constructor(suiteName, itName, params) { 53 | this.suiteName = suiteName; 54 | this.itName = itName; 55 | this.params = params; 56 | } 57 | 58 | filterSuite() { 59 | return !this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 60 | } 61 | 62 | filterIt() { 63 | return !this.params.split(',').map(item => item == this.itName).reduce((pre, cur) => pre || cur, false); 64 | } 65 | } 66 | 67 | 68 | class TestTypesFilter { 69 | constructor(suiteName, itName, fi, params) { 70 | this.suiteName = suiteName; 71 | this.itName = itName; 72 | this.params = params; 73 | this.fi = fi; 74 | } 75 | 76 | filterIt() { 77 | return !((this.params === (this.fi & this.params)) || this.fi === 0); 78 | } 79 | } 80 | 81 | export {ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter}; 82 | -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/config/Filter.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021-2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class ClassFilter { 17 | constructor(suiteName, itName, params) { 18 | this.suiteName = suiteName; 19 | this.itName = itName; 20 | this.params = params; 21 | } 22 | 23 | filterSuite() { 24 | return !this.params.split(',').map(item => item.split('#')[0]).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 25 | } 26 | 27 | filterIt() { 28 | let classArray = this.params.split(',') || []; 29 | let suiteFilterResult = classArray.filter(item => !item.includes('#')).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 30 | let itFilterResult = classArray.filter(item => item.includes('#')).map(item => item == (this.suiteName + '#' + this.itName)).reduce((pre, cur) => pre || cur, false); 31 | return !(suiteFilterResult || itFilterResult); 32 | } 33 | } 34 | 35 | class NotClassFilter { 36 | constructor(suiteName, itName, params) { 37 | this.suiteName = suiteName; 38 | this.itName = itName; 39 | this.params = params; 40 | } 41 | 42 | filterSuite() { 43 | return this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 44 | } 45 | 46 | filterIt() { 47 | return this.params.split(',').some(item => item == (this.suiteName + '#' + this.itName)); 48 | } 49 | } 50 | 51 | class SuiteAndItNameFilter { 52 | constructor(suiteName, itName, params) { 53 | this.suiteName = suiteName; 54 | this.itName = itName; 55 | this.params = params; 56 | } 57 | 58 | filterSuite() { 59 | return !this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); 60 | } 61 | 62 | filterIt() { 63 | return !this.params.split(',').map(item => item == this.itName).reduce((pre, cur) => pre || cur, false); 64 | } 65 | } 66 | 67 | 68 | class TestTypesFilter { 69 | constructor(suiteName, itName, fi, params) { 70 | this.suiteName = suiteName; 71 | this.itName = itName; 72 | this.params = params; 73 | this.fi = fi; 74 | } 75 | 76 | filterIt() { 77 | return !((this.params === (this.fi & this.params)) || this.fi === 0); 78 | } 79 | } 80 | 81 | export {ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter}; 82 | -------------------------------------------------------------------------------- /oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SysTestKit { 17 | 18 | static delegator = null; 19 | static systemTime = null; 20 | 21 | constructor() { 22 | this.id = 'sysTestKit'; 23 | this.index = 0; 24 | } 25 | 26 | static actionStart(tag) { 27 | console.info(JSON.stringify(tag)); 28 | var message = '\n' + 'OHOS_REPORT_ACTIONSTART: ' + JSON.stringify(tag) + '\n'; 29 | SysTestKit.print(message); 30 | console.info(tag + ' actionStart print success'); 31 | } 32 | 33 | static actionEnd(tag) { 34 | console.info(JSON.stringify(tag)); 35 | var message = '\n' + 'OHOS_REPORT_ACTIONEND: ' + JSON.stringify(tag) + '\n'; 36 | SysTestKit.print(message); 37 | console.info(tag + ' actionEnd print success'); 38 | } 39 | 40 | static async existKeyword(keyword, timeout) { 41 | let reg = new RegExp(/^[a-zA-Z0-9]{1,}$/) 42 | if (!reg.test(keyword)) { 43 | throw new Error('keyword must contain more than one string, and only letters and numbers are supported.') 44 | } 45 | timeout = timeout || 4; 46 | 47 | let searchResult = false; 48 | let cmd = 'hilog -x | grep -i \'' + keyword + '\' | wc -l'; 49 | await executePromise(cmd, timeout).then((data) => { 50 | searchResult = data; 51 | }); 52 | return searchResult; 53 | } 54 | static async print(message) { 55 | if ('printSync' in SysTestKit.delegator) { 56 | console.debug(`printSync called ...`); 57 | SysTestKit.delegator.printSync(message); 58 | } else { 59 | await SysTestKit.delegator.print(message); 60 | } 61 | } 62 | 63 | static async getRealTime() { 64 | let currentTime = new Date().getTime(); 65 | if (SysTestKit.systemTime !== null && SysTestKit.systemTime !== undefined) { 66 | await SysTestKit.systemTime.getRealTime().then((time) => { 67 | console.info(`systemTime.getRealTime success data: ${JSON.stringify(time)}`); 68 | currentTime = time; 69 | }).catch((error) => { 70 | console.error(`failed to systemTime.getRealTime because ${JSON.stringify(error)}`); 71 | }); 72 | } 73 | return currentTime; 74 | } 75 | } 76 | 77 | function executePromise(cmd, timeout) { 78 | return new Promise((resolve, reject) => { 79 | SysTestKit.delegator.executeShellCommand(cmd, timeout, 80 | (error, data) => { 81 | console.info('existKeyword CallBack: err : ' + JSON.stringify(error)); 82 | console.info('existKeyword CallBack: data : ' + JSON.stringify(data)); 83 | resolve(parseInt(data.stdResult) > 3 ? true : false); 84 | }); 85 | }); 86 | } 87 | 88 | export default SysTestKit; -------------------------------------------------------------------------------- /oh_modules/.ohpm/oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SysTestKit { 17 | 18 | static delegator = null; 19 | static systemTime = null; 20 | 21 | constructor() { 22 | this.id = 'sysTestKit'; 23 | this.index = 0; 24 | } 25 | 26 | static actionStart(tag) { 27 | console.info(JSON.stringify(tag)); 28 | var message = '\n' + 'OHOS_REPORT_ACTIONSTART: ' + JSON.stringify(tag) + '\n'; 29 | SysTestKit.print(message); 30 | console.info(tag + ' actionStart print success'); 31 | } 32 | 33 | static actionEnd(tag) { 34 | console.info(JSON.stringify(tag)); 35 | var message = '\n' + 'OHOS_REPORT_ACTIONEND: ' + JSON.stringify(tag) + '\n'; 36 | SysTestKit.print(message); 37 | console.info(tag + ' actionEnd print success'); 38 | } 39 | 40 | static async existKeyword(keyword, timeout) { 41 | let reg = new RegExp(/^[a-zA-Z0-9]{1,}$/) 42 | if (!reg.test(keyword)) { 43 | throw new Error('keyword must contain more than one string, and only letters and numbers are supported.') 44 | } 45 | timeout = timeout || 4; 46 | 47 | let searchResult = false; 48 | let cmd = 'hilog -x | grep -i \'' + keyword + '\' | wc -l'; 49 | await executePromise(cmd, timeout).then((data) => { 50 | searchResult = data; 51 | }); 52 | return searchResult; 53 | } 54 | static async print(message) { 55 | if ('printSync' in SysTestKit.delegator) { 56 | console.debug(`printSync called ...`); 57 | SysTestKit.delegator.printSync(message); 58 | } else { 59 | await SysTestKit.delegator.print(message); 60 | } 61 | } 62 | 63 | static async getRealTime() { 64 | let currentTime = new Date().getTime(); 65 | if (SysTestKit.systemTime !== null && SysTestKit.systemTime !== undefined) { 66 | await SysTestKit.systemTime.getRealTime().then((time) => { 67 | console.info(`systemTime.getRealTime success data: ${JSON.stringify(time)}`); 68 | currentTime = time; 69 | }).catch((error) => { 70 | console.error(`failed to systemTime.getRealTime because ${JSON.stringify(error)}`); 71 | }); 72 | } 73 | return currentTime; 74 | } 75 | } 76 | 77 | function executePromise(cmd, timeout) { 78 | return new Promise((resolve, reject) => { 79 | SysTestKit.delegator.executeShellCommand(cmd, timeout, 80 | (error, data) => { 81 | console.info('existKeyword CallBack: err : ' + JSON.stringify(error)); 82 | console.info('existKeyword CallBack: data : ' + JSON.stringify(data)); 83 | resolve(parseInt(data.stdResult) > 3 ? true : false); 84 | }); 85 | }); 86 | } 87 | 88 | export default SysTestKit; -------------------------------------------------------------------------------- /oh_modules/.ohpm/@ohos+hypium@1.0.6/oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2022 Huawei Device Co., Ltd. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | * 7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | */ 15 | 16 | class SysTestKit { 17 | 18 | static delegator = null; 19 | static systemTime = null; 20 | 21 | constructor() { 22 | this.id = 'sysTestKit'; 23 | this.index = 0; 24 | } 25 | 26 | static actionStart(tag) { 27 | console.info(JSON.stringify(tag)); 28 | var message = '\n' + 'OHOS_REPORT_ACTIONSTART: ' + JSON.stringify(tag) + '\n'; 29 | SysTestKit.print(message); 30 | console.info(tag + ' actionStart print success'); 31 | } 32 | 33 | static actionEnd(tag) { 34 | console.info(JSON.stringify(tag)); 35 | var message = '\n' + 'OHOS_REPORT_ACTIONEND: ' + JSON.stringify(tag) + '\n'; 36 | SysTestKit.print(message); 37 | console.info(tag + ' actionEnd print success'); 38 | } 39 | 40 | static async existKeyword(keyword, timeout) { 41 | let reg = new RegExp(/^[a-zA-Z0-9]{1,}$/) 42 | if (!reg.test(keyword)) { 43 | throw new Error('keyword must contain more than one string, and only letters and numbers are supported.') 44 | } 45 | timeout = timeout || 4; 46 | 47 | let searchResult = false; 48 | let cmd = 'hilog -x | grep -i \'' + keyword + '\' | wc -l'; 49 | await executePromise(cmd, timeout).then((data) => { 50 | searchResult = data; 51 | }); 52 | return searchResult; 53 | } 54 | static async print(message) { 55 | if ('printSync' in SysTestKit.delegator) { 56 | console.debug(`printSync called ...`); 57 | SysTestKit.delegator.printSync(message); 58 | } else { 59 | await SysTestKit.delegator.print(message); 60 | } 61 | } 62 | 63 | static async getRealTime() { 64 | let currentTime = new Date().getTime(); 65 | if (SysTestKit.systemTime !== null && SysTestKit.systemTime !== undefined) { 66 | await SysTestKit.systemTime.getRealTime().then((time) => { 67 | console.info(`systemTime.getRealTime success data: ${JSON.stringify(time)}`); 68 | currentTime = time; 69 | }).catch((error) => { 70 | console.error(`failed to systemTime.getRealTime because ${JSON.stringify(error)}`); 71 | }); 72 | } 73 | return currentTime; 74 | } 75 | } 76 | 77 | function executePromise(cmd, timeout) { 78 | return new Promise((resolve, reject) => { 79 | SysTestKit.delegator.executeShellCommand(cmd, timeout, 80 | (error, data) => { 81 | console.info('existKeyword CallBack: err : ' + JSON.stringify(error)); 82 | console.info('existKeyword CallBack: data : ' + JSON.stringify(data)); 83 | resolve(parseInt(data.stdResult) > 3 ? true : false); 84 | }); 85 | }); 86 | } 87 | 88 | export default SysTestKit; --------------------------------------------------------------------------------