diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.hml b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.hml
index 62ba67761b7a56e502042c2183bc252b7b7e7517..2ce65d89dabcbd8d2c0fe62c6b6ecf4c07bff4c6 100644
--- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.hml
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.hml
@@ -226,6 +226,14 @@
方法30
+
+
+ 方法31
+
+
+
+ 方法32
+
diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.js b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.js
index d8da70683a82e0ddd9c8ba808c39ddecddd1a261..e870ba3c148a7b9083ba801127475ced4eeaf0f5 100644
--- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.js
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/compomettestjs/CanvasRenderingContext2D/index.js
@@ -398,6 +398,31 @@
ctx.rotateZ(10);
ctx.fillRect(10, 10, 30, 30);
},
+ functionTouch30() {
+ const el =this.$refs.function15;
+ const ctx = el.getContext('2d');
+ ctx.fillRect(10, 10, 30, 30);
+ ctx.rotateZ(10);
+ ctx.fillRect(10, 10, 30, 30);
+ },
+ functionTouch31() {
+ let mat = new Matix2D();
+ mat.multiply();
+ let stack = new StackAttribute();
+ stack.alignContent();
+ const el =this.$refs.function15;
+ const ctx = el.getContext('2d');
+ ctx.fillRect(10, 10, 30, 30);
+ ctx.multiply();
+ ctx.fillRect(10, 10, 30, 30);
+ },
+ functionTouch32() {
+ const el =this.$refs.function15;
+ const ctx = el.getContext('2d');
+ ctx.fillRect(10, 10, 30, 30);
+ ctx.translateZ(50);
+ ctx.fillRect(10, 10, 30, 30);
+ },
}
\ No newline at end of file
diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPrompt24.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPrompt24.ets
new file mode 100644
index 0000000000000000000000000000000000000000..ef5a2ec40dd5850bafc134bfbb14b947bfc50b7a
--- /dev/null
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPrompt24.ets
@@ -0,0 +1,250 @@
+// @ts-nocheck
+/**
+ * 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 prompt from '@ohos.prompt';
+import promptAction from '@ohos.promptAction';
+import events_emitter from '@ohos.events.emitter';
+
+@Entry
+@Component
+struct promptExample {
+ @State text: string = 'item1'
+ @State color: string = '#000000'
+ build(){
+ Column(){
+ Button('showActionMenu')
+ .key('button1')
+ .backgroundColor('#FF0B8FE2')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=>{
+ prompt.showActionMenu({
+ title: 'Title Info',
+ buttons: [
+ {
+ text: this.text,
+ color: this.color,
+ },
+ ],
+ success: function(data) {
+ console.log('dialog success callback,click button : ' + data.tapIndex);
+ },
+ fail: function(data) {
+ console.log('dialog fail callback' + data.errMsg);
+ },
+ });
+ })
+ Button('showDialog')
+ .key('button2')
+ .backgroundColor('#FF0B8FE2')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=> {
+ prompt.showDialog({
+ title: 'Title Info',
+ message: 'Message Info',
+ buttons: [
+ {
+ text: this.text,
+ color: this.color,
+ },
+ ],
+ success: function(data) {
+ console.log('dialog success callback,click button : ' + data.index);
+ },
+ cancel: function() {
+ console.log('dialog cancel callback');
+ },
+ });
+ })
+ Button('showActionMenu1')
+ .key('button3')
+ .backgroundColor('#ffe20b48')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=>{
+ prompt.showDialog({
+ title: 'Title Info',
+ message: 'Message Info',
+ buttons: [
+ {
+ text: 'button1',
+ color: '#000000',
+ },
+ {
+ text: 'button2',
+ color: '#000000',
+ }
+ ],
+ })
+ .then(data => {
+ Utils.emitEvent('sucessful',422)
+ console.info('showDialog success, click button: ' + data.index);
+ })
+ .catch(err => {
+ console.info('showDialog error: ' + err);
+ })
+ })
+
+ Button('showActionMenu2')
+ .key('button6')
+ .backgroundColor('#ffe20b48')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=>{
+ prompt.showActionMenu({
+ title: 'showActionMenu Title Info',
+ buttons: [
+ {
+ text: 'item1',
+ color: '#666666',
+ },
+ {
+ text: 'item2',
+ color: '#000000',
+ },
+ ]
+ })
+ .then(data => {
+ console.info('showActionMenu success, click button: ' + data.index);
+ })
+ .catch(err => {
+ console.info('showActionMenu error: ' + err);
+ })
+ })
+ Button('showDialog2')
+ .key('button5')
+ .backgroundColor('#ffe20b56')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=> {
+ promptAction.showDialog({
+ title: 'Title Info',
+ message: 'Message Info',
+ buttons: [
+ {
+ text: this.text,
+ color: this.color,
+ },
+ ],
+ })
+ .then(data => {
+ console.info('showDialog success, click button: ' + data.tapIndex);
+ Utils.emitEvent('sucessful',422)
+ })
+ .catch(data => {
+ console.info('showDialog error: ' + data.errMsg);
+ });
+ })
+ Button('showDialog2')
+ .key('button5')
+ .backgroundColor('#ffe20b56')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=> {
+ try {
+ promptAction.showDialog({
+ title: 'showDialog Title Info',
+ message: 'Message Info',
+ buttons: [
+ {
+ text: 'button1',
+ color: '#000000',
+ },
+ {
+ text: 'button2',
+ color: '#000000',
+ }
+ ]
+ }, (err, data) => {
+ if (err) {
+ console.info('showDialog err: ' + err);
+ return;
+ }
+ console.info('showDialog success callback, click button: ' + data.index);
+ });
+ } catch (error) {
+ console.error(`showDialog args error code is ${error.code}, message is ${error.message}`);
+ };
+ })
+ Button('showDialog2')
+ .key('button5')
+ .backgroundColor('#ffe20b56')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=> {
+
+ try {
+ promptAction.showActionMenu({
+ title: 'showActionMenu Title Info',
+ buttons: [
+ {
+ text: 'item1',
+ color: '#666666',
+ },
+ {
+ text: 'item2',
+ color: '#000000',
+ },
+ ]
+ })
+ .then(data => {
+ console.info('showActionMenu success, click button: ' + data.index);
+ })
+ .catch(err => {
+ console.info('showActionMenu error: ' + err);
+ })
+ } catch (error) {
+ console.error(`showActionMenu args error code is ${error.code}, message is ${error.message}`);
+ };
+
+ })
+ Button('showDialog2')
+ .key('button5')
+ .backgroundColor('#ffe20b56')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=> {
+ try {
+ promptAction.showActionMenu({
+ title: 'showActionMenu Title Info',
+ buttons: [
+ {
+ text: 'item1',
+ color: '#666666',
+ },
+ {
+ text: 'item2',
+ color: '#000000',
+ },
+ ]
+ })
+ .then(data => {
+ console.info('showActionMenu success, click button: ' + data.index);
+ })
+ .catch(err => {
+ console.info('showActionMenu error: ' + err);
+ })
+ } catch (error) {
+ console.error(`showActionMenu args error code is ${error.code}, message is ${error.message}`);
+ };
+ })
+
+
+
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPromptg.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPromptg.ets
index e004134bade51889084d3d6205e574f90fdcde17..6c6b322aa9ba979d8535b731707219015256028a 100644
--- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPromptg.ets
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosPromptg.ets
@@ -70,84 +70,171 @@ struct promptExample {
},
});
})
- Button('showActionMenu1')
- .key('button3')
- .backgroundColor('#ffe20b48')
+
+ Button('protshowDialog')
+ .key('buttonp')
+ .backgroundColor('#FF0B8FE2')
.fontSize(20)
.margin({top: 20})
- .onClick(()=>{
+ .onClick(()=> {
prompt.showDialog({
title: 'Title Info',
message: 'Message Info',
buttons: [
{
- text: this.text,
- color: this.color,
+ text: 'button1',
+ color: '#000000',
},
+ {
+ text: 'button2',
+ color: '#000000',
+ }
],
})
.then(data => {
- console.info('showDialog success, click button: ' + data.tapIndex);
- Utils.emitEvent('sucessful',422)
-
+ console.info('showDialog success, click button: ' + data.index);
+ })
+ .catch(err => {
+ console.info('showDialog error: ' + err);
})
- .catch(data => {
- console.info('showDialog error: ' + data.errMsg);
- });
-
})
- Button('showDialog1')
- .key('button4')
- .backgroundColor('#ffe20b56')
+ Button('protshowDialog')
+ .key('buttonp')
+ .backgroundColor('#FF0B8FE2')
.fontSize(20)
.margin({top: 20})
.onClick(()=> {
prompt.showDialog({
- title: 'Title Info',
+ title: 'showDialog Title Info',
message: 'Message Info',
buttons: [
{
- text: this.text,
- color: this.color,
+ text: 'button1',
+ color: '#000000',
},
- ],
- })
- .then(data => {
- console.info('showDialog success, click button: ' + data.tapIndex);
- Utils.emitEvent('sucessful',422)
+ {
+ text: 'button2',
+ color: '#000000',
+ }
+ ]
+ }, (err, data) => {
+ if (err) {
+ console.info('showDialog err: ' + err);
+ return;
+ }
+ console.info('showDialog success callback, click button: ' + data.index);
+ });
- })
- .catch(data => {
- console.info('showDialog error: ' + data.errMsg);
- });
- })
+ Button('protshowActionMenu1')
+ .key('buttons1')
+ .backgroundColor('#FF0B8FE2')
+ .fontSize(20)
+ .margin({top: 20})
+ .onClick(()=> {
+ prompt.showActionMenu({
+ title: 'Title Info',
+ buttons: [
+ {
+ text: 'item1',
+ color: '#666666',
+ },
+ {
+ text: 'item2',
+ color: '#000000',
+ },
+ ]
+ }, (err, data) => {
+ if (err) {
+ console.info('showActionMenu err: ' + err);
+ return;
+ }
+ console.info('showActionMenu success callback, click button: ' + data.index);
+ });
-
- Button('showActionMenu2')
- .key('button6')
- .backgroundColor('#ffe20b48')
+ Button('protshowActionMenu2')
+ .key('buttons2')
+ .backgroundColor('#FF0B8FE2')
.fontSize(20)
.margin({top: 20})
- .onClick(()=>{
- promptAction.showDialog({
- title: 'Title Info',
- message: 'Message Info',
+ .onClick(()=> {
+ prompt.showActionMenu({
+ title: 'showActionMenu Title Info',
buttons: [
{
- text: this.text,
- color: this.color,
+ text: 'item1',
+ color: '#666666',
},
- ],
+ {
+ text: 'item2',
+ color: '#000000',
+ },
+ ]
})
.then(data => {
- console.info('showDialog success, click button: ' + data.tapIndex);
- Utils.emitEvent('sucessful',422)
-
+ console.info('showActionMenu success, click button: ' + data.index);
})
- .catch(data => {
- console.info('showDialog error: ' + data.errMsg);
- });
+ .catch(err => {
+ console.info('showActionMenu error: ' + err);
+ })
+
+
+
+
+
+
+ })
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+in({top: 20})
+ .onClick(()=>{
+ prompt.showActionMenu({
+ title: 'showActionMenu Title Info',
+ buttons: [
+ {
+ text: 'item1',
+ color: '#666666',
+ },
+ {
+ text: 'item2',
+ color: '#000000',
+ },
+ ]
+ })
+ .then(data => {
+ console.info('showActionMenu success, click button: ' + data.index);
+ })
+ .catch(err => {
+ console.info('showActionMenu error: ' + err);
+ })
})
Button('showDialog2')
diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosRouterA_y.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosRouterA_y.ets
index 1c06a084240ad20b8faeff825ecdae24cad97790..58a7b8ecd7d2da16af737a90e4d1132a40bca329 100644
--- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosRouterA_y.ets
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/ohosRouterA_y.ets
@@ -58,24 +58,24 @@ struct OhosRouterA {
.margin({top: 20})
.onClick(() => {
try {
- routery.pushUrl({
- url: 'pages/routerpage2',
- params: {
- data1: 'message',
- data2: {
- data3: [123, 456, 789]
- },
- },
- }, (err) => {
- if (err) {
- console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info('pushUrl success');
- });
- } catch (error) {
- console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
- };
+ routery.pushUrl({
+ url: 'pages/routerpage2',
+ params: {
+ data1: 'message',
+ data2: {
+ data3: [123, 456, 789]
+ },
+ },
+ })
+ .then(() => {
+ // success
+ })
+ .catch(err => {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ })
+ } catch (error) {
+ console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
+ };
});
Button('pushUrl')
.key('pushButtonA1')
@@ -84,48 +84,48 @@ struct OhosRouterA {
.margin({top: 20})
.onClick(() => {
try {
- routery.pushUrl({
- url: 'pages/routerpage2',
- params: {
- data1: 'message',
- data2: {
- data3: [123, 456, 789]
- },
- },
- }, (err) => {
- if (err) {
- console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info('pushUrl success');
- });
- } catch (error) {
- console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
- };
+ routery.pushUrl({
+ url: 'pages/routerpage2',
+ params: {
+ data1: 'message',
+ data2: {
+ data3: [123, 456, 789]
+ },
+ },
+ }, routery.RouterMode.Standard)
+ .then(() => {
+ // success
+ })
+ .catch(err => {
+ console.error(`pushUrl failed, code is ${err.code}, message is ${err.message}`);
+ })
+ } catch (error) {
+ console.error(`pushUrl args error code is ${error.code}, message is ${error.message}`);
+ };
});
- Button('replaceUrl')
- .key('pushButtonA1')
+ Button('replaceUr2')
+ .key('pushButtonA2')
.backgroundColor('#FF0B8FE2')
.fontSize(20)
.margin({top: 20})
.onClick(() => {
try {
- routery.replaceUrl({
- url: 'pages/detail',
- params: {
- data1: 'message',
- },
- }, routery.RouterMode.Standard, (err) => {
- if (err) {
- console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info('replaceUrl success');
- });
- } catch (error) {
- console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
- };
+ routery.replaceUrl({
+ url: 'pages/detail',
+ params: {
+ data1: 'message',
+ },
+ }, routery.RouterMode.Standard)
+ .then(() => {
+ // success
+ })
+ .catch(err => {
+ console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
+ })
+ } catch (error) {
+ console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
+ };
});
Button('replaceUrl')
.key('pushButtonA1')
@@ -134,21 +134,21 @@ struct OhosRouterA {
.margin({top: 20})
.onClick(() => {
try {
- routery.replaceUrl({
- url: 'pages/detail',
- params: {
- data1: 'message',
- },
- }, (err) => {
- if (err) {
- console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
- return;
- }
- console.info('replaceUrl success');
- });
- } catch (error) {
- console.error(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
- };
+ routery.replaceUrl({
+ url: 'pages/detail',
+ params: {
+ data1: 'message',
+ },
+ })
+ .then(() => {
+ // success
+ })
+ .catch(err => {
+ console.info(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
+ })
+ } catch (error) {
+ console.info(`replaceUrl args error code is ${error.code}, message is ${error.message}`);
+ };
});
Button('clear')
diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/shapeClipping_y.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/shapeClipping_y.ets
index 26f0bedae4bbc0eb0a89470989ddeb97ba8359b2..00cdc9d51f0ab18bf0970f1bb6e5a59349417629 100644
--- a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/shapeClipping_y.ets
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/shapeClipping_y.ets
@@ -23,73 +23,38 @@ struct ClipAndMaskExample {
@State isClipCircle:boolean = true;
@State maskType: CommonShapeMethod= new Rect({ width: 280, height: 280 });
@State clipType: CommonShapeMethod= new Circle({ width: 280, height: 280 });
- @State shape_Type: CommonShapeMethod= new elliptical({ width: 200, height: 280 });
- @State lengthType: CommonShapeMethod= new line({ width: 0, height: 10 });
- @State pathType: CommonShapeMethod= new path({ width: 10, height: 10 });
- @State shape_2_Type: CommonShapeMethod= new polygon({ width: 5, height: 10 });
- @State shape_3_Type: CommonShapeMethod= new polyine({ width: 5, height: 10 });
- @State shape_4_Type: CommonShapeMethod= new rect_({ width: 5, height: 10 ,radius : 5});
+ polygonInterface:PolygonInterface = Polygon
+ pathInterface : PathInterface = Path
- private stateChangCallBack = (eventData) => {
- if (eventData != null) {
- console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
- if(eventData.data.maskValue != null) {
- this.maskType = new Circle({ width: 280, height: 280 });
- }
- }
- }
+ shape:ShapeInterface = Shape
- private stateChangCallBack = (eventData) => {
- if (eventData != null) {
- console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
- if(eventData.data.maskValue != null) {
- this.shape_Type = new elliptical({ width: 200, height: 280 });
- }
- }
- }
+ rect: RectInterface = Rect
+ polylineInterface:PolylineInterface = Polyline
+
+
+ ellsple: EllipseAttribute = new Ellipse({
+ width:'150px',
+ height: '150px'
+ })
+ circle : CircleAttribute = new Circle({
+ width:'150px',
+ height: '150px'
+ })
+
+ line : LineAttribute = new Line({
+ width:'15px',
+ height: '15px'
+ })
private stateChangCallBack = (eventData) => {
if (eventData != null) {
console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
if(eventData.data.maskValue != null) {
- this.lengthType = new line({ width: 200, height: 280 });
- }
- }
- }
- private stateChangCallBack = (eventData) => {
- if (eventData != null) {
- console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
- if(eventData.data.maskValue != null) {
- this.shape_4_Type = new rect_({ width: 200, height: 280 });
- }
- }
- }
- private stateChangCallBack = (eventData) => {
- if (eventData != null) {
- console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
- if(eventData.data.maskValue != null) {
- this.pathType = new path({ width: 200, height: 280 });
- }
- }
- }
- private stateChangCallBack = (eventData) => {
- if (eventData != null) {
- console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
- if(eventData.data.maskValue != null) {
- this.shape_2_Type = new polygon({ width: 200, height: 280 });
- }
- }
- }
- private stateChangCallBack = (eventData) => {
- if (eventData != null) {
- console.info("shapeClipping page state change called:" + JSON.stringify(eventData));
- if(eventData.data.maskValue != null) {
- this.shape_3_Type = new polyine({ width: 200, height: 280 });
+ this.maskType = new Circle({ width: 280, height: 280 });
}
}
}
-
private shapeChangCallBack = (eventData) => {
if (eventData != null) {
console.info("shapeClipping page shape change called:" + JSON.stringify(eventData));
diff --git a/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/web.ets b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/web.ets
new file mode 100644
index 0000000000000000000000000000000000000000..1a8aa736e879aa9e792eb299b4c5ce04897613c7
--- /dev/null
+++ b/arkui/ace_ets_component_apilack/entry/src/main/ets/MainAbility/pages/conponentadd/web.ets
@@ -0,0 +1,628 @@
+/*
+ * 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 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 Index {
+ ConsoleMessage:ConsoleMessage=new ConsoleMessage();
+ webconTextmenuparam:webConTextMenuParam = new webConTextMenuParam();
+ controllerhader: ControllerHandler = new ControllerHandler();
+ WebMessagePortController: WebMessagePort = new WebMessagePort();
+ controllersss: WebAttribute = new WebAttribute();
+ controllerE: WebMessageEvent = new WebMessageEvent();
+ newcontroller: web_webview.WebviewController = new web_webview.WebviewController();
+ controller:WebController = new WebController()
+ responseweb: WebResourceResponse = new WebResourceResponse()
+ @State str:string="emitStoreWebArchive"
+ @State text:string=""
+ @State textRatio:number=100
+ @State zoomAccessValue:boolean=true
+ handler: FullScreenExitHandler = null
+ ports: WebMessagePort[]
+ host: string = "www.spincast.org"
+ realm: string = "protected example"
+ username_password: string[]
+ origin: string="file:///"
+ 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;
+ }
+ }
+ }
+ private jsObj={
+ test:(res)=>{
+ Utils.emitEvent(res,102);
+ },
+ toString:(str)=>{
+ console.info("ets toString:"+String(str));
+ },
+ register:(res)=>{
+ Utils.emitEvent(res,86);
+ return "web222"
+ }
+ }
+ aboutToAppear(){
+ let abilityDelegator: any
+ abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
+ let abilityDelegatorArguments: any
+ abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
+ console.info('start run testcase!!!')
+ Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
+ }
+ build(){
+ Column(){
+ Web({src:$rawfile('index.html'),controller:this.controller})
+ .databaseAccess(true)
+ .zoomAccess(this.zoomAccessValue)
+ .textZoomRatio(this.textRatio)
+ .onConsole((event) => {
+ let level = event.message.getMessageLevel()
+ let msg = event.message.getMessage()
+ let lineNumber = event.message.getLineNumber().toString()
+ let sourceId = event.message.getSourceId()
+ console.log("lineNumber:" + lineNumber)
+ setTimeout(()=>{
+ Utils.emitEvent(lineNumber,420)
+ },3000)
+ setTimeout(()=>{
+ Utils.emitEvent(sourceId,422)
+ },3000)
+ return false
+ })
+ .onSearchResultReceive(ret=>{
+ var searchResult = ret.activeMatchOrdinal.toString() +
+ ret.numberOfMatches.toString()
+ console.log("searchResult" + searchResult)
+ setTimeout(()=>{
+ Utils.emitEvent(searchResult,426)
+ },3000)
+ })
+ .onFullScreenExit(() => {
+ console.log("onFullScreenExit...");
+ this.handler.constructor();
+ this.handler.exitFullScreen();
+ })
+ .onSslErrorEventReceive((event) => {
+ AlertDialog.show({
+ title: 'onSslErrorEventReceive',
+ message: 'text',
+ primaryButton: {
+ value: 'confirm',
+ action: () => {
+ event.handler.handleConfirm();
+ }
+ },
+ secondaryButton: {
+ value: 'cancel',
+ action: () => {
+ event.handler.handleCancel();
+ }
+ },
+ cancel: () => {
+ event.handler.handleCancel();
+ }
+ })
+ return true;
+ })
+ .onFullScreenEnter((event) => {
+ this.handler = event.handler;
+ })
+ Row(){
+ Button("web click").key('webcomponent').onClick(async ()=>{
+ console.info("key==>"+this.str)
+ switch(this.str){
+ case "emitStoreWebArchive":{
+ let webAsyncController = new web_webview.WebAsyncController(this.controller)
+ webAsyncController.storeWebArchive("/data/storage/el2/base/",true,(filename) => {
+ if(filename != null) {
+ Utils.emitEvent(filename,400)
+ }
+ })
+ break;
+ }
+ case "emitAllowGeolocation":{
+ web_webview.GeolocationPermissions.allowGeolocation("file:///")
+ web_webview.GeolocationPermissions.getAccessibleGeolocation(this.origin, (error, result) => {
+ if (error) {
+ console.log('error:' + JSON.stringify(error));
+ this.text = this.origin + ",error ," + JSON.stringify(error);
+ return;
+ }
+ this.text = this.origin + ", result: " + result;
+ Utils.emitEvent(this.text,402)
+ })
+ break;
+ }
+ case "emitDeleteGeolocation":{
+ web_webview.GeolocationPermissions.deleteGeolocation("file:///")
+ web_webview.GeolocationPermissions.getStoredGeolocation((error,origins) => {
+ if (error) {
+ console.log('error:' + JSON.stringify(error));
+ this.text = origins + ",error ," + JSON.stringify(error);
+ return;
+ }
+ this.text = origins.join();
+ Utils.emitEvent(this.text,404)
+ })
+ break;
+ }
+ case "emitDeleteAllGeolocation":{
+ web_webview.GeolocationPermissions.allowGeolocation("file:///")
+ web_webview.GeolocationPermissions.deleteAllGeolocation()
+ web_webview.GeolocationPermissions.getStoredGeolocation((error,origins) => {
+ if (error) {
+ console.log('error:' + JSON.stringify(error));
+ this.text = origins + ",error ," + JSON.stringify(error);
+ return;
+ }
+ this.text = origins.join();
+ Utils.emitEvent(this.text,406)
+ })
+ break;
+ }
+ case "emitIsCookieAllowed":{
+ web_webview.WebCookieManager.putAcceptCookieEnabled(false);
+ setTimeout(()=>{
+ Utils.emitEvent(web_webview.WebCookieManager.isCookieAllowed(),408)
+ },3000)
+ break;
+ }
+ case "emitSaveCookieAsync":{
+ web_webview.WebCookieManager.saveCookieAsync(function(result){
+ Utils.emitEvent(result,410)
+ })
+ break;
+ }
+ case "emitIsThirdPartyCookieAllowed":{
+ web_webview.WebCookieManager.putAcceptThirdPartyCookieEnabled(false);
+ setTimeout(()=>{
+ var result = web_webview.WebCookieManager.isThirdPartyCookieAllowed();
+ console.log(result.toString());
+ Utils.emitEvent(web_webview.WebCookieManager.isThirdPartyCookieAllowed(),412)
+ },3000)
+ break;
+ }
+ case "emitExistCookie":{
+ this.controller.getCookieManager().deleteEntireCookie();
+ setTimeout(()=>{
+ var result = web_webview.WebCookieManager.existCookie();
+ console.log(result.toString());
+ Utils.emitEvent(result,414)
+ },3000)
+ break ;
+ }
+ case "emitOnConsole":{
+ this.controller.runJavaScript({script:"consoleTest()"})
+ break;
+ }
+ case "emitLoaData":{
+ this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
+ setTimeout(()=>{
+ this.controller.loadData({
+ data: "
index",
+ mimeType: "text/html",
+ encoding: "UTF-8"
+ })
+ },3000)
+ setTimeout(()=>{
+ this.text = this.controller.getTitle();
+ Utils.emitEvent(this.text,424)
+ },4000)
+ break ;
+ }
+ case "emitZoomAccess":{
+ this.zoomAccessValue = false
+ this.controller.refresh()
+ var origin = this.controller.getPageHeight()
+ var zoomInCalled = false
+ setTimeout(()=>{
+ this.controller.zoomIn()
+ if (this.controller.getPageHeight() > origin) {
+ zoomInCalled = true
+ }
+ console.log("final" + this.controller.getPageHeight())
+ Utils.emitEvent(zoomInCalled,428);
+ },3000);
+ break ;
+ }
+ case "emitSaveHttpAuthCredentials":{
+ web_webview.WebDataBase.saveHttpAuthCredentials(this.host, this.realm, "Stromgol", "Laroche");
+ setTimeout(()=>{
+ let result = web_webview.WebDataBase.existHttpAuthCredentials();
+ Utils.emitEvent(result,442)
+ },3000)
+ break;
+ }
+ case "emitGetHttpAuthCredentials":{
+ this.username_password = web_webview.WebDataBase.getHttpAuthCredentials(this.host, this.realm);
+ setTimeout(()=>{
+ let result = this.username_password[0];
+ Utils.emitEvent(result,444)
+ },3000)
+ break;
+ }
+ case "emitDeleteHttpAuthCredentials":{
+ web_webview.WebDataBase.deleteHttpAuthCredentials();
+ setTimeout(()=>{
+ let result = web_webview.WebDataBase.existHttpAuthCredentials();
+ Utils.emitEvent(result,446)
+ },3000)
+ break;
+ }
+
+
+
+
+
+
+ case "emitdeleteAllData":{
+ setTimeout(()=>{
+ try{
+ web_webview.WebStorage.deleteAllData()
+ let result = 'succesful'
+ Utils.emitEvent(result,446)
+ }catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`)
+ let result = 'fail'
+ Utils.emitEvent(result,446)
+ }
+ },3000)
+ break;
+ }
+ case "emitdeleteOringin":{
+ setTimeout(()=>{
+ try{
+ web_webview.WebStorage.deleteOrigin(this.origin);
+ let result = 'succesful'
+ Utils.emitEvent(result,446)
+ }catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`)
+ let result = 'fail'
+ Utils.emitEvent(result,446)
+ }
+ },3000)
+ break;
+ }
+ case "emitgetOringin":{
+ setTimeout(()=>{
+ web_webview.WebStorage.getOrigins((error, origins) => {
+ if (error) {
+ console.log('error: ' + error);
+ Utils.emitEvent(result,446)
+ }
+ for (let i = 0; i < origins.length; i++) {
+ console.log('origin: ' + origins[i].origin);
+ console.log('usage: ' + origins[i].usage);
+ console.log('quota: ' + origins[i].quota);
+ }
+ })
+ },3000)
+ break;
+
+ }
+ case "emitgetOringinQuota":{
+ try{
+ web_webview.WebStorage.getOriginQuota(this.origin);
+ setTimeout(()=>{
+ console.info('sucessful')
+ Utils.emitEvent('sucessful',446)
+ },3000)
+ }catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ Utils.emitEvent('fail',446)
+ }
+ break;
+ }
+ case "emitgetOringinUsage":{
+ setTimeout(()=>{
+ try{
+ web_webview.WebStorage.getOriginUsage(this.origin, (error, usage) => {
+ if (error) {
+ console.log('error: ' + error);
+ Utils.emitEvent(error,446)
+ }
+ console.log('usage: ' + usage);
+ Utils.emitEvent(usage,446)
+ })
+ Utils.emitEvent('sucessful',446)
+ }catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+ break;
+ }
+ case "emitAsyncControllerconstructor":{
+ setTimeout(()=>{
+ let webAsyncController = new web_webview.WebAsyncController(this.controller)
+ webAsyncController.constructor()
+ Utils.emitEvent('sucessful',446)
+ },3000)
+ break;
+ }
+ case "emitdeleteSessionCookie":{
+ setTimeout(()=>{
+ web_webview.WebCookieManager.deleteSessionCookie()
+ Utils.emitEvent('succesful',410)
+ },3000)
+ break;
+ }
+ case "emitSearchAllAsync":{
+ this.controller.loadUrl({url:"file:///data/storage/el1/bundle/phone/resources/rawfile/index.html"})
+ setTimeout(()=>{
+ this.controller.searchAllAsync("首页");
+ },3000)
+ break;
+ }
+ case "emitclose":{
+ setTimeout(() => {
+ this.ports[1].close()
+ Utils.emitEvent('sucessful', 446)
+ },3000)
+ break;
+ }
+ case "emitpostMessageEvent":{
+ setTimeout(()=>{
+ try {
+ var msg = new WebMessageEvent();
+ msg.setData("post message from ets to html5");
+ this.ports[0].postMessageEvent(msg)
+ Utils.emitEvent('sucessful', 446)
+
+ } catch (error) {
+ console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+ break;
+ }
+ case "emitonMessageEvent":{
+ setTimeout(()=>{
+ try {
+ this.ports = this.controller.createWebMessagePorts();
+ this.ports[1].onMessageEvent((msg) => {
+ console.info("received message from html5, on message:" + msg);
+ })
+ } catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ Utils.emitEvent('sucessful', 446)
+ },3000)
+ break;
+ }
+
+ case "newemitonMessageEvent":{
+ setTimeout(()=>{
+ this.ports[0].onMessageEvent((result: string) => {
+ console.log("received message from html5, on message:" + result);
+ Utils.emitEvent('sucessful', 446)
+ })
+ },3000)
+ break;
+ }
+
+
+ case "emitgetHitTestValue":{
+ setTimeout(() => {
+ try {
+ let hitValue = this.newcontroller.getHitTestValue();
+ console.info("hitType: " + hitValue.type);
+ console.info("extra: " + hitValue.extra);
+ Utils.emitEvent('sucessful', 446)
+ } catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+
+ break;
+ }
+ case "emitgetUserAgent":{
+ setTimeout(() => {
+ try{
+ let userAgent = this.newcontroller.getUserAgent();
+ console.log("userAgent: " + userAgent);
+ Utils.emitEvent('sucessful',446)
+ }catch (error) {
+ console.info(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+
+ break;
+ }
+ case "emitcreateWebMessagePorts":{
+ setTimeout(() => {
+ try {
+ this.ports = this.controller.createWebMessagePorts();
+ Utils.emitEvent('succesful',446)
+ } catch (error) {
+ console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+ break;
+ }
+ case "emitclearMatches":{
+ setTimeout(() => {
+ try {
+ this.newcontroller.clearMatches();
+ Utils.emitEvent('succesful',446)
+ } catch (error) {
+ console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+ break;
+ }
+ case "emitsearchNext":{
+ setTimeout(() => {
+ try {
+ this.newcontroller.searchNext(true);
+ Utils.emitEvent('succesful',446)
+ } catch (error) {
+ console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+
+ break;
+ }
+ case "emitclearSslCache":{
+ setTimeout(() => {
+ try {
+ this.newcontroller.clearSslCache();
+ Utils.emitEvent('succesful',446)
+
+ } catch (error) {
+ console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+
+ break;
+ }
+ case "emitclearClientAuthenticationCache":{
+ setTimeout(() => {
+ try {
+ this.newcontroller.clearClientAuthenticationCache();
+ Utils.emitEvent('succesful',446)
+ } catch (error) {
+ console.error(`Errorcode: ${error.code}, Message: ${error.message}`);
+ }
+ },3000)
+
+ break;
+ }
+ case "emitgetUrl":{
+ try{
+ setTimeout(() => {
+ this.controller.getUrl();
+ Utils.emitEvent('succesful',446)
+ },3000)
+ }catch (error) {
+ console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ }
+
+ break;
+ }
+ case "emitonFullScreenExitconstructor":{
+ setTimeout(() => {
+ this.handler.constructor()
+ Utils.emitEvent('sucessful',446)
+ })
+ break;
+ }
+ // case "emitexitfullscreen":{
+ // setTimeout(()=>{
+ // this.handler.exitfullscreen()
+ // console.info('succesful')
+ // Utils.emitEvent('succesful',69)
+ // },3000)
+ // break;
+ // }
+ // ts not exist
+
+ // case "emitpostMessageEvent1":{
+ // setTimeout(() => {
+ // try {
+ // this.controllerE.postMessageEvent();
+ // Utils.emitEvent('succesful',446)
+ // } catch (error) {
+ // console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ // }
+ // })
+ // }
+ // ts not exist
+
+ // case "emitpostMessage":{
+ // setTimeout(() => {
+ // try {
+ // this.controllerE.postMessage();
+ // Utils.emitEvent('succesful',446)
+ // } catch (error) {
+ // console.error(`ErrorCode: ${error.code}, Message: ${error.message}`);
+ // }
+ // })
+ // }
+ // ts not exist
+
+ case "emitWebMessageEventconstructor":{
+ setTimeout(()=>{
+ this.controllerE.constructor()
+ Utils.emitEvent('sucessful',446)
+ },3000)
+ break;
+ }
+ case "emitgetData":{
+ setTimeout(()=>{
+ this.controllerE.getData()
+ console.info('succesful')
+ Utils.emitEvent('succesful',69)
+ },3000)
+ break;
+ }
+ case "emitsetData":{
+ setTimeout(()=>{
+ this.controllerE.setData('1')
+ console.info('succesful')
+ Utils.emitEvent('succesful',69)
+ },3000)
+ break;
+ }
+ case "emitgetPorts":{
+ setTimeout(()=>{
+ this.controllerE.getPorts()
+ console.info('succesful')
+ Utils.emitEvent('succesful',69)
+ },3000)
+ break;
+ }
+ case "emitsetPorts":{
+ setTimeout(()=>{
+ this.ports = this.controller.createWebMessagePorts()
+ this.controllerE.setPorts(this.ports)
+ console.info('succesful')
+ Utils.emitEvent('succesful',69)
+ },3000)
+ break;
+ }
+ case "webmessageportonMessageEvent":{
+ setTimeout(()=>{
+ this.ports[0].onMessageEvent((result: string) => {
+ console.info("received message from html5, on message:" + result);
+ Utils.emitEvent('succesful',69)
+
+ },3000)
+ break;
+ }
+
+ default:
+ console.info("can not match case")
+ }
+ })
+ }
+ }
+ }
+}