diff --git a/arkui/BUILD.gn b/arkui/BUILD.gn index 32f916b04e97c443ba6ea74cbc61265143fd71bf..989171313812e09307342b203cbc66788a2fdec2 100644 --- a/arkui/BUILD.gn +++ b/arkui/BUILD.gn @@ -28,6 +28,7 @@ group("arkui") { "ace_ets_third_test:ActsAceEtsThirdTest", "ace_ets_web_dev:ActsAceWebDevTest", "ace_ets_web_dev_two:ActsAceWebDevTwoTest", + "ace_ets_web_dev_three:ActsAceWebDevThreeTest", "ace_ets_xcomponent:ActsAceXComponentEtsTest", "ace_js_attribute_api:ActsAceJsApiTest", "ace_napi_test:ActsAceNapiEtsTest", diff --git a/arkui/ace_ets_web_dev_three/AppScope/app.json b/arkui/ace_ets_web_dev_three/AppScope/app.json new file mode 100644 index 0000000000000000000000000000000000000000..52fd9651408ad407e3020e35e240170115e1977e --- /dev/null +++ b/arkui/ace_ets_web_dev_three/AppScope/app.json @@ -0,0 +1,21 @@ +{ + "app": { + "bundleName": "com.open.harmony.acewebthreetest", + "vendor": "huawei", + "versionCode": 1000000, + "versionName": "1.0.0", + "debug": false, + "icon": "$media:icon", + "label": "$string:app_name", + "description": "$string:description_application", + "distributedNotificationEnabled": true, + "keepAlive": true, + "singleUser": true, + "minAPIVersion": 9, + "targetAPIVersion": 9, + "car": { + "apiCompatibleVersion": 9, + "singleUser": false + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/AppScope/resources/base/element/string.json b/arkui/ace_ets_web_dev_three/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ee69f9a861d9dc269ed6638735d52674583498e1 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string":[ + { + "name":"app_name", + "value":"ohosProject" + } + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/AppScope/resources/base/media/app_icon.png b/arkui/ace_ets_web_dev_three/AppScope/resources/base/media/app_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/arkui/ace_ets_web_dev_three/AppScope/resources/base/media/app_icon.png differ diff --git a/arkui/ace_ets_web_dev_three/BUILD.gn b/arkui/ace_ets_web_dev_three/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..23be4f01df0c3ed1ca3ecd396251f4257ef8ce60 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/BUILD.gn @@ -0,0 +1,41 @@ +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//test/xts/tools/build/suite.gni") + +ohos_js_hap_suite("ActsAceWebDevThreeTest") { + hap_profile = "entry/src/main/module.json" + js_build_mode = "debug" + deps = [ + ":ace_ets_web_dev_js_assets", + ":ace_ets_web_dev_resources", + ] + ets2abc = true + certificate_profile = "signature/openharmony_sx.p7b" + hap_name = "ActsAceWebDevThreeTest" +} + +ohos_app_scope("ace_ets_web_dev_app_profile") { + app_profile = "AppScope/app.json" + sources = [ "AppScope/resources" ] +} + +ohos_js_assets("ace_ets_web_dev_js_assets") { + source_dir = "entry/src/main/ets" +} + +ohos_resources("ace_ets_web_dev_resources") { + sources = [ "entry/src/main/resources" ] + deps = [ ":ace_ets_web_dev_app_profile" ] + hap_profile = "entry/src/main/module.json" +} diff --git a/arkui/ace_ets_web_dev_three/Test.json b/arkui/ace_ets_web_dev_three/Test.json new file mode 100644 index 0000000000000000000000000000000000000000..bd2f19203a23a4bdc76acf6b1b5135c861e3568b --- /dev/null +++ b/arkui/ace_ets_web_dev_three/Test.json @@ -0,0 +1,18 @@ +{ + "description": "Configuration for hjunit demo Tests", + "driver": { + "type": "OHJSUnitTest", + "test-timeout": "600000", + "bundle-name": "com.open.harmony.acewebthreetest", + "module-name": "phone", + "shell-timeout": "600000", + "testcase-timeout": 70000 + }, + "kits": [{ + "test-file-name": [ + "ActsAceWebDevThreeTest.hap" + ], + "type": "AppInstallKit", + "cleanup-apps": true + }] +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/Application/AbilityStage.ts b/arkui/ace_ets_web_dev_three/entry/src/main/ets/Application/AbilityStage.ts new file mode 100644 index 0000000000000000000000000000000000000000..e3fdadfebeeeb676df2ce8f78f4b59e26fae9cf0 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/Application/AbilityStage.ts @@ -0,0 +1,9 @@ +import AbilityStage from "@ohos.application.AbilityStage" + +export default class MyAbilityStage extends AbilityStage { + onCreate() { + console.log("[Demo] MyAbilityStage onCreate") + globalThis.stageOnCreateRun = 1; + globalThis.stageContext = this.context; + } +} diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/MainAbility.ts b/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/MainAbility.ts new file mode 100644 index 0000000000000000000000000000000000000000..59523bc6f264d3bd1e38c03be90358e12f7f5c28 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/MainAbility.ts @@ -0,0 +1,37 @@ +import Ability from '@ohos.application.Ability' + +export default class MainAbility extends Ability { + onCreate(want,launchParam){ + // Ability is creating, initialize resources for this ability + console.log("[Demo] MainAbility onCreate") + globalThis.abilityWant = want; + } + + onDestroy() { + // Ability is destroying, release resources for this ability + console.log("[Demo] MainAbility onDestroy") + } + + onWindowStageCreate(windowStage) { + // Main window is created, set main page for this ability + console.log("[Demo] MainAbility onWindowStageCreate windowStage="+ windowStage) + globalThis.windowStage = windowStage + globalThis.abilityContext = this.context + windowStage.setUIContent(this.context, "MainAbility/pages/web", null) + } + + onWindowStageDestroy() { + //Main window is destroyed, release UI related resources + console.log("[Demo] MainAbility onWindowStageDestroy") + } + + onForeground() { + // Ability has brought to foreground + console.log("[Demo] MainAbility onForeground") + } + + onBackground() { + // Ability has back to background + console.log("[Demo] MainAbility onBackground") + } +}; diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets b/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets new file mode 100644 index 0000000000000000000000000000000000000000..ee9332cbcc80d9c9753b66a269a666f967858d2b --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/MainAbility/pages/web.ets @@ -0,0 +1,244 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import events_emitter from '@ohos.events.emitter'; +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../../test/List.test'; +import Utils from '../../test/Utils'; +import web_webview from '@ohos.web.webview'; + +let loadedUrl; +@Entry +@Component +struct Index { + controller:WebController = new WebController() + responseweb: WebResourceResponse = new WebResourceResponse() + @State str:string="emitOnInterceptRequest" + @State text:string="" + @State num:number=0 + @State textRatio:number=100 + heads:Header[] = new Array(); + @State webdata: string = "\n" + + "\n"+ + "\n"+ + "intercept test\n"+ + "\n"+ + "\n"+ + "

intercept test

\n"+ + "\n"+ + "" + onPageShow(){ + let valueChangeEvent={ + eventId:10, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(valueChangeEvent,this.valueChangeCallBack) + } + private valueChangeCallBack=(eventData)=>{ + console.info("web page valueChangeCallBack"); + if(eventData != null){ + console.info("valueChangeCallBack:"+ JSON.stringify(eventData)); + if(eventData.data.ACTION != null){ + this.str = eventData.data.ACTION; + } + } + } + aboutToAppear(){ + let abilityDelegator: any + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + let abilityDelegatorArguments: any + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + console.info('start run testcase!!!') + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) + } + build(){ + Column(){ + Web({src:"www.example.com",controller:this.controller}) + .webDebuggingAccess(true) + .databaseAccess(true) + .textZoomRatio(this.textRatio) + .mediaPlayGestureAccess(true) + .onGeolocationHide(() => { + console.log("geoloc hide") + }) + .onSearchResultReceive(ret => { + console.log("on search result receive:" + "[cur]" + ret.activeMatchOrdinal + + "[total]" + ret.numberOfMatches + "[isDone]"+ ret.isDoneCounting); + }) + .onGeolocationShow((event) => { + AlertDialog.show({ + title: 'title', + message: 'text', + confirm: { + value: 'onConfirm', + action: () => { + event.geolocation.invoke(event.origin, true, true); + } + }, + cancel: () => { + event.geolocation.invoke(event.origin, false, true); + } + }) + }) + .onPermissionRequest((event) => { + AlertDialog.show({ + title: 'title', + message: 'text', + primaryButton: { + value: 'deny', + action: () => { + event.request.deny(); + } + }, + secondaryButton: { + value: 'onConfirm', + action: () => { + event.request.grant(event.request.getAccessibleResource()); + } + }, + cancel: () => { + event.request.deny(); + } + }) + event.request.getOrigin(); + }) + .onInterceptRequest((event) => { + console.log('url:' + event.request.getRequestUrl()); + var head1:Header = { + headerKey:"Connection", + headerValue:"keep-alive" + } + var head2:Header = { + headerKey:"Cache-Control", + headerValue:"no-cache" + } + var length = this.heads.push(head1); + length = this.heads.push(head2); + this.responseweb.setResponseHeader(this.heads); + this.responseweb.setResponseData(this.webdata); + this.responseweb.setResponseEncoding('utf-8'); + this.responseweb.setResponseMimeType('text/html'); + this.responseweb.setResponseCode(404); + this.responseweb.setReasonMessage('OK'); + return this.responseweb; + }) + .onHttpErrorReceive((event) => { + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getResponseData:' + event.response.getResponseData()); + console.log('getResponseEncoding:' + event.response.getResponseEncoding()); + console.log('getResponseMimeType:' + event.response.getResponseMimeType()); + console.log('getResponseCode:' + event.response.getResponseCode()); + console.log('getReasonMessage:' + event.response.getReasonMessage()); + let result = event.request.getRequestHeader(); + console.log('The request header result size is ' + result.length); + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + let resph = event.response.getResponseHeader(); + console.log('The response header result size is ' + resph.length); + for (let i of resph) { + console.log('The response header key is : ' + i.headerKey + ' , value is : ' + i.headerValue); + } + setTimeout(()=>{ + let result2 = event.response.getResponseCode() + Utils.emitEvent(result2.toString(),452) + },3000) + setTimeout(()=>{ + let result3 = event.response.getReasonMessage() + Utils.emitEvent(result3.toString(),453) + },3000) + setTimeout(()=>{ + let result4 = event.request.isMainFrame() + Utils.emitEvent(result4.toString(),454) + },3000) + setTimeout(()=>{ + let result5 = event.request.isRedirect() + Utils.emitEvent(result5.toString(),455) + },3000) + setTimeout(()=>{ + let result6 = event.request.isRequestGesture() + Utils.emitEvent(result6.toString(),456) + },3000) + setTimeout(()=>{ + Utils.emitEvent(resph[0].headerKey.toString(),457) + },3000) + }) + .onErrorReceive((event) => { + console.log('getErrorInfo:' + event.error.getErrorInfo()); + console.log('getErrorCode:' + event.error.getErrorCode()); + console.log('url:' + event.request.getRequestUrl()); + console.log('isMainFrame:' + event.request.isMainFrame()); + console.log('isRedirect:' + event.request.isRedirect()); + console.log('isRequestGesture:' + event.request.isRequestGesture()); + console.log('getRequestHeader_headerKey:' + event.request.getRequestHeader().toString()); + let result = event.request.getRequestHeader(); + console.log('The request header result size is ' + result.length); + for (let i of result) { + console.log('The request header key is : ' + i.headerKey + ', value is : ' + i.headerValue); + } + }) + Row(){ + Button("web click").key('webcomponent').onClick(async ()=>{ + console.info("key==>"+this.str) + switch(this.str){ + case "emitOnInterceptRequest":{ + var str1= MessageLevel.Debug + MessageLevel.Error + MessageLevel.Info + MessageLevel.Log + MessageLevel.Warn + var str2= MixedMode.All+MixedMode.Compatible + var str3= HitTestType.EditText+HitTestType.Email+HitTestType.HttpAnchor +HitTestType.HttpAnchorImg+HitTestType.Img+HitTestType.Map+HitTestType.Phone+HitTestType.Unknown + var str4= CacheMode.None + CacheMode.Online + var str5= RenderExitReason.ProcessAbnormalTermination + RenderExitReason.ProcessWasKilled + RenderExitReason.ProcessOom +RenderExitReason.ProcessExitUnknown + var str7= FileSelectorMode.FileOpenMode+FileSelectorMode.FileOpenFolderMode+FileSelectorMode.FileSaveMode + var str8= ProtectedResourceType.MidiSysex + setTimeout(()=>{ + let result = this.controller.getTitle() + Utils.emitEvent(result,450) + },3000) + break; + } + case "emitGetRequestHeader":{ + this.controller.refresh() + break; + } + case "emitGetErrorCode":{ + this.controller.refresh() + break; + } + case "emitIsMainFrame":{ + this.controller.refresh() + break; + } + case "emitIsRedirect":{ + this.controller.refresh() + break; + } + case "emitIsRequestGesture":{ + this.controller.refresh() + break; + } + case "emitGetReasonMessage":{ + this.controller.refresh() + break; + } + default: + console.info("can not match case") + } + }) + } + } + } +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/arkui/ace_ets_web_dev_three/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..a4ee2f1652b3d04ce83ece64ef70f8dfa62a2dc8 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import TestRunner from '@ohos.application.testRunner' +import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' + +var abilityDelegator = undefined +var abilityDelegatorArguments = undefined + +function translateParamsToString(parameters) { + const keySet = new Set([ + '-s class', '-s notClass', '-s suite', '-s it', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun' + ]) + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams = `${targetParams} ${key} ${parameters[key]}` + } + } + return targetParams.trim() +} + +async function onAbilityCreateCallback() { + console.log("onAbilityCreateCallback"); +} + +async function addAbilityMonitorCallback(err: any) { + console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) +} + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + console.info("OpenHarmonyTestRunner OnPrepare ") + } + + async onRun() { + console.log('OpenHarmonyTestRunner onRun run') + abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() + abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() + var testAbilityName = abilityDelegatorArguments.bundleName + '.MainAbility' + let lMonitor = { + abilityName: testAbilityName, + onAbilityCreate: onAbilityCreateCallback, + }; + abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) + var cmd = 'aa start -d 0 -a com.example.myapplication.MainAbility' + ' -b ' + abilityDelegatorArguments.bundleName + cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) + var debug = abilityDelegatorArguments.parameters["-D"] + if (debug == 'true') + { + cmd += ' -D' + } + console.info('cmd : '+cmd) + abilityDelegator.executeShellCommand(cmd, + (err: any, d: any) => { + console.info('executeShellCommand : err : ' + JSON.stringify(err)); + console.info('executeShellCommand : data : ' + d.stdResult); + console.info('executeShellCommand : data : ' + d.exitCode); + }) + console.info('OpenHarmonyTestRunner onRun end') + } +}; \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/List.test.ets b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..079023dd24ba05f62f21dacf79f7077bb41b6e0d --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/List.test.ets @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2021 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import webJsunit from './WebJsunit.test' + +export default function testsuite() { + webJsunit() +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/Utils.ets b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/Utils.ets new file mode 100644 index 0000000000000000000000000000000000000000..1a90ba6aedd9cd4c5662f10bd0f033f6136cb61a --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/Utils.ets @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import events_emitter from '@ohos.events.emitter'; +import { expect } from "@ohos/hypium"; +export default class Utils { + static sleep(time){ + return new Promise((resolve,reject)=>{ + setTimeout(()=>{ + resolve("ok") + },time) + }).then(()=>{ + console.info(`sleep ${time} over...`) + }) + } + static registerEvent(testCaseName,expectedValue,eventId,done){ + console.info(`[${testCaseName}] START`); + try{ + let callBack=(backData)=>{ + console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); + expect(backData.data.ACTION).assertEqual(expectedValue); + console.info(`[${testCaseName}] END`); + done() + } + let innerEvent = { + eventId:eventId, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(innerEvent,callBack) + }catch(err){ + console.info(`[${testCaseName}] err:`+JSON.stringify(err)); + } + } + static emitEvent(actualValue,eventId){ + try { + let backData = { + data: { + "ACTION": actualValue + } + } + let backEvent = { + eventId:eventId, + priority:events_emitter.EventPriority.LOW + } + console.info("webFlag start to emit action state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("webFlag emit action state err: " + JSON.stringify(err)); + } + } + static registerEventTwo(testCaseName,eventId,done){ + console.info(`[${testCaseName}] START`); + try{ + let callBack=(backData)=>{ + console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); + expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100); + expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100)); + console.info(`[${testCaseName}] END`); + done() + } + let innerEvent = { + eventId:eventId, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(innerEvent,callBack) + }catch(err){ + console.info(`[${testCaseName}] err:`+JSON.stringify(err)); + } + } + static emitEventTwo(expectedValue,actualValue,eventId){ + try { + let backData = { + data: { + "expectedValue":expectedValue, + "actualValue":actualValue + } + } + let backEvent = { + eventId:eventId, + priority:events_emitter.EventPriority.LOW + } + console.info("webFlag start to emit action state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("webFlag emit action state err: " + JSON.stringify(err)); + } + } + static registerContainEvent(testCaseName,expectedValue,eventId,done){ + console.info(`[${testCaseName}] START`); + try{ + let callBack=(backData)=>{ + console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); + expect(backData.data.ACTION).assertContain(expectedValue); + console.info(`[${testCaseName}] END`); + done() + } + let innerEvent = { + eventId:eventId, + priority:events_emitter.EventPriority.LOW + } + events_emitter.on(innerEvent,callBack) + }catch(err){ + console.info(`[${testCaseName}] err:`+JSON.stringify(err)); + } + } + static commitKey(emitKey){ + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + } +} diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..3e3e2501bd31d0def535c3be70c0453da323743d --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/ets/test/WebJsunit.test.ets @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// @ts-nocheck +import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium"; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +let emitKey = "emitOnInterceptRequest"; +export default function webJsunit() { + describe('ActsAceWebDevTest', function () { + beforeEach(async function (done) { + await Utils.sleep(2000); + console.info("web beforeEach start"); + done(); + }) + afterEach(async function (done) { + console.info("web afterEach start:"+emitKey); + try { + let backData = { + data: { + "ACTION": emitKey + } + } + let backEvent = { + eventId:10, + priority:events_emitter.EventPriority.LOW + } + console.info("start send emitKey"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit emitKey err: " + JSON.stringify(err)); + } + await Utils.sleep(2000); + done(); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_066 + *tc.name onInterceptRequest + *tc.desic Save current page + */ + it('onInterceptRequest',0,async function(done){ + emitKey="emitGetReasonMessage"; + Utils.registerContainEvent("onInterceptRequest","intercept test",450,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_067 + *tc.name getReasonMessage + *tc.desic allow specific url to access the geolocation + */ + it('getReasonMessage',0,async function(done){ + emitKey="emitGetErrorCode"; + Utils.registerEvent("getReasonMessage","OK",453,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_069 + *tc.name getErrorCode + *tc.desic delete all restored geolocation + */ + it('getResponseCode',0,async function(done){ + emitKey="emitIsMainFrame"; + Utils.registerEvent("getResponseCode","404",452,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_071 + *tc.name isMainFrame + *tc.desic return whether the cookie is allowed + */ + it('isMainFrame',0,async function(done){ + emitKey="emitIsRedirect"; + Utils.registerEvent("isMainFrame","true",454,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_072 + *tc.name isRedirect + *tc.desic return whether the third party cookie is allowed + */ + it('isRedirect',0,async function(done){ + emitKey="emitIsRequestGesture"; + Utils.registerEvent("isRedirect","false",455,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_073 + *tc.name isRequestGesture + *tc.desic return whether the third party cookie is allowed + */ + it('isRequestGesture',0,async function(done){ + emitKey="emitGetRequestHeader"; + Utils.registerEvent("isRequestGesture","false",456,done); + sendEventByKey('webcomponent',10,''); + }) + /* + *tc.number SUB_ACE_BASIC_ETS_API_074 + *tc.name isRequestGesture + *tc.desic return whether the third party cookie is allowed + */ + it('getRequestHeader',0,async function(done){ + emitKey="emitGetRequestHeader"; + Utils.registerEvent("getRequestHeader","Accept",457,done); + sendEventByKey('webcomponent',10,''); + }) + }) +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/module.json b/arkui/ace_ets_web_dev_three/entry/src/main/module.json new file mode 100644 index 0000000000000000000000000000000000000000..1caeca096d756373af7eff5cea74a02a2c054cd0 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/module.json @@ -0,0 +1,41 @@ +{ + "module": { + "name": "phone", + "type": "entry", + "srcEntrance": "./ets/Application/AbilityStage.ts", + "description": "$string:phone_entry_dsc", + "mainElement": "MainAbility", + "deviceTypes": [ + "phone" + ], + "deliveryWithInstall": true, + "installationFree": false, + "uiSyntax": "ets", + "pages": "$profile:main_pages", + "abilities": [{ + "name": "com.example.myapplication.MainAbility", + "srcEntrance": "./ets/MainAbility/MainAbility.ts", + "description": "$string:phone_entry_main", + "icon": "$media:icon", + "label": "$string:entry_label", + "visible": true, + "orientation": "portrait", + "skills": [{ + "actions": [ + "action.system.home" + ], + "entities": [ + "entity.system.home" + ] + }] + }], + "requestPermissions": [ + { + "name": "ohos.permission.LOCATION" + }, + { + "name": "ohos.permission.INTERNET" + } + ] + } +} diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/element/string.json b/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..2977b612ec4595b13eaaffe3e8fc578e83c42d48 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/element/string.json @@ -0,0 +1,32 @@ +{ + "string": [ + { + "name": "phone_entry_dsc", + "value": "i am an entry for phone" + }, + { + "name": "phone_entry_main", + "value": "the phone entry ability" + }, + { + "name": "entry_label", + "value": "ActsContextTest" + }, + { + "name": "form_description", + "value": "my form" + }, + { + "name": "serviceability_description", + "value": "my whether" + }, + { + "name": "description_application", + "value": "demo for test" + }, + { + "name": "app_name", + "value": "Demo" + } + ] +} diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/media/icon.png b/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/media/icon.png differ diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/profile/main_pages.json b/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..accbf272408dce05ff15f78a1adf077bafc62174 --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "MainAbility/pages/web" + ] +} \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/extra.html b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/extra.html new file mode 100644 index 0000000000000000000000000000000000000000..cefc3262907470c309ab76c57114eaf91ff95a9f --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/extra.html @@ -0,0 +1,7 @@ + + + +
+

This is a link

+ + \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/icon.png b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..474a55588fd7216113dd42073aadf254d4dba023 Binary files /dev/null and b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/icon.png differ diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.html b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.html new file mode 100644 index 0000000000000000000000000000000000000000..bd56a8209695b0732a480ccf0b5ed2eced1ae3ab --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/index.html @@ -0,0 +1,70 @@ + + + + + + + index + + + +
首页
+
+ 打开rawfile文件 + icon + + + diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/second.html b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/second.html new file mode 100644 index 0000000000000000000000000000000000000000..3017554b2ab0ca8725fd3acf1711c6d9b6aab02b --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/second.html @@ -0,0 +1,12 @@ + + + + + + + second + + +
second pages
+ + \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/webstorage.html b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/webstorage.html new file mode 100644 index 0000000000000000000000000000000000000000..397ebc4118ebf6a48c31c9a60174b9cebdfed13a --- /dev/null +++ b/arkui/ace_ets_web_dev_three/entry/src/main/resources/rawfile/webstorage.html @@ -0,0 +1,39 @@ + + + + + + + + + +
状态信息
+ + + \ No newline at end of file diff --git a/arkui/ace_ets_web_dev_three/signature/openharmony_sx.p7b b/arkui/ace_ets_web_dev_three/signature/openharmony_sx.p7b new file mode 100644 index 0000000000000000000000000000000000000000..bd2ec963919e78b14f7b0a95673312126655f454 Binary files /dev/null and b/arkui/ace_ets_web_dev_three/signature/openharmony_sx.p7b differ