未验证 提交 dcb38280 编写于 作者: O openharmony_ci 提交者: Gitee

!6043 【ACE子系统】新增接口用例

Merge pull request !6043 from hekun/master
/*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry';
import { Hypium } from '@ohos/hypium';
import web_webview from '@ohos.web.webview';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
@Entry
@Component
struct Index {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State isSuccess:Boolean = false;
hitTestValue :HitTestValue = new HitTestValue();
@State str:string="emitUserAgent"
webConTextMenuResult:WebContextMenuResult = new WebContextMenuResult();
controllerWeb: WebController = new WebController();
fileSelector:FileSelectorResult = new FileSelectorResult();
fileSelectorParam:FileSelectorParam = new FileSelectorParam();
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;
}
}
}
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(){
Web({ src: 'www.baidu.com', controller: this.controller })
.onContextMenuShow((event) => {
console.info("x coord = " + event.param.x());
console.info("x coord = " + event.param.y());
console.info("link url = " + event.param.getLinkUrl());
console.info("source url = " + event.param.getSourceUrl());
console.info("source url = " + event.param.getUnfilterendLinkUrl());
console.info("source url = " + event.param.existsImageContents());
console.info("" + event.result.copyImage());
console.info("" + event.result.closeContextMenu());
this.isSuccess = true;
Utils.emitEvent(this.isSuccess,1101)
return true;
}).onWindowNew((event) => {
console.log("onWindowNew...");
var popController: WebController = new WebController();
event.handler.setWebController(popController);
this.isSuccess = true;
Utils.emitEvent(this.isSuccess,1102)
}).onShowFileSelector((event) => {
AlertDialog.show({
title: event.fileSelector.getTitle(),
message: 'isCapture:' + event.fileSelector.isCapture() + " mode:" + event.fileSelector.getMode() + 'acceptType:' + event.fileSelector.getAcceptType(),
confirm: {
value: 'upload',
action: () => {
let fileList: Array<string> = [
'/data/storage/el2/base/test',
]
event.result.handleFileList(fileList)
}
},
cancel: () => {
let fileList: Array<string> = []
event.result.handleFileList(fileList)
}
})
return true;
}).onAlert((event) => {
AlertDialog.show({
title: 'onAlert',
message: 'text',
primaryButton: {
value: 'cancel',
action: () => {
event.result.handleCancel()
}
},
secondaryButton: {
value: 'ok',
action: () => {
event.result.handlePromptConfirm("已經確認")
}
},
cancel: () => {
event.result.handleCancel()
}
})
return true;
})
Web({ src: 'www.baidu.com', controller: this.controller })
.onShowFileSelector((event) => {
AlertDialog.show({
title: event.fileSelector.getTitle(),
message: 'isCapture:' + event.fileSelector.isCapture() + " mode:" + event.fileSelector.getMode() + 'acceptType:' + event.fileSelector.getAcceptType(),
confirm: {
value: 'upload',
action: () => {
let fileList: Array<string> = [
'/data/storage/el2/base/test',
]
event.result.handleFileList(fileList)
}
},
cancel: () => {
let fileList: Array<string> = []
console.info("this is Capture " + event.fileSelector.isCapture());
console.info("this is getTitle" + event.fileSelector.getTitle());
console.info("this is getMode" + event.fileSelector.getMode());
console.info("this is getAcceptType" + event.fileSelector.getAcceptType().length);
}
})
return true;
})
Row() {
Button("webTest").key('web2').onClick(async () => {
console.info("key==>"+this.str);
switch(this.str){
// add
case "emitHitTestValue":
let hitValue = this.controller.getHitTestValue();
console.info("hitType: " + hitValue.getType());
console.info("extra: " + hitValue.getExtra());
Utils.emitEvent(hitValue.getType(),1103);
default:
console.info("can not match case")
}
})
}
}
}
}
/*
* 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 { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import router from '@system.router';
import Utils from './Utils.ets';
let emitKey = "emitUserAgent";
export default function web9Jsunit() {
describe('web9Jsunit', function () {
beforeEach(async function (done) {
let options = {
uri: 'pages/web_api_9',
}
try {
router.clear();
let pages = router.getState();
console.info("get web9Jsunit state success " + JSON.stringify(pages));
if (!("AlphabetIndexer" == pages.name)) {
console.info("get web9Jsunit state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push web9Jsunit page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push web9Jsunit page error " + JSON.stringify(err));
}
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_0001
* tc.name WebContextMenuResult
* tc.desic webContextMenuResult
*/
it('webContextMenuResultTest001',0,async function(done){
emitKey="emitwebContextMenuResult";
Utils.registerContainEvent("webContextMenuResult",true,1101,done);
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_0002
* tc.name HitTestValue
* tc.desic webContextMenuResult
*/
it('setWebControllerTest002',0,async function(done){
emitKey="emitsetWebController";
Utils.registerContainEvent("setWebController",true,1102,done);
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_0002
* tc.name HitTestValue
* tc.desic webContextMenuResult
*/
it('setWebControllerTest003',0,async function(done){
emitKey="emitHitTestValue";
Utils.registerContainEvent("HitTestValue",true,1103,done);
sendEventByKey('web2',10,'');
})
})
}
......@@ -320,96 +320,6 @@ export default function webJsunit() {
Utils.registerContainEvent("isThirdPartyCookieAllowed",false,826,done);
sendEventByKey('webcomponentapi9',10,'');
});
/*
*tc.number SUB_ACE_BASIC_ETS_API_066
*tc.name storeWebArchive
*tc.desic Save current page
*/
it('storeWebArchive',0,async function(done){
emitKey="emitAllowGeolocation";
Utils.registerContainEvent("storeWebArchive","/data/storage/el2/base/",400,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_072
*tc.name isThirdPartyCookieAllowed
*tc.desic return whether the third party cookie is allowed
*/
it('isThirdPartyCookieAllowed',0,async function(done){
emitKey="emitExistCookie";
Utils.registerEvent("isThirdPartyCookieAllowed",false,412,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_073
*tc.name existCookie
*tc.desic return whether there exits cookie
*/
it('existCookie',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("existCookie",false,414,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_076
*tc.name getLineNumber
*tc.desic return the number of console message lines
*/
it('getLineNumber',0,async function(done){
emitKey="emitOnConsole";
Utils.registerEvent("getLineNumber","51",420,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_077
*tc.name getSourceId
*tc.desic return the source url
*/
it('getSourceId',0,async function(done){
emitKey="emitLoaData";
Utils.registerEvent("getSourceId","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",422,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_078
*tc.name loadData
*tc.desic load specific strings
*/
it('loadData',0,async function(done){
emitKey="emitZoomAccess";
Utils.registerEvent("loadData","index",424,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_080
*tc.name zoomAccess
*tc.desic set whether it is allowed to zoom
*/
it('zoomAccess',0,async function(done){
emitKey="emitSaveHttpAuthCredentials";
Utils.registerEvent("zoomAccess",false,428,done);
sendEventByKey('webcomponent',10,'');
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册