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

!5092 web失败用例修改代码合入monthly分支

Merge pull request !5092 from 章靖/monthly_20220816
...@@ -179,7 +179,8 @@ struct Index { ...@@ -179,7 +179,8 @@ struct Index {
let webPageHeight=this.controller.getPageHeight()+"" let webPageHeight=this.controller.getPageHeight()+""
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getPageHeight()",callback:(res)=>{ this.controller.runJavaScript({script:"getPageHeight()",callback:(res)=>{
Utils.emitEvent(webPageHeight==res,124) console.info("getPageHeight==>"+res)
Utils.emitEventTwo(res,webPageHeight,124)
}}) }})
},3000) },3000)
break; break;
...@@ -235,4 +236,4 @@ struct Index { ...@@ -235,4 +236,4 @@ struct Index {
} }
} }
} }
} }
\ No newline at end of file
...@@ -60,4 +60,59 @@ export default class Utils { ...@@ -60,4 +60,59 @@ export default class Utils {
console.info("webFlag emit action state err: " + JSON.stringify(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));
}
}
} }
...@@ -19,7 +19,7 @@ import Utils from './Utils.ets'; ...@@ -19,7 +19,7 @@ import Utils from './Utils.ets';
let emitKey = "emitUserAgent"; let emitKey = "emitUserAgent";
export default function webJsunit() { export default function webJsunit() {
describe('ActsAceWebDevTest', function () { describe('ActsAceWebDevTest', function () {
beforeEach(async function () { beforeEach(async function (done) {
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("web beforeEach start"); console.info("web beforeEach start");
done(); done();
...@@ -70,7 +70,7 @@ export default function webJsunit() { ...@@ -70,7 +70,7 @@ export default function webJsunit() {
*/ */
it('onUrlLoadIntercept',0,async function(done){ it('onUrlLoadIntercept',0,async function(done){
emitKey="emitOnRenderExited"; emitKey="emitOnRenderExited";
Utils.registerEvent("onUrlLoadIntercept","https://www.gitee.com",104,done); Utils.registerEvent("onUrlLoadIntercept","https://gitee.com/",104,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
...@@ -100,7 +100,7 @@ export default function webJsunit() { ...@@ -100,7 +100,7 @@ export default function webJsunit() {
*/ */
it('loadUrl',0,async function(done){ it('loadUrl',0,async function(done){
emitKey="emitRunJavaScript"; emitKey="emitRunJavaScript";
Utils.registerEvent("loadUrl","基于Git的代码托管和研发协作平台--Gitee | Software Development and Collaboration Platform",110,done); Utils.registerContainEvent("loadUrl","代码托管和研发协作平台",110,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
...@@ -168,7 +168,7 @@ export default function webJsunit() { ...@@ -168,7 +168,7 @@ export default function webJsunit() {
*/ */
it('getPageHeight',0,async function(done){ it('getPageHeight',0,async function(done){
emitKey="emitGetRequestFocus"; emitKey="emitGetRequestFocus";
Utils.registerEvent("getPageHeight","true",124,done); Utils.registerEventTwo("getPageHeight",124,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
......
...@@ -29,14 +29,13 @@ ...@@ -29,14 +29,13 @@
] ]
}] }]
}], }],
"requestPermissions": [{ "requestPermissions": [
"name": "ohos.permission.SYSTEM_FLOAT_WINDOW", {
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW" "name": "ohos.permission.LOCATION"
}, },
{ {
"name": "ohos.permission.CAPTURE_SCREEN", "name": "ohos.permission.INTERNET"
"reason": "need use ohos.permission.SYSTEM_FLOAT_WINDOW"
} }
] ]
} }
} }
\ No newline at end of file
...@@ -5,9 +5,15 @@ ...@@ -5,9 +5,15 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index</title> <title>index</title>
<style>
#pageHeight{
height:1300px
}
</style>
</head> </head>
<body> <body>
<div id="container">首页</div> <div id="container">首页</div>
<div id="pageHeight"></div>
</body> </body>
<script> <script>
function getUserAgent(){ function getUserAgent(){
...@@ -24,4 +30,4 @@ ...@@ -24,4 +30,4 @@
return height return height
} }
</script> </script>
</html> </html>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册