Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
81d1bb6a
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
81d1bb6a
编写于
5月 15, 2023
作者:
O
openharmony_ci
提交者:
Gitee
5月 15, 2023
浏览文件
操作
浏览文件
下载
差异文件
!8626 add webViewController_part2 xts_acts testcase & pages
Merge pull request !8626 from 王倩/webView_two
上级
73a0aff9
ec7c927a
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
1410 addition
and
1 deletion
+1410
-1
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewHasImage.ets
.../entry/src/main/ets/MainAbility/pages/webViewHasImage.ets
+169
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewScrollBy.ets
.../entry/src/main/ets/MainAbility/pages/webViewScrollBy.ets
+368
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewScrollTo.ets
.../entry/src/main/ets/MainAbility/pages/webViewScrollTo.ets
+235
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets
...v_webviewController/entry/src/main/ets/test/List.test.ets
+6
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewHasImageJsunit.test.ets
...er/entry/src/main/ets/test/webViewHasImageJsunit.test.ets
+134
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSrollByJsunit.test.ets
...ler/entry/src/main/ets/test/webViewSrollByJsunit.test.ets
+200
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSrollToJsunit.test.ets
...ler/entry/src/main/ets/test/webViewSrollToJsunit.test.ets
+144
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json
...ler/entry/src/main/resources/base/profile/main_pages.json
+4
-1
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/hasImageOne.html
...troller/entry/src/main/resources/rawfile/hasImageOne.html
+74
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/hasImageTwo.html
...troller/entry/src/main/resources/rawfile/hasImageTwo.html
+23
-0
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/theScroll.html
...ontroller/entry/src/main/resources/rawfile/theScroll.html
+53
-0
未找到文件。
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewHasImage.ets
0 → 100644
浏览文件 @
81d1bb6a
/**
* 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 { 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 webViewHasImage {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitHasImagePm";
@State webId:number=0;
@State hasImagePm:boolean=true;
@State hasImagePmSvg:boolean=true;
@State hasImagePmOnline:boolean=true;
@State hasImageCb:boolean=true;
@State hasImageCbSvg:boolean=true;
@State hasImageCbOnline:boolean=true;
@State javaScriptAccess:boolean=true;
@State fileAccess:boolean=true;
@State domStorageAccess:boolean=false;
@State imageAccess:boolean=true;
@State onlineImageAccess:boolean=false;
@State databaseAccess:boolean=true;
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;
}
}
}
build(){
Column(){
Row() {
Button("web click").key('webImagecomponent').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitHasImagePm": {
try {
this.controller.hasImage().then((data) => {
console.info('HasImagePm: ' + data);
this.hasImagePm = data;
})
.catch(function (error) {
console.error("error: " + error);
})
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.hasImagePm, 202);
}
case "emitHasImagePmSvg": {
this.controller.loadUrl($rawfile('hasImageTwo.html'))
await Utils.sleep(2000)
try {
this.controller.hasImage().then((data) => {
console.info('HasImagePmSvg: ' + data);
this.hasImagePmSvg = data;
})
.catch(function (error) {
console.error("error: " + error);
})
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.hasImagePmSvg, 204);
}
case "emitHasImagePmOnline": {
this.controller.loadUrl($rawfile('onlineImageAccess.html'))
try {
this.controller.hasImage().then((data) => {
console.info('HasImagePmOnline: ' + data);
this.hasImagePmOnline = data;
})
.catch(function (error) {
console.error("error: " + error);
})
} catch (error) {
console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.hasImagePmOnline, 206);
}
case "emitHasImageCb": {
this.controller.loadUrl($rawfile('hasImageOne.html'))
try {
this.controller.hasImage((error, data) => {
if (error) {
console.info(`hasImageCb error: ` + JSON.stringify(error))
return
}
this.hasImageCb = data;
console.info("hasImageCb: " + data);
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.hasImageCb, 208);
}
case "emitHasImageCbSvg": {
this.controller.loadUrl($rawfile('hasImageTwo.html'))
await Utils.sleep(2000)
try {
this.controller.hasImage((error, data) => {
if (error) {
console.info(`hasImageCbSvg error: ` + JSON.stringify(error))
return;
}
this.hasImageCbSvg = data;
console.info("hasImageCbSvg: " + data);
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.hasImageCbSvg, 210);
}
case "emitHasImageCbOnline": {
this.controller.loadUrl($rawfile('onlineImageAccess.html'))
try {
this.controller.hasImage((error, data) => {
if (error) {
console.info(`hasImageCbOnline error: ` + JSON.stringify(error))
return;
}
this.hasImageCbOnline = data;
console.info("hasImageCbOnline: " + data);
});
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
Utils.emitEvent(this.hasImageCbOnline, 212);
}
}
})
}
Web({src:$rawfile('hasImageOne.html'),controller:this.controller})
.javaScriptAccess(this.javaScriptAccess)
.fileAccess(this.fileAccess)
.imageAccess(this.imageAccess)
.domStorageAccess(this.domStorageAccess)
.onlineImageAccess(this.onlineImageAccess)
.databaseAccess(this.databaseAccess)
}
}
}
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewScrollBy.ets
0 → 100644
浏览文件 @
81d1bb6a
此差异已折叠。
点击以展开。
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/MainAbility/pages/webViewScrollTo.ets
0 → 100644
浏览文件 @
81d1bb6a
/**
* 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 { 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 webViewScrollTo {
controller: web_webview.WebviewController = new web_webview.WebviewController();
@State str:string="emitScrollToOne";
@State res:boolean = false;
@State xNum:number = 0;
@State yNum:number = 0;
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;
}
}
}
build(){
Column(){
Row() {
Button("web click").key('webcomponentScrolTo').onClick(async () => {
console.info("key==>" + this.str)
switch (this.str) {
case "emitScrollToOne" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = -10;
this.yNum = -10;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()",(error, result) => {
if (error) {
console.info(`emitScrollToOne runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToOne runJavaScript.result: " + result);
}
Utils.emitEvent(result, 214)
console.info("emitScrollToOne res: " + result);
})
break;
}
case "emitScrollToTwo" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = -10;
this.yNum = 3500;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()",(error, result) => {
if (error) {
console.info(`emitScrollToTwo runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToTwo runJavaScript.result: " + result);
if(JSON.parse(result)[0] == 0 && JSON.parse(result)[1] > 200){
this.res = true;
}else{
this.res = false;
}
}
Utils.emitEvent(this.res, 216)
console.info("emitScrollToTwo res: " + result);
})
break;
}
case "emitScrollToThree" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = -10;
this.yNum = 200;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000);
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()",(error, result) => {
if (error) {
console.info(`emitScrollToThree runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToThree runJavaScript.result: " + result);
}
Utils.emitEvent(result, 218)
console.info("emitScrollToThree res: " + result);
})
break;
}
case "emitScrollToFour" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = 200;
this.yNum = -10;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()", (error, result) => {
if (error) {
console.info(`emitScrollToFour runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToFour runJavaScript.result: " + result);
}
Utils.emitEvent(result, 220)
console.info("emitScrollToFour res: " + result);
})
break;
}
case "emitScrollToFive" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = 4000;
this.yNum = -10;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()", (error, result) => {
if (error) {
console.info(`emitScrollToFive runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToFive runJavaScript.result: " + result);
if(JSON.parse(result)[0] > 200 && JSON.parse(result)[1] == 0){
this.res = true;
}else{
this.res = false;
}
}
Utils.emitEvent(this.res, 222)
console.info("emitScrollToFive res: " + result);
})
break;
}
case "emitScrollToSix" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = 200;
this.yNum = 200;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()", (error, result) => {
if (error) {
console.info(`emitScrollToSix runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToSix runJavaScript.result: " + result);
}
Utils.emitEvent(result, 224)
console.info("emitScrollToSix res: " + result);
})
break;
}
case "emitScrollToSeven" :{
this.controller.loadUrl($rawfile('theScroll.html'));
this.xNum = 4000;
this.yNum = 3500;
await Utils.sleep(1000);
try {
this.controller.scrollTo(this.xNum, this.yNum);
await Utils.sleep(1000)
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
this.controller.runJavaScript("getScroll()", (error, result) => {
if (error) {
console.info(`emitScrollToSeven runJavaScript error: ` + JSON.stringify(error))
return;
} else {
console.log("emitScrollToSeven runJavaScript.result: " + result);
if(JSON.parse(result)[0] > 200 && JSON.parse(result)[1] > 200){
this.res = true;
}else{
this.res = false;
}
}
Utils.emitEvent(this.res, 226)
console.info("emitScrollToSeven res: " + result);
})
break;
}
}
})
}
Web({src:$rawfile('theScroll.html'),controller:this.controller})
}
}
}
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/List.test.ets
浏览文件 @
81d1bb6a
...
...
@@ -16,9 +16,15 @@ import webViewControllerJsunit from './webViewControllerJsunit.test'
import webViewOnWindowNewJsunit from './WebViewOnWindowNewJsunit.test'
import webViewOnErrorReceive02Jsunit from './WebViewOnErrorReceive02Jsunit.test'
import webViewOnErrorReceive03Jsunit from './WebViewOnErrorReceive03Jsunit.test'
import webViewHasImageJsunit from './webViewHasImageJsunit.test'
import webViewSrollToJsunit from './webViewSrollToJsunit.test'
import webViewSrollByJsunit from './webViewSrollByJsunit.test'
export default function testsuite() {
webViewControllerJsunit()
webViewOnWindowNewJsunit()
webViewOnErrorReceive02Jsunit()
webViewOnErrorReceive03Jsunit()
webViewHasImageJsunit()
webViewSrollToJsunit()
webViewSrollByJsunit()
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewHasImageJsunit.test.ets
0 → 100644
浏览文件 @
81d1bb6a
/**
* 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.
*/
// @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 = "emitHasImagePm";
import router from '@system.router';
export default function webViewHasImageJsunit() {
describe('ActsAcewebViewHasImageJsunitTest', function () {
beforeAll(async function (done) {
let options = {
uri: "MainAbility/pages/webViewHasImage"
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewHasImage state success " + JSON.stringify(pages));
if (!("webViewHasImage" == pages.name)) {
console.info("get webViewHasImage state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewHasImage page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewHasImage page error: " + err);
}
done()
});
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_TESTHASIMAGE_0100
* tc.name testHasImagePm
* tc.desc There are offline images in the H5 page that are loaded using the img tag, and the interface
* hasImage:Promise results in true
*/
it('testHasImagePm',0,async function(done){
emitKey="emitHasImagePmSvg";
Utils.registerEvent("testHasImagePm",true,202,done);
sendEventByKey('webImagecomponent',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTHASIMAGE_0200
* tc.name testHasImagePmSvg
* tc.desc There is no image loaded using the img tag in the H5 page, only svg, and the interface
* hasImage:Promise result is false
*/
it('testHasImagePmSvg',0,async function(done){
emitKey="emitHasImagePmOnline";
Utils.registerEvent("testHasImageSvg",false,204,done);
sendEventByKey('webImagecomponent',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTHASIMAGE_0300
* tc.name testHasImagePmOnline
* tc.desc The H5 page has an online web page loaded using the img tag, and the interface
* hasImage:Promise result is false
*/
it('testHasImagePmOnline',0,async function(done){
emitKey="emitHasImageCb";
Utils.registerEvent("testHasImagePmOnline",false,206,done);
sendEventByKey('webImagecomponent',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTHASIMAGE_0400
* tc.name testHasImageCb
* tc.desc There are offline images in the H5 page that are loaded using the img tag, and the interface
* hasImage:Callback results in true
*/
it('testHasImageCb',0,async function(done){
emitKey="emitHasImageCbSvg";
Utils.registerEvent("testHasImageCb",true,208,done);
sendEventByKey('webImagecomponent',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTHASIMAGE_0500
* tc.name testHasImageCbSvg
* tc.desc There is no image loaded using the img tag in the H5 page, only svg, and the interface
* hasImage:Callback result is false
*/
it('testHasImageCbSvg',0,async function(done){
emitKey="emitHasImageCbOnline";
Utils.registerEvent("testHasImageCbSvg",false,210,done);
sendEventByKey('webImagecomponent',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTHASIMAGE_0600
* tc.name testHasImageCbOnline
* tc.desc The H5 page has an online web page loaded using the img tag, and the interface
* hasImage:Callback result is false
*/
it('testHasImageCbOnline',0,async function(done){
emitKey="emitHasImageCbOnline";
Utils.registerEvent("testHasImageCbOnline",false,212,done);
sendEventByKey('webImagecomponent',10,'');
})
})
}
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSrollByJsunit.test.ets
0 → 100644
浏览文件 @
81d1bb6a
/**
* 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.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitScrollByOne";
export default function webViewSrollByJsunit() {
describe('ActsAceWebViewScrollByTest', function () {
beforeAll(async function (done) {
let options = {
uri: "MainAbility/pages/webViewScrollBy"
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewScroll state success " + JSON.stringify(pages));
if (!("webViewScrollBy" == pages.name)) {
console.info("get webViewScrollBy state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewScrollBy page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewScrollBy page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewScrollBy beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewScrollBy 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_TESTSCROLLBY_0100
* tc.name testScrollByOne
* tc.desc When calling the scrollTo interface, x=0 and the y input parameter is a positive number,
* which is half the page height
*/
it('testScrollByOne',0,async function(done){
emitKey="emitScrollByTwo";
Utils.registerEvent("testScrollByOne",true,228,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0200
* tc.name testScrollByTwo
* tc.desc When calling the scrollTo interface, x=0 and the y input parameter is a positive number,
* which is greater than the content height
*/
it('testScrollByTwo',0,async function(done){
emitKey="emitScrollByThree";
Utils.registerEvent("testScrollByTwo",true,230,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0300
* tc.name testScrollByThree
* tc.desc When calling the scrollTo interface, x=0 and the y input parameter is negative, which is half the
* page height
*/
it('testScrollByThree',0,async function(done){
emitKey="emitScrollByFour";
Utils.registerEvent("testScrollByThree","[0,0]",232,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0400
* tc.name testScrollByFour
* tc.desc When calling the scrollTo interface, x=0 and the y input parameter is negative, exceeding the
* page height
*/
it('testScrollByFour',0,async function(done){
emitKey="emitScrollByFive";
Utils.registerEvent("emitScrollByFour","[0,0]",234,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0500
* tc.name testScrollByFive
* tc.desc When calling the scrollTo interface, y=0 and the x input parameter is a positive number, which is
* half the page length
*/
it('testScrollByFive',0,async function(done){
emitKey="emitScrollBySix";
Utils.registerEvent("testScrollByFive",true,236,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0600
* tc.name testScrollBySix
* tc.desc When calling the scrollTo interface, y=0 and the x input parameter is positive, which is
* greater than the page length
*/
it('testScrollBySix',0,async function(done){
emitKey="emitScrollBySeven";
Utils.registerEvent("testScrollBySix",true,238,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0700
* tc.name testScrollByEight
* tc.desc When calling the scrollTo interface, y=0 and the x input parameter is negative, which is greater
* than the page length
*/
it('testScrollBySeven',0,async function(done){
emitKey="emitScrollByEight";
Utils.registerEvent("testScrollBySeven","[0,0]",240,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0800
* tc.name testScrollBySeven
* tc.desc When calling the scrollTo interface, y=0 and the x input parameter is negative, which is half the
* page length
*/
it('testScrollByEight',0,async function(done){
emitKey="emitScrollByNine";
Utils.registerEvent("testScrollByEight","[0,0]",242,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_0900
* tc.name testScrollByNine
* tc.desc When calling the scrollTo interface, the yx input parameter is a positive number, which is half
* the width and height of the page
*/
it('testScrollByNine',0,async function(done){
emitKey="emitScrollByTen";
Utils.registerEvent("testScrollByNine",true,244,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_1000
* tc.name testScrollByTen
* tc.desc When the scrollTo interface is called, the yx input parameter is a positive number, which exceeds
* the page width and height
*/
it('testScrollByTen',0,async function(done){
emitKey="emitScrollByEleven";
Utils.registerEvent("testScrollByTen",true,246,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_1100
* tc.name testScrollByEleven
* tc.desc When calling the scrollTo interface, the yx input parameter is negative, which is half the width
* and height of the page
*/
it('testScrollByEleven',0,async function(done){
emitKey="emitScrollByTwelve";
Utils.registerEvent("testScrollByEleven","[0,0]",248,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLBY_1200
* tc.name testScrollByTwelve
* tc.desc When calling the scrollTo interface, the yx input parameter is negative, which exceeds the page
* width and height
*/
it('testScrollByTwelve',0,async function(done){
emitKey="emitScrollByTwelve";
Utils.registerEvent("testScrollByTwelve","[0,0]",250,done);
sendEventByKey('webcomponentScrollBy',10,'');
})
})
}
arkui/ace_ets_web_dev_webviewController/entry/src/main/ets/test/webViewSrollToJsunit.test.ets
0 → 100644
浏览文件 @
81d1bb6a
/**
* 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.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect } from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets';
import router from '@system.router';
let emitKey = "emitScrollToOne";
export default function webViewSrollToJsunit() {
describe('ActsAceWebViewScrollToTest', function () {
beforeAll(async function (done) {
let options = {
uri: "MainAbility/pages/webViewScrollTo"
}
try {
router.clear();
let pages = router.getState();
console.info("get webViewScroll state success " + JSON.stringify(pages));
if (!("webViewScrollTo" == pages.name)) {
console.info("get webViewScrollTo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webViewScrollTo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webViewScrollTo page error: " + err);
}
done()
});
beforeEach(async function (done) {
await Utils.sleep(2000);
console.info("webViewScrollTo beforeEach start");
done();
})
afterEach(async function (done) {
console.info("webViewScrollTo 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_TESTSCROLLTO_0100
* tc.name testScrollToOne
* tc.desc When calling the scrollTo interface, the x,y input parameters are negative
*/
it('testScrollToOne',0,async function(done){
emitKey="emitScrollToTwo";
Utils.registerEvent("testScrollToOne","[0,0]",214,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLTO_0200
* tc.name testScrollToTwo
* tc.desc When calling the scrollTo interface, the x input parameter is negative and the y input parameter is
* positive, which is greater than the page height
*/
it('testScrollToTwo',0,async function(done){
emitKey="emitScrollToThree";
Utils.registerEvent("testScrollToTwo",true,216,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLTO_0300
* tc.name testScrollToThree
* tc.desc When calling the scrollTo interface, the x input parameter is negative and the y input parameter is
* positive, which is less than the page height
*/
it('testScrollToThree',0,async function(done){
emitKey="emitScrollToFour";
Utils.registerEvent("testScrollToThree","[0,200]",218,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLTO_0400
* tc.name testScrollToFour
* tc.desc When calling the scrollTo interface, the y input parameter is negative and the x input parameter is
* positive, which is less than the page length
*/
it('testScrollToFour',0,async function(done){
emitKey="emitScrollToFive";
Utils.registerEvent("testScrollToFour","[200,0]",220,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLTO_0500
* tc.name testScrollToFive
* tc.desc When calling the scrollTo interface, the y input parameter is negative and the x input parameter is
* positive, which is greater than the page length
*/
it('testScrollToFive',0,async function(done){
emitKey="emitScrollToSix";
Utils.registerEvent("testScrollToFive",true,222,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLTO_0600
* tc.name testScrollToSix
* tc.desc When calling the scrollTo interface, the y input parameter is a positive number and the x input parameter
* is a positive number, both of which are less than the page height
*/
it('testScrollToSix',0,async function(done){
emitKey="emitScrollToSeven";
Utils.registerEvent("testScrollToSix","[200,200]",224,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
/*
* tc.number SUB_ACE_BASIC_ETS_API_TESTSCROLLTO_0700
* tc.name testScrollToSeven
* tc.desc When the scrollTo interface is called, the y input parameter is a positive number and the x input
* parameter is a positive number, both of which are greater than the page width and height
*/
it('testScrollToSeven',0,async function(done){
emitKey="emitScrollToSeven";
Utils.registerEvent("testScrollToSeven",true,226,done);
sendEventByKey('webcomponentScrolTo',10,'');
})
})
}
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/base/profile/main_pages.json
浏览文件 @
81d1bb6a
...
...
@@ -3,6 +3,9 @@
"MainAbility/pages/webViewController"
,
"MainAbility/pages/onWindowNew"
,
"MainAbility/pages/onErrorReceive02"
,
"MainAbility/pages/onErrorReceive03"
"MainAbility/pages/onErrorReceive03"
,
"MainAbility/pages/webViewHasImage"
,
"MainAbility/pages/webViewScrollTo"
,
"MainAbility/pages/webViewScrollBy"
]
}
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/hasImageOne.html
0 → 100644
浏览文件 @
81d1bb6a
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
index
</title>
<style>
#pageHeight
{
height
:
1300px
}
</style>
</head>
<body>
<div
id=
"container"
>
首页
</div>
<div
id=
"pageHeight"
></div>
<a
href=
"second.html"
id=
"fileAccess"
>
打开rawfile文件
</a>
<img
src=
"icon.png"
alt=
"icon"
id=
"imgs"
>
</body>
<script>
let
ele
=
document
.
getElementById
(
"
imgs
"
);
let
loadImage
;
ele
.
onload
=
function
(){
loadImage
=
"
load complete
"
}
function
getUserAgent
(){
return
navigator
.
userAgent
}
function
test
(){
backToEts
.
test
(
"
backToEts
"
)
}
function
testRunJavaScript
(){
return
"
testRunJavaScript
"
}
function
getPageHeight
(){
let
height
=
document
.
body
.
scrollHeight
return
height
}
function
proxy
(){
objName
.
register
(
"
backToEts
"
)
}
function
registerTest
(){
let
str
=
objName
.
register
();
console
.
log
(
str
);
return
str
}
function
jsAccess
(){
console
.
log
(
"
web111
"
)
}
function
consoleTest
(){
console
.
log
(
"
console test
"
)
}
function
alertTest
(){
alert
(
'
alert test
'
)
}
function
confirmTest
(){
confirm
(
"
confirm test
"
)
}
function
getImgResult
(){
return
loadImage
}
function
toPrompt
(){
let
result
=
prompt
(
"
age
"
,
"
20
"
);
console
.
log
(
"
result:
"
+
result
)
}
function
openRawFile
(){
document
.
getElementById
(
"
fileAccess
"
).
click
()
}
function
gettitle
(){
return
document
.
title
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/hasImageTwo.html
0 → 100644
浏览文件 @
81d1bb6a
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
second
</title>
</head>
<body>
<div
style=
"height: 1300px;background-color: #999999;"
>
<text>
second pages
</text>
<svg
width=
"300"
height=
"200"
>
<rect
width=
"100%"
height=
"100%"
fill=
"green"
/>
</svg>
</div>
</body>
<script>
function
gettitle
(){
return
document
.
title
}
</script>
</html>
\ No newline at end of file
arkui/ace_ets_web_dev_webviewController/entry/src/main/resources/rawfile/theScroll.html
0 → 100644
浏览文件 @
81d1bb6a
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
homework
</title>
<style>
html
{
width
:
2000px
;
}
#kuang
{
height
:
220px
;
white-space
:
nowrap
;
}
img
{
border-radius
:
5px
;
margin-top
:
10px
;
width
:
1000px
;
height
:
200px
;
display
:
inline
}
#centerHeight
{
height
:
3000px
;
}
</style>
</head>
<body>
<div
>
<div
id=
"kuang"
>
<img
src=
"icon.png"
id =
"leftImg"
>
<img
src=
"icon.png"
id =
"centerImg"
>
<img
src=
"icon.png"
id =
"rightImg"
>
</div>
<div
id=
"gao"
>
<div
id=
"centerHeight"
></div>
<img
src=
"icon.png"
alt=
"icon"
id=
"bottomImg"
>
</div>
</div>
</body>
</html>
<script>
function
getScroll
(){
let
x
=
document
.
documentElement
.
scrollLeft
;
let
y
=
document
.
documentElement
.
scrollTop
;
let
z
=
document
.
body
.
scrollHeight
;
let
p
=
document
.
body
.
scrollWidth
;
let
arr
=
[
x
,
y
];
console
.
log
(
arr
)
return
arr
;
}
getScroll
();
</script>
</html>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录