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

!7497 【OpenHarmony 4.0.3.2】【monthly_20221018】【ARKUI子系统】【TOD】【rk3568】【必现】新增web-xts用例

Merge pull request !7497 from 王旭鹏/monthly_20221018
......@@ -18,4 +18,4 @@
"singleUser": false
}
}
}
\ No newline at end of file
}
......@@ -18,17 +18,22 @@ import { Hypium } from '@ohos/hypium';
import testsuite from '../../test/List.test';
import Utils from '../../test/Utils';
import web_webview from '@ohos.web.webview';
import fileio from '@ohos.fileio';
let loadedUrl;
@Entry
@Component
struct Index {
controller: web_webview.WebviewController = new web_webview.WebviewController();
controllerTwo: web_webview.WebviewController = new web_webview.WebviewController();
scheme1: web_webview.WebCustomScheme = {schemeName: "name1", isSupportCORS: true, isSupportFetch: true}
responseweb: WebResourceResponse = new WebResourceResponse()
@State str:string="emitLoadUrl"
@State text:boolean=false
@State num:number=0
@State mode: WebDarkMode = WebDarkMode.Off
@State mode1: WebDarkMode = WebDarkMode.On
@State mode2: WebDarkMode = WebDarkMode.Auto
ports: web_webview.WebMessagePort[];
testObj = {
testOne: (data) => {
Utils.emitEvent(data,13)
......@@ -62,6 +67,14 @@ struct Index {
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
try{
web_webview.once("webInited",()=>{
web_webview.WebCookieManager.setCookie("https://www.huawei.com", "a=b");
})
}catch(error){
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
}
build(){
Column(){
......@@ -72,7 +85,7 @@ struct Index {
case "emitLoadUrl":{
try {
setTimeout(()=>{
this.controller.loadUrl('www.baidu.com');
this.controller.loadUrl("file:///data/storage/el1/bundle/phone/resources/rawfile/index.html");
setTimeout(()=>{
let title = this.controller.getTitle();
Utils.emitEvent(title,1)
......@@ -406,16 +419,126 @@ struct Index {
}
break;
}
case "emitOnce":{
try {
let re = web_webview.WebCookieManager.getCookie("https://www.huawei.com")
Utils.emitEvent(re, 31)
console.log("result: " + re);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitGetItemAtIndex":{
try {
let res = this.controller.getBackForwardEntries()
let item =res.getItemAtIndex(0)
Utils.emitEvent(item.title, 32)
console.log("result: " + item.title);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitSlideScroll":{
try {
this.controller.slideScroll(10, 10);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
try {
let state = this.controller.serializeWebState();
let path = globalThis.AbilityContext.cacheDir;
path += '/WebState';
let fd = fileio.openSync(path, 0o2 | 0o100, 0o666);
fileio.writeSync(fd, state.buffer);
fileio.closeSync(fd);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
try {
let path = globalThis.AbilityContext.cacheDir;
path += '/WebState';
let fd = fileio.openSync(path, 0o002, 0o666);
let stat = fileio.fstatSync(fd);
let size = stat.size;
let buf = new ArrayBuffer(size);
fileio.read(fd, buf, (err, data) => {
if (data) {
this.controller.restoreWebState(new Uint8Array(data.buffer));
}
fileio.closeSync(fd);
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
try {
this.ports = this.controller.createWebMessagePorts();
this.ports[1].onMessageEvent((msg) => {
if (typeof(msg) == "string") {
console.log("received string message from html5, string is:" + msg);
} else if (typeof(msg) == "object") {
if (msg instanceof ArrayBuffer) {
console.log("received arraybuffer from html5, length is:" + msg.byteLength);
} else {
console.log("not support");
}
} else {
console.log("not support");
}
})
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitContextMenuMediaType":{
try {
let con = ContextMenuMediaType.Image
Utils.emitEvent(con, 33)
console.log("result: " + con);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitContextMenuInputFieldType":{
try {
Utils.emitEvent(ContextMenuInputFieldType.PlainText, 34)
Utils.emitEvent(ContextMenuInputFieldType.Telephone, 35)
Utils.emitEvent(ContextMenuInputFieldType.Other, 36)
console.log("result: " + ContextMenuInputFieldType.PlainText);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
case "emitContextMenuEditStateFlags":{
try {
Utils.emitEvent(ContextMenuEditStateFlags.NONE, 37)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_CUT, 38)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_COPY, 39)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_PASTE, 40)
Utils.emitEvent(ContextMenuEditStateFlags.CAN_SELECT_ALL, 41)
console.log("result: " + ContextMenuEditStateFlags.CAN_SELECT_ALL);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
break;
}
default:
console.info("can not match case")
}
})
}
Web({src:"www.example.com",controller:this.controller})
.webDebuggingAccess(true)
.mediaPlayGestureAccess(true)
.javaScriptAccess(true)
.zoomAccess(this.text)
.onDataResubmitted((event) => {
console.log('onDataResubmitted')
event.handler.resend();
})
.onSearchResultReceive(ret=>{
var searchResult = ret.activeMatchOrdinal.toString() +
ret.numberOfMatches.toString()
......@@ -424,6 +547,29 @@ struct Index {
Utils.emitEvent(searchResult,16)
},3000)
})
.onContextMenuShow((event) => {
console.info(event.param.getMediaType() + event.param.getSelectionText() + event.param.getSourceType())
console.info(event.param.getInputFieldType().toString())
console.info(event.param.isEditable().toString())
console.info(event.param.getEditStateFlags().toString())
event.result.paste()
event.result.cut()
return true
})
.onHttpErrorReceive((event) => {
event.response.setResponseIsReady(true)
})
.darkMode(this.mode)
.forceDarkAccess(false)
.webSerifFont('serif')
.webFixedFont('fixed')
.webSansSerifFont('serif')
.minLogicalFontSize(1)
.horizontalScrollBarAccess(true)
.verticalScrollBarAccess(true)
.onTouchIconUrlReceived((event) => {
console.log('onTouchIconUrlReceived:' + JSON.stringify(event))
})
}
}
......
......@@ -51,7 +51,7 @@ export default function webJsunit() {
*/
it('LoadUrl',0,async function(done){
emitKey="emitLoadData";
Utils.registerContainEvent("LoadUrl","百度一下,你就知道",1,done);
Utils.registerContainEvent("LoadUrl","index",1,done);
sendEventByKey('webcomponent',10,'');
})
/*
......@@ -71,7 +71,7 @@ export default function webJsunit() {
*/
it('Backward',0,async function(done){
emitKey="emitForward";
Utils.registerEvent("Backward","百度一下,你就知道",3,done);
Utils.registerEvent("Backward","index",3,done);
sendEventByKey('webcomponent',10,'');
})
/*
......@@ -340,9 +340,65 @@ export default function webJsunit() {
*tc.desic Save current page
*/
it('GetUrl',0,async function(done){
emitKey="emitGetUrl";
emitKey="emitOnce";
Utils.registerContainEvent("GetUrl","17100001",30,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_031
*tc.name Once
*tc.desic Save current page
*/
it('Once',0,async function(done){
emitKey="emitGetItemAtIndex";
Utils.registerContainEvent("Once","a=b",31,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_032
*tc.name GetItemAtIndex
*tc.desic Save current page
*/
it('GetItemAtIndex',0,async function(done){
emitKey="emitContextMenuMediaType";
Utils.registerEvent("GetItemAtIndex","index",32,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_033
*tc.name ContextMenuMediaType
*tc.desic Save current page
*/
it('ContextMenuMediaType',0,async function(done){
emitKey="emitContextMenuInputFieldType";
Utils.registerEvent("ContextMenuMediaType",1,33,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_034
*tc.name ContextMenuInputFieldType
*tc.desic Save current page
*/
it('ContextMenuInputFieldType',0,async function(done){
emitKey="emitContextMenuEditStateFlags";
Utils.registerEvent("ContextMenuInputFieldType",1,34,done);
Utils.registerEvent("ContextMenuInputFieldType",4,35,done);
Utils.registerEvent("ContextMenuInputFieldType",5,36,done);
sendEventByKey('webcomponent',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_035
*tc.name ContextMenuEditStateFlags
*tc.desic Save current page
*/
it('ContextMenuEditStateFlags',0,async function(done){
emitKey="emitContextMenuEditStateFlags";
Utils.registerEvent("ContextMenuEditStateFlags",0,37,done);
Utils.registerEvent("ContextMenuEditStateFlags",1,38,done);
Utils.registerEvent("ContextMenuEditStateFlags",2,39,done);
Utils.registerEvent("ContextMenuEditStateFlags",4,40,done);
Utils.registerEvent("ContextMenuEditStateFlags",8,41,done);
sendEventByKey('webcomponent',10,'');
})
})
}
\ No newline at end of file
......@@ -15,11 +15,11 @@
"uiSyntax": "ets",
"pages": "$profile:main_pages",
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "false"
}
],
{
"name": "ArkTSPartialUpdate",
"value": "true"
}
],
"abilities": [{
"name": "com.example.myapplication.MainAbility",
"srcEntrance": "./ets/MainAbility/MainAbility.ts",
......@@ -46,4 +46,4 @@
}
]
}
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册