提交 19bd1b16 编写于 作者: Z zhangjing

web组件接口变更相关用例修改

Signed-off-by: Nzhangjing <zhangjing403@huawei.com>
上级 32e66d66
...@@ -269,7 +269,7 @@ struct Index { ...@@ -269,7 +269,7 @@ struct Index {
break; break;
} }
case "emitOnResourceLoad":{ case "emitOnResourceLoad":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/second.html"}) this.controller.loadUrl({url:"resource://rawfile/second.html"});
setTimeout(()=>{ setTimeout(()=>{
Utils.emitEvent(this.loadedResource,108) Utils.emitEvent(this.loadedResource,108)
},3000) },3000)
...@@ -284,7 +284,7 @@ struct Index { ...@@ -284,7 +284,7 @@ struct Index {
break; break;
} }
case "emitRunJavaScript":{ case "emitRunJavaScript":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"testRunJavaScript()",callback:(res)=>{ this.controller.runJavaScript({script:"testRunJavaScript()",callback:(res)=>{
Utils.emitEvent(res,112) Utils.emitEvent(res,112)
...@@ -299,7 +299,7 @@ struct Index { ...@@ -299,7 +299,7 @@ struct Index {
break; break;
} }
case "emitOnRefreshAccessedHistory":{ case "emitOnRefreshAccessedHistory":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/second.html"}) this.controller.loadUrl({url:"resource://rawfile/second.html"});
setTimeout(()=>{ setTimeout(()=>{
Utils.emitEvent(this.newUrl,116) Utils.emitEvent(this.newUrl,116)
},3000) },3000)
...@@ -316,7 +316,7 @@ struct Index { ...@@ -316,7 +316,7 @@ struct Index {
break; break;
} }
case "emitGetTitle":{ case "emitGetTitle":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
let webTitle=this.controller.getTitle() let webTitle=this.controller.getTitle()
Utils.emitEvent(webTitle,122) Utils.emitEvent(webTitle,122)
...@@ -324,7 +324,7 @@ struct Index { ...@@ -324,7 +324,7 @@ struct Index {
break; break;
} }
case "emitGetPageHeight":{ case "emitGetPageHeight":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
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)=>{
...@@ -335,7 +335,7 @@ struct Index { ...@@ -335,7 +335,7 @@ struct Index {
break; break;
} }
case "emitGetRequestFocus":{ case "emitGetRequestFocus":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/second.html"}) this.controller.loadUrl({url:"resource://rawfile/second.html"});
await Utils.sleep(2000) await Utils.sleep(2000)
sendEventByKey('textInput',10,'') sendEventByKey('textInput',10,'')
break; break;
...@@ -382,7 +382,7 @@ struct Index { ...@@ -382,7 +382,7 @@ struct Index {
case "emitGeolocationAccessFalse":{ case "emitGeolocationAccessFalse":{
this.geolocationAccess=false this.geolocationAccess=false
await Utils.sleep(2000) await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/geo.html"}) this.controller.loadUrl({url:"resource://rawfile/geo.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getGeoResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getGeoResult()",callback:(res)=>{
console.info("getGeoResult==>"+res) console.info("getGeoResult==>"+res)
...@@ -394,7 +394,7 @@ struct Index { ...@@ -394,7 +394,7 @@ struct Index {
case "emitInitialScale":{ case "emitInitialScale":{
this.initialScale=120 this.initialScale=120
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/second.html"}) this.controller.loadUrl({url:"resource://rawfile/second.html"});
this.enterPageEnd=true this.enterPageEnd=true
break; break;
} }
...@@ -409,13 +409,13 @@ struct Index { ...@@ -409,13 +409,13 @@ struct Index {
this.geolocationAccess=true this.geolocationAccess=true
this.geoShow=true this.geoShow=true
await Utils.sleep(2000) await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/geo.html"}) this.controller.loadUrl({url:"resource://rawfile/geo.html"});
break; break;
} }
case "emitDomStorageAccessFalse":{ case "emitDomStorageAccessFalse":{
this.domStorageAccess=false this.domStorageAccess=false
await Utils.sleep(2000) await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/domApi.html"}) this.controller.loadUrl({url:"resource://rawfile/domApi.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getDomResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getDomResult()",callback:(res)=>{
console.info("getDomResult==>"+res) console.info("getDomResult==>"+res)
...@@ -427,7 +427,7 @@ struct Index { ...@@ -427,7 +427,7 @@ struct Index {
case "emitDomStorageAccessTrue":{ case "emitDomStorageAccessTrue":{
this.domStorageAccess=true this.domStorageAccess=true
await Utils.sleep(2000) await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/domApi.html"}) this.controller.loadUrl({url:"resource://rawfile/domApi.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getDomResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getDomResult()",callback:(res)=>{
console.info("getDomResult==>"+res) console.info("getDomResult==>"+res)
...@@ -439,7 +439,7 @@ struct Index { ...@@ -439,7 +439,7 @@ struct Index {
case "emitImageAccessFalse":{ case "emitImageAccessFalse":{
this.imageAccess=false this.imageAccess=false
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getImgResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getImgResult()",callback:(res)=>{
console.info("getImgResult==>"+res) console.info("getImgResult==>"+res)
...@@ -451,7 +451,7 @@ struct Index { ...@@ -451,7 +451,7 @@ struct Index {
case "emitImageAccessTrue":{ case "emitImageAccessTrue":{
this.imageAccess=true this.imageAccess=true
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getImgResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getImgResult()",callback:(res)=>{
console.info("getImgResult==>"+res) console.info("getImgResult==>"+res)
...@@ -463,7 +463,7 @@ struct Index { ...@@ -463,7 +463,7 @@ struct Index {
case "emitOnlineImageAccessFalse":{ case "emitOnlineImageAccessFalse":{
this.onlineImageAccess=false this.onlineImageAccess=false
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/onlineImageAccess.html"}) this.controller.loadUrl({url:"resource://rawfile/onlineImageAccess.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getImageLoadResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getImageLoadResult()",callback:(res)=>{
console.info("getImageLoadResult==>"+res) console.info("getImageLoadResult==>"+res)
...@@ -475,7 +475,7 @@ struct Index { ...@@ -475,7 +475,7 @@ struct Index {
case "emitOnlineImageAccessTrue":{ case "emitOnlineImageAccessTrue":{
this.onlineImageAccess=true this.onlineImageAccess=true
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/onlineImageAccess.html"}) this.controller.loadUrl({url:"resource://rawfile/onlineImageAccess.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getImageLoadResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getImageLoadResult()",callback:(res)=>{
console.info("getImageLoadResult==>"+res) console.info("getImageLoadResult==>"+res)
...@@ -487,7 +487,7 @@ struct Index { ...@@ -487,7 +487,7 @@ struct Index {
case "emitDatabaseAccessTrue":{ case "emitDatabaseAccessTrue":{
this.databaseAccess=true this.databaseAccess=true
await Utils.sleep(2000) await Utils.sleep(2000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/databaseAccess.html"}) this.controller.loadUrl({url:"resource://rawfile/databaseAccess.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getDataResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getDataResult()",callback:(res)=>{
console.info("getDataResult==>"+res) console.info("getDataResult==>"+res)
...@@ -499,7 +499,7 @@ struct Index { ...@@ -499,7 +499,7 @@ struct Index {
case "emitOverviewModeAccessFalse":{ case "emitOverviewModeAccessFalse":{
this.overviewModeAccess=false this.overviewModeAccess=false
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"}) this.controller.loadUrl({url:"resource://rawfile/overview.html"});
setTimeout(()=>{ setTimeout(()=>{
let webPageHeight=this.controller.getPageHeight() let webPageHeight=this.controller.getPageHeight()
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
...@@ -513,7 +513,7 @@ struct Index { ...@@ -513,7 +513,7 @@ struct Index {
case "emitOverviewModeAccessTrue":{ case "emitOverviewModeAccessTrue":{
this.overviewModeAccess=true this.overviewModeAccess=true
await Utils.sleep(1000) await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"}) this.controller.loadUrl({url:"resource://rawfile/overview.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{ this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res) console.info("getViewResult==>"+res)
...@@ -523,7 +523,7 @@ struct Index { ...@@ -523,7 +523,7 @@ struct Index {
break; break;
} }
case "emitOnPrompt":{ case "emitOnPrompt":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.runJavaScript({script:"toPrompt()"}) this.controller.runJavaScript({script:"toPrompt()"})
},3000) },3000)
...@@ -562,7 +562,7 @@ struct Index { ...@@ -562,7 +562,7 @@ struct Index {
} }
case "emitFileAccessTrue":{ case "emitFileAccessTrue":{
this.fileAccess=true this.fileAccess=true
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
this.controller.runJavaScript({script:"openRawFile()"}) this.controller.runJavaScript({script:"openRawFile()"})
setTimeout(()=>{ setTimeout(()=>{
let webTitle=this.controller.getTitle() let webTitle=this.controller.getTitle()
...@@ -615,10 +615,10 @@ struct Index { ...@@ -615,10 +615,10 @@ struct Index {
this.controller.loadUrl({url:'https://example1.com/path/does/not/exist/index.jsp'}) this.controller.loadUrl({url:'https://example1.com/path/does/not/exist/index.jsp'})
break; break;
} }
case "emitOnTitleReceive":{ case "emitOnTitleReceive":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
Utils.emitEvent(this.titleReceive,67) Utils.emitEvent(this.titleReceive,67)
},3000) },3000)
break; break;
} }
...@@ -644,9 +644,9 @@ struct Index { ...@@ -644,9 +644,9 @@ struct Index {
},3000) },3000)
break; break;
} }
case "emitZoom":{ case "emitZoom":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
this.controller.zoom(2) this.controller.zoom(2)
setTimeout(() => { setTimeout(() => {
if(this.controller.getPageHeight() > 1400){ if(this.controller.getPageHeight() > 1400){
...@@ -728,8 +728,8 @@ struct Index { ...@@ -728,8 +728,8 @@ struct Index {
} }
case "emitOnActive":{ case "emitOnActive":{
this.controller.onActive() this.controller.onActive()
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}) this.controller.loadUrl({url:"resource://rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
let onActiveCalled = this.pageBegin let onActiveCalled = this.pageBegin
Utils.emitEvent(onActiveCalled,85) Utils.emitEvent(onActiveCalled,85)
},5000) },5000)
......
...@@ -29,9 +29,13 @@ export default class Utils { ...@@ -29,9 +29,13 @@ export default class Utils {
console.info(`[${testCaseName}] START`); console.info(`[${testCaseName}] START`);
try{ try{
let callBack=(backData)=>{ let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertEqual(expectedValue); expect(backData.data.ACTION).assertEqual(expectedValue);
console.info(`[${testCaseName}] END`); console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done() done()
} }
let innerEvent = { let innerEvent = {
...@@ -64,10 +68,14 @@ export default class Utils { ...@@ -64,10 +68,14 @@ export default class Utils {
console.info(`[${testCaseName}] START`); console.info(`[${testCaseName}] START`);
try{ try{
let callBack=(backData)=>{ let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100); expect(backData.data.actualValue).assertLarger(backData.data.expectedValue-100);
expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100)); expect(backData.data.actualValue).assertLess(backData.data.expectedValue-(-100));
console.info(`[${testCaseName}] END`); console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done() done()
} }
let innerEvent = { let innerEvent = {
...@@ -101,9 +109,13 @@ export default class Utils { ...@@ -101,9 +109,13 @@ export default class Utils {
console.info(`[${testCaseName}] START`); console.info(`[${testCaseName}] START`);
try{ try{
let callBack=(backData)=>{ let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.ACTION).assertContain(expectedValue); expect(backData.data.ACTION).assertContain(expectedValue);
console.info(`[${testCaseName}] END`); console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done() done()
} }
let innerEvent = { let innerEvent = {
...@@ -136,9 +148,13 @@ export default class Utils { ...@@ -136,9 +148,13 @@ export default class Utils {
console.info(`[${testCaseName}] START`); console.info(`[${testCaseName}] START`);
try{ try{
let callBack=(backData)=>{ let callBack=(backData)=>{
try{
console.info(`${testCaseName} get result is:`+JSON.stringify(backData)); console.info(`${testCaseName} get result is:`+JSON.stringify(backData));
expect(backData.data.actualValue).assertLarger(backData.data.expectedValue); expect(backData.data.actualValue).assertLarger(backData.data.expectedValue);
console.info(`[${testCaseName}] END`); console.info(`[${testCaseName}] END`);
}catch(err){
console.info(`[${testCaseName}] err:`+JSON.stringify(err));
}
done() done()
} }
let innerEvent = { let innerEvent = {
......
...@@ -91,7 +91,7 @@ export default function webJsunit() { ...@@ -91,7 +91,7 @@ export default function webJsunit() {
*/ */
it('onResourceLoad',0,async function(done){ it('onResourceLoad',0,async function(done){
emitKey="emitLoadUrl"; emitKey="emitLoadUrl";
Utils.registerEvent("onResourceLoad","file:///data/storage/el1/bundle/phone/resources/rawfile/second.html",108,done); Utils.registerContainEvent("onResourceLoad","second.html",108,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
...@@ -129,7 +129,7 @@ export default function webJsunit() { ...@@ -129,7 +129,7 @@ export default function webJsunit() {
*/ */
it('onRefreshAccessedHistory',0,async function(done){ it('onRefreshAccessedHistory',0,async function(done){
emitKey="emitGetHitTest"; emitKey="emitGetHitTest";
Utils.registerEvent("onRefreshAccessedHistory","file:///data/storage/el1/bundle/phone/resources/rawfile/second.html",116,done); Utils.registerContainEvent("onRefreshAccessedHistory","second.html",116,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
...@@ -439,7 +439,7 @@ export default function webJsunit() { ...@@ -439,7 +439,7 @@ export default function webJsunit() {
*/ */
it('onPageBegin',0,async function(done){ it('onPageBegin',0,async function(done){
emitKey="emitOnPageEnd"; emitKey="emitOnPageEnd";
Utils.registerEvent("onPageBegin","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",59,done); Utils.registerContainEvent("onPageBegin","index.html",59,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
...@@ -449,7 +449,7 @@ export default function webJsunit() { ...@@ -449,7 +449,7 @@ export default function webJsunit() {
*/ */
it('onPageEnd',0,async function(done){ it('onPageEnd',0,async function(done){
emitKey="emitOnConsole"; emitKey="emitOnConsole";
Utils.registerEvent("onPageEnd","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",60,done); Utils.registerContainEvent("onPageEnd","index.html",60,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
...@@ -629,7 +629,7 @@ export default function webJsunit() { ...@@ -629,7 +629,7 @@ export default function webJsunit() {
*/ */
it('onActive',0,async function(done){ it('onActive',0,async function(done){
emitKey="emitRegisterJavaScriptProxy"; emitKey="emitRegisterJavaScriptProxy";
Utils.registerEvent("onActive","file:///data/storage/el1/bundle/phone/resources/rawfile/index.html",85,done); Utils.registerContainEvent("onActive","index.html",85,done);
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
/* /*
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
<body> <body>
<div id="container">首页</div> <div id="container">首页</div>
<div id="pageHeight"></div> <div id="pageHeight"></div>
<a href="file:///data/storage/el1/bundle/phone/resources/rawfile/second.html" id="fileAccess">打开rawfile文件</a> <a href="second.html" id="fileAccess">打开rawfile文件</a>
<img src="file:///data/storage/el1/bundle/phone/resources/rawfile/icon.png" alt="icon" id="imgs"> <img src="icon.png" alt="icon" id="imgs">
</body> </body>
<script> <script>
let ele=document.getElementById("imgs"); let ele=document.getElementById("imgs");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册