提交 0db4e38f 编写于 作者: Y yupeng

app api

Signed-off-by: Nyupeng <yupeng78@huawei.com>
上级 0a5d0310
...@@ -28,6 +28,7 @@ struct Index { ...@@ -28,6 +28,7 @@ struct Index {
@State outputStr: string = '' @State outputStr: string = ''
@State playing: boolean = false @State playing: boolean = false
@State str:string="emitOnLoadIntercept" @State str:string="emitOnLoadIntercept"
@State arrid:number = 0
onPageShow(){ onPageShow(){
let valueChangeEvent={ let valueChangeEvent={
eventId:10, eventId:10,
...@@ -62,6 +63,10 @@ struct Index { ...@@ -62,6 +63,10 @@ struct Index {
this.controller.loadUrl("https://www.baidu.com/") this.controller.loadUrl("https://www.baidu.com/")
break; break;
} }
case "emitOnControllerAttached":{
Utils.emitEvent(this.arrid,7)
break;
}
default: default:
console.info("can not match case") console.info("can not match case")
...@@ -82,6 +87,65 @@ struct Index { ...@@ -82,6 +87,65 @@ struct Index {
console.log('getErrorInfo:' + event.error.getErrorInfo()) console.log('getErrorInfo:' + event.error.getErrorInfo())
Utils.emitEvent(event.error.getErrorInfo(),3) Utils.emitEvent(event.error.getErrorInfo(),3)
}) })
.onScreenCaptureRequest((event) => {
AlertDialog.show({
title: 'title: ' + event.handler.getOrigin(),
message: 'text',
primaryButton: {
value: 'deny',
action: () => {
event.handler.deny()
}
},
secondaryButton: {
value: 'onConfirm',
action: () => {
event.handler.grant({ captureMode: WebCaptureMode.HOME_SCREEN })
}
},
cancel: () => {
event.handler.deny()
}
})
})
.onControllerAttached(() => {
try {
this.arrid = this.controller.getWebId();
console.log("id++++++: " + this.arrid);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
})
.onOverScroll((event) => {
console.info("x = " + event.xOffset)
console.info("y = " + event.yOffset)
})
.onClientAuthenticationRequest((event) => {
AlertDialog.show({
title: 'onClientAuthenticationRequest',
message: 'text',
primaryButton: {
value: 'confirm',
action: () => {
event.handler.confirm("/system/etc/user.pk8", "/system/etc/chain-user.pem")
}
},
secondaryButton: {
value: 'cancel',
action: () => {
event.handler.cancel()
}
},
cancel: () => {
event.handler.ignore()
}
})
})
} }
} }
......
/* /*
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
...@@ -15,6 +16,7 @@ ...@@ -15,6 +16,7 @@
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from '../../test/Utils'; import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview'; import web_webview from '@ohos.web.webview';
import UIAbility from '@ohos.app.ability.UIAbility';
function Uint8ArrayToString(dataArray) { function Uint8ArrayToString(dataArray) {
var dataString = '' var dataString = ''
...@@ -40,7 +42,9 @@ function ParseX509CertInfo(x509CertArray) { ...@@ -40,7 +42,9 @@ function ParseX509CertInfo(x509CertArray) {
@Entry @Entry
@Component @Component
struct Second { struct Second {
@State outputStr: string = '' @State outputStr: string = ''
@State firsttime:number = 0
@State arr: Array<number> = [0, 0]
webviewCtl: web_webview.WebviewController = new web_webview.WebviewController(); webviewCtl: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitGetCertificate" @State str:string="emitGetCertificate"
onPageShow(){ onPageShow(){
...@@ -78,13 +82,61 @@ struct Second { ...@@ -78,13 +82,61 @@ struct Second {
} }
break; break;
} }
case "emitPrefetchPage": {
try {
this.webviewCtl.removeCache(true)
this.webviewCtl.loadUrl('https://www.huawei.com')
if (this.arr.length > 2) {
this.webviewCtl.removeCache(true)
}
this.webviewCtl.prefetchPage('https://www.huawei.com');
this.webviewCtl.loadUrl('https://www.huawei.com')
setTimeout(()=>{
if (this.arr.length > 3) {
if (this.arr[3]-this.arr[2] < 0) {
Utils.emitEvent("success",6)
}
}
},2000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitPrepareForPageLoad": {
try {
this.webviewCtl.removeCache(true)
this.webviewCtl.loadUrl('https://www.jd.com/')
if (this.arr.length > 4) {
this.webviewCtl.removeCache(true)
}
web_webview.WebviewController.prepareForPageLoad("https://www.jd.com/", true, 6);
this.webviewCtl.loadUrl('https://www.jd.com/')
setTimeout(()=>{
if (this.arr.length > 5) {
if (this.arr[5]-this.arr[4] < 0) {
Utils.emitEvent("success",8)
}
}
},2000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
default: default:
console.info("can not match case"); console.info("can not match case");
} }
}) })
} }
Web({ src: 'https://www.example.com', controller: this.webviewCtl }) Web({ src: 'www.baidu.com', controller: this.webviewCtl })
.fileAccess(true) .fileAccess(true)
.javaScriptAccess(true) .javaScriptAccess(true)
.domStorageAccess(true) .domStorageAccess(true)
...@@ -92,6 +144,13 @@ struct Second { ...@@ -92,6 +144,13 @@ struct Second {
.onPageEnd((e) => { .onPageEnd((e) => {
this.outputStr = 'onPageEnd : url = ' + e.url this.outputStr = 'onPageEnd : url = ' + e.url
}) })
.onFirstContentfulPaint(event => {
console.log("onFirstContentfulPaint:" + "[navigationStartTick]:" +
event.navigationStartTick + ", [firstContentfulPaintMs]:" +
event.firstContentfulPaintMs)
this.firsttime = event.firstContentfulPaintMs - event.navigationStartTick/1000
this.arr.push(this.firsttime)
})
} }
} }
} }
\ No newline at end of file
...@@ -45,14 +45,22 @@ export default function webJsunit() { ...@@ -45,14 +45,22 @@ export default function webJsunit() {
done(); done();
}) })
/* /*
*tc.number SUB_ACE_BASIC_ETS_API_002 *tc.number SUB_ACE_BASIC_ETS_API_001
*tc.name OnLoadIntercept *tc.desic Injects the JavaScript object into window and invoke the function in window *tc.name OnLoadIntercept *tc.desic Injects the JavaScript object into window and invoke the function in window
*/ */
it('OnLoadIntercept',0,async function(done){ it('OnLoadIntercept',0,async function(done){
emitKey="emitOnLoadIntercept"; emitKey="emitOnControllerAttached";
Utils.registerEvent("OnLoadIntercept","https://www.baidu.com/",2,done); Utils.registerEvent("OnLoadIntercept","https://www.baidu.com/",2,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/*
*tc.number SUB_ACE_BASIC_ETS_API_002
*tc.name OnControllerAttached *tc.desic Injects the JavaScript object into window and invoke the function in window
*/
it('OnControllerAttached',0,async function(done){
emitKey="emitOnControllerAttached";
Utils.registerEvent("OnControllerAttached",1,7,done);
sendEventByKey('webcomponent',10,'');
})
}) })
} }
...@@ -70,9 +70,29 @@ export default function webTwoJsunit() { ...@@ -70,9 +70,29 @@ export default function webTwoJsunit() {
*tc.desic Sets allow the Web access overview mode *tc.desic Sets allow the Web access overview mode
*/ */
it('GetCertificate',0,async function(done){ it('GetCertificate',0,async function(done){
emitKey="emitOverviewModeAccessFalse"; emitKey="emitGetCertificate";
Utils.registerEvent("GetCertificate","getCertificate success: len = 0",4,done); Utils.registerEvent("GetCertificate","getCertificate success: len = 0",4,done);
sendEventByKey('webcomponenttwo',10,''); sendEventByKey('webcomponenttwo',10,'');
}) })
///*
// *tc.number SUB_ACE_BASIC_ETS_API_002
// *tc.name PrefetchPage
// *tc.desic Sets allow the Web access overview mode
// */
//it('PrefetchPage',0,async function(done){
// emitKey="emitPrepareForPageLoad";
// Utils.registerEvent("PrefetchPage","success",6,done);
// sendEventByKey('webcomponenttwo',10,'');
//})
///*
// *tc.number SUB_ACE_BASIC_ETS_API_003
// *tc.name PrepareForPageLoad
// *tc.desic Sets allow the Web access overview mode
// */
//it('PrepareForPageLoad',0,async function(done){
// emitKey="emitPrepareForPageLoad";
// Utils.registerEvent("PrepareForPageLoad","success",8,done);
// sendEventByKey('webcomponenttwo',10,'');
//})
}) })
} }
\ No newline at end of file
...@@ -8,42 +8,37 @@ ...@@ -8,42 +8,37 @@
"deviceTypes": [ "deviceTypes": [
"tablet", "tablet",
"default", "default",
"phone", "phone"
"2in1"
], ],
"deliveryWithInstall": true, "deliveryWithInstall": true,
"installationFree": false, "installationFree": false,
"uiSyntax": "ets", "uiSyntax": "ets",
"pages": "$profile:main_pages", "pages": "$profile:main_pages",
"metadata": [ "metadata": [
{ {
"name": "ArkTSPartialUpdate", "name": "ArkTSPartialUpdate",
"value": "true" "value": "true"
} }
], ],
"abilities": [ "abilities": [{
{ "name": "com.example.myapplication.MainAbility",
"name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts",
"srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main",
"description": "$string:phone_entry_main", "icon": "$media:icon",
"icon": "$media:icon", "label": "$string:entry_label",
"label": "$string:entry_label", "visible": true,
"visible": true, "orientation": "portrait",
"orientation": "portrait", "skills": [{
"skills": [ "actions": [
{ "action.system.home"
"actions": [ ],
"action.system.home" "entities": [
], "entity.system.home"
"entities": [
"entity.system.home"
]
}
] ]
} }]
], }],
"requestPermissions": [ "requestPermissions": [
{ {
"name": "ohos.permission.LOCATION" "name": "ohos.permission.LOCATION"
}, },
{ {
......
<!-- index.html -->
<!DOCTYPE html>
<html>
<body>
<p>Hello World</p>
</body>
</html>
\ No newline at end of file
...@@ -113,7 +113,6 @@ struct webViewContMessageError { ...@@ -113,7 +113,6 @@ struct webViewContMessageError {
this.ports[1].postMessageEvent("post message from ets to html5"); this.ports[1].postMessageEvent("post message from ets to html5");
} catch (error) { } catch (error) {
console.error(`emitPostMessageEventUnPortErr ErrorCode: ${error.code}, Message: ${error.message}`); console.error(`emitPostMessageEventUnPortErr ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
this.errorMsg = error.message this.errorMsg = error.message
} }
this.controller.runJavaScript("test()",(res) => { this.controller.runJavaScript("test()",(res) => {
...@@ -122,6 +121,7 @@ struct webViewContMessageError { ...@@ -122,6 +121,7 @@ struct webViewContMessageError {
}) })
break; break;
} }
} }
}) })
} }
......
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 UIAbility from '@ohos.app.ability.UIAbility';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct webViewContPageAndprepareForPageLoadErrorOne {
controller20: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[];
msgPort: web_webview.WebMessagePort[] = null;
@State str:string="emitPrefetchPageErr";
@State errorCode: string = '0';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContPageAndprepareForPageLoadErrorOne page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
private jsObj={
test:(res)=>{
Utils.emitEvent(res,102);
},
toString:(str)=>{
console.info("ets toString:"+String(str));
},
register:(res)=>{
Utils.emitEvent(res,86);
return "web222"
}
}
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(){
Row() {
Button("messageEventErrorTest").key('webViewContPageAndprepareForPageLoadErrorOne').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitPrefetchPageErr": {
try {
this.controller20.prefetchPage('百度');
console.info("---666---444---8888")
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("789+++987"+this.errorCode)
Utils.emitEvent(this.errorCode, 900)
}
break;
}
}
})
}
}
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 UIAbility from '@ohos.app.ability.UIAbility';
import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
@Entry
@Component
struct webViewContPageAndprepareForPageLoadErrorTwo {
controller: web_webview.WebviewController = new web_webview.WebviewController();
ports: web_webview.WebMessagePort[];
msgPort: web_webview.WebMessagePort[] = null;
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=true;
@State databaseAccess:boolean=true;
@State zoomAccess:boolean=false;
@State str:string="emitPostMessageInitErr";
@State errorCode: string = '0';
onPageShow(){
let valueChangeEvent={
eventId:10,
priority:events_emitter.EventPriority.LOW
}
events_emitter.on(valueChangeEvent,this.valueChangeCallBack)
}
private valueChangeCallBack=(eventData)=>{
console.info("webViewContPageAndprepareForPageLoadErrorTwo page valueChangeCallBack");
if(eventData != null){
console.info("valueChangeCallBack:"+ JSON.stringify(eventData));
if(eventData.data.ACTION != null){
this.str = eventData.data.ACTION;
}
}
}
private jsObj={
test:(res)=>{
Utils.emitEvent(res,102);
},
toString:(str)=>{
console.info("ets toString:"+String(str));
},
register:(res)=>{
Utils.emitEvent(res,86);
return "web222"
}
}
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(){
Row() {
Button("messageEventErrorTest").key('webViewContPageAndprepareForPageLoadErrorTwo').onClick(() => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitPrefetchPageErr": {
try {
this.controller.prefetchPage('华为');
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("123+++321"+this.errorCode)
Utils.emitEvent(this.errorCode, 903)
}
break;
}
case "emitPrepareForPageLoadErr": {
try {
web_webview.WebviewController.prepareForPageLoad("华为", true, 6);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("456+++654"+this.errorCode)
Utils.emitEvent(this.errorCode, 904)
}
break;
}
case "emitPrepareForPageLoadErrTwo": {
try {
web_webview.WebviewController.prepareForPageLoad("huawei", true, 7);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
this.errorCode = error.code
console.info("4566+++6546"+this.errorCode)
Utils.emitEvent(this.errorCode, 905)
}
break;
}
}
})
}
Web({src:'www.example.com',controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
.zoomAccess(this.zoomAccess)
}
}
}
\ No newline at end of file
...@@ -21,6 +21,8 @@ import webViewContGetUrlAndOthersError from './webViewContGetUrlAndOthersError.t ...@@ -21,6 +21,8 @@ import webViewContGetUrlAndOthersError from './webViewContGetUrlAndOthersError.t
import webViewContCookieToGeoLocationError from './webViewContCookieToGeoLocationError.test' import webViewContCookieToGeoLocationError from './webViewContCookieToGeoLocationError.test'
import webViewContJsMessageExtReturnError from './webViewContJsMessageExtReturnError.test' import webViewContJsMessageExtReturnError from './webViewContJsMessageExtReturnError.test'
import webViewContWebMessageExtReturnError from './webViewContWebMessageExtReturnError.test' import webViewContWebMessageExtReturnError from './webViewContWebMessageExtReturnError.test'
import webViewContPageAndprepareForPageLoadErrorOne from './webViewContPageAndprepareForPageLoadErrorOne.test'
import webViewContPageAndprepareForPageLoadErrorTwo from './webViewContPageAndprepareForPageLoadErrorTwo.test'
export default function testsuite() { export default function testsuite() {
webViewContMessageError() webViewContMessageError()
...@@ -32,4 +34,7 @@ export default function testsuite() { ...@@ -32,4 +34,7 @@ export default function testsuite() {
webViewContCookieToGeoLocationError() webViewContCookieToGeoLocationError()
webViewContJsMessageExtReturnError() webViewContJsMessageExtReturnError()
webViewContWebMessageExtReturnError() webViewContWebMessageExtReturnError()
//webViewContPageAndprepareForPageLoadErrorOne()
//webViewContPageAndprepareForPageLoadErrorTwo()
} }
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitPrefetchPageErr";
export default function webViewContPageAndprepareForPageLoadErrorOne() {
describe('ActsAceWebDevWebViewContPageAndPrepareForPageLoadErrorOneTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContPageAndprepareForPageLoadErrorOne',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContPageAndprepareForPageLoadErrorOne state success " + JSON.stringify(pages));
if (!("webViewContPageAndprepareForPageLoadErrorOne" == pages.name)) {
console.info("get webViewContPageAndprepareForPageLoadErrorOne state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContPageAndprepareForPageLoadErrorOne page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContPageAndprepareForPageLoadErrorOne page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContPageAndprepareForPageLoadErrorOne beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContPageAndprepareForPageLoadErrorOne 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_WEBVIEWERROR_0100
*tc.name testPostMessageInitErr
*tc.desc test interface of postMessage with not been associated with specific Web Components
*/
it('PrefetchPageErr',0,async function(done){
emitKey="emitPrepareForPageLoadErr";
Utils.registerEvent("PrefetchPageErr","17100001",900,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorOne',10,'');
})
})
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) Co.,Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitPrefetchPageErr";
export default function webViewContPageAndprepareForPageLoadErrorTwo() {
describe('ActsAceWebDevWebViewContPageAndPrepareForPageLoadErrorTwoTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webViewContPageAndprepareForPageLoadErrorTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewContPageAndprepareForPageLoadErrorTwo state success " + JSON.stringify(pages));
if (!("webViewContPageAndprepareForPageLoadErrorTwo" == pages.name)) {
console.info("get webViewContPageAndprepareForPageLoadErrorTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewContPageAndprepareForPageLoadErrorTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewContPageAndprepareForPageLoadErrorTwo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewContPageAndprepareForPageLoadErrorTwo beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewContPageAndprepareForPageLoadErrorTwo 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_WEBVIEWERROR_0100
*tc.name testPostMessageInitErr
*tc.desc test interface of postMessage with not been associated with specific Web Components
*/
it('PrefetchPageErr',0,async function(done){
emitKey="emitPrepareForPageLoadErr";
Utils.registerEvent("PrefetchPageErr","17100002",903,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorTwo',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_0200
*tc.name testPostMessageEventPortClose
*tc.desc test interface of postMessageEvent with WebMessagePort been closed by ets
*/
it('PrepareForPageLoadErr',0,async function(done){
emitKey="emitPrepareForPageLoadErrTwo";
Utils.registerEvent("PrepareForPageLoadErr","17100002",904,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorTwo',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_WEBVIEWERROR_0200
*tc.name testPostMessageEventPortClose
*tc.desc test interface of postMessageEvent with WebMessagePort been closed by ets
*/
it('PrepareForPageLoadErrTwo',0,async function(done){
emitKey="emitPrepareForPageLoadErrTwo";
Utils.registerEvent("PrepareForPageLoadErrTwo","171000013",905,done);
sendEventByKey('webViewContPageAndprepareForPageLoadErrorTwo',10,'');
})
})
}
\ No newline at end of file
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
"deviceTypes": [ "deviceTypes": [
"tablet", "tablet",
"default", "default",
"phone", "phone"
"2in1"
], ],
"deliveryWithInstall": true, "deliveryWithInstall": true,
"installationFree": false, "installationFree": false,
...@@ -17,33 +16,29 @@ ...@@ -17,33 +16,29 @@
"pages": "$profile:main_pages", "pages": "$profile:main_pages",
"metadata": [ "metadata": [
{ {
"name": "ArkTSPartialUpdate", "name": "ArkTSPartialUpdate",
"value": "true" "value": "true"
} }
], ],
"abilities": [ "abilities": [{
{ "name": "com.example.myapplication.MainAbility",
"name": "com.example.myapplication.MainAbility", "srcEntrance": "./ets/MainAbility/MainAbility.ts",
"srcEntrance": "./ets/MainAbility/MainAbility.ts", "description": "$string:phone_entry_main",
"description": "$string:phone_entry_main", "icon": "$media:icon",
"icon": "$media:icon", "label": "$string:entry_label",
"label": "$string:entry_label", "visible": true,
"visible": true, "orientation": "portrait",
"orientation": "portrait", "skills": [{
"skills": [ "actions": [
{ "action.system.home"
"actions": [ ],
"action.system.home" "entities": [
], "entity.system.home"
"entities": [
"entity.system.home"
]
}
] ]
} }]
], }],
"requestPermissions": [ "requestPermissions": [
{ {
"name": "ohos.permission.LOCATION" "name": "ohos.permission.LOCATION"
}, },
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册