提交 ba880200 编写于 作者: W wang-xupeng2

revise api

Signed-off-by: Nwang-xupeng2 <wangxupeng2@huawei.com>
上级 dba54068
...@@ -17,4 +17,4 @@ ...@@ -17,4 +17,4 @@
"cleanup-apps": true "cleanup-apps": true
} }
] ]
} }
\ No newline at end of file
...@@ -43,7 +43,6 @@ struct Index { ...@@ -43,7 +43,6 @@ struct Index {
@State geolocationAccess:boolean=true @State geolocationAccess:boolean=true
@State onlineImageAccess:boolean=true @State onlineImageAccess:boolean=true
@State databaseAccess:boolean=true @State databaseAccess:boolean=true
@State overviewModeAccess:boolean=false
@State initialScale:number=100 @State initialScale:number=100
@State enterPageEnd:boolean=false @State enterPageEnd:boolean=false
@State newScale:number=0 @State newScale:number=0
...@@ -54,7 +53,6 @@ struct Index { ...@@ -54,7 +53,6 @@ struct Index {
@State cacheError:boolean=false @State cacheError:boolean=false
@State mixedSwitch:boolean=false @State mixedSwitch:boolean=false
@State mixedAllSwitch:boolean=false @State mixedAllSwitch:boolean=false
@State overViewFalseHeight:number=0
@State isProgressFinish:boolean=false @State isProgressFinish:boolean=false
@State isHttpErrorReceive:boolean=false @State isHttpErrorReceive:boolean=false
onPageShow(){ onPageShow(){
...@@ -106,7 +104,6 @@ struct Index { ...@@ -106,7 +104,6 @@ struct Index {
.cacheMode(this.cacheMode) .cacheMode(this.cacheMode)
.initialScale(this.initialScale) .initialScale(this.initialScale)
.mixedMode(this.mixedMode) .mixedMode(this.mixedMode)
.overviewModeAccess(this.overviewModeAccess)
.userAgent("Mozila/5.0 (Linux; Andriod 9; VRD-AL10; HMSCore 6.3.0.331) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.0.4.1 MobileSafari/537.36") .userAgent("Mozila/5.0 (Linux; Andriod 9; VRD-AL10; HMSCore 6.3.0.331) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.105 HuaweiBrowser/12.0.4.1 MobileSafari/537.36")
.javaScriptProxy({ .javaScriptProxy({
object:this.jsObj, object:this.jsObj,
...@@ -313,7 +310,7 @@ struct Index { ...@@ -313,7 +310,7 @@ struct Index {
break; break;
} }
case "emitGetWebId":{ case "emitGetWebId":{
Utils.emitEvent("webId",120) Utils.emitEvent(webId,120)
break; break;
} }
case "emitGetRequestFocus":{ case "emitGetRequestFocus":{
...@@ -471,31 +468,6 @@ struct Index { ...@@ -471,31 +468,6 @@ struct Index {
},3000) },3000)
break; break;
} }
case "emitOverviewModeAccessFalse":{
this.overviewModeAccess=false
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"});
setTimeout(()=>{
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
this.overViewFalseHeight=parseInt(res)
console.info("getViewResult==>"+res)
Utils.emitEventTwo(this.overViewFalseHeight,parseInt(res),168)
}})
},3000)
break;
}
case "emitOverviewModeAccessTrue":{
this.overviewModeAccess=true
await Utils.sleep(1000)
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/overview.html"});
setTimeout(()=>{
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res)
Utils.emitEventTwo(this.overViewFalseHeight,parseInt(res),170)
}})
},3000)
break;
}
case "emitOnPrompt":{ case "emitOnPrompt":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}); this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"});
setTimeout(()=>{ setTimeout(()=>{
...@@ -641,18 +613,17 @@ struct Index { ...@@ -641,18 +613,17 @@ struct Index {
},3000) },3000)
break; break;
} }
case "emitOnInactive":{ case "emitOnInactive":{
this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"}); this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"});
this.controller.onInactive() this.controller.onInactive()
setTimeout(()=>{ setTimeout(()=>{
var onInactiveCalled = false
this.controller.runJavaScript({script:"gettitle()",callback:(res)=>{ this.controller.runJavaScript({script:"gettitle()",callback:(res)=>{
console.info("gettitle++++++"+res) console.info("gettitle++++++"+res)
if(res == "\"index\""){ if(res == "\"index\""){
onInactiveCalled = true onInactiveCalled = true
} }
Utils.emitEvent(onInactiveCalled,84) Utils.emitEvent(onInactiveCalled,84)
}}) }})
},3000) },3000)
break; break;
} }
......
/*
* Copyright (c) 2021 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 Utils from '../../test/Utils';
@Entry
@Component
struct Second {
controller:WebController = new WebController()
@State str:string="emitOverviewModeAccessTrue"
@State overviewModeAccess:boolean=true
@State overviewScale:string=""
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('webcomponenttwo').onClick(async ()=>{
console.info("key==>"+this.str);
switch(this.str){
case "emitOverviewModeAccessTrue":{
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res);
this.overviewScale=res;
Utils.emitEventTwo(res,"1",168);
}});
break;
}
case "emitOverviewModeAccessFalse":{
this.overviewModeAccess=false;
await Utils.sleep(2000);
this.controller.runJavaScript({script:"getViewResult()",callback:(res)=>{
console.info("getViewResult==>"+res);
Utils.emitEventTwo(this.overviewScale,res,170);
}});
break;
}
default:
console.info("can not match case");
}
})
}
Web({src:$rawfile('overview.html'),controller:this.controller})
.overviewModeAccess(this.overviewModeAccess)
}
}
}
\ No newline at end of file
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
* limitations under the License. * limitations under the License.
*/ */
import webJsunit from './WebJsunit.test' import webJsunit from './WebJsunit.test'
import webTwoJsunit from './WebTwoJsunit.test'
export default function testsuite() { export default function testsuite() {
webJsunit() webJsunit()
webTwoJsunit()
} }
\ No newline at end of file
/*
* 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.
*/
// @ts-nocheck
import { describe, beforeEach, afterEach, it, expect, beforeAll} from "@ohos/hypium";
import events_emitter from '@ohos.events.emitter';
import router from '@system.router';
import Utils from './Utils.ets';
let emitKey = "emitOverviewModeAccessTrue";
export default function webTwoJsunit() {
describe('overviewTest', function () {
beforeAll(async function (done) {
let options = {
uri: 'MainAbility/pages/webTwo',
}
try {
router.clear();
let pages = router.getState();
console.info("get webTwo state success " + JSON.stringify(pages));
if (!("webTwo" == pages.name)) {
console.info("get webTwo state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push webTwo page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push webTwo 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_001
*tc.name overviewModeAccessTrue
*tc.desic Sets allow the Web access overview mode
*/
it('overviewModeAccessTrue',0,async function(done){
emitKey="emitOverviewModeAccessFalse";
Utils.registerLargerEvent("overviewModeAccessTrue",168,done);
sendEventByKey('webcomponenttwo',10,'');
})
/*
*tc.number SUB_ACE_BASIC_ETS_API_002
*tc.name overviewModeAccessFalse
*tc.desic Sets not allow the Web access overview mode
*/
it('overviewModeAccessFalse',0,async function(done){
emitKey="emitOverviewModeAccessFalse";
Utils.registerLargerEvent("overviewModeAccessFalse",170,done);
sendEventByKey('webcomponenttwo',10,'');
})
})
}
\ No newline at end of file
{ {
"src": [ "src": [
"MainAbility/pages/web" "MainAbility/pages/web",
"MainAbility/pages/webTwo"
] ]
} }
\ No newline at end of file
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
</body> </body>
<script> <script>
function getViewResult(){ function getViewResult(){
let height=document.getElementsByTagName("body")[0].scrollHeight; let scaleNumber=window.visualViewport.scale;
return height; return scaleNumber;
} }
</script> </script>
</html> </html>
\ No newline at end of file
...@@ -74,13 +74,9 @@ struct Index { ...@@ -74,13 +74,9 @@ struct Index {
Row(){ Row(){
Button("web click").key('webcomponent').onClick(async ()=>{ Button("web click").key('webcomponent').onClick(async ()=>{
console.info("key==>"+this.str) console.info("key==>"+this.str)
switch(this.str){ switch(this.str){
case "emitAllowGeolocation":{ case "emitAllowGeolocation":{
try { web_webview.GeolocationPermissions.allowGeolocation("file:///")
web_webview.GeolocationPermissions.allowGeolocation("resource://rawfile/");
} catch (error) {
console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
}
web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => { web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
if (error) { if (error) {
console.log('error:' + JSON.stringify(error)); console.log('error:' + JSON.stringify(error));
...@@ -174,7 +170,7 @@ struct Index { ...@@ -174,7 +170,7 @@ struct Index {
} }
Utils.emitEvent(zoomInCalled,428); Utils.emitEvent(zoomInCalled,428);
}}) }})
}}) }})
},3000); },3000);
break ; break ;
} }
......
...@@ -132,4 +132,4 @@ export default class Utils { ...@@ -132,4 +132,4 @@ export default class Utils {
console.info("emit emitKey err: " + JSON.stringify(err)); console.info("emit emitKey err: " + JSON.stringify(err));
} }
} }
} }
\ No newline at end of file
...@@ -175,4 +175,4 @@ export default function webJsunit() { ...@@ -175,4 +175,4 @@ export default function webJsunit() {
sendEventByKey('webcomponent',10,''); sendEventByKey('webcomponent',10,'');
}) })
}) })
} }
\ No newline at end of file
...@@ -46,4 +46,4 @@ ...@@ -46,4 +46,4 @@
} }
] ]
} }
} }
\ No newline at end of file
...@@ -70,4 +70,4 @@ ...@@ -70,4 +70,4 @@
return document.title return document.title
} }
</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.
先完成此消息的编辑!
想要评论请 注册