diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/appear.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/appear.ets index a9635f631ea27b6c3c1c3bca0e87de54f8d9f4e7..3378116eef4643f343d7532e36c39de9954fea94 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/appear.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/appear.ets @@ -20,7 +20,7 @@ import prompt from '@system.prompt' @Entry @Preview @Component -struct AppearExample { +struct AppearExample { @State isShow: boolean = true @State appearFlag: boolean = false @State disAppearFlag: boolean = false @@ -40,7 +40,7 @@ struct AppearExample { console.info("[appear] page stateChangCallBack"); if (eventData != null) { console.info("[appear] page state change called:" + JSON.stringify(eventData)); - if(eventData.data.isShow != null) { + if (eventData.data.isShow != null) { this.isShow = eventData.data.isShow; } } @@ -60,7 +60,7 @@ struct AppearExample { this.changeAppear = 'Show Text' console.info('appearFlag current action state is: ' + this.appearFlag); prompt.showToast({ message: 'The text is shown', duration: 2000 }) - try{ + try { var backData = { data: { "ACTION": this.appearFlag, @@ -72,7 +72,7 @@ struct AppearExample { } console.info("appearFlag start to emit action state") events_emitter.emit(backEvent, backData) - }catch{ + } catch { console.info("appearFlag emit action state err: " + JSON.stringify(err.message)) } }) @@ -81,7 +81,7 @@ struct AppearExample { this.changeAppear = 'Hide Text' console.info('disAppearFlag current action state is: ' + this.disAppearFlag); prompt.showToast({ message: 'The text is hidden', duration: 2000 }) - try{ + try { var backData = { data: { "ACTION": this.disAppearFlag, @@ -93,7 +93,7 @@ struct AppearExample { } console.info("disAppearFlag start to emit action state") events_emitter.emit(backEvent, backData) - }catch{ + } catch { console.info("disAppearFlag emit action state err: " + JSON.stringify(err.message)) } }) diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/column.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/column.ets new file mode 100755 index 0000000000000000000000000000000000000000..27bcd39a5eb02c4d7462b6de5ef4495f8416d554 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/column.ets @@ -0,0 +1,56 @@ +// @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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct ColumnExample { + @State alignItems: HorizontalAlign = HorizontalAlign.Start; + + onPageShow() { + console.info('[column] page show called'); + var stateChangeEvent = { + eventId: 192, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + } + + private stateChangCallBack = (eventData) => { + console.info("[column] page stateChangCallBack"); + if (eventData != null) { + console.info("[column] page state change called:" + JSON.stringify(eventData)); + if(eventData.data.alignItems != null) { + this.alignItems = eventData.data.alignItems; + } + } + } + + build() { + Column() { + Text('alignItems').fontSize(9).fontColor(0xCCCCCC).width('90%') + Column() { + Column().width('50%').height(30).backgroundColor(0xAFEEEE) + Column().width('50%').height(30).backgroundColor(0x00FFFF) + } + .key("alignItemsColumn") + .width('90%') + .border({ width: 1 }) + .alignItems(this.alignItems) + }.width('100%').padding({ top: 5 }) + } +} \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/ellipse.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/ellipse.ets index 23b741784ae832d923baddad5d84a29ff0086653..cb7e32d46177b21802707bb2ba4b60417b8d8ce0 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/ellipse.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/ellipse.ets @@ -1,52 +1,64 @@ -// @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 events_emitter from '@ohos.emitter'; - -@Entry -@Component -struct EllipseExample { - @State width: string = "200px"; - @State height: string = "200px"; - - onPageShow() { - console.info('[ellipse] page show called'); - var stateChangeEvent = { - eventId: 92, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack); - } - - private stateChangCallBack = (eventData) => { - console.info("[ellipse] page stateChangCallBack"); - if (eventData != null) { - console.info("[ellipse] page state change called:" + JSON.stringify(eventData)); - if(eventData.data.width != null) { - this.width = eventData.data.width; - } - if(eventData.data.height != null) { - this.height = eventData.data.height; - } - } - } - - build() { - Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center,justifyContent: FlexAlign.Center}) { - Ellipse().width(`${this.width}`).height(`${this.height}`).key('ellipse') - }.width('100%').height('100%') - } +// @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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct EllipseExample { + @State width: string = "200px"; + @State height: string = "200px"; + + onPageShow() { + console.info('[ellipse] page show called'); + var stateChangeEvent = { + eventId: 92, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEventTwo = { + eventId: 907, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack); + + var stateChangeEventThree = { + eventId: 908, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventThree, this.stateChangCallBack); + } + + private stateChangCallBack = (eventData) => { + console.info("[ellipse] page stateChangCallBack"); + if (eventData != null) { + console.info("[ellipse] page state change called:" + JSON.stringify(eventData)); + if (eventData.data.width != null) { + this.width = eventData.data.width; + } + if (eventData.data.height != null) { + this.height = eventData.data.height; + } + } + } + + build() { + Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) { + Ellipse().width(`${this.width}`).height(`${this.height}`).key('ellipse') + }.width('100%').height('100%') + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/enable.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/enable.ets index 47d7ab5dcfadcd582632d625406ae3ab14368edf..c0a0195ac8febe1897242bf8faea26c950156f5a 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/enable.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/enable.ets @@ -1,61 +1,69 @@ -// @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 events_emitter from '@ohos.emitter' - -@Entry -@Component -struct EnabledExample { - @State enabled: boolean = true; - @State text: string = "enable"; - - onPageShow() { - console.info('[enabled] page show called '); - var stateChangeEvent = { - eventId: 93, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack); - - } - - private stateChangCallBack = (eventData) => { - console.info("[stateChangCallBack] stateChangCallBack "); - if (eventData != null) { - console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); - if (eventData.data.enabled != null) { - this.enabled = eventData.data.enabled - } - if (eventData.data.text != null) { - this.text = eventData.data.text - } - } - } - - build() { - Flex({ justifyContent: FlexAlign.SpaceAround }) { - Button('disable') - .enabled(false) - .backgroundColor(0x317aff) - .opacity(0.4) - Button(this.text) - .key('enabled') - .backgroundColor(0x317aff) - .enabled(this.enabled) - } - .width('100%') - .padding({ top: 5 }) - } +// @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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct EnabledExample { + @State enabled: boolean = true; + @State text: string = "enable"; + + onPageShow() { + console.info('[enabled] page show called '); + var stateChangeEvent = { + eventId: 93, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent2 = { + eventId: 1111, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent2, this.stateChangCallBack); + + } + + private stateChangCallBack = (eventData) => { + console.info("[stateChangCallBack] stateChangCallBack "); + if (eventData != null) { + console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); + if (eventData.data.enabled != null) { + this.enabled = eventData.data.enabled + } + if (eventData.data.text != null) { + this.text = eventData.data.text + } + } + } + + build() { + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Button('disable') + .enabled(false) + .backgroundColor(0x317aff) + .opacity(0.4) + Button(this.text) + .key('enabled') + .backgroundColor(0x317aff) + .enabled(this.enabled) + } + .width('100%') + .padding({ top: 5 }) + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/flex.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/flex.ets index ca90c9236245aedb5bb862afcd47fe62c1294d14..28a34c76c26d4db6e6527fa9021e31ca9a0b0721 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/flex.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/flex.ets @@ -23,25 +23,24 @@ struct FlexExample { private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Flex page state change called:" + JSON.stringify(eventData)); - if(eventData.data.flexBasis != null) { + if (eventData.data.flexBasis != null) { this.flexBasis = eventData.data.flexBasis; } - if(eventData.data.flexGrow != null) { + if (eventData.data.flexGrow != null) { this.flexGrow = eventData.data.flexGrow; } - if(eventData.data.flexShrink != null) { + if (eventData.data.flexShrink != null) { this.flexShrink = eventData.data.flexShrink; } - if(eventData.data.alignSelf != null) { + if (eventData.data.alignSelf != null) { this.alignSelf = eventData.data.alignSelf; } } } - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Flex page state change called:" + JSON.stringify(eventData)); - switch(eventData.data.alignSelf) { + switch (eventData.data.alignSelf) { case 'Auto': this.alignSelf = ItemAlign.Auto; break; @@ -80,33 +79,60 @@ struct FlexExample { Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%') Flex() { Text('flexBasis("auto")') - .flexBasis('auto').key("flexBasis").width('60%').height(100).lineHeight(70) - .backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + .flexBasis('auto') + .key("flexBasis") + .width('60%') + .height(100) + .lineHeight(70) + .backgroundColor(0xD2B48C) + .textAlign(TextAlign.Center) Text('flexBasis(100)') - .flexBasis('100').height(100).lineHeight(70) - .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + .flexBasis('100') + .height(100) + .lineHeight(70) + .backgroundColor(0xF5DEB3) + .textAlign(TextAlign.Center) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) Text('flexGrow').key("flexGrow").fontSize(9).fontColor(0xCCCCCC).width('90%') Flex() { Text('flexGrow(2)') - .flexGrow(2).height(100).lineHeight(70) - .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + .flexGrow(2) + .height(100) + .lineHeight(70) + .backgroundColor(0xF5DEB3) + .textAlign(TextAlign.Center) Text('flexGrow(1)') - .flexGrow(1).height(100).lineHeight(70) - .backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + .flexGrow(1) + .height(100) + .lineHeight(70) + .backgroundColor(0xD2B48C) + .textAlign(TextAlign.Center) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) Text('flexShrink').fontSize(9).fontColor(0xCCCCCC).width('90%') Flex({ direction: FlexDirection.Row }) { Text('flexShrink(0)') - .flexShrink(0).key("flexShrink").width('50%').height(100).lineHeight(70) - .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + .flexShrink(0) + .key("flexShrink") + .width('50%') + .height(100) + .lineHeight(70) + .backgroundColor(0xF5DEB3) + .textAlign(TextAlign.Center) Text('no flexShrink') - .width('40%').height(100).lineHeight(70).backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + .width('40%') + .height(100) + .lineHeight(70) + .backgroundColor(0xD2B48C) + .textAlign(TextAlign.Center) Text('flexShrink(2)') - .flexShrink(2).width('40%').height(100) .lineHeight(70) - .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) + .flexShrink(2) + .width('40%') + .height(100) + .lineHeight(70) + .backgroundColor(0xF5DEB3) + .textAlign(TextAlign.Center) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) Text('alignSelf').key("alignSelf").fontSize(9).fontColor(0xCCCCCC).width('90%') @@ -114,11 +140,20 @@ struct FlexExample { Text('no alignSelf,height:80').width('33%').height(80) .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) Text('alignSelf stretch') - .alignSelf(ItemAlign.Stretch).width('33%').height(80).lineHeight(70) - .backgroundColor(0xD2B48C).textAlign(TextAlign.Center) + .alignSelf(ItemAlign.Stretch) + .width('33%') + .height(80) + .lineHeight(70) + .backgroundColor(0xD2B48C) + .textAlign(TextAlign.Center) Text('no alignSelf,height:100').width('34%').height(100) .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) - }.key('flex').width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) + } + .key('flex') + .width('90%') + .height(120) + .padding(10) + .backgroundColor(0xAFEEEE) }.width('100%').margin({ top: 5 }) } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gauge.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gauge.ets index 4c31e891f4cc2ea23f4f6085d0edb2aa19b8eb80..5ce02c6873ab9a4965281b4e27aa2c0b92bfa27f 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gauge.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gauge.ets @@ -1,77 +1,94 @@ -// @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 events_emitter from '@ohos.emitter'; - -@Entry -@Component -struct GaugeExample { - @State gaugeValue: string = 50; - @State strokeWidthValue: string = 20; - @State startAngleValue: string = 210; - @State endAngleValue: string = 150; - @State colorValues: Array = [[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]; - - private stateChangCallBack = (eventData) => { - if (eventData != null) { - console.info("gauge page state change called:" + JSON.stringify(eventData)); - if(eventData.data.gaugeValue != null) { - this.gaugeValue = eventData.data.gaugeValue; - } - if(eventData.data.strokeWidthValue != null) { - this.strokeWidthValue = eventData.data.strokeWidthValue; - } - if(eventData.data.startAngleValue != null) { - this.startAngleValue = eventData.data.startAngleValue; - } - if(eventData.data.endAngleValue != null) { - this.endAngleValue = eventData.data.endAngleValue; - } - if(eventData.data.colorValues != null) { - this.colorValues = JSON.parse(eventData.data.colorValues); - } - } - } - - onPageShow() { - console.info('gauge page show called'); - var stateChangeEvent = { - eventId: 102, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack); - - var stateChangeEventTwo = { - eventId: 103, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEventTwo, this.stateChangCallBack); - } - - build() { - Column() { - Gauge({ value: 0, min: 0, max: 100 }) - .key("gauge") - .value(`${this.gaugeValue}`) - .startAngle(`${this.startAngleValue}`) - .endAngle(`${this.endAngleValue}`) - .colors(this.colorValues) - .strokeWidth(`${this.strokeWidthValue}`) - .width(200).height(200) - }.width('100%').margin({ top: 300 }) - } -} - +// @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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct GaugeExample { + @State gaugeValue: string = 50; + @State strokeWidthValue: string = 20; + @State startAngleValue: string = 210; + @State endAngleValue: string = 150; + @State colorValues: Array = [[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]; + private stateChangCallBack = (eventData) => { + if (eventData != null) { + console.info("gauge page state change called:" + JSON.stringify(eventData)); + if (eventData.data.gaugeValue != null) { + this.gaugeValue = eventData.data.gaugeValue; + } + if (eventData.data.strokeWidthValue != null) { + this.strokeWidthValue = eventData.data.strokeWidthValue; + } + if (eventData.data.startAngleValue != null) { + this.startAngleValue = eventData.data.startAngleValue; + } + if (eventData.data.endAngleValue != null) { + this.endAngleValue = eventData.data.endAngleValue; + } + if (eventData.data.colorValues != null) { + this.colorValues = JSON.parse(eventData.data.colorValues); + } + } + } + + onPageShow() { + console.info('gauge page show called'); + var stateChangeEvent = { + eventId: 102, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEventTwo = { + eventId: 103, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack); + + var stateChangeEvent3 = { + eventId: 904, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent3, this.stateChangCallBack); + + var stateChangeEvent4 = { + eventId: 905, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent4, this.stateChangCallBack); + + var stateChangeEvent5 = { + eventId: 906, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent5, this.stateChangCallBack); + } + + build() { + Column() { + Gauge({ value: 0, min: 0, max: 100 }) + .key("gauge") + .value(`${this.gaugeValue}`) + .startAngle(`${this.startAngleValue}`) + .endAngle(`${this.endAngleValue}`) + .strokeWidth(`${this.strokeWidthValue}`) + .width(200) + .height(200) + }.width('100%').margin({ top: 300 }) + } +} + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/global.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/global.ets index 4c090f354c5129d8c8f02390e8dea9b5a6cce802..c401d23a25118e952cacf30585d05c34d88a61bf 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/global.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/global.ets @@ -17,7 +17,6 @@ @Entry @Component struct GlobalExample { - onPageShow() { } @@ -44,9 +43,9 @@ struct GlobalExample { let width = img.width; let height = img.height; this.context.imageSmoothingEnabled = false; - this.context.drawImage( img, 30, 950, 160, 100); - console.log("imagebitmap_width="+width); - console.log("imagebitmap_height="+height); + this.context.drawImage(img, 30, 950, 160, 100); + console.log("imagebitmap_width=" + width); + console.log("imagebitmap_height=" + height); } testOffscreenCanvas() { @@ -63,17 +62,19 @@ struct GlobalExample { testImageData() { var offscreen = new OffscreenCanvas(300, 300); var offCanvas2 = offscreen.getContext("2d"); - var imageData = offCanvas2.createImageData(100,100); + var imageData = offCanvas2.createImageData(100, 100); var imgData = imageData.data; - console.log("imageData_width="+imageData.width); - console.log("imageData_height="+imageData.height); + console.log("imageData_width=" + imageData.width); + console.log("imageData_height=" + imageData.height); } - testImage(){ - var img = new Image("/images/bg.jpg",100,100) - .onload(()=>{}) - .onerror(()=>{}); - console.log("img_width="+img.width); - console.log("img_height="+img.height); + testImage() { + var img = new Image("/images/bg.jpg", 100, 100) + .onload(() => { + }) + .onerror(() => { + }); + console.log("img_width=" + img.width); + console.log("img_height=" + img.height); } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridSettings.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridSettings.ets index b9999409c5df6eb0725f01837f897a6d20b3a73e..9e990d41b9b9af48ce999017febc4a0ab3b8440e 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridSettings.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/gridSettings.ets @@ -24,8 +24,8 @@ struct GridSetting { @State gridSpan: number = 1; @State gridOffset: number = 0; - build(){ - GridContainer({sizeType: SizeType.SM}) { + build() { + GridContainer({ sizeType: SizeType.SM }) { Row({}) { Row() { Text('Left').fontSize(25) @@ -34,6 +34,7 @@ struct GridSetting { .height("100%") .backgroundColor(0x66bbb2cb) .key('gridOffset') + Row() { Text('Center').fontSize(25) } @@ -44,6 +45,7 @@ struct GridSetting { .height("100%") .backgroundColor(0x66b6c5d1) .key('gridRow') + Row() { Text('Right').fontSize(25) } @@ -58,6 +60,7 @@ struct GridSetting { .margin({ top: 10 }) .key('gridContainer') } + onPageShow() { let smChangeEvent = { eventId: 9, @@ -75,6 +78,7 @@ struct GridSetting { } events_emitter.on(spanChangeEvent, this.stateChangCallBack); } + stateChangCallBack = (eventData) => { console.info("GridSetting page stateChangCallBack" + JSON.stringify(eventData)); if (eventData && eventData.data) { diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets index e9da3e7d11670c50c80a8419a4bd15f9776e3edb..3b474f93fde7d515a812b2cadd63f0bd0cf1b577 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/imageEffects.ets @@ -28,7 +28,6 @@ struct ImageEffectsExample { @State contrastValue: string= 20; @State invertValue: string= 10; @State hueRotateValue: string= 10 - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("imageEffects page state change called:" + JSON.stringify(eventData)); diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/index.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/index.ets index 2607563902184ddd2914549d08ddc135b004b31a..6ed3125259bd28941eb5bb5152ec40221cbaeef2 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/index.ets @@ -14,7 +14,6 @@ * limitations under the License. */ import file from '@system.file'; - import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; import testsuite from "../test/List.test.ets"; import featureAbility from "@ohos.ability.featureAbility"; diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/layoutConstraints.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/layoutConstraints.ets index 969a0c095421478d9886bdd09e7e705514f1d58f..b77c516f6492768bc598df3d8f4cf833e221b3f4 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/layoutConstraints.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/layoutConstraints.ets @@ -1,136 +1,144 @@ -// @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 events_emitter from '@ohos.emitter'; - -class ContainerInfo { - label : string = '' - size : string = '' -}; - -class ChildInfo { - text : string = '' - priority : number = 0 -}; - -@Entry -@Component -struct LayoutConstraints { - private children : string[] = ['1', '2', '3', '4', '5', '6']; - @State aspectRatio: number = 1.5; - private container: ContainerInfo[] = [ - {label: 'Big container', size: '97%'}, - {label: 'Small container', size: '30%'}]; - @State priorityChildren: any[] = [ - {text: '1\n(priority:1)', priority: 1}, - {text: '2\n(priority:2)', priority: 2}, - {text: '3\n(priority:3)', priority: 3}, - {text: '4\n(priority:4)', priority: 4}]; - @State currentIndex : number = 0; - - build() { - Column({ space: 20 }) { - Text('using container: row').fontSize(20).fontColor(Color.Black).width('100%') - Row({space: 10}) { - ForEach(this.children, (item) => { - Text(item) - .backgroundColor(0xbbb2cb) - .fontSize(20) - .aspectRatio(this.aspectRatio) - .height(60) - Text(item) - .backgroundColor(0xbbb2cb) - .fontSize(20) - .aspectRatio(this.aspectRatio) - .width(60) - .key('aspectRatio') - }, item=>item) - } - .size({width: "100%", height: 100}) - .backgroundColor(0xd2cab3) - .clip(true) - - Text('using container: grid').fontSize(20).fontColor(Color.Black).width('100%') - Grid() { - ForEach(this.children, (item) => { - GridItem() { - Text(item) - .backgroundColor(0xbbb2cb) - .fontSize(40) - .aspectRatio(this.aspectRatio) - } - }, item=>item) - } - .columnsTemplate('1fr 1fr 1fr') - .columnsGap(10) - .rowsGap(10) - .size({width: "100%", height: 165}) - .backgroundColor(0xd2cab3) - - Text('displayPriority 4').fontSize(20).fontColor(Color.Black).width('100%') - Flex({justifyContent: FlexAlign.SpaceBetween}) { - ForEach(this.priorityChildren, (item)=>{ - if (item.priority === 1 || item.priority === 5) { - Text(`1\n(priority:${item.priority})`) - .width(135) - .height(60) - .fontSize(18) - .textAlign(TextAlign.Center) - .backgroundColor(0xbbb2cb) - .displayPriority(item.priority) - .key('displayPriority') - } else { - Text(item.text) - .width(135) - .height(60) - .fontSize(18) - .textAlign(TextAlign.Center) - .backgroundColor(0xbbb2cb) - .displayPriority(item.priority) - } - }, item=>item.text) - } - .width(this.container[this.currentIndex].size) - .backgroundColor(0xd2cab3) - }.padding(10) - } - onPageShow() { - let aspectRatioChangeEvent = { - eventId: 20, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(aspectRatioChangeEvent, this.stateChangCallBack); - - let priorityChangeEvent = { - eventId: 21, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(priorityChangeEvent, this.stateChangCallBack); - } - stateChangCallBack = (eventData) => { - console.info("LayoutConstraints page stateChangCallBack" + JSON.stringify(eventData)); - if (eventData) { - if (eventData.data.aspectRatio) { - this.aspectRatio = eventData.data.aspectRatio; - } else if (eventData.data.displayPriority) { - let priority = JSON.parse(JSON.stringify(this.priorityChildren)); - priority[0].priority = eventData.data.displayPriority; - this.priorityChildren = []; - this.priorityChildren = priority; - } - } - } +// @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 events_emitter from '@ohos.emitter'; + +class ContainerInfo { + label: string = '' + size: string = '' +}; + +class ChildInfo { + text: string = '' + priority: number = 0 +}; + +@Entry +@Component +struct LayoutConstraints { + private children: string[] = ['1', '2', '3', '4', '5', '6']; + @State aspectRatio: number = 1.5; + private container: ContainerInfo[] = [ + { label: 'Big container', size: '97%' }, + { label: 'Small container', size: '30%' }]; + @State priorityChildren: any[] = [ + { text: '1\n(priority:1)', priority: 1 }, + { text: '2\n(priority:2)', priority: 2 }, + { text: '3\n(priority:3)', priority: 3 }, + { text: '4\n(priority:4)', priority: 4 }]; + @State currentIndex: number = 0; + + build() { + Column({ space: 20 }) { + Text('using container: row').fontSize(20).fontColor(Color.Black).width('100%') + Row({ space: 10 }) { + ForEach(this.children, (item) => { + Text(item) + .backgroundColor(0xbbb2cb) + .fontSize(20) + .aspectRatio(this.aspectRatio) + .height(60) + Text(item) + .backgroundColor(0xbbb2cb) + .fontSize(20) + .aspectRatio(this.aspectRatio) + .width(60) + .key('aspectRatio') + }, item => item) + } + .size({ width: "100%", height: 100 }) + .backgroundColor(0xd2cab3) + .clip(true) + + Text('using container: grid').fontSize(20).fontColor(Color.Black).width('100%') + Grid() { + ForEach(this.children, (item) => { + GridItem() { + Text(item) + .backgroundColor(0xbbb2cb) + .fontSize(40) + .aspectRatio(this.aspectRatio) + } + }, item => item) + } + .columnsTemplate('1fr 1fr 1fr') + .columnsGap(10) + .rowsGap(10) + .size({ width: "100%", height: 165 }) + .backgroundColor(0xd2cab3) + + Text('displayPriority 4').fontSize(20).fontColor(Color.Black).width('100%') + Flex({ justifyContent: FlexAlign.SpaceBetween }) { + ForEach(this.priorityChildren, (item) => { + if (item.priority === 1 || item.priority === 5) { + Text(`1\n(priority:${item.priority})`) + .width(135) + .height(60) + .fontSize(18) + .textAlign(TextAlign.Center) + .backgroundColor(0xbbb2cb) + .displayPriority(item.priority) + .key('displayPriority') + } else { + Text(item.text) + .width(135) + .height(60) + .fontSize(18) + .textAlign(TextAlign.Center) + .backgroundColor(0xbbb2cb) + .displayPriority(item.priority) + } + }, item => item.text) + } + .width(this.container[this.currentIndex].size) + .backgroundColor(0xd2cab3) + }.padding(10) + } + + onPageShow() { + let aspectRatioChangeEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(aspectRatioChangeEvent, this.stateChangCallBack); + + let priorityChangeEvent = { + eventId: 21, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(priorityChangeEvent, this.stateChangCallBack); + + let priorityChangeEvent2 = { + eventId: 1112, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(priorityChangeEvent2, this.stateChangCallBack); + } + + stateChangCallBack = (eventData) => { + console.info("LayoutConstraints page stateChangCallBack" + JSON.stringify(eventData)); + if (eventData) { + if (eventData.data.aspectRatio) { + this.aspectRatio = eventData.data.aspectRatio; + } else if (eventData.data.displayPriority) { + let priority = JSON.parse(JSON.stringify(this.priorityChildren)); + priority[0].priority = eventData.data.displayPriority; + this.priorityChildren = []; + this.priorityChildren = priority; + } + } + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/list.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/list.ets index ac5a3f49b045676982a786f1b1baa4d257f6fc1b..45b537f2239053cfd2af2d6a2775d6d70c7fbd18 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/list.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/list.ets @@ -1,126 +1,154 @@ -// @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 events_emitter from '@ohos.emitter'; - -@Entry -@Component -struct ListExample { - private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; - @State listDirection: Axis = Axis.Vertical; - @State editMode: boolean = false; - @State edgeEffect: EdgeEffect = EdgeEffect.None; - @State chainAnimation: boolean = false; - @State strokeWidth: number = 2.000000; - @State color: string = 0xFFFFFF; - @State startMargin: number = 20.000000; - @State endMargin: number = 20.000000; - - onPageShow() { - console.info('[list] page show called'); - var stateChangeEvent = { - eventId: 124, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack); - - var stateChangeEventTwo = { - eventId: 125, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEventTwo, this.stateChangCallBackTwo); - } - - private stateChangCallBack = (eventData) => { - console.info("[stateChangCallBack] stateChangCallBack"); - if (eventData != null) { - console.info("[stateChangCallBack] state change called:" + JSON.stringify(eventData)); - if(eventData.data.listDirection != null) { - this.listDirection = eventData.data.listDirection; - } - if(eventData.data.editMode != null) { - this.editMode = eventData.data.editMode; - } - if(eventData.data.edgeEffect != null) { - this.edgeEffect = eventData.data.edgeEffect; - } - if(eventData.data.chainAnimation != null) { - this.chainAnimation = eventData.data.chainAnimation; - } - } - } - - private stateChangCallBackTwo = (eventData) => { - console.info("[stateChangCallBackTwo] stateChangCallBack"); - if (eventData != null) { - console.info("[stateChangCallBackTwo] state change called:" + JSON.stringify(eventData)); - if(eventData.data.strokeWidth != null) { - this.strokeWidth = eventData.data.strokeWidth; - } - if(eventData.data.color != null) { - this.color = eventData.data.color; - } - if(eventData.data.startMargin != null) { - this.startMargin = eventData.data.startMargin; - } - if(eventData.data.endMargin != null) { - this.endMargin = eventData.data.endMargin; - } - } - } - - build() { - Stack({ alignContent: Alignment.TopStart }) { - Column() { - List({ space: 20, initialIndex: 0 }) { - ForEach(this.arr, (item) => { - ListItem() { - Text('' + item) - .width('100%').height(100).fontSize(16) - .textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) - }.editable(true) - }, item => item) - } - .key('list') - .listDirection(this.listDirection) - .divider({ strokeWidth: this.strokeWidth, color: this.color, startMargin: this.startMargin, endMargin: this.endMargin }) - .edgeEffect(this.edgeEffect) - .chainAnimation(this.chainAnimation) - .multiSelectable(true) - .onScrollIndex((firstIndex: number, lastIndex: number) => { - console.info('first' + firstIndex) - console.info('last' + lastIndex) - }) - .onScroll((scrollOffset: number, scrollState: ScrollState) => { - console.info('scrollOffset:' + scrollOffset) - console.info('scrollState:' + scrollState) - }) - .editMode(this.editMode) - .onItemDelete((index: number) => { - console.info(this.arr[index] + 'Delete') - this.arr.splice(index, 1) - console.info(JSON.stringify(this.arr)) - this.editFlag = false - return true - }).width('90%') - }.width('100%') - Button('edit list') - .onClick(() => { - this.editMode = !this.editMode - }).margin({ top: 5, left: 20 }) - }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) - } +// @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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct ListExample { + private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; + @State listDirection: Axis = Axis.Vertical; + @State editMode: boolean = false; + @State edgeEffect: EdgeEffect = EdgeEffect.None; + @State chainAnimation: boolean = false; + @State strokeWidth: number = 2.000000; + @State color: string = 0xFFFFFF; + @State startMargin: number = 20.000000; + @State endMargin: number = 20.000000; + + onPageShow() { + console.info('[list] page show called'); + var stateChangeEvent = { + eventId: 124, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEventTwo = { + eventId: 125, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBackTwo); + + var stateChangeEvent3 = { + eventId: 901, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent3, this.stateChangCallBackTwo); + + var stateChangeEvent4 = { + eventId: 902, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent4, this.stateChangCallBackTwo); + + var stateChangeEvent5 = { + eventId: 903, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent5, this.stateChangCallBackTwo); + } + + private stateChangCallBack = (eventData) => { + console.info("[stateChangCallBack] stateChangCallBack"); + if (eventData != null) { + console.info("[stateChangCallBack] state change called:" + JSON.stringify(eventData)); + if (eventData.data.listDirection != null) { + this.listDirection = eventData.data.listDirection; + } + if (eventData.data.editMode != null) { + this.editMode = eventData.data.editMode; + } + if (eventData.data.edgeEffect != null) { + this.edgeEffect = eventData.data.edgeEffect; + } + if (eventData.data.chainAnimation != null) { + this.chainAnimation = eventData.data.chainAnimation; + } + } + } + private stateChangCallBackTwo = (eventData) => { + console.info("[stateChangCallBackTwo] stateChangCallBack"); + if (eventData != null) { + console.info("[stateChangCallBackTwo] state change called:" + JSON.stringify(eventData)); + if (eventData.data.strokeWidth != null) { + this.strokeWidth = eventData.data.strokeWidth; + } + if (eventData.data.color != null) { + this.color = eventData.data.color; + } + if (eventData.data.startMargin != null) { + this.startMargin = eventData.data.startMargin; + } + if (eventData.data.endMargin != null) { + this.endMargin = eventData.data.endMargin; + } + } + } + + build() { + Stack({ alignContent: Alignment.TopStart }) { + Column() { + List({ space: 20, initialIndex: 0 }) { + ForEach(this.arr, (item) => { + ListItem() { + Text('' + item) + .width('100%') + .height(100) + .fontSize(16) + .textAlign(TextAlign.Center) + .borderRadius(10) + .backgroundColor(0xFFFFFF) + }.editable(true) + }, item => item) + } + .key('list') + .listDirection(this.listDirection) + .divider({ + strokeWidth: this.strokeWidth, + color: this.color, + startMargin: this.startMargin, + endMargin: this.endMargin + }) + .edgeEffect(this.edgeEffect) + .chainAnimation(this.chainAnimation) + .multiSelectable(true) + .onScrollIndex((firstIndex: number, lastIndex: number) => { + console.info('first' + firstIndex) + console.info('last' + lastIndex) + }) + .onScroll((scrollOffset: number, scrollState: ScrollState) => { + console.info('scrollOffset:' + scrollOffset) + console.info('scrollState:' + scrollState) + }) + .editMode(this.editMode) + .onItemDelete((index: number) => { + console.info(this.arr[index] + 'Delete') + this.arr.splice(index, 1) + console.info(JSON.stringify(this.arr)) + this.editFlag = false + return true + }) + .width('90%') + }.width('100%') + + Button('edit list') + .onClick(() => { + this.editMode = !this.editMode + }).margin({ top: 5, left: 20 }) + }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/marquee.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/marquee.ets index 1db3abe5e2b96e912af1e683afcd04f95d673e7a..17db402b7b887564815dc383ab52179666552ad1 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/marquee.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/marquee.ets @@ -44,7 +44,7 @@ struct MarqueeExample { .allowScale(false) .fontWeight(FontWeight.Bold) .backgroundColor(Color.Black) - .margin({bottom:40}) + .margin({ bottom: 40 }) .onStart(() => { console.log('Marquee animation complete onStart') console.info('Onstart current action state is: ' + this.fontColor); @@ -125,7 +125,7 @@ struct MarqueeExample { }) .width(200) .height(60) - .margin({bottom:20}) + .margin({ bottom: 20 }) } .width('100%') .height('100%') diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/overlay.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/overlay.ets index 0ae9c25b98c7f5f86c7003b945f3b84d9eb17534..6b55cb04efcd6f9e5fe9bf19e71d6d5354014a8e 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/overlay.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/overlay.ets @@ -1,71 +1,77 @@ -// @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 events_emitter from '@ohos.emitter' - -@Entry -@Component -struct OverlayExample { - @State title: string = 'old title' - @State x: number = 0 - @State y: number = -15 - @State alignment: Alignment = Alignment.Bottom - - onPageShow() { - console.info('[overlay] page show called '); - var stateChangeEvent = { - eventId: 143, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack); - } - - private stateChangCallBack = (eventData) => { - console.info("[stateChangCallBack] stateChangCallBack "); - if (eventData != null) { - console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); - if (eventData.data.align != null) { - this.alignment = eventData.data.align - } - if (eventData.data.title != null) { - this.title = eventData.data.title - } - if (eventData.data.x != null) { - this.x = eventData.data.x - } - if (eventData.data.y != null) { - this.y = eventData.data.y - } - - } - } - - build() { - Column() { - Column() { - Text('floating layer') - .fontSize(12).fontColor(0xCCCCCC).maxLines(1) - Column() { - Image('/images/img.jpeg') - .width(340).height(240) - .key('overlay') - .overlay(this.title, - { align: this.alignment, offset: { x: this.x, y: this.y } }) - }.border({ color: Color.Black, width: 2 }) - }.width('100%') - }.padding({ top: 20 }) - } +// @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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct OverlayExample { + @State title: string = 'old title' + @State x: number = 0 + @State y: number = -15 + @State alignment: Alignment = Alignment.Bottom + + onPageShow() { + console.info('[overlay] page show called '); + var stateChangeEvent = { + eventId: 143, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent2 = { + eventId: 1110, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent2, this.stateChangCallBack); + } + + private stateChangCallBack = (eventData) => { + console.info("[stateChangCallBack] stateChangCallBack "); + if (eventData != null) { + console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); + if (eventData.data.align != null) { + this.alignment = eventData.data.align + } + if (eventData.data.title != null) { + this.title = eventData.data.title + } + if (eventData.data.x != null) { + this.x = eventData.data.x + } + if (eventData.data.y != null) { + this.y = eventData.data.y + } + + } + } + + build() { + Column() { + Column() { + Text('floating layer') + .fontSize(12).fontColor(0xCCCCCC).maxLines(1) + Column() { + Image('/images/img.jpeg') + .width(340).height(240) + .key('overlay') + .overlay(this.title, + { align: this.alignment, offset: { x: this.x, y: this.y } }) + }.border({ color: Color.Black, width: 2 }) + }.width('100%') + }.padding({ top: 20 }) + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stepper.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stepper.ets index 86c5db9b37b6fbdbe65f40c212cadc26e713cfe1..d5f05114c35570c1e2ef5777a3d1029a8c38ed75 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stepper.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/stepper.ets @@ -1,120 +1,135 @@ -// @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 events_emitter from '@ohos.emitter' - -@Entry -@Component -struct StepperExample { - @State currentIndex: number = 0 - @State firstState: ItemState = ItemState.Normal - @State secondState: ItemState = ItemState.Normal - @State disabled: ItemState = ItemState.Normal - - build() { - Stepper({ - index: this.currentIndex - }) { - StepperItem() { - Text('Page One') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - } - .nextLabel('') - .position({x: '35%', y: 0}) - .key('stepperItem1') - StepperItem() { - Text('Page Two') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - .key('text1') - .onClick(()=>{ - this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip - }) - } - .nextLabel('Next') - .prevLabel('Previous') - .status(this.firstState) - .position({x: '35%', y: 0}) - .key('stepperItem2') - StepperItem() { - Text('Page Three') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - .key('text2') - .onClick(()=>{ - this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting - }) - } - .position({x: '35%', y: 0}) - .status(this.secondState) - .key('stepperItem3') - StepperItem() { - Text('Page four') - .fontSize(35) - .fontColor(Color.Blue) - .width(200) - .lineHeight(50) - .margin({top:250}) - } - .position({x: '35%', y: 0}) - .nextLabel('Finish') - .key('stepperItem4') - } - .onFinish(() => { - console.log('onFinish') - }) - .onSkip(() => { - console.log('onSkip') - }) - .onChange((prevIndex: number, index: number) => { - this.currentIndex = index - }) - .align(Alignment.Center) - .key('stepper') - } - - onPageShow() { - console.info('stepper page show called'); - var stateChangeEvent = { - eventId: 202, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack) - } - - private stateChangCallBack = (eventData) => { - console.info("stepper page stateChangCallBack" + JSON.stringify(eventData)); - if (eventData != null) { - console.info("stepper page state change called:" + JSON.stringify(eventData)); - if(eventData.data.currentIndex != null) { - this.currentIndex = parseInt(eventData.data.currentIndex); - } - if(eventData.data.disabled != null) { - this.disabled = eventData.data.disabled; - } - } - } +// @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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct StepperExample { + @State currentIndex: number = 0 + @State firstState: ItemState = ItemState.Normal + @State secondState: ItemState = ItemState.Normal + @State disabled: ItemState = ItemState.Normal + + build() { + Stepper({ + index: this.currentIndex + }) { + StepperItem() { + Text('Page One') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({ top: 250 }) + } + .nextLabel('') + .position({ x: '35%', y: 0 }) + .key('stepperItem1') + + StepperItem() { + Text('Page Two') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({ top: 250 }) + .key('text1') + .onClick(() => { + this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip + }) + } + .nextLabel('Next') + .prevLabel('Previous') + .status(this.firstState) + .position({ x: '35%', y: 0 }) + .key('stepperItem2') + + StepperItem() { + Text('Page Three') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({ top: 250 }) + .key('text2') + .onClick(() => { + this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting + }) + } + .position({ x: '35%', y: 0 }) + .status(this.secondState) + .key('stepperItem3') + + StepperItem() { + Text('Page four') + .fontSize(35) + .fontColor(Color.Blue) + .width(200) + .lineHeight(50) + .margin({ top: 250 }) + } + .position({ x: '35%', y: 0 }) + .nextLabel('Finish') + .key('stepperItem4') + } + .onFinish(() => { + console.log('onFinish') + }) + .onSkip(() => { + console.log('onSkip') + }) + .onChange((prevIndex: number, index: number) => { + this.currentIndex = index + }) + .align(Alignment.Center) + .key('stepper') + } + + onPageShow() { + console.info('stepper page show called'); + var stateChangeEvent = { + eventId: 202, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack) + + var stateChangeEventTwo = { + eventId: 909, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack); + + var stateChangeEventThree = { + eventId: 910, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventThree, this.stateChangCallBack); + } + + private stateChangCallBack = (eventData) => { + console.info("stepper page stateChangCallBack" + JSON.stringify(eventData)); + if (eventData != null) { + console.info("stepper page state change called:" + JSON.stringify(eventData)); + if (eventData.data.currentIndex != null) { + this.currentIndex = parseInt(eventData.data.currentIndex); + } + if (eventData.data.disabled != null) { + this.disabled = eventData.data.disabled; + } + } + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/swiper.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/swiper.ets index 2ecaf7cb66950621a1c5974205f8bad8ecc85f52..3c86e68e9ee0486012fbda6d409b97c20499b248 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/swiper.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/swiper.ets @@ -92,7 +92,7 @@ struct SwiperExample { .displayMode(this.displayMode) .displayCount(this.displayCount) .effectMode(this.edgeEffect) - .indicatorStyle({ top: 20, right: 20,size:2,color: Color.Blue}) + .indicatorStyle({ top: 20, right: 20, size: 2, color: Color.Blue }) .key('swiper') .onChange((index: number) => { console.info(index.toString()) diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/textStyle.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/textStyle.ets index 0de318885b18f5e67ec9e02abbe0e9d2ad6fb03d..1c416aec4dde052afac7c532a9f202426a44d3b9 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/textStyle.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/textStyle.ets @@ -68,8 +68,9 @@ struct TextStyle { .fontStyle(FontStyle.Normal) .fontWeight(400) .fontFamily('source-sans-pro,cursive,sans-serif') - }.width('100%').margin({top: 20}) + }.width('100%').margin({ top: 20 }) } + onPageShow() { let fontColorChangeEvent = { eventId: 37, @@ -97,6 +98,7 @@ struct TextStyle { } events_emitter.on(fontFamilyChangeEvent, this.textStyleChangCallBack); } + textStyleChangCallBack = (eventData) => { console.info("textStyle page stateChangCallBack" + JSON.stringify(eventData)); if (eventData && eventData.data) { diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touch.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touch.ets index 4fa1495acbde130413b871546eec2b4828db63bb..d2f0963e4fb7260766976f1ca8993ae9ea87d4f2 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touch.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touch.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.emitter' @Entry @Preview @Component -struct TouchExample { +struct TouchExample { @State text: string = '' @State eventType: string = '' @State touchFlag: boolean = false @@ -37,13 +37,13 @@ struct TouchExample { console.info("[touch] page stateChangCallBack"); if (eventData != null) { console.info("[touch] page state change called:" + JSON.stringify(eventData)); - if(eventData.data.text != null) { + if (eventData.data.text != null) { this.text = eventData.data.text; } - if(eventData.data.eventType != null) { + if (eventData.data.eventType != null) { this.eventType = eventData.data.eventType; } - if(eventData.data.touchFlag != null) { + if (eventData.data.touchFlag != null) { this.touchFlag = eventData.data.touchFlag } } @@ -51,7 +51,10 @@ struct TouchExample { build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { - Button('Touch').backgroundColor(0x2788D9).height(40).width(80) + Button('Touch') + .backgroundColor(0x2788D9) + .height(40) + .width(80) .key('touch') .onTouch((event: Touch) => { if (event.type === TouchType.Down) { @@ -72,7 +75,7 @@ struct TouchExample { stopPropagation: () => { console.info('stopPropagation') } - console.info('onTouch successful, touchFlag is : ' + this.eventType + ', ' +this.touchFlag) + console.info('onTouch successful, touchFlag is : ' + this.eventType + ', ' + this.touchFlag) console.info(this.text = 'TouchType:' + this.eventType + '\nDistance between touch point and touch element:\nx: ' + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:(' @@ -84,7 +87,7 @@ struct TouchExample { + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + event.target.area.width + '\nheight:' + event.target.area.height) console.log('fang--->A') - try{ + try { console.log('fang--->B') var backData = { data: { @@ -99,7 +102,7 @@ struct TouchExample { console.log('fang--->D') console.info("touchFlag start to emit action state") events_emitter.emit(backEvent, backData) - }catch{ + } catch { console.info("touchFlag emit action state err: " + JSON.stringify(err.message)) } }) diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touchAble.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touchAble.ets index 5f1be1a1bf0d377368178b99288d5826bb3bc029..98909027fca647f2a32cca575d425c65f5890617 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touchAble.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/touchAble.ets @@ -23,7 +23,6 @@ struct TouchAbleExample { @State text1: string = ''; @State text2: string = ''; @State touchableValue: boolean = false; - private stateChangCallBack = (eventData) => { console.info("[TouchAble] page stateChangCallBack"); if (eventData != null) { @@ -46,13 +45,17 @@ struct TouchAbleExample { build() { Stack() { Rect() - .fill(Color.Gray).width(150).height(150) + .fill(Color.Gray) + .width(150) + .height(150) .onClick(() => { console.info(this.text1 = 'Rect Clicked') }) .overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) Ellipse() - .fill(Color.Pink).width(150).height(80) + .fill(Color.Pink) + .width(150) + .height(80) .key('ellipse') .touchable(this.touchableValue) .onClick(() => { diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/visibility.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/visibility.ets index 3d373657ff6ecb234c87e1a92028e2e9de139197..d9a6312292995fd7eba8fa83b5e1575c6bc7943b 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/visibility.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/visibility.ets @@ -1,69 +1,85 @@ -// @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 events_emitter from '@ohos.emitter'; - -@Entry -@Component -struct VisibilityExample { - @State visibility: Visibility = Visibility.Visible; - - onPageShow() { - let hiddenChangeEvent = { - eventId: 47, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(hiddenChangeEvent, this.hiddenChangCallBack) - - let noneChangeEvent = { - eventId: 48, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(noneChangeEvent, this.noneChangCallBack) - } - - private hiddenChangCallBack = (eventData) => { - console.info("[hiddenChangCallBack] stateChangCallBack"); - if (eventData != null) { - console.info("[hiddenChangCallBack] state change called:" + JSON.stringify(eventData)); - if(eventData.data.visibility != null) { - this.visibility = eventData.data.visibility; - } - } - } - - private noneChangCallBack = (eventData) => { - console.info("[noneChangCallBack] stateChangCallBack"); - if (eventData != null) { - console.info("[noneChangCallBack] state change called:" + JSON.stringify(eventData)); - if(eventData.data.visibility != null) { - this.visibility = eventData.data.visibility; - } - } - } - - build() { - Column() { - Column() { - Text('BoxOne').fontSize(9).width('90%').fontColor(0xCCCCCC) - Row().visibility(this.visibility).width('90%').height(80).backgroundColor(0xAFEEEE).padding(20).key('box') - - Text('BoxTwo').fontSize(9).width('90%').fontColor(0xCCCCCC) - Row().visibility(Visibility.Visible).width('90%').height(80).backgroundColor(0xAFEEEE).padding(20) - }.width('90%').border({ width: 1 }) - }.width('100%').margin({ top: 5 }) - } -} +// @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 events_emitter from '@ohos.emitter'; + +@Entry +@Component +struct VisibilityExample { + @State visibility: Visibility = Visibility.Visible; + + onPageShow() { + let hiddenChangeEvent = { + eventId: 47, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(hiddenChangeEvent, this.hiddenChangCallBack) + + let noneChangeEvent = { + eventId: 48, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(noneChangeEvent, this.noneChangCallBack) + + var stateChangeEvent2 = { + eventId: 1116, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent2, this.stateChangCallBack); + } + + private hiddenChangCallBack = (eventData) => { + console.info("[hiddenChangCallBack] stateChangCallBack"); + if (eventData != null) { + console.info("[hiddenChangCallBack] state change called:" + JSON.stringify(eventData)); + if (eventData.data.visibility != null) { + this.visibility = eventData.data.visibility; + } + } + } + private noneChangCallBack = (eventData) => { + console.info("[noneChangCallBack] stateChangCallBack"); + if (eventData != null) { + console.info("[noneChangCallBack] state change called:" + JSON.stringify(eventData)); + if (eventData.data.visibility != null) { + this.visibility = eventData.data.visibility; + } + } + } + + build() { + Column() { + Column() { + Text('BoxOne').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .visibility(this.visibility) + .width('90%') + .height(80) + .backgroundColor(0xAFEEEE) + .padding(20) + .key('box') + + Text('BoxTwo').fontSize(9).width('90%').fontColor(0xCCCCCC) + Row() + .visibility(Visibility.Visible) + .width('90%') + .height(80) + .backgroundColor(0xAFEEEE) + .padding(20) + }.width('90%').border({ width: 1 }) + }.width('100%').margin({ top: 5 }) + } +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/zIndex.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/zIndex.ets index 173a8d29c0f6347fdbf82e17ea1a7d9998062e99..0058290918e46ad7713716b5749ae5355977036e 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/zIndex.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/pages/zIndex.ets @@ -1,62 +1,68 @@ -// @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 events_emitter from '@ohos.emitter' - -@Entry -@Component -struct zIndexExample { - @State zIndex: number = 1; - - onPageShow() { - console.info('[zIndex] page show called '); - var stateChangeEvent = { - eventId: 236, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(stateChangeEvent, this.stateChangCallBack); - - } - - private stateChangCallBack = (eventData) => { - console.info("[stateChangCallBack] stateChangCallBack "); - if (eventData != null) { - console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); - if (eventData.data.zIndex != null) { - this.zIndex = eventData.data.zIndex - } - } - } - - build() { - Column() { - Stack() { - Text('first child, zIndex(2)') - .size({ width: '40%', height: '60%' }).backgroundColor(0xbbb2cb) - .zIndex(2) - Text('second child, default zIndex(0)') - .size({ width: '90%', height: '80%' }).backgroundColor(0xd2cab3).align(Alignment.TopStart) - Text('third child, zIndex(1)') - .size({ width: '70%', height: '50%' }) - .backgroundColor(0xc1cbac) - .align(Alignment.TopStart) - .zIndex(this.zIndex) - .key('zIndex') - } - }.width('100%').height(200) - } +// @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 events_emitter from '@ohos.emitter' + +@Entry +@Component +struct zIndexExample { + @State zIndex: number = 1; + + onPageShow() { + console.info('[zIndex] page show called '); + var stateChangeEvent = { + eventId: 236, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent2 = { + eventId: 1113, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent2, this.stateChangCallBack); + + } + + private stateChangCallBack = (eventData) => { + console.info("[stateChangCallBack] stateChangCallBack "); + if (eventData != null) { + console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); + if (eventData.data.zIndex != null) { + this.zIndex = eventData.data.zIndex + } + } + } + + build() { + Column() { + Stack() { + Text('first child, zIndex(2)') + .size({ width: '40%', height: '60%' }).backgroundColor(0xbbb2cb) + .zIndex(2) + Text('second child, default zIndex(0)') + .size({ width: '90%', height: '80%' }).backgroundColor(0xd2cab3).align(Alignment.TopStart) + Text('third child, zIndex(1)') + .size({ width: '70%', height: '50%' }) + .backgroundColor(0xc1cbac) + .align(Alignment.TopStart) + .zIndex(this.zIndex) + .key('zIndex') + } + }.width('100%').height(200) + } } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AppearJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AppearJsunit.test.ets index 61924c80e460650497bdebd7427118f3e001d6ba..96f6b9126c37a612e3c00621bc14f12c5d2a9628 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AppearJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AppearJsunit.test.ets @@ -1,107 +1,108 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter' -import Utils from './Utils'; -export default function appearJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("appear beforeEach start"); - let options = { - uri: 'pages/appear', - } - let result; - try { - router.clear(); - let pages = router.getState(); - console.info("get appear state pages: " + JSON.stringify(pages)); - if (!("appear" == pages.name)) { - console.info("get appear state pages.name: " + JSON.stringify(pages.name)); - result = await router.push(options); - await Utils.sleep(2000); - console.info("push appear page result: " + JSON.stringify(result)); - } - } catch (err) { - console.error("push appear page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("appear after each called"); - }) - - it('testAppear01', 0, async function (done) { - console.info('[testAppear01] START'); - await Utils.sleep(1000); - try { - let callBackAppear = (backData) => { - console.info("testAppear01 get appearEvent result is: " + JSON.stringify(appearEvent)); - expect(backData.data.ACTION).assertEqual(true); - } - var appearEvent = { - eventId: 58, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(appearEvent, callBackAppear); - } catch (err) { - console.info("testAppear01 on appearEvent err : " + JSON.stringify(err)); - } - console.info("testAppear01 click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); - console.info('[testAppear01] END'); - done(); - }); - - it('testAppear02', 0, async function (done) { - console.info('[testAppear02] START'); - await Utils.sleep(1000); - try { - let callBackAppear = (backData) => { - console.info("testAppear02 get appearEvent result is: " + JSON.stringify(appearEvent)); - expect(backData.data.ACTION).assertEqual(true); - } - var appearEvent = { - eventId: 59, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(appearEvent, callBackAppear); - } catch (err) { - console.info("testAppear02 on appearEvent err : " + JSON.stringify(err)); - } - console.info("testAppear02 appearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); - - try { - let callBackDisAppear = (backData) => { - console.info("testAppear02 get disAppearEvent result is: " + JSON.stringify(disAppearEvent)); - expect(backData.data.ACTION).assertEqual(true); - } - var disAppearEvent = { - eventId: 60, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(disAppearEvent, callBackDisAppear); - } catch (err) { - console.info("testAppear02 on disAppearEvent err : " + JSON.stringify(err)); - } - console.info("testAppear02 disAppearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); - console.info('[testAppear02] END'); - done(); - }); - - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils.ets'; + +export default function appearJsunit() { + describe('appearTest', function () { + beforeEach(async function (done) { + console.info("appear beforeEach start"); + let options = { + uri: 'pages/appear', + } + let result; + try { + router.clear(); + let pages = router.getState(); + console.info("get appear state pages: " + JSON.stringify(pages)); + if (!("appear" == pages.name)) { + console.info("get appear state pages.name: " + JSON.stringify(pages.name)); + result = await router.push(options); + await Utils.sleep(2000); + console.info("push appear page result: " + JSON.stringify(result)); + } + } catch (err) { + console.error("push appear page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("appear after each called"); + }) + + it('testAppear01', 0, async function (done) { + console.info('[testAppear01] START'); + await Utils.sleep(1000); + try { + let callBackAppear = (backData) => { + console.info("testAppear01 get appearEvent result is: " + JSON.stringify(appearEvent)); + expect(backData.data.ACTION).assertEqual(true); + } + var appearEvent = { + eventId: 58, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(appearEvent, callBackAppear); + } catch (err) { + console.info("testAppear01 on appearEvent err : " + JSON.stringify(err)); + } + console.info("testAppear01 click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); + console.info('[testAppear01] END'); + done(); + }); + + it('testAppear02', 0, async function (done) { + console.info('[testAppear02] START'); + await Utils.sleep(1000); + try { + let callBackAppear = (backData) => { + console.info("testAppear02 get appearEvent result is: " + JSON.stringify(appearEvent)); + expect(backData.data.ACTION).assertEqual(true); + } + var appearEvent = { + eventId: 59, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(appearEvent, callBackAppear); + } catch (err) { + console.info("testAppear02 on appearEvent err : " + JSON.stringify(err)); + } + console.info("testAppear02 appearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); + + try { + let callBackDisAppear = (backData) => { + console.info("testAppear02 get disAppearEvent result is: " + JSON.stringify(disAppearEvent)); + expect(backData.data.ACTION).assertEqual(true); + } + var disAppearEvent = { + eventId: 60, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(disAppearEvent, callBackDisAppear); + } catch (err) { + console.info("testAppear02 on disAppearEvent err : " + JSON.stringify(err)); + } + console.info("testAppear02 disAppearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); + console.info('[testAppear02] END'); + done(); + }); + + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AreaChangeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AreaChangeJsunit.test.ets index 0715e4be526c2dfd5f5ffc467216792a745bbf4a..86818894bfaecf8b34e653778f674739325619a6 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AreaChangeJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/AreaChangeJsunit.test.ets @@ -1,129 +1,130 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter' -import Utils from './Utils'; -export default function areaChangeJsunit() { - describe('areaChange', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/areaChange', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get areaChange state success " + JSON.stringify(pages)); - if (!("areaChange" == pages.name)) { - console.info("get areaChange state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(1000); - console.info("push areaChange page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push areaChange page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("areaChange after each called"); - }); - - it('areaChangeTest_0100', 0, async function (done) { - console.info('areaChangeTest_0100 START'); - let strJson = getInspectorByKey('text1'); - console.info("areaChangeTest_0100 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("areaChangeTest_0100 component obj is: " + JSON.stringify(obj)); - expect(obj.$type).assertEqual('Text'); - expect(obj.$attrs.width).assertEqual('42.000000'); - expect(obj.$attrs.height).assertEqual('23.000000'); - console.info('areaChangeTest_0100 END'); - done(); - }); - - it('areaChangeTest_0200', 0, async function (done) { - console.info('areaChangeTest_0200 START'); - let strJson = getInspectorByKey('text2'); - console.info("areaChangeTest_0200 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("areaChangeTest_0200 component obj is: " + JSON.stringify(obj)); - expect(obj.$type).assertEqual('Text'); - expect(obj.$attrs.width).assertEqual('519.000000'); - expect(obj.$attrs.height).assertEqual('140.000000'); - console.info('areaChangeTest_0200 END'); - done(); - }); - - it('areaChangeTest_0300', 0, async function (done) { - console.info('areaChangeTest_0300 START'); - await Utils.sleep(1000); - let callback = (indexEvent) => { - console.info("areaChangeTest_0300 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.value).assertEqual('TextText'); - } - let indexEvent = { - eventId: 61, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err)); - } - console.info("areaChangeTest_0300 click result is: " + JSON.stringify(sendEventByKey('text1', 10, ""))); - var innerEventOne = { - eventId: 62, - priority: events_emitter.EventPriority.LOW - } - await Utils.sleep(1500); - var callback1 = (eventData) => { - console.info("areaChangeTest_0300 get event state result is: " + JSON.stringify(eventData)); - expect(eventData.data.ACTION).assertEqual(true); - } - try { - events_emitter.on(innerEventOne, callback1); - } catch (err) { - console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err)); - } - console.info('areaChangeTest_0300 END'); - done(); - }); - - it('areaChangeTest_0400', 0, async function (done) { - console.info('areaChangeTest_0400 START'); - await Utils.sleep(1000); - let callback = (indexEvent) => { - console.info("areaChangeTest_0400 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.value).assertEqual('TextTextText'); - } - let indexEvent = { - eventId: 62, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("areaChangeTest_0400 on events_emitter err : " + JSON.stringify(err)); - } - console.info("areaChangeTest_0400 click result is: " + JSON.stringify(sendEventByKey('text1',10,""))); - console.info('areaChangeTest_0400 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils.ets'; + +export default function areaChangeJsunit() { + describe('areaChangeTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/areaChange', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get areaChange state success " + JSON.stringify(pages)); + if (!("areaChange" == pages.name)) { + console.info("get areaChange state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push areaChange page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push areaChange page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("areaChange after each called"); + }); + + it('areaChangeTest_0100', 0, async function (done) { + console.info('areaChangeTest_0100 START'); + let strJson = getInspectorByKey('text1'); + console.info("areaChangeTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("areaChangeTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Text'); + expect(obj.$attrs.width).assertEqual('42.000000'); + expect(obj.$attrs.height).assertEqual('23.000000'); + console.info('areaChangeTest_0100 END'); + done(); + }); + + it('areaChangeTest_0200', 0, async function (done) { + console.info('areaChangeTest_0200 START'); + let strJson = getInspectorByKey('text2'); + console.info("areaChangeTest_0200 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("areaChangeTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Text'); + expect(obj.$attrs.width).assertEqual('519.000000'); + expect(obj.$attrs.height).assertEqual('210.000000'); + console.info('areaChangeTest_0200 END'); + done(); + }); + + it('areaChangeTest_0300', 0, async function (done) { + console.info('areaChangeTest_0300 START'); + await Utils.sleep(1000); + let callback = (indexEvent) => { + console.info("areaChangeTest_0300 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.value).assertEqual('TextText'); + } + let indexEvent = { + eventId: 61, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err)); + } + console.info("areaChangeTest_0300 click result is: " + JSON.stringify(sendEventByKey('text1', 10, ""))); + var innerEventOne = { + eventId: 62, + priority: events_emitter.EventPriority.LOW + } + await Utils.sleep(1500); + var callback1 = (eventData) => { + console.info("areaChangeTest_0300 get event state result is: " + JSON.stringify(eventData)); + expect(eventData.data.ACTION).assertEqual(true); + } + try { + events_emitter.on(innerEventOne, callback1); + } catch (err) { + console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err)); + } + console.info('areaChangeTest_0300 END'); + done(); + }); + + it('areaChangeTest_0400', 0, async function (done) { + console.info('areaChangeTest_0400 START'); + await Utils.sleep(1000); + let callback = (indexEvent) => { + console.info("areaChangeTest_0400 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.value).assertEqual('TextTextText'); + } + let indexEvent = { + eventId: 62, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("areaChangeTest_0400 on events_emitter err : " + JSON.stringify(err)); + } + console.info("areaChangeTest_0400 click result is: " + JSON.stringify(sendEventByKey('text1', 10, ""))); + console.info('areaChangeTest_0400 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ColumnJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ColumnJsunit.test.ets new file mode 100755 index 0000000000000000000000000000000000000000..696277fdc1b6fc07406e1c53e808456afbcd4387 --- /dev/null +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ColumnJsunit.test.ets @@ -0,0 +1,86 @@ +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function columnJsunit() { + describe('columnTest', function () { + beforeEach(async function (done) { + console.info("column beforeEach start"); + let options = { + uri: 'pages/column', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get column state pages:" + JSON.stringify(pages)); + if (!("column" == pages.name)) { + console.info("get column state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push column page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push column page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("column after each called"); + }); + + it('testColumn01', 0, async function (done) { + console.info('[testColumn01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('alignItemsColumn'); + let obj = JSON.parse(strJson); + console.info("[testColumn01] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.alignItems).assertEqual('HorizontalAlign.Start'); + console.info('[testColumn01] END'); + done(); + }); + + it('testColumn02', 0, async function (done) { + console.info('[testColumn02] START'); + try { + var eventData = { + data: { + "alignItems":HorizontalAlign.Center + } + } + var innerEvent = { + eventId: 192, + priority: events_emitter.EventPriority.LOW + } + console.info("[testColumn02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testColumn02] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('alignItemsColumn'); + let obj = JSON.parse(strJson); + console.info("[testColumn02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.alignItems).assertEqual('HorizontalAlign.Center'); + console.info('[testColumn02] END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets index 7f32a8378379b2a083f88f5099580e4cd5d584af..5c61aa0d84f8e186dfc6cef5d295b612319ead7b 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EllipseJsunit.test.ets @@ -1,113 +1,217 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function ellipseJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("ellipse beforeEach start"); - let options = { - uri: 'pages/ellipse', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get ellipse state pages:" + JSON.stringify(pages)); - if (!("ellipse" == pages.name)) { - console.info("get ellipse state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push ellipse page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push ellipse page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("ellipse after each called"); - }); - - it('testEllipse01', 0, async function (done) { - console.info('[testEllipse01] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('ellipse'); - let obj = JSON.parse(strJson); - console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.height).assertEqual('200.00px'); - expect(obj.$attrs.width).assertEqual('200.00px'); - console.info('testEllipse02 END'); - done(); - }); - - it('testEllipse02', 0, async function (done) { - console.info('[testEllipse02] START'); - try { - var eventData = { - data: { - "width": '100px' - } - } - var innerEvent = { - eventId: 92, - priority: events_emitter.EventPriority.LOW - } - console.info("[testEllipse02] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testEllipse02] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('ellipse'); - let obj = JSON.parse(strJson); - console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.width).assertEqual('100.00px'); - console.info('testEllipse02 END'); - done(); - }); - - it('testEllipse03', 0, async function (done) { - console.info('[testEllipse03] START'); - try { - var eventData = { - data: { - "height": '500px' - } - } - var innerEvent = { - eventId: 92, - priority: events_emitter.EventPriority.LOW - } - console.info("[testEllipse03] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testEllipse03] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('ellipse'); - let obj = JSON.parse(strJson); - console.info("[testEllipse03] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.height).assertEqual('500.00px'); - console.info('testEllipse03 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function ellipseJsunit() { + describe('ellipseTest', function () { + beforeEach(async function (done) { + console.info("ellipse beforeEach start"); + let options = { + uri: 'pages/ellipse', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get ellipse state pages:" + JSON.stringify(pages)); + if (!("ellipse" == pages.name)) { + console.info("get ellipse state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push ellipse page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push ellipse page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("ellipse after each called"); + }); + + it('testEllipse01', 0, async function (done) { + console.info('[testEllipse01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('200.00px'); + expect(obj.$attrs.width).assertEqual('200.00px'); + console.info('testEllipse02 END'); + done(); + }); + + it('testEllipse02', 0, async function (done) { + console.info('[testEllipse02] START'); + try { + var eventData = { + data: { + "width": '100px' + } + } + var innerEvent = { + eventId: 92, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse02] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual('100.00px'); + console.info('testEllipse02 END'); + done(); + }); + + it('testEllipse03', 0, async function (done) { + console.info('[testEllipse03] START'); + try { + var eventData = { + data: { + "height": '500px' + } + } + var innerEvent = { + eventId: 92, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse03] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse03] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('500.00px'); + console.info('testEllipse03 END'); + done(); + }); + + it('testEllipse04', 0, async function (done) { + console.info('[testEllipse04] START'); + try { + var eventData = { + data: { + "width": '1111111111111' + } + } + var innerEvent = { + eventId: 907, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse04] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse04] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse04] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual('1111111111111.00px'); + console.info('testEllipse04 END'); + done(); + }); + + it('testEllipse05', 0, async function (done) { + console.info('[testEllipse05] START'); + try { + var eventData = { + data: { + "height": '12111111111111' + } + } + var innerEvent = { + eventId: 907, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse05] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse05] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse05] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('12111111111111.00px'); + console.info('testEllipse05 END'); + done(); + }); + + it('testEllipse06', 0, async function (done) { + console.info('[testEllipse06] START'); + try { + var eventData = { + data: { + "height": '-40' + } + } + var innerEvent = { + eventId: 908, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse06] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse06] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse06] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.height).assertEqual('-40.00px'); + console.info('testEllipse06 END'); + done(); + }); + + it('testEllipse07', 0, async function (done) { + console.info('[testEllipse07] START'); + try { + var eventData = { + data: { + "width": '-10' + } + } + var innerEvent = { + eventId: 908, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEllipse07] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEllipse07] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('ellipse'); + let obj = JSON.parse(strJson); + console.info("[testEllipse07] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.width).assertEqual('-10.00px'); + console.info('testEllipse07 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EnableJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EnableJsunit.test.ets index 6e8fda4acefca97f877bbd67f8dabf7a6b067d19..c9a757876f4ecc1ece3a9f9fa3e411ace9c38dbe 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EnableJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/EnableJsunit.test.ets @@ -1,87 +1,137 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter' -import Utils from './Utils'; - -export default function enableJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("enable beforeEach start"); - let options = { - uri: 'pages/enable', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get enable state pages: " + JSON.stringify(pages)); - if (!("enable" == pages.name)) { - console.info("get enable state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push enable page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push enable page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("enable after each called"); - }); - - it('testEnable01', 0, async function (done) { - console.info('[testEnable01] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('enabled'); - let obj = JSON.parse(strJson); - console.info("[testEnable01] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.enabled).assertEqual(true); - console.info('[testEnable01] END'); - done(); - }); - - it('testEnable02', 0, async function (done) { - console.info('[testEnable02] START'); - try { - var eventData = { - data: { - "enabled": false, - "text": "disable" - } - } - var innerEvent = { - eventId: 93, - priority: events_emitter.EventPriority.LOW - } - console.info("[testEnable02] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testEnable02] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJson = getInspectorByKey('enabled'); - let obj = JSON.parse(strJson); - console.info("[testEnable02] obj is: " + JSON.stringify(obj.$attrs.enabled)); - expect(obj.$attrs.enabled).assertEqual(false); - console.info('testEnable02 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils.ets'; +export default function enableJsunit() { + describe('enableTest', function () { + beforeEach(async function (done) { + console.info("enable beforeEach start"); + let options = { + uri: 'pages/enable', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get enable state pages: " + JSON.stringify(pages)); + if (!("enable" == pages.name)) { + console.info("get enable state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push enable page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push enable page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("enable after each called"); + }); + + it('testEnable01', 0, async function (done) { + console.info('[testEnable01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('enabled'); + let obj = JSON.parse(strJson); + console.info("[testEnable01] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.enabled).assertEqual(true); + console.info('[testEnable01] END'); + done(); + }); + + it('testEnable02', 0, async function (done) { + console.info('[testEnable02] START'); + try { + var eventData = { + data: { + "enabled": false, + "text": "disable" + } + } + var innerEvent = { + eventId: 93, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEnable02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEnable02] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('enabled'); + let obj = JSON.parse(strJson); + console.info("[testEnable02] obj is: " + JSON.stringify(obj.$attrs.enabled)); + expect(obj.$attrs.enabled).assertEqual(false); + console.info('testEnable02 END'); + done(); + }); + + it('testEnable03', 0, async function (done) { + console.info('[testEnable03] START'); + try { + var eventData = { + data: { + "enabled": -3 + } + } + var innerEvent = { + eventId: 1111, + priority: events_emitter.EventPriority.LOW + } + console.info("[testEnable03] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testEnable03] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('enabled'); + let obj = JSON.parse(strJson); + console.info("[testEnable03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.enabled).assertEqual(true); + console.info('testEnable03 END'); + done(); + }); + + it('testEnable04', 0, async function (done) { + console.info('testEnable04 START'); + try { + let eventData = { + data: { + "enabled": 33567444 + } + } + let indexEvent = { + eventId: 1111, + priority: events_emitter.EventPriority.LOW + } + console.info("testEnable04 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testEnable04 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('enabled'); + let objNew = JSON.parse(strJsonNew); + console.info("testEnable04 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.enabled).assertEqual(true); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GaugeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GaugeJsunit.test.ets index 03cb3599501d0eb84ba115bd21eaece10b733918..b0a30b0f9b162d9bc398b19d3da124ccfbc637ba 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GaugeJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GaugeJsunit.test.ets @@ -1,187 +1,394 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function gaugeJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/gauge', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get gauge state success " + JSON.stringify(pages)); - if (!("gauge" == pages.name)) { - console.info("get gauge state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push gauge page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push gauge page error " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(2000); - console.info("gauge after each called"); - }); - - it('testGauge001', 0, async function (done) { - console.info('[testGauge001] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('gauge'); - let obj = JSON.parse(strJson); - console.info("[testGauge001] component obj is: " + JSON.stringify(obj)); - expect(obj.$type).assertEqual('Gauge'); - expect(obj.$attrs.strokeWidth).assertEqual('20.00vp'); - expect(obj.$attrs.width).assertEqual('200.00vp'); - expect(obj.$attrs.height).assertEqual('200.00vp'); - expect(obj.$attrs.value).assertEqual('50.00'); - done(); - }); - - it('testGauge002', 0, async function (done) { - console.info('[testGauge002] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "gaugeValue": "10" - } - } - var innerEvent = { - eventId: 102, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGauge002] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testGauge002] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('gauge'); - let objNew = JSON.parse(strJsonNew); - console.info("[testGauge002] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.value).assertEqual('10.00'); - done(); - }); - - it('testGauge003', 0, async function (done) { - console.info('[testGauge003] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "strokeWidthValue": "30", - } - } - var innerEvent = { - eventId: 102, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGauge003] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testGauge003] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('gauge'); - let objNew = JSON.parse(strJsonNew); - console.info("[testGauge003] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.strokeWidth).assertEqual('30.00vp'); - done(); - }); - - it('testGauge004', 0, async function (done) { - console.info('[testGauge004] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "startAngleValue": "200" - } - } - var innerEvent = { - eventId: 102, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGauge004] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testGauge004] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('gauge'); - let objNew = JSON.parse(strJsonNew); - console.info("[testGauge004] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.startAngle).assertEqual('200.00'); - done(); - }); - - it('testGauge005', 0, async function (done) { - console.info('[testGauge005] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "endAngleValue": "200" - } - } - var innerEvent = { - eventId: 102, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGauge005] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testGauge005] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('gauge'); - let objNew = JSON.parse(strJsonNew); - console.info("[testGauge005] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.endAngle).assertEqual('200.00'); - done(); - }); - - it('testGauge006', 0, async function (done) { - console.info('[testGauge006] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "colorValues": JSON.stringify([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1]]) - } - } - var innerEvent = { - eventId: 103, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGauge006] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testGauge006] change component data error: " + err.message); - } - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +export default function gaugeJsunit() { + describe('gaugeTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/gauge', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get gauge state success " + JSON.stringify(pages)); + if (!("gauge" == pages.name)) { + console.info("get gauge state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push gauge page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push gauge page error " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info("gauge after each called"); + }); + + it('testGauge001', 0, async function (done) { + console.info('[testGauge001] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('gauge'); + let obj = JSON.parse(strJson); + console.info("[testGauge001] component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Gauge'); + expect(obj.$attrs.strokeWidth).assertEqual('20.00vp'); + expect(obj.$attrs.width).assertEqual('200.00vp'); + expect(obj.$attrs.height).assertEqual('200.00vp'); + expect(obj.$attrs.value).assertEqual('50.00'); + done(); + }); + + it('testGauge002', 0, async function (done) { + console.info('[testGauge002] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "gaugeValue": "10" + } + } + var innerEvent = { + eventId: 102, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge002] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge002] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge002] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.value).assertEqual('10.00'); + done(); + }); + + it('testGauge003', 0, async function (done) { + console.info('[testGauge003] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "strokeWidthValue": "30", + } + } + var innerEvent = { + eventId: 102, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge003] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge003] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge003] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.strokeWidth).assertEqual('30.00vp'); + done(); + }); + + it('testGauge004', 0, async function (done) { + console.info('[testGauge004] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "startAngleValue": "200" + } + } + var innerEvent = { + eventId: 102, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge004] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge004] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge004] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.startAngle).assertEqual('200.00'); + done(); + }); + + it('testGauge005', 0, async function (done) { + console.info('[testGauge005] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "endAngleValue": "200" + } + } + var innerEvent = { + eventId: 102, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge005] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge005] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge005] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.endAngle).assertEqual('200.00'); + done(); + }); + + it('testGauge006', 0, async function (done) { + console.info('[testGauge006] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "colorValues": JSON.stringify([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1]]) + } + } + var innerEvent = { + eventId: 103, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge006] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge006] change component data error: " + err.message); + } + done(); + }); + + it('testGauge007', 0, async function (done) { + console.info('[testGauge007] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "gaugeValue": "-10" + } + } + var innerEvent = { + eventId: 904, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge007] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge007] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge007] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.value).assertEqual('-10.00'); + done(); + }); + + it('testGauge008', 0, async function (done) { + console.info('[testGauge008] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "gaugeValue": 'nan' + } + } + var innerEvent = { + eventId: 904, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge008] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge008] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge008] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.value).assertEqual('nan'); + done(); + }); + + it('testGauge009', 0, async function (done) { + console.info('[testGauge009] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "strokeWidthValue": "-30", + } + } + var innerEvent = { + eventId: 904, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge009] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge009] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge009] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.strokeWidth).assertEqual('-30.00vp'); + done(); + }); + + it('testGauge010', 0, async function (done) { + console.info('[testGauge010] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "startAngleValue": "-10" + } + } + var innerEvent = { + eventId: 905, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge010] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge010] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge010] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.startAngle).assertEqual('-10.00'); + done(); + }); + + it('testGauge011', 0, async function (done) { + console.info('[testGauge011] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "startAngleValue": "nan" + } + } + var innerEvent = { + eventId: 905, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge011] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge011] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge011] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.startAngle).assertEqual('nan'); + done(); + }); + + it('testGauge012', 0, async function (done) { + console.info('[testGauge012] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "endAngleValue": "nan" + } + } + var innerEvent = { + eventId: 906, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge012] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge012] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge012] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.endAngle).assertEqual('nan'); + done(); + }); + + it('testGauge013', 0, async function (done) { + console.info('[testGauge013] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "endAngleValue": "-10" + } + } + var innerEvent = { + eventId: 906, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge013] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge013] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge013] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.endAngle).assertEqual('-10.00'); + done(); + }); + + it('testGauge014', 0, async function (done) { + console.info('[testGauge014] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "strokeWidthValue": "121111111" + } + } + var innerEvent = { + eventId: 905, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGauge014] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGauge014] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('gauge'); + let objNew = JSON.parse(strJsonNew); + console.info("[testGauge014] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.strokeWidth).assertEqual('121111111.00vp'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GlobalJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GlobalJsunit.test.ets index a8f05159ca11afca0377401467a61f18e945b146..d9c6df51704b14369701a00662d6bcc5cd2c65e6 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GlobalJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GlobalJsunit.test.ets @@ -15,7 +15,7 @@ */ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import router from '@system.router'; -import Utils from './Utils'; +import Utils from './Utils.ets'; export default function globalJsunit() { describe('globalJsunit', function () { @@ -50,7 +50,7 @@ export default function globalJsunit() { * @tc.desc Test setTimeout */ it('ACE_global_setTimeout', 0, function (done) { - let caseName:string = "ACE_global_setTimeout" + let caseName: string = "ACE_global_setTimeout" console.info(`${caseName} START`); setTimeout(() => { expect(true).assertTrue(); @@ -65,9 +65,9 @@ export default function globalJsunit() { * @tc.desc Test canIUse */ it('ACE_global_canIUse', 0, function (done) { - let caseName:string = "ACE_global_canIUse" + let caseName: string = "ACE_global_canIUse" console.info(`${caseName} START`); - let syscapName:string = ""; + let syscapName: string = ""; var result = canIUse(syscapName); expect(result === false).assertTrue(); console.info(`${caseName} END`); @@ -80,11 +80,12 @@ export default function globalJsunit() { * @tc.desc Test getApp */ it('ACE_global_getApp', 0, function (done) { - let caseName:string = "ACE_global_getApp" + let caseName: string = "ACE_global_getApp" console.info(`${caseName} START`); - try{ + try { var info = getApp(); - }catch(err){} + } catch (err) { + } console.info(`${caseName} END`); done(); }); @@ -95,11 +96,12 @@ export default function globalJsunit() { * @tc.desc Test createLocalParticleAbility */ it('ACE_global_createLocalParticleAbility', 0, function (done) { - let caseName:string = "ACE_global_createLocalParticleAbility" + let caseName: string = "ACE_global_createLocalParticleAbility" console.info(`${caseName} START`); - try{ + try { var info = createLocalParticleAbility(100); - }catch(err){} + } catch (err) { + } console.info(`${caseName} END`); done(); }); @@ -166,6 +168,5 @@ export default function globalJsunit() { }); - }) } diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets index ec9448775728240b1b5c00d7ffba0b96030a3545..42f617cbf363ece0dc87cb2bc343676610c31f9a 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridContainerJsunit.test.ets @@ -1,91 +1,91 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function girdContainerJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("girdContainer beforeEach start"); - let options = { - uri: 'pages/gridContainer', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get girdContainer state pages:" + JSON.stringify(pages)); - if (!("gridContainer" == pages.name)) { - console.info("get girdContainer state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push girdContainer page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push girdContainer page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("girdContainer after each called"); - }); - - it('testGirdContainer01', 0, async function (done) { - console.info('[testGirdContainer01] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('gridContainer'); - let obj = JSON.parse(strJson); - console.info("[testGirdContainer01] obj is: " + JSON.stringify(obj)); - expect(obj.$type).assertEqual('GridContainer'); - expect(obj.$attrs.constructor.columns).assertEqual('12'); - expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.XS'); - expect(obj.$attrs.constructor.gutter).assertEqual('10.00vp'); - expect(obj.$attrs.constructor.margin).assertEqual('20.00vp'); - console.info('testGirdContainer01 END'); - done(); - }); - - - it('testGirdContainer02', 0, async function (done) { - console.info('[testEllipse02] START'); - try { - var eventData = { - data: { - "sizeType": 'SM' - } - } - var innerEvent = { - eventId: 109, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGirdContainer02] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testGirdContainer02] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('gridContainer'); - let obj = JSON.parse(strJson); - console.info("[testGirdContainer02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.SM'); - console.info('testGirdContainer02 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function girdContainerJsunit() { + describe('girdContainerTest', function () { + beforeEach(async function (done) { + console.info("girdContainer beforeEach start"); + let options = { + uri: 'pages/gridContainer', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get girdContainer state pages:" + JSON.stringify(pages)); + if (!("gridContainer" == pages.name)) { + console.info("get girdContainer state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push girdContainer page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push girdContainer page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("girdContainer after each called"); + }); + + it('testGirdContainer01', 0, async function (done) { + console.info('[testGirdContainer01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('gridContainer'); + let obj = JSON.parse(strJson); + console.info("[testGirdContainer01] obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('GridContainer'); + expect(obj.$attrs.constructor.columns).assertEqual('12'); + expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.XS'); + expect(obj.$attrs.constructor.gutter).assertEqual('10.00vp'); + expect(obj.$attrs.constructor.margin).assertEqual('20.00vp'); + console.info('testGirdContainer01 END'); + done(); + }); + + + it('testGirdContainer02', 0, async function (done) { + console.info('[testEllipse02] START'); + try { + var eventData = { + data: { + "sizeType": 'SM' + } + } + var innerEvent = { + eventId: 109, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGirdContainer02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testGirdContainer02] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('gridContainer'); + let obj = JSON.parse(strJson); + console.info("[testGirdContainer02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.SM'); + console.info('testGirdContainer02 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridSettingsJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridSettingsJsunit.test.ets index 314be977f20e3edebb9f1bff3f863a1a6c48c3c3..db5b9381356cb706d61716a2e19ee41cbaf3f978 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridSettingsJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/GridSettingsJsunit.test.ets @@ -1,168 +1,411 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils.ets'; - -export default function gridSettingsJsunit() { - describe('gridSettingsTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/gridSettings', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get gridSettings state pages:" + JSON.stringify(pages)); - if (!("gridSettings" == pages.name)) { - console.info("get gridSettings state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push gridSettings page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push gridSettings page error:" + err); - } - done(); - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("gridSettings after each called"); - }); - - it('testGridSettings001', 0, async function (done) { - console.info('[testGridSettings001] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('gridRow'); - console.info("[testGridSettings001] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testGridSettings001] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); - expect(obj.$attrs.useSizeType.sm.span).assertEqual(2); - expect(obj.$attrs.useSizeType.sm.offset).assertEqual(1); - console.info('[testGridSettings001] END'); - done(); - }); - - it('testGridSettings002', 0, async function (done) { - console.info('[testGridSettings002] START'); - try { - let eventData = { - data: { - "span": 1, - "offset": 2 - } - } - let indexEvent = { - eventId: 9, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGridSettings002] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testGridSettings002] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('gridRow'); - console.info("[testGridSettings002] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testGridSettings002] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); - expect(obj.$attrs.useSizeType.sm.span).assertEqual(1); - expect(obj.$attrs.useSizeType.sm.offset).assertEqual(2); - console.info('[testGridSettings002] END'); - done(); - }); - - it('testGridSettings003', 0, async function (done) { - console.info('[testGridSettings003] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('gridOffset'); - console.info("[testGridSettings003] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testGridSettings003] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); - expect(obj.$attrs.gridOffset).assertEqual(0); - console.info('[testGridSettings003] END'); - done(); - }); - - it('testGridSettings004', 0, async function (done) { - console.info('[testGridSettings004] START'); - try { - let eventData = { - data: { - "gridOffset": 1 - } - } - let indexEvent = { - eventId: 10, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGridSettings004] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testGridSettings004] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('gridOffset'); - console.info("[testGridSettings004] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testGridSettings004] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); - expect(obj.$attrs.gridOffset).assertEqual(1); - console.info('[testGridSettings004] END'); - done(); - }); - - it('testGridSettings005', 0, async function (done) { - console.info('[testGridSettings005] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('gridSpan'); - console.info("[testGridSettings005] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testGridSettings005] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); - expect(obj.$attrs.gridSpan).assertEqual(1); - console.info('[testGridSettings005] END'); - done(); - }); - - it('testGridSettings006', 0, async function (done) { - console.info('[testGridSettings006] START'); - try { - let eventData = { - data: { - "gridSpan": 2 - } - } - let indexEvent = { - eventId: 11, - priority: events_emitter.EventPriority.LOW - } - console.info("[testGridSettings006] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testGridSettings006] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('gridSpan'); - console.info("[testGridSettings006] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testGridSettings006] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); - expect(obj.$attrs.gridSpan).assertEqual(2); - console.info('[testGridSettings006] END'); - done(); - }); - }); +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function gridSettingsJsunit() { + describe('gridSettingsTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/gridSettings', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get gridSettings state pages:" + JSON.stringify(pages)); + if (!("textStyle" == pages.name)) { + console.info("get gridSettings state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push gridSettings page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push gridSettings page error:" + err); + } + done(); + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("gridSettings after each called"); + }); + + it('testGridSettings000', 0, async function (done) { + console.info('[testGridSettings000] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('gridContainer'); + console.info("[testGridSettings000] component strJson:" + strJson); + expect(true).assertEqual(true); + done(); + }); + + it('testGridSettings001', 0, async function (done) { + console.info('[testGridSettings001] START'); + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridRow'); + console.info("[testGridSettings001] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings001] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); + expect(obj.$attrs.useSizeType.sm.span).assertEqual(2); + expect(obj.$attrs.useSizeType.sm.offset).assertEqual(1); + done(); + }); + + it('testGridSettings002', 0, async function (done) { + console.info('[testGridSettings002] START'); + try { + let eventData = { + data: { + "span": 1, + "offset": 2 + } + } + let indexEvent = { + eventId: 9, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings002] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings002] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridRow'); + console.info("[testGridSettings002] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings002] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); + expect(obj.$attrs.useSizeType.sm.span).assertEqual(1); + expect(obj.$attrs.useSizeType.sm.offset).assertEqual(2); + done(); + }); + + it('testGridSettings003', 0, async function (done) { + console.info('[testGridSettings003] START'); + try { + let eventData = { + data: { + "span": 0x80000000, + "offset": 0x80000000 + } + } + let indexEvent = { + eventId: 9, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings003] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings003] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridRow'); + console.info("[testGridSettings003] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings003] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); + expect(obj.$attrs.useSizeType.sm.span).assertEqual(-2147483648); + expect(obj.$attrs.useSizeType.sm.offset).assertEqual(-2147483648); + done(); + }); + + it('testGridSettings004', 0, async function (done) { + console.info('[testGridSettings004] START'); + try { + let eventData = { + data: { + "span": 0x7FFFFFFF, + "offset": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 9, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings004] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings004] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridRow'); + console.info("[testGridSettings004] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings004] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); + expect(obj.$attrs.useSizeType.sm.span).assertEqual(0x7FFFFFFF); + expect(obj.$attrs.useSizeType.sm.offset).assertEqual(0x7FFFFFFF); + done(); + }); + + it('testGridSettings005', 0, async function (done) { + console.info('[testGridSettings005] START'); + try { + let eventData = { + data: { + "span": 'error', + "offset": 'error' + } + } + let indexEvent = { + eventId: 9, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings005] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings005] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridRow'); + console.info("[testGridSettings005] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings005] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); + expect(obj.$attrs.useSizeType.sm.span).assertEqual(0); + expect(obj.$attrs.useSizeType.sm.offset).assertEqual(0); + done(); + }); + + it('testGridSettings006', 0, async function (done) { + console.info('[testGridSettings006] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('gridOffset'); + console.info("[testGridSettings006] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings006] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); + expect(obj.$attrs.gridOffset).assertEqual(0); + done(); + }); + + it('testGridSettings007', 0, async function (done) { + console.info('[testGridSettings007] START'); + try { + let eventData = { + data: { + "gridOffset": 1 + } + } + let indexEvent = { + eventId: 10, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings007] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings007] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridOffset'); + console.info("[testGridSettings007] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings007] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); + expect(obj.$attrs.gridOffset).assertEqual(1); + done(); + }); + + it('testGridSettings008', 0, async function (done) { + console.info('[testGridSettings008] START'); + try { + let eventData = { + data: { + "gridOffset": 0x80000000 + } + } + let indexEvent = { + eventId: 10, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings008] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings008] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridOffset'); + console.info("[testGridSettings008] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings008] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); + expect(obj.$attrs.gridOffset).assertEqual(-2147483648); + done(); + }); + + it('testGridSettings009', 0, async function (done) { + console.info('[testGridSettings009] START'); + try { + let eventData = { + data: { + "gridOffset": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 10, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings009] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings009] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridOffset'); + console.info("[testGridSettings009] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings009] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); + expect(obj.$attrs.gridOffset).assertEqual(0x7FFFFFFF); + done(); + }); + + it('testGridSettings010', 0, async function (done) { + console.info('[testGridSettings010] START'); + try { + let eventData = { + data: { + "gridOffset": 'error' + } + } + let indexEvent = { + eventId: 10, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings010] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings010] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridOffset'); + console.info("[testGridSettings010] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings010] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); + expect(obj.$attrs.gridOffset).assertEqual(2147483647); + done(); + }); + + it('testGridSettings011', 0, async function (done) { + console.info('[testGridSettings011] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('gridSpan'); + console.info("[testGridSettings011] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings011] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); + expect(obj.$attrs.gridSpan).assertEqual(1); + done(); + }); + + it('testGridSettings012', 0, async function (done) { + console.info('[testGridSettings012] START'); + try { + let eventData = { + data: { + "gridSpan": 2 + } + } + let indexEvent = { + eventId: 11, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings012] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings012] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridSpan'); + console.info("[testGridSettings012] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings012] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); + expect(obj.$attrs.gridSpan).assertEqual(2); + done(); + }); + + it('testGridSettings013', 0, async function (done) { + console.info('[testGridSettings013] START'); + try { + let eventData = { + data: { + "gridSpan": 0x80000000 + } + } + let indexEvent = { + eventId: 11, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings013] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings013] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridSpan'); + console.info("[testGridSettings013] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings013] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); + expect(obj.$attrs.gridSpan).assertEqual(-2147483648); + done(); + }); + + it('testGridSettings014', 0, async function (done) { + console.info('[testGridSettings014] START'); + try { + let eventData = { + data: { + "gridSpan": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 11, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings014] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings014] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridSpan'); + console.info("[testGridSettings014] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings014] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); + expect(obj.$attrs.gridSpan).assertEqual(0x7FFFFFFF); + done(); + }); + + it('testGridSettings015', 0, async function (done) { + console.info('[testGridSettings015] START'); + try { + let eventData = { + data: { + "gridSpan": 'error' + } + } + let indexEvent = { + eventId: 11, + priority: events_emitter.EventPriority.LOW + } + console.info("[testGridSettings015] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testGridSettings015] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('gridSpan'); + console.info("[testGridSettings015] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testGridSettings015] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); + expect(obj.$attrs.gridSpan).assertEqual(2147483647); + done(); + }); + }); } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ImageEffectsJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ImageEffectsJsunit.test.ets index db3a1522c61b2773683c68af96cc81a3ba8d197a..a623fc8f88f6b143ffa700d9c91a61192f5960f3 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ImageEffectsJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ImageEffectsJsunit.test.ets @@ -1,322 +1,882 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function imageEffectsJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/imageEffects', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get imageEffects state success " + JSON.stringify(pages)); - if (!("imageEffects" == pages.name)) { - console.info("get imageEffects state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push imageEffects page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push imageEffects page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(2000); - console.info("imageEffects after each called"); - }); - - it('testImageEffects001', 0, async function (done) { - console.info('[testSizeSetting001] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow'); - console.info("[testImageEffects001] component strJson:" + strJson); - let obj = JSON.parse(strJson); - expect(obj.$type).assertEqual('Text'); - expect(obj.$attrs.blur).assertEqual(100); - done(); - }); - - it('testImageEffects002', 0, async function (done) { - console.info('[testImageEffects002] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "blurValue": "10" - } - } - var innerEvent = { - eventId: 12, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects002] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects002] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects002] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.blur).assertEqual(10); - done(); - }); - - it('testImageEffects003', 0, async function (done) { - console.info('[testImageEffects003] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow3'); - let obj = JSON.parse(strJson); - console.info("[testImageEffects003] component strJson:" + obj.$attrs.shadow); - expect(obj.$attrs.shadow.radius).assertEqual("10.000000"); - expect(obj.$attrs.shadow.color).assertEqual("#FF808080"); - expect(obj.$attrs.shadow.offsetX).assertEqual("5.000000"); - expect(obj.$attrs.shadow.offsetY).assertEqual("5.000000"); - done(); - }); - - it('testImageEffects004', 0, async function (done) { - console.info('[testImageEffects004] START'); - await Utils.sleep(1000); - let shadowValue = { radius: 20, color: Color.Gray, offsetX: 10, offsetY: 10 }; - try { - var eventData = { - data: { - "shadowValue": JSON.stringify(shadowValue) - } - } - var innerEvent = { - eventId: 13, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects004] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects004] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow3'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects004] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.shadow.radius).assertEqual("20.000000"); - expect(objNew.$attrs.shadow.color).assertEqual("#FF808080"); - expect(objNew.$attrs.shadow.offsetX).assertEqual("10.000000"); - expect(objNew.$attrs.shadow.offsetY).assertEqual("10.000000"); - done(); - }); - - it('testImageEffects007', 0, async function (done) { - console.info('[testSizeSetting007] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow5'); - console.info("[testImageEffects007] component strJson:" + strJson); - let obj = JSON.parse(strJson); - expect(obj.$attrs.brightness).assertEqual(20); - done(); - }); - - it('testImageEffects008', 0, async function (done) { - console.info('[testImageEffects002] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "brightnessValue": "15" - } - } - var innerEvent = { - eventId: 15, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects008] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects008] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow5'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects008] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.brightness).assertEqual(15); - done(); - }); - - it('testImageEffects009', 0, async function (done) { - console.info('[testImageEffects009] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow6'); - console.info("[testImageEffects009] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testImageEffects009] component strJson:" + obj.$attrs.saturate); - expect(obj.$attrs.saturate).assertEqual(50); - done(); - }); - - it('testImageEffects010', 0, async function (done) { - console.info('[testImageEffects010] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "saturateValue": "40" - } - } - var innerEvent = { - eventId: 16, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects010] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects010] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow6'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects010] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.saturate).assertEqual(40); - done(); - }); - - it('testImageEffects011', 0, async function (done) { - console.info('[testSizeSetting011] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow7'); - console.info("[testImageEffects011] component strJson:" + strJson); - let obj = JSON.parse(strJson); - expect(obj.$attrs.contrast).assertEqual(20); - done(); - }); - - it('testImageEffects012', 0, async function (done) { - console.info('[testImageEffects012] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "contrastValue": "10" - } - } - var innerEvent = { - eventId: 17, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects012] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects012] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow7'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects012] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.contrast).assertEqual(10); - done(); - }); - - it('testImageEffects013', 0, async function (done) { - console.info('[testSizeSetting0013] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow8'); - console.info("[testImageEffects013] component strJson:" + strJson); - let obj = JSON.parse(strJson); - expect(obj.$attrs.invert).assertEqual(10); - done(); - }); - - it('testImageEffects014', 0, async function (done) { - console.info('[testImageEffects014] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "invertValue": "20" - } - } - var innerEvent = { - eventId: 18, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects014] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects014] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow8'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects014] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.invert).assertEqual(20); - done(); - }); - - it('testImageEffects015', 0, async function (done) { - console.info('[testImageEffects015] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('centerRow9'); - console.info("[testImageEffects015] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testImageEffects015] component strJson:" + obj.$attrs.shadow); - expect(obj.$attrs.hueRotate).assertEqual(10); - done(); - }); - - it('testImageEffects016', 0, async function (done) { - console.info('[testImageEffects016] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "hueRotateValue": "20" - } - } - var innerEvent = { - eventId: 19, - priority: events_emitter.EventPriority.LOW - } - console.info("[testImageEffects016] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testImageEffects016] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJsonNew = getInspectorByKey('centerRow9'); - let objNew = JSON.parse(strJsonNew); - console.info("[testImageEffects016] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.hueRotate).assertEqual(20); - done(); - }); - }) -} - - - - - - - - - - - - +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function imageEffectsJsunit() { + describe('imageEffectsTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/imageEffects', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get imageEffects state success " + JSON.stringify(pages)); + if (!("imageEffects" == pages.name)) { + console.info("get imageEffects state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push imageEffects page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push imageEffects page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info("imageEffects after each called"); + }); + + it('testImageEffects001', 0, async function (done) { + console.info('[testSizeSetting001] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow'); + console.info("[testImageEffects001] component strJson:" + strJson); + let obj = JSON.parse(strJson); + expect(obj.$type).assertEqual('Text'); + expect(obj.$attrs.blur).assertEqual(100); + done(); + }); + + it('testImageEffects002', 0, async function (done) { + console.info('[testImageEffects002] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "blurValue": "10" + } + } + var innerEvent = { + eventId: 12, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects002] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects002] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects002] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.blur).assertEqual(10); + done(); + }); + + it('testImageEffects003', 0, async function (done) { + console.info('[testImageEffects003] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "blurValue": 0x80000000 + } + } + var innerEvent = { + eventId: 12, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects003] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects003] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects003] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.blur).assertEqual(-2147483648); + done(); + }); + + it('testImageEffects004', 0, async function (done) { + console.info('[testImageEffects004] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "blurValue": 0x7FFFFFFF + } + } + var innerEvent = { + eventId: 12, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects004] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects004] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects004] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.blur).assertEqual(2147483648); + done(); + }); + + it('testImageEffects005', 0, async function (done) { + console.info('[testImageEffects005] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "blurValue": 'error' + } + } + var innerEvent = { + eventId: 12, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects005] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects005] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects005] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.blur).assertEqual(0); + done(); + }); + + it('testImageEffects006', 0, async function (done) { + console.info('[testImageEffects006] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow3'); + let obj = JSON.parse(strJson); + console.info("[testImageEffects006] component strJson:" + obj.$attrs.shadow); + expect(obj.$attrs.shadow.radius).assertEqual("10.000000"); + expect(obj.$attrs.shadow.color).assertEqual("#FF808080"); + expect(obj.$attrs.shadow.offsetX).assertEqual("5.000000"); + expect(obj.$attrs.shadow.offsetY).assertEqual("5.000000"); + done(); + }); + + it('testImageEffects007', 0, async function (done) { + console.info('[testImageEffects007] START'); + await Utils.sleep(1000); + let shadowValue = { + radius: 20, color: Color.Gray, offsetX: 10, offsetY: 10 + }; + try { + var eventData = { + data: { + "shadowValue": JSON.stringify(shadowValue) + } + } + var innerEvent = { + eventId: 13, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects007] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects007] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow3'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects007] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("20.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#FF808080"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("10.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("10.000000"); + done(); + }); + + it('testImageEffects008', 0, async function (done) { + console.info('[testImageEffects008] START'); + await Utils.sleep(1000); + let shadowValue = { radius: 0x80000000, color: 0x80000000, offsetX: 0x80000000, offsetY: 0x80000000 }; + try { + var eventData = { + data: { + "shadowValue": JSON.stringify(shadowValue) + } + } + var innerEvent = { + eventId: 13, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects008] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects008] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow3'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects008] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("2147483648.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#80000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("2147483648.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("2147483648.000000"); + done(); + }); + + it('testImageEffects009', 0, async function (done) { + console.info('[testImageEffects009] START'); + await Utils.sleep(1000); + let shadowValue = { radius: 0x7FFFFFFF, color: 0x7FFFFFFF, offsetX: 0x7FFFFFFF, offsetY: 0x7FFFFFFF }; + try { + var eventData = { + data: { + "shadowValue": JSON.stringify(shadowValue) + } + } + var innerEvent = { + eventId: 13, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects009] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects009] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow3'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects009] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("2147483647.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#7FFFFFFF"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("2147483647.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("2147483647.000000"); + done(); + }); + + it('testImageEffects010', 0, async function (done) { + console.info('[testImageEffects010] START'); + await Utils.sleep(1000); + let shadowValue = { radius: 'error', color: 'error', offsetX: 'error', offsetY: 'error' }; + try { + var eventData = { + data: { + "shadowValue": JSON.stringify(shadowValue) + } + } + var innerEvent = { + eventId: 13, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects010] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects010] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow3'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects010] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.shadow.radius).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.color).assertEqual("#FF000000"); + expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000"); + expect(objNew.$attrs.shadow.offsetY).assertEqual("0.000000"); + done(); + }); + + it('testImageEffects011', 0, async function (done) { + console.info('[testSizeSetting011] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow5'); + console.info("[testImageEffects011] component strJson:" + strJson); + let obj = JSON.parse(strJson); + expect(obj.$attrs.brightness).assertEqual(20); + done(); + }); + + it('testImageEffects012', 0, async function (done) { + console.info('[testImageEffects012] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "brightnessValue": "15" + } + } + var innerEvent = { + eventId: 15, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects012] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects012] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow5'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects012] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.brightness).assertEqual(15); + done(); + }); + + it('testImageEffects013', 0, async function (done) { + console.info('[testImageEffects012] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "brightnessValue": 0x80000000 + } + } + var innerEvent = { + eventId: 15, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects013] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects013] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow5'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects013] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.brightness).assertEqual(-2147483648); + done(); + }); + + it('testImageEffects014', 0, async function (done) { + console.info('[testImageEffects014] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "brightnessValue": 0x7FFFFFFF + } + } + var innerEvent = { + eventId: 15, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects014] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects014] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow5'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects014] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.brightness).assertEqual(2147483647); + done(); + }); + + it('testImageEffects015', 0, async function (done) { + console.info('[testImageEffects015] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "brightnessValue": 'error' + } + } + var innerEvent = { + eventId: 15, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects015] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects015] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow5'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects015] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.brightness).assertEqual(0.0000019999999949504854); + done(); + }); + + it('testImageEffects016', 0, async function (done) { + console.info('[testImageEffects016] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow6'); + console.info("[testImageEffects016] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testImageEffects016] component strJson:" + obj.$attrs.saturate); + expect(obj.$attrs.saturate).assertEqual(50); + done(); + }); + + it('testImageEffects017', 0, async function (done) { + console.info('[testImageEffects017] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "saturateValue": "40" + } + } + var innerEvent = { + eventId: 16, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects017] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects017] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow6'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects017] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.saturate).assertEqual(40); + done(); + }); + + it('testImageEffects018', 0, async function (done) { + console.info('[testImageEffects018] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "saturateValue": 0x80000000 + } + } + var innerEvent = { + eventId: 16, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects018] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects018] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow6'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects018] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.saturate).assertEqual(0); + done(); + }); + + it('testImageEffects019', 0, async function (done) { + console.info('[testImageEffects019] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "saturateValue": 0x7FFFFFFF + } + } + var innerEvent = { + eventId: 16, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects019] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects019] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow6'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects019] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.saturate).assertEqual(2147483647); + done(); + }); + + it('testImageEffects020', 0, async function (done) { + console.info('[testImageEffects020] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "saturateValue": 'error' + } + } + var innerEvent = { + eventId: 16, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects020] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects020] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow6'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects020] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.saturate).assertEqual(0.0000019999999949504854); + done(); + }); + + it('testImageEffects021', 0, async function (done) { + console.info('[testSizeSetting021] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow7'); + console.info("[testImageEffects021] component strJson:" + strJson); + let obj = JSON.parse(strJson); + expect(obj.$attrs.contrast).assertEqual(20); + done(); + }); + + it('testImageEffects022', 0, async function (done) { + console.info('[testImageEffects022] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "contrastValue": "10" + } + } + var innerEvent = { + eventId: 17, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects022] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects022] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow7'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects022] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.contrast).assertEqual(10); + done(); + }); + + it('testImageEffects023', 0, async function (done) { + console.info('[testImageEffects023] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "contrastValue": 0x80000000 + } + } + var innerEvent = { + eventId: 17, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects023] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects023] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow7'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects023] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.contrast).assertEqual(0); + done(); + }); + + it('testImageEffects024', 0, async function (done) { + console.info('[testImageEffects024] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "contrastValue": 0x7FFFFFFF + } + } + var innerEvent = { + eventId: 17, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects024] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects024] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow7'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects024] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.contrast).assertEqual(2147483647); + done(); + }); + + it('testImageEffects025', 0, async function (done) { + console.info('[testImageEffects025] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "contrastValue": 'error' + } + } + var innerEvent = { + eventId: 17, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects025] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects025] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow7'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects025] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.contrast).assertEqual(0.0000019999999949504854); + done(); + }); + + it('testImageEffects026', 0, async function (done) { + console.info('[testSizeSetting0026] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow8'); + console.info("[testImageEffects026] component strJson:" + strJson); + let obj = JSON.parse(strJson); + expect(obj.$attrs.invert).assertEqual(10); + done(); + }); + + it('testImageEffects027', 0, async function (done) { + console.info('[testImageEffects027] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "invertValue": "20" + } + } + var innerEvent = { + eventId: 18, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects027] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects027] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow8'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects027] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.invert).assertEqual(20); + done(); + }); + + it('testImageEffects028', 0, async function (done) { + console.info('[testImageEffects028] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "invertValue": 0x80000000 + } + } + var innerEvent = { + eventId: 18, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects028] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects028] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow8'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects028] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.invert).assertEqual(0); + done(); + }); + + it('testImageEffects029', 0, async function (done) { + console.info('[testImageEffects029] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "invertValue": 0x7FFFFFFF + } + } + var innerEvent = { + eventId: 18, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects029] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects029] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow8'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects029] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.invert).assertEqual(2147483647); + done(); + }); + + it('testImageEffects030', 0, async function (done) { + console.info('[testImageEffects030] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "invertValue": 'error' + } + } + var innerEvent = { + eventId: 18, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects030] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects030] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow8'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects030] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.invert).assertEqual(0); + done(); + }); + + it('testImageEffects031', 0, async function (done) { + console.info('[testImageEffects031] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('centerRow9'); + console.info("[testImageEffects031] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testImageEffects031] component strJson:" + obj.$attrs.shadow); + expect(obj.$attrs.hueRotate).assertEqual(10); + done(); + }); + + it('testImageEffects032', 0, async function (done) { + console.info('[testImageEffects032] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "hueRotateValue": "20" + } + } + var innerEvent = { + eventId: 19, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects032] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects032] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow9'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects032] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.hueRotate).assertEqual(20); + done(); + }); + + it('testImageEffects033', 0, async function (done) { + console.info('[testImageEffects033] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "hueRotateValue": 0x80000000 + } + } + var innerEvent = { + eventId: 19, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects033] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects033] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow9'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects033] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.hueRotate).assertEqual(-2147483648); + done(); + }); + + it('testImageEffects034', 0, async function (done) { + console.info('[testImageEffects034] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "hueRotateValue": 0x7FFFFFFF + } + } + var innerEvent = { + eventId: 19, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects034] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects034] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow9'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects034] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.hueRotate).assertEqual(2147483648); + done(); + }); + + it('testImageEffects035', 0, async function (done) { + console.info('[testImageEffects035] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "hueRotateValue": 'error' + } + } + var innerEvent = { + eventId: 19, + priority: events_emitter.EventPriority.LOW + } + console.info("[testImageEffects035] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testImageEffects035] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('centerRow9'); + let objNew = JSON.parse(strJsonNew); + console.info("[testImageEffects035] component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.hueRotate).assertEqual(0); + done(); + }); + }) +} + + + + + + + + + + + + diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LayoutConstraintsJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LayoutConstraintsJsunit.test.ets index aa98f601808266a86edc7df916f882ad1c3ff031..b18034b8b02afdb76c2f22132045da4dfe8ea549 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LayoutConstraintsJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/LayoutConstraintsJsunit.test.ets @@ -1,123 +1,175 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils.ets'; - -export default function layoutConstraintsJsunit() { - describe('layoutConstraintsTest', function () { - beforeEach(async function (done) { - console.info("layoutConstraints beforeEach start"); - let options = { - uri: 'pages/layoutConstraints', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get layoutConstraints state pages:" + JSON.stringify(pages)); - if (!("layoutConstraints" == pages.name)) { - console.info("get layoutConstraints state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push layoutConstraints page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push layoutConstraints page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("layoutConstraints after each called"); - }); - - it('testLayoutConstraints001', 0, async function (done) { - console.info('[testLayoutConstraints001] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('aspectRatio'); - console.info("[testLayoutConstraints001] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testLayoutConstraints001] aspectRatio: " + obj.$attrs.aspectRatio); - expect(obj.$attrs.aspectRatio).assertEqual(1.5); - done(); - }); - - it('testLayoutConstraints002', 0, async function (done) { - console.info('[testLayoutConstraints002] START'); - try { - let eventData = { - data: { - "aspectRatio": 2 - } - } - let indexEvent = { - eventId: 20, - priority: events_emitter.EventPriority.LOW - } - console.info("[testLayoutConstraints002] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testLayoutConstraints002] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('aspectRatio'); - console.info("[testLayoutConstraints002] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testLayoutConstraints002] aspectRatio: " + obj.$attrs.aspectRatio); - expect(obj.$attrs.aspectRatio).assertEqual(2); - done(); - }); - - it('testLayoutConstraints003', 0, async function (done) { - console.info('[testLayoutConstraints003] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('displayPriority'); - console.info("[testLayoutConstraints003] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testLayoutConstraints003] displayPriority: " + obj.$attrs.displayPriority); - expect(obj.$attrs.displayPriority).assertEqual(1); - done(); - }); - - it('testLayoutConstraints004', 0, async function (done) { - console.info('[testLayoutConstraints004] START'); - try { - let eventData = { - data: { - "displayPriority": 5 - } - } - let indexEvent = { - eventId: 21, - priority: events_emitter.EventPriority.LOW - } - console.info("[testLayoutConstraints004] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testLayoutConstraints004] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('displayPriority'); - console.info("[testLayoutConstraints004] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testLayoutConstraints004] displayPriority: " + obj.$attrs.displayPriority); - expect(obj.$attrs.displayPriority).assertEqual(5); - done(); - }); - }); +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function layoutConstraintsJsunit() { + describe('layoutConstraintsTest', function () { + beforeEach(async function (done) { + console.info("layoutConstraints beforeEach start"); + let options = { + uri: 'pages/layoutConstraints', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get layoutConstraints state pages:" + JSON.stringify(pages)); + if (!("layoutConstraints" == pages.name)) { + console.info("get layoutConstraints state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push layoutConstraints page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push layoutConstraints page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("layoutConstraints after each called"); + }); + + it('testLayoutConstraints001', 0, async function (done) { + console.info('[testLayoutConstraints001] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('aspectRatio'); + console.info("[testLayoutConstraints001] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testLayoutConstraints001] aspectRatio: " + obj.$attrs.aspectRatio); + expect(obj.$attrs.aspectRatio).assertEqual(1.5); + done(); + }); + + it('testLayoutConstraints002', 0, async function (done) { + console.info('[testLayoutConstraints002] START'); + try { + let eventData = { + data: { + "aspectRatio": 2 + } + } + let indexEvent = { + eventId: 20, + priority: events_emitter.EventPriority.LOW + } + console.info("[testLayoutConstraints002] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testLayoutConstraints002] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('aspectRatio'); + console.info("[testLayoutConstraints002] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testLayoutConstraints002] aspectRatio: " + obj.$attrs.aspectRatio); + expect(obj.$attrs.aspectRatio).assertEqual(2); + done(); + }); + + it('testLayoutConstraints003', 0, async function (done) { + console.info('[testLayoutConstraints003] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('displayPriority'); + console.info("[testLayoutConstraints003] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testLayoutConstraints003] displayPriority: " + obj.$attrs.displayPriority); + expect(obj.$attrs.displayPriority).assertEqual(1); + done(); + }); + + it('testLayoutConstraints004', 0, async function (done) { + console.info('[testLayoutConstraints004] START'); + try { + let eventData = { + data: { + "displayPriority": 5 + } + } + let indexEvent = { + eventId: 21, + priority: events_emitter.EventPriority.LOW + } + console.info("[testLayoutConstraints004] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testLayoutConstraints004] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('displayPriority'); + console.info("[testLayoutConstraints004] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testLayoutConstraints004] displayPriority: " + obj.$attrs.displayPriority); + expect(obj.$attrs.displayPriority).assertEqual(5); + done(); + }); + + it('testLayoutConstraints005', 0, async function (done) { + console.info('[testLayoutConstraints005] START'); + try { + let eventData = { + data: { + "aspectRatio": -4 + } + } + let indexEvent = { + eventId: 1112, + priority: events_emitter.EventPriority.LOW + } + console.info("[testLayoutConstraints005] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testLayoutConstraints005] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('aspectRatio'); + console.info("[testLayoutConstraints005] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testLayoutConstraints005] aspectRatio: " + obj.$attrs.aspectRatio); + expect(obj.$attrs.aspectRatio).assertEqual(-4); + done(); + }); + + it('testLayoutConstraints006', 0, async function (done) { + console.info('[testLayoutConstraints006] START'); + try { + let eventData = { + data: { + "aspectRatio": 9997077 + } + } + let indexEvent = { + eventId: 1112, + priority: events_emitter.EventPriority.LOW + } + console.info("[testLayoutConstraints006] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testLayoutConstraints006] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('aspectRatio'); + console.info("[testLayoutConstraints006] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testLayoutConstraints006] aspectRatio: " + obj.$attrs.aspectRatio); + expect(obj.$attrs.aspectRatio).assertEqual(9997077); + done(); + }); + }); } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets index 284be6bd84740912338648c93e27810e5dedb95f..81edb16dd2e9a81b2f6434d1679e0db843b27ea2 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/List.test.ets @@ -1,60 +1,62 @@ -/** - * 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 appearJsunit from './AppearJsunit.test.ets'; -import areaChangeJsunit from './AreaChangeJsunit.test.ets'; -import ellipseJsunit from './EllipseJsunit.test.ets'; -import enableJsunit from './EnableJsunit.test.ets'; -import flexJsunit from './FlexJsunit.test.ets'; -import gaugeJsunit from './GaugeJsunit.test.ets'; -import globalJsunit from './GlobalJsunit.test.ets'; -import girdContainerJsunit from './GridContainerJsunit.test.ets'; -import gridSettingsJsunit from './GridSettingsJsunit.test.ets'; -import imageEffectsJsunit from './ImageEffectsJsunit.test.ets'; -import layoutConstraintsJsunit from './LayoutConstraintsJsunit.test.ets'; -import listJsunit from './ListJsunit.test.ets'; -import marqueeJsunit from './MarqueeJsunit.test.ets'; -import overLayJsunit from './OverlayJsunit.test.ets'; -import stepperJsunit from './StepperJsunit.test.ets'; -import swiperJsunit from './SwiperJsunit.test.ets'; -import textStyleJsunit from './TextStyleJsunit.test.ets'; -import touchAbleJsunit from './TouchAbleJsunit.test.ets'; -import touchJsunit from './TouchJsunit.test.ets'; -import visibilityJsunit from './VisibilityJsunit.test.ets'; -import zIndexJsunit from './ZIndexJsunit.test.ets'; - -export default function testsuite() { - enableJsunit(); - appearJsunit(); - zIndexJsunit(); - ellipseJsunit(); - flexJsunit(); - gaugeJsunit(); - globalJsunit(); - visibilityJsunit(); - girdContainerJsunit(); - areaChangeJsunit(); - gridSettingsJsunit(); - imageEffectsJsunit(); - layoutConstraintsJsunit(); - listJsunit(); - marqueeJsunit(); - overLayJsunit(); - stepperJsunit(); - swiperJsunit(); - textStyleJsunit(); - touchAbleJsunit(); - touchJsunit(); +/** + * 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 appearJsunit from './AppearJsunit.test.ets'; +import areaChangeJsunit from './AreaChangeJsunit.test.ets'; +import ellipseJsunit from './EllipseJsunit.test.ets'; +import enableJsunit from './EnableJsunit.test.ets'; +import flexJsunit from './FlexJsunit.test.ets'; +import gaugeJsunit from './GaugeJsunit.test.ets'; +import globalJsunit from './GlobalJsunit.test.ets'; +import girdContainerJsunit from './GridContainerJsunit.test.ets'; +import gridSettingsJsunit from './GridSettingsJsunit.test.ets'; +import imageEffectsJsunit from './ImageEffectsJsunit.test.ets'; +import layoutConstraintsJsunit from './LayoutConstraintsJsunit.test.ets'; +import listJsunit from './ListJsunit.test.ets'; +import marqueeJsunit from './MarqueeJsunit.test.ets'; +import overLayJsunit from './OverlayJsunit.test.ets'; +import stepperJsunit from './StepperJsunit.test.ets'; +import swiperJsunit from './SwiperJsunit.test.ets'; +import textStyleJsunit from './TextStyleJsunit.test.ets'; +import touchAbleJsunit from './TouchAbleJsunit.test.ets'; +import touchJsunit from './TouchJsunit.test.ets'; +import visibilityJsunit from './VisibilityJsunit.test.ets'; +import zIndexJsunit from './ZIndexJsunit.test.ets'; +import columnJsunit from './ColumnJsunit.test.ets'; + +export default function testsuite() { + touchAbleJsunit(); + columnJsunit(); + enableJsunit(); + appearJsunit(); + zIndexJsunit(); + ellipseJsunit(); + flexJsunit(); + gaugeJsunit(); + globalJsunit(); + visibilityJsunit(); + girdContainerJsunit(); + areaChangeJsunit(); + imageEffectsJsunit(); + layoutConstraintsJsunit(); + listJsunit(); + marqueeJsunit(); + overLayJsunit(); + stepperJsunit(); + swiperJsunit(); + textStyleJsunit(); + touchJsunit(); + gridSettingsJsunit(); } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListJsunit.test.ets index 7a06b68a8036dfd951586255fcbf64eb207c02a5..796ef283045fe8077c45cb5c4350566a119cb7fa 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ListJsunit.test.ets @@ -1,275 +1,352 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function listJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("list beforeEach start"); - let options = { - uri: 'pages/list', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get list state pages:" + JSON.stringify(pages)); - if (!("list" == pages.name)) { - console.info("get list state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push list page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push list page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("list after each called"); - }); - - it('testList01', 0, async function (done) { - console.info('[testList01] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList01] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.listDirection).assertEqual('Axis.Vertical'); - expect(obj.$attrs.editMode).assertEqual('false'); - expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.None'); - expect(obj.$attrs.chainAnimation).assertEqual('false'); - expect(obj.$attrs.divider.strokeWidth).assertEqual("2.00vp"); - expect(obj.$attrs.divider.color).assertEqual("#FFFFFFFF"); - expect(obj.$attrs.divider.startMargin).assertEqual("20.00vp"); - expect(obj.$attrs.divider.endMargin).assertEqual("20.00vp"); - console.info('[testList01] END'); - done(); - }); - - it('testList02', 0, async function (done) { - console.info('[testList02] START'); - try { - var eventData = { - data: { - "listDirection": Axis.Horizontal - } - } - var innerEvent = { - eventId: 124, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList02] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList02] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.listDirection).assertEqual('Axis.Horizontal'); - console.info('testList02 END'); - done(); - }); - - it('testList03', 0, async function (done) { - console.info('[testList03] START'); - try { - var eventData = { - data: { - "editMode": true - } - } - var innerEvent = { - eventId: 124, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList03] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList03] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList03] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.editMode).assertEqual('true'); - console.info('testList03 END'); - done(); - }); - - it('testList04', 0, async function (done) { - console.info('[testList04] START'); - try { - var eventData = { - data: { - "edgeEffect": EdgeEffect.Spring - } - } - var innerEvent = { - eventId: 124, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList04] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList04] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList04] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.Spring'); - console.info('testList04 END'); - done(); - }); - - it('testList05', 0, async function (done) { - console.info('[testList05] START'); - try { - var eventData = { - data: { - "chainAnimation": true - } - } - var innerEvent = { - eventId: 124, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList05] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList05] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList05] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.chainAnimation).assertEqual('true'); - console.info('testList05 END'); - done(); - }); - - it('testList06', 0, async function (done) { - console.info('[testList06] START'); - try { - var eventData = { - data: { - "strokeWidth": "3.000000vp" - } - } - var innerEvent = { - eventId: 125, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList06] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList06] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList06] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.divider.strokeWidth).assertEqual("3.00vp"); - console.info('testList06 END'); - done(); - }); - - it('testList07', 0, async function (done) { - console.info('[testList07] START'); - try { - var eventData = { - data: { - "color": "#FF0000FF" - } - } - var innerEvent = { - eventId: 125, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList07] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList07] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList07] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.divider.color).assertEqual("#FF0000FF"); - console.info('testList07 END'); - done(); - }); - - it('testList08', 0, async function (done) { - console.info('[testList08] START'); - try { - var eventData = { - data: { - "startMargin": "30.000000vp" - } - } - var innerEvent = { - eventId: 125, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList08] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList08] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList08] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.divider.startMargin).assertEqual("30.00vp"); - console.info('testList08 END'); - done(); - }); - - it('testList09', 0, async function (done) { - console.info('[testList09] START'); - try { - var eventData = { - data: { - "endMargin": "30.000000vp" - } - } - var innerEvent = { - eventId: 125, - priority: events_emitter.EventPriority.LOW - } - console.info("[testList09] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testList09] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('list'); - let obj = JSON.parse(strJson); - console.info("[testList09] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.divider.endMargin).assertEqual("30.00vp"); - console.info('testList09 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +export default function listJsunit() { + describe('listTest', function () { + beforeEach(async function (done) { + console.info("list beforeEach start"); + let options = { + uri: 'pages/list', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get list state pages:" + JSON.stringify(pages)); + if (!("list" == pages.name)) { + console.info("get list state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push list page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push list page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("list after each called"); + }); + + it('testList01', 0, async function (done) { + console.info('[testList01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList01] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.listDirection).assertEqual('Axis.Vertical'); + expect(obj.$attrs.editMode).assertEqual('false'); + expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.None'); + expect(obj.$attrs.chainAnimation).assertEqual('false'); + expect(obj.$attrs.divider.strokeWidth).assertEqual("2.00vp"); + expect(obj.$attrs.divider.color).assertEqual("#FFFFFFFF"); + expect(obj.$attrs.divider.startMargin).assertEqual("20.00vp"); + expect(obj.$attrs.divider.endMargin).assertEqual("20.00vp"); + console.info('[testList01] END'); + done(); + }); + + it('testList02', 0, async function (done) { + console.info('[testList02] START'); + try { + var eventData = { + data: { + "listDirection": Axis.Horizontal + } + } + var innerEvent = { + eventId: 124, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList02] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList02] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.listDirection).assertEqual('Axis.Horizontal'); + console.info('testList02 END'); + done(); + }); + + it('testList03', 0, async function (done) { + console.info('[testList03] START'); + try { + var eventData = { + data: { + "editMode": true + } + } + var innerEvent = { + eventId: 124, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList03] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList03] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.editMode).assertEqual('true'); + console.info('testList03 END'); + done(); + }); + + it('testList04', 0, async function (done) { + console.info('[testList04] START'); + try { + var eventData = { + data: { + "edgeEffect": EdgeEffect.Spring + } + } + var innerEvent = { + eventId: 124, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList04] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList04] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList04] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.Spring'); + console.info('testList04 END'); + done(); + }); + + it('testList05', 0, async function (done) { + console.info('[testList05] START'); + try { + var eventData = { + data: { + "chainAnimation": true + } + } + var innerEvent = { + eventId: 124, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList05] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList05] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList05] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.chainAnimation).assertEqual('true'); + console.info('testList05 END'); + done(); + }); + + it('testList06', 0, async function (done) { + console.info('[testList06] START'); + try { + var eventData = { + data: { + "strokeWidth": "3.000000vp" + } + } + var innerEvent = { + eventId: 125, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList06] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList06] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList06] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.divider.strokeWidth).assertEqual("3.00vp"); + console.info('testList06 END'); + done(); + }); + + it('testList07', 0, async function (done) { + console.info('[testList07] START'); + try { + var eventData = { + data: { + "color": "#FF0000FF" + } + } + var innerEvent = { + eventId: 125, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList07] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList07] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList07] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.divider.color).assertEqual("#FF0000FF"); + console.info('testList07 END'); + done(); + }); + + it('testList08', 0, async function (done) { + console.info('[testList08] START'); + try { + var eventData = { + data: { + "startMargin": "30.000000vp" + } + } + var innerEvent = { + eventId: 125, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList08] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList08] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList08] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.divider.startMargin).assertEqual("30.00vp"); + console.info('testList08 END'); + done(); + }); + + it('testList09', 0, async function (done) { + console.info('[testList09] START'); + try { + var eventData = { + data: { + "endMargin": "30.000000vp" + } + } + var innerEvent = { + eventId: 125, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList09] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList09] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList09] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.divider.endMargin).assertEqual("30.00vp"); + console.info('testList09 END'); + done(); + }); + + it('testList10', 0, async function (done) { + console.info('[testList10] START'); + try { + var eventData = { + data: { + "editMode": "true123" + } + } + var innerEvent = { + eventId: 901, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList10] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList10] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList10] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.editMode).assertEqual('true'); + console.info('testList10 END'); + done(); + }); + + it('testList11', 0, async function (done) { + console.info('[testList11] START'); + try { + var eventData = { + data: { + "editMode": "39000000" + } + } + var innerEvent = { + eventId: 902, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList11] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList11] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList11] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.editMode).assertEqual('true'); + console.info('testList11 END'); + done(); + }); + + it('testList12', 0, async function (done) { + console.info('[testList12] START'); + try { + var eventData = { + data: { + "chainAnimation": "true123" + } + } + var innerEvent = { + eventId: 903, + priority: events_emitter.EventPriority.LOW + } + console.info("[testList12] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testList12] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('list'); + let obj = JSON.parse(strJson); + console.info("[testList12] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.chainAnimation).assertEqual('true'); + console.info('testList12 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/MarqueeJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/MarqueeJsunit.test.ets index 5ea983cc34b12e92ba73fc9cad68d3c48f4d5ffb..98fe17ef0c5f38b31ce62db5cdf2bce6edadcf2c 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/MarqueeJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/MarqueeJsunit.test.ets @@ -1,154 +1,154 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import Utils from './Utils'; - -import events_emitter from '@ohos.events.emitter'; -export default function marqueeJsunit() { - describe('marqueeTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/marquee', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get marquee state success " + JSON.stringify(pages)); - if (!("marquee" == pages.name)) { - console.info("get marquee state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(4000); - console.info("push marquee page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push marquee page error " + JSON.stringify(result)); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("marquee after each called"); - }); - - - it('testMarquee_0100', 0, async function (done) { - console.info('testMarquee_0100 START'); - await Utils.sleep(1500); - let callback = (indexEvent) => { - console.info("testMarquee_0100 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.start).assertEqual(true); - } - let indexEvent = { - eventId: 130, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err)); - } - console.info("testMarquee_0100 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); - await Utils.sleep(1000); - var callback1 = (eventData) => { - console.info("testMarquee_0100 get event state result is: " + JSON.stringify(eventData)); - expect(eventData.data.fontColor).assertEqual(Color.Blue); - } - var innerEventOne = { - eventId: 127, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(innerEventOne, callback1); - } catch (err) { - console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err)); - } - console.info('testMarquee_0100 END'); - done(); - }); - - it('testMarquee_0200', 0, async function (done) { - console.info('testMarquee_0200 START'); - await Utils.sleep(1500); - let callback = (indexEvent) => { - console.info("testMarquee_0200 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.start).assertEqual(true); - } - let indexEvent = { - eventId: 130, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err)); - } - console.info("testMarquee_0200 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); - await Utils.sleep(1000); - var callback1 = (eventData) => { - console.info("testMarquee_0200 get event state result is: " + JSON.stringify(eventData)); - expect(eventData.data.fontSize).assertEqual(50); - } - var innerEventOne = { - eventId: 128, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(innerEventOne, callback1) - } catch (err) { - console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err)); - } - console.info('testMarquee_0200 END'); - done(); - }); - - it('testMarquee_0300', 0, async function (done) { - console.info('testMarquee_0300 START'); - await Utils.sleep(1500); - let callback = (indexEvent) => { - console.info("testMarquee_0300 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.start).assertEqual(true); - } - let indexEvent = { - eventId: 130, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err)); - } - console.info("testMarquee_0300 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); - await Utils.sleep(1000); - var callback1 = (eventData) => { - console.info("testMarquee_0300 get event state result is: " + JSON.stringify(eventData)); - expect(eventData.data.ACTION).assertEqual(true); - } - var innerEventOne = { - eventId: 129, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(innerEventOne, callback1) - } catch (err) { - console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err)); - } - console.info('testMarquee_0300 END'); - done(); - }); - }) +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils.ets'; +import events_emitter from '@ohos.events.emitter'; + +export default function marqueeJsunit() { + describe('marqueeTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/marquee', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get marquee state success " + JSON.stringify(pages)); + if (!("marquee" == pages.name)) { + console.info("get marquee state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(4000); + console.info("push marquee page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push marquee page error " + JSON.stringify(result)); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("marquee after each called"); + }); + + + it('testMarquee_0100', 0, async function (done) { + console.info('testMarquee_0100 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("testMarquee_0100 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.start).assertEqual(true); + } + let indexEvent = { + eventId: 130, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info("testMarquee_0100 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); + await Utils.sleep(1000); + var callback1 = (eventData) => { + console.info("testMarquee_0100 get event state result is: " + JSON.stringify(eventData)); + expect(eventData.data.fontColor).assertEqual(Color.Blue); + } + var innerEventOne = { + eventId: 127, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(innerEventOne, callback1); + } catch (err) { + console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err)); + } + console.info('testMarquee_0100 END'); + done(); + }); + + it('testMarquee_0200', 0, async function (done) { + console.info('testMarquee_0200 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("testMarquee_0200 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.start).assertEqual(true); + } + let indexEvent = { + eventId: 130, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err)); + } + console.info("testMarquee_0200 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); + await Utils.sleep(1000); + var callback1 = (eventData) => { + console.info("testMarquee_0200 get event state result is: " + JSON.stringify(eventData)); + expect(eventData.data.fontSize).assertEqual(50); + } + var innerEventOne = { + eventId: 128, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(innerEventOne, callback1) + } catch (err) { + console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err)); + } + console.info('testMarquee_0200 END'); + done(); + }); + + it('testMarquee_0300', 0, async function (done) { + console.info('testMarquee_0300 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("testMarquee_0300 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.start).assertEqual(true); + } + let indexEvent = { + eventId: 130, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err)); + } + console.info("testMarquee_0300 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); + await Utils.sleep(1000); + var callback1 = (eventData) => { + console.info("testMarquee_0300 get event state result is: " + JSON.stringify(eventData)); + expect(eventData.data.ACTION).assertEqual(true); + } + var innerEventOne = { + eventId: 129, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(innerEventOne, callback1) + } catch (err) { + console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err)); + } + console.info('testMarquee_0300 END'); + done(); + }); + }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/OverlayJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/OverlayJsunit.test.ets index 8382bbe5db921ca633c7d6f78a64b85c9e5e0088..c5d4ee2e199a82b422a471d404040344757d281b 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/OverlayJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/OverlayJsunit.test.ets @@ -1,146 +1,252 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter' -import Utils from './Utils'; - -export default function overLayJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("overlay beforeEach start"); - let options = { - uri: 'pages/overlay', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get overlay state pages: " + JSON.stringify(pages)); - if (!("overlay" == pages.name)) { - console.info("get overlay state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push overlay page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push overlay page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("overlay after each called"); - }); - - it('testOverlay01', 0, async function (done) { - console.info('[testOverlay01] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('overlay'); - let obj = JSON.parse(strJson); - console.info("[testOverlay01] obj is: " + JSON.stringify(obj.$attrs.overlay)); - expect(obj.$attrs.overlay.title).assertEqual("old title"); - expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Bottom"); - expect(obj.$attrs.overlay.options.offset.x).assertEqual('0.00vp'); - expect(obj.$attrs.overlay.options.offset.y).assertEqual('-15.00vp'); - console.info('[testOverlay01] END'); - done(); - }); - - it('testOverlay02', 0, async function (done) { - console.info('[testOverlay02] START'); - try { - var eventData = { - data: { - "title": "new title" - } - } - var innerEvent = { - eventId: 143, - priority: events_emitter.EventPriority.LOW - } - console.info("[testOverlay02] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testOverlay02] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJson = getInspectorByKey('overlay'); - let obj = JSON.parse(strJson); - console.info("[testOverlay02] obj is: " + JSON.stringify(obj.$attrs.overlay)); - expect(obj.$attrs.overlay.title).assertEqual("new title"); - console.info('testOverlay02 END'); - done(); - }); - - it('testOverlay03', 0, async function (done) { - console.info('[testOverlay03] START'); - try { - var eventData = { - data: { - "align": "Alignment.TopStart", - "x": 30, - "y": -30 - } - } - var innerEvent = { - eventId: 143, - priority: events_emitter.EventPriority.LOW - } - console.info("[testOverlay03] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testOverlay03] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJson = getInspectorByKey('overlay'); - let obj = JSON.parse(strJson); - console.info("[testOverlay03] obj is: " + JSON.stringify(obj.$attrs.overlay)); - expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart"); - expect(obj.$attrs.overlay.options.offset.x).assertEqual('30.00vp'); - expect(obj.$attrs.overlay.options.offset.y).assertEqual('-30.00vp'); - console.info('testOverlay03 END'); - done(); - }); - - it('testOverlay04', 0, async function (done) { - console.info('[testOverlay04] START'); - await Utils.sleep(1000); - try { - var eventData = { - data: { - "align": "Alignment.Center" - } - } - var innerEvent = { - eventId: 143, - priority: events_emitter.EventPriority.LOW - } - console.info("[testOverlay04] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testOverlay04] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJson = getInspectorByKey('overlay'); - let obj = JSON.parse(strJson); - console.info("[testOverlay04] obj is: " + JSON.stringify(obj.$attrs.overlay)); - expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart"); - console.info('testOverlay04 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils.ets'; + +export default function overLayJsunit() { + describe('overLayTest', function () { + beforeEach(async function (done) { + console.info("overlay beforeEach start"); + let options = { + uri: 'pages/overlay', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get overlay state pages: " + JSON.stringify(pages)); + if (!("overlay" == pages.name)) { + console.info("get overlay state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push overlay page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push overlay page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("overlay after each called"); + }); + + it('testOverlay01', 0, async function (done) { + console.info('[testOverlay01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay01] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.title).assertEqual("old title"); + expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Bottom"); + expect(obj.$attrs.overlay.options.offset.x).assertEqual('0.00vp'); + expect(obj.$attrs.overlay.options.offset.y).assertEqual('-15.00vp'); + console.info('[testOverlay01] END'); + done(); + }); + + it('testOverlay02', 0, async function (done) { + console.info('[testOverlay02] START'); + try { + var eventData = { + data: { + "title": "new title" + } + } + var innerEvent = { + eventId: 143, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay02] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay02] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.title).assertEqual("new title"); + console.info('testOverlay02 END'); + done(); + }); + + it('testOverlay03', 0, async function (done) { + console.info('[testOverlay03] START'); + try { + var eventData = { + data: { + "align": "Alignment.TopStart", + "x": 30, + "y": -30 + } + } + var innerEvent = { + eventId: 143, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay03] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay03] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay03] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart"); + expect(obj.$attrs.overlay.options.offset.x).assertEqual('30.00vp'); + expect(obj.$attrs.overlay.options.offset.y).assertEqual('-30.00vp'); + console.info('testOverlay03 END'); + done(); + }); + + it('testOverlay04', 0, async function (done) { + console.info('[testOverlay04] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "align": "Alignment.Center" + } + } + var innerEvent = { + eventId: 143, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay04] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay04] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay04] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart"); + console.info('testOverlay04 END'); + done(); + }); + + it('testOverlay05', 0, async function (done) { + console.info('[testOverlay05] START'); + try { + var eventData = { + data: { + "align":'-1' + } + } + var innerEvent = { + eventId: 1110, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay05] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay05] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay05] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Center"); + console.info('testOverlay05 END'); + done(); + }); + + it('testOverlay06', 0, async function (done) { + console.info('[testOverlay06] START'); + try { + var eventData = { + data: { + "x": -30, + "y": 30 + } + } + var innerEvent = { + eventId: 1110, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay06] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay06] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay06] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.options.offset.x).assertEqual('-30.00vp'); + expect(obj.$attrs.overlay.options.offset.y).assertEqual('30.00vp'); + console.info('testOverlay06 END'); + done(); + }); + + it('testOverlay07', 0, async function (done) { + console.info('[testOverlay07] START'); + try { + var eventData = { + data: { + "x": 1111111111 + } + } + var innerEvent = { + eventId: 1110, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay07] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay07] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay07] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.options.offset.x).assertEqual('1111111111.00vp'); + console.info('testOverlay07 END'); + done(); + }); + + it('testOverlay08', 0, async function (done) { + console.info('[testOverlay08] START'); + try { + var eventData = { + data: { + "y": 1111111111 + } + } + var innerEvent = { + eventId: 1110, + priority: events_emitter.EventPriority.LOW + } + console.info("[testOverlay08] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testOverlay08] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('overlay'); + let obj = JSON.parse(strJson); + console.info("[testOverlay08] obj is: " + JSON.stringify(obj.$attrs.overlay)); + expect(obj.$attrs.overlay.options.offset.x).assertEqual('1111111111.00vp'); + console.info('testOverlay08 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/StepperJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/StepperJsunit.test.ets index c2fa85e8af7e90ba98c7fde695dd3d564e4df33a..20179d027e5fc200c67a51b356097a9effb2a51c 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/StepperJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/StepperJsunit.test.ets @@ -1,91 +1,177 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import Utils from './Utils'; -import events_emitter from '@ohos.events.emitter'; - -export default function stepperJsunit() { - describe('stepperTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/stepper', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get stepper state success " + JSON.stringify(pages)); - if (!("stepper" == pages.name)) { - console.info("get stepper state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(1000); - console.info("push stepper page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push stepper page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("stepper after each called"); - }); - - it('stepperTest_0100', 0, async function (done) { - console.info('stepperTest_0100 START'); - let strJson = getInspectorByKey('stepper'); - console.info("stepperTest_0100 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("stepperTest_0100 component obj is: " + JSON.stringify(obj)); - expect(obj.$type).assertEqual('Stepper'); - expect(obj.$attrs.index).assertEqual('0'); - console.info('stepperTest_0100 END'); - done(); - }); - - it('stepperTest_0200', 0, async function (done) { - console.info('stepperTest_0200 START'); - let strJson = getInspectorByKey('stepper'); - console.info("stepperTest_0200 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("stepperTest_0200 component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.index).assertEqual('0'); - try { - let eventData = { - data: { - "currentIndex": "1", - } - } - let indexEvent = { - eventId: 202, - priority: events_emitter.EventPriority.LOW - } - console.info("stepperTest_0200 start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("stepperTest_0200 change component data error: " + err.message); - } - await Utils.sleep(3000); - let strJsonNew = getInspectorByKey('stepper'); - let objNew = JSON.parse(strJsonNew); - console.info("stepperTest_0200 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.index).assertEqual('1'); - console.info('stepperTest_0200 END'); - done(); - }); - }) +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils.ets'; +import events_emitter from '@ohos.events.emitter'; + +export default function stepperJsunit() { + describe('stepperTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/stepper', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get stepper state success " + JSON.stringify(pages)); + if (!("stepper" == pages.name)) { + console.info("get stepper state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push stepper page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push stepper page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("stepper after each called"); + }); + + it('stepperTest_0100', 0, async function (done) { + console.info('stepperTest_0100 START'); + let strJson = getInspectorByKey('stepper'); + console.info("stepperTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("stepperTest_0100 component obj is: " + JSON.stringify(obj)); + expect(obj.$type).assertEqual('Stepper'); + expect(obj.$attrs.index).assertEqual('0'); + console.info('stepperTest_0100 END'); + done(); + }); + + it('stepperTest_0200', 0, async function (done) { + console.info('stepperTest_0200 START'); + let strJson = getInspectorByKey('stepper'); + console.info("stepperTest_0200 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("stepperTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.index).assertEqual('0'); + try { + let eventData = { + data: { + "currentIndex": "1", + } + } + let indexEvent = { + eventId: 202, + priority: events_emitter.EventPriority.LOW + } + console.info("stepperTest_0200 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("stepperTest_0200 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('stepper'); + let objNew = JSON.parse(strJsonNew); + console.info("stepperTest_0200 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.index).assertEqual('1'); + console.info('stepperTest_0200 END'); + done(); + }); + + it('stepperTest_0300', 0, async function (done) { + console.info('stepperTest_0300v START'); + let strJson = getInspectorByKey('stepper'); + console.info("stepperTest_0300 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("stepperTest_0300 component obj is: " + JSON.stringify(obj)); + try { + let eventData = { + data: { + "currentIndex": "11111111", + } + } + let indexEvent = { + eventId: 909, + priority: events_emitter.EventPriority.LOW + } + console.info("stepperTest_0300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("stepperTest_0300 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('stepper'); + let objNew = JSON.parse(strJsonNew); + console.info("stepperTest_0300 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.index).assertEqual('11111111'); + console.info('stepperTest_0300 END'); + done(); + }); + + it('stepperTest_0400', 0, async function (done) { + console.info('stepperTest_0400 START'); + let strJson = getInspectorByKey('stepper'); + console.info("stepperTest_0400 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("stepperTest_0400 component obj is: " + JSON.stringify(obj)); + try { + let eventData = { + data: { + "currentIndex": "-558038585", + } + } + let indexEvent = { + eventId: 909, + priority: events_emitter.EventPriority.LOW + } + console.info("stepperTest_0400 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("stepperTest_0400 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('stepper'); + let objNew = JSON.parse(strJsonNew); + console.info("stepperTest_0400 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.index).assertEqual('-558038585'); + console.info('stepperTest_0400 END'); + done(); + }); + + it('stepperTest_0500', 0, async function (done) { + console.info('[stepperTest_0500] START'); + try { + var eventData = { + data: { + "currentIndex": '-10' + } + } + var innerEvent = { + eventId: 910, + priority: events_emitter.EventPriority.LOW + } + console.info("[stepperTest_0500] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[stepperTest_0500] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('stepper'); + let obj = JSON.parse(strJson); + console.info("[stepperTest_0500] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.index).assertEqual('-10'); + console.info('stepperTest_0500 END'); + done(); + }); + }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SwiperJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SwiperJsunit.test.ets index a01204bab79077d45f8281e82e4d83fd709fe0d2..3cc310c12ac0d7954baeb387085a1e3cb27d7fb8 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SwiperJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/SwiperJsunit.test.ets @@ -1,301 +1,474 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import Utils from './Utils'; -import events_emitter from '@ohos.events.emitter'; - -export default function swiperJsunit() { - describe('swiperTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/swiper', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get swiper state success " + JSON.stringify(pages)); - if (!("swiper" == pages.name)) { - console.info("get swiper state success " + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(1000); - console.info("push swiper page success " + JSON.stringify(result)); - } - } catch (err) { - console.error("push swiper page error: " + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("swiper after each called"); - }); - - it('swiperTest_0100', 0, async function (done) { - console.info('swiperTest_0100 START'); - let strJson = getInspectorByKey('swiper'); - console.info("swiperTest_0100 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("swiperTest_0100 component obj is: " + JSON.stringify(obj)); - console.info("swiperTest_0100 obj.$attrs.index: " + obj.$attrs.index); - console.info("swiperTest_0100 obj.$attrs.indicatorStyle: " + obj.$attrs.indicatorStyle); - expect(obj.$type).assertEqual('Swiper'); - expect(obj.$attrs.index).assertEqual('1'); - done(); - }); - - it('swiperTest_0200', 0, async function (done) { - console.info('swiperTest_0200 START'); - let strJson = getInspectorByKey('swiper'); - console.info("swiperTest_0200 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("swiperTest_0200 component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.indicator).assertEqual('true'); - expect(obj.$attrs.loop).assertEqual('false'); - console.info('swiperTest_0200 END'); - done(); - }); - - it('swiperTest_0300', 0, async function (done) { - console.info('swiperTest_0300 START'); - let strJson = getInspectorByKey('swiper'); - console.info("swiperTest_0300 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("swiperTest_0300 component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.duration).assertEqual('1000.000000'); - expect(obj.$attrs.vertical).assertEqual('false'); - console.info('swiperTest_0300 END'); - done(); - }); - - it('swiperTest_0400', 0, async function (done) { - console.info('swiperTest_0400 START'); - let strJson = getInspectorByKey('swiper'); - console.info("swiperTest_0400 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("swiperTest_0400 component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.autoPlay).assertEqual('true'); - expect(obj.$attrs.interval).assertEqual('4000'); - console.info('swiperTest_0400 END'); - done(); - }); - - it('swiperTest_0500', 0, async function (done) { - console.info('swiperTest_0500 START'); - let strJson = getInspectorByKey('swiper'); - console.info("swiperTest_0500 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("swiperTest_0500 component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.itemSpace).assertEqual('0.00vp'); - expect(obj.$attrs.disableSwipe).assertEqual('false'); - console.info('swiperTest_0500 END'); - done(); - }); - - it('swiperTest_0600', 0, async function (done) { - console.info('swiperTest_0600 START'); - try { - let eventData = { - data: { - "index": "3", - "autoPlay": "false", - } - } - let indexEvent = { - eventId: 207, - priority: events_emitter.EventPriority.LOW - } - console.info("swiperTest_0600 start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("swiperTest_0600 change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJsonNew = getInspectorByKey('swiper'); - let objNew = JSON.parse(strJsonNew); - console.info("swiperTest_0600 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.index).assertEqual('3'); - expect(objNew.$attrs.autoPlay).assertEqual('false'); - console.info('swiperTest_0600 END'); - done(); - }); - - it('swiperTest_0700', 0, async function (done) { - console.info('swiperTest_0700 START'); - await Utils.sleep(1500); - let callback = (indexEvent) => { - console.info("swiperTest_0700 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.ACTION).assertEqual(true); - } - let indexEvent = { - eventId: 205, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("swiperTest_0700 on events_emitter err : " + JSON.stringify(err)); - } - console.info("swiperTest_0700 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); - await Utils.sleep(1000); - console.info('swiperTest_0700 END'); - done(); - }); - - it('swiperTest_0800', 0, async function (done) { - console.info('swiperTest_0800 START'); - await Utils.sleep(1500); - let callback = (indexEvent) => { - console.info("swiperTest_0800 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.ACTION).assertEqual(true); - } - let indexEvent = { - eventId: 206, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("swiperTest_0800 on events_emitter err : " + JSON.stringify(err)); - } - console.info("swiperTest_0800 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); - await Utils.sleep(1000); - console.info('swiperTest_0800 END'); - done(); - }); - - it('swiperTest_0900', 0, async function (done) { - console.info('swiperTest_0900 START'); - await Utils.sleep(1500); - let callbackOne = (indexEventOne) => { - console.info("swiperTest_0900 get state result is: " + JSON.stringify(indexEventOne)); - expect(indexEventOne.data.ACTION).assertEqual(true); - } - let indexEventOne = { - eventId: 206, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEventOne, callbackOne); - } catch (err) { - console.info("swiperTest_0900 on events_emitter err : " + JSON.stringify(err)); - } - console.info("swiperTest_0900 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); - await Utils.sleep(1500); - let callback = (indexEvent) => { - console.info("swiperTest_0900 get state result is: " + JSON.stringify(indexEvent)); - expect(indexEvent.data.ACTION).assertEqual(true); - } - let indexEvent = { - eventId: 204, - priority: events_emitter.EventPriority.LOW - } - try { - events_emitter.on(indexEvent, callback); - } catch (err) { - console.info("swiperTest_0900 on events_emitter err : " + JSON.stringify(err)); - } - console.info('swiperTest_0900 END'); - done(); - }); - - it('swiperTest_1000', 0, async function (done) { - console.info('swiperTest_1000 START'); - try { - let eventData = { - data: { - "loop": true, - "vertical": true, - } - } - let indexEvent = { - eventId: 208, - priority: events_emitter.EventPriority.LOW - } - console.info("swiperTest_1000 start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("swiperTest_1000 change component data error: " + err.message); - } - await Utils.sleep(3000); - let strJsonNew = getInspectorByKey('swiper'); - let objNew = JSON.parse(strJsonNew); - console.info("swiperTest_1000 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.loop).assertEqual('true'); - expect(objNew.$attrs.vertical).assertEqual('true'); - console.info('swiperTest_1000 END'); - done(); - }); - - - it('swiperTest_1100', 0, async function (done) { - console.info('swiperTest_1100 START'); - try { - let eventData = { - data: { - "interval": "3000", - "indicator": "false", - } - } - let indexEvent = { - eventId: 209, - priority: events_emitter.EventPriority.LOW - } - console.info("swiperTest_1100 start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("swiperTest_1100 change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJsonNew = getInspectorByKey('swiper'); - let objNew = JSON.parse(strJsonNew); - console.info("swiperTest_1100 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.interval).assertEqual('3000'); - expect(objNew.$attrs.indicator).assertEqual('false'); - console.info('swiperTest_1100 END'); - done(); - }); - - it('swiperTest_1200', 0, async function (done) { - console.info('swiperTest_1200 START'); - try { - let eventData = { - data: { - "duration": "500", - "itemSpace": "1", - } - } - let indexEvent = { - eventId: 210, - priority: events_emitter.EventPriority.LOW - } - console.info("swiperTest_1200 start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("swiperTest_1200 change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJsonNew = getInspectorByKey('swiper'); - let objNew = JSON.parse(strJsonNew); - console.info("swiperTest_1200 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.duration).assertEqual('500.000000'); - expect(objNew.$attrs.itemSpace).assertEqual('1.00vp'); - console.info('swiperTest_1200 END'); - done(); - }); - }) +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import Utils from './Utils.ets'; +import events_emitter from '@ohos.events.emitter'; + +export default function swiperJsunit() { + describe('swiperTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/swiper', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get swiper state success " + JSON.stringify(pages)); + if (!("swiper" == pages.name)) { + console.info("get swiper state success " + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(1000); + console.info("push swiper page success " + JSON.stringify(result)); + } + } catch (err) { + console.error("push swiper page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("swiper after each called"); + }); + + it('swiperTest_0100', 0, async function (done) { + console.info('swiperTest_0100 START'); + let strJson = getInspectorByKey('swiper'); + console.info("swiperTest_0100 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("swiperTest_0100 component obj is: " + JSON.stringify(obj)); + console.info("swiperTest_0100 obj.$attrs.index: " + obj.$attrs.index); + console.info("swiperTest_0100 obj.$attrs.indicatorStyle: " + obj.$attrs.indicatorStyle); + expect(obj.$type).assertEqual('Swiper'); + expect(obj.$attrs.index).assertEqual('1'); + done(); + }); + + it('swiperTest_0200', 0, async function (done) { + console.info('swiperTest_0200 START'); + let strJson = getInspectorByKey('swiper'); + console.info("swiperTest_0200 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("swiperTest_0200 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.indicator).assertEqual('true'); + expect(obj.$attrs.loop).assertEqual('false'); + console.info('swiperTest_0200 END'); + done(); + }); + + it('swiperTest_0300', 0, async function (done) { + console.info('swiperTest_0300 START'); + let strJson = getInspectorByKey('swiper'); + console.info("swiperTest_0300 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("swiperTest_0300 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.duration).assertEqual('1000.000000'); + expect(obj.$attrs.vertical).assertEqual('false'); + console.info('swiperTest_0300 END'); + done(); + }); + + it('swiperTest_0400', 0, async function (done) { + console.info('swiperTest_0400 START'); + let strJson = getInspectorByKey('swiper'); + console.info("swiperTest_0400 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("swiperTest_0400 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.autoPlay).assertEqual('true'); + expect(obj.$attrs.interval).assertEqual('4000'); + console.info('swiperTest_0400 END'); + done(); + }); + + it('swiperTest_0500', 0, async function (done) { + console.info('swiperTest_0500 START'); + let strJson = getInspectorByKey('swiper'); + console.info("swiperTest_0500 component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("swiperTest_0500 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.itemSpace).assertEqual('0.00vp'); + expect(obj.$attrs.disableSwipe).assertEqual('false'); + console.info('swiperTest_0500 END'); + done(); + }); + + it('swiperTest_0600', 0, async function (done) { + console.info('swiperTest_0600 START'); + try { + let eventData = { + data: { + "index": "3" + } + } + let indexEvent = { + eventId: 207, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_0600 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_0600 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_0600 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.index).assertEqual('3'); + console.info('swiperTest_0600 END'); + done(); + }); + + it('swiperTest_0700', 0, async function (done) { + console.info('swiperTest_0700 START'); + try { + let eventData = { + data: { + "autoPlay": "false" + } + } + let indexEvent = { + eventId: 207, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_0700 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_0700 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_0700 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.autoPlay).assertEqual('false'); + console.info('swiperTest_0700 END'); + done(); + }); + + it('swiperTest_0800', 0, async function (done) { + console.info('swiperTest_0800 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("swiperTest_0800 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(true); + } + let indexEvent = { + eventId: 205, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("swiperTest_0800 on events_emitter err : " + JSON.stringify(err)); + } + console.info("swiperTest_0800 click result is: " + JSON.stringify(sendEventByKey('button1', 10, ""))); + await Utils.sleep(1000); + console.info('swiperTest_0800 END'); + done(); + }); + + it('swiperTest_0900', 0, async function (done) { + console.info('swiperTest_0900 START'); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("swiperTest_0900 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(true); + } + let indexEvent = { + eventId: 206, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("swiperTest_0900 on events_emitter err : " + JSON.stringify(err)); + } + console.info("swiperTest_0900 click result is: " + JSON.stringify(sendEventByKey('button2', 10, ""))); + await Utils.sleep(1000); + console.info('swiperTest_0900 END'); + done(); + }); + + it('swiperTest_1000', 0, async function (done) { + console.info('swiperTest_1000 START'); + await Utils.sleep(1500); + let callbackOne = (indexEventOne) => { + console.info("swiperTest_1000 get state result is: " + JSON.stringify(indexEventOne)); + expect(indexEventOne.data.ACTION).assertEqual(true); + } + let indexEventOne = { + eventId: 206, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEventOne, callbackOne); + } catch (err) { + console.info("swiperTest_1000 on events_emitter err : " + JSON.stringify(err)); + } + console.info("swiperTest_1000 click result is: " + JSON.stringify(sendEventByKey('button2', 10, ""))); + await Utils.sleep(1500); + let callback = (indexEvent) => { + console.info("swiperTest_1000 get state result is: " + JSON.stringify(indexEvent)); + expect(indexEvent.data.ACTION).assertEqual(true); + } + let indexEvent = { + eventId: 204, + priority: events_emitter.EventPriority.LOW + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("swiperTest_1000 on events_emitter err : " + JSON.stringify(err)); + } + console.info('swiperTest_1000 END'); + done(); + }); + + it('swiperTest_1100', 0, async function (done) { + console.info('swiperTest_1100 START'); + try { + let eventData = { + data: { + "loop": true + } + } + let indexEvent = { + eventId: 208, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1100 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1100 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1100 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.loop).assertEqual('true'); + console.info('swiperTest_1100 END'); + done(); + }); + + it('swiperTest_1200', 0, async function (done) { + console.info('swiperTest_1200 START'); + try { + let eventData = { + data: { + "vertical": true + } + } + let indexEvent = { + eventId: 208, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1200 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1200 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1200 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.vertical).assertEqual('true'); + console.info('swiperTest_1200 END'); + done(); + }); + + it('swiperTest_1300', 0, async function (done) { + console.info('swiperTest_1300 START'); + try { + let eventData = { + data: { + "interval": "3000" + } + } + let indexEvent = { + eventId: 209, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1300 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1300 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.interval).assertEqual('3000'); + console.info('swiperTest_1300 END'); + done(); + }); + + it('swiperTest_1400', 0, async function (done) { + console.info('swiperTest_1400 START'); + try { + let eventData = { + data: { + "indicator": "false" + } + } + let indexEvent = { + eventId: 209, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1400 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1400 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1400 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.indicator).assertEqual('false'); + console.info('swiperTest_1400 END'); + done(); + }); + + it('swiperTest_1500', 0, async function (done) { + console.info('swiperTest_1500 START'); + try { + let eventData = { + data: { + "duration": "500" + } + } + let indexEvent = { + eventId: 210, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1500 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1500 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1500 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.duration).assertEqual('500.000000'); + console.info('swiperTest_1500 END'); + done(); + }); + + it('swiperTest_1600', 0, async function (done) { + console.info('swiperTest_1600 START'); + try { + let eventData = { + data: { + "itemSpace": "1" + } + } + let indexEvent = { + eventId: 210, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1600 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1600 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1600 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.itemSpace).assertEqual('1.00vp'); + console.info('swiperTest_1600 END'); + done(); + }); + + it('swiperTest_1700', 0, async function (done) { + console.info('swiperTest_1700 START'); + try { + let eventData = { + data: { + "loop": "true123" + } + } + let indexEvent = { + eventId: 208, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1700 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1700 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1700 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.loop).assertEqual('false'); + console.info('swiperTest_1700 END'); + done(); + }); + + it('swiperTest_1800', 0, async function (done) { + console.info('swiperTest_1800 START'); + try { + let eventData = { + data: { + "autoPlay": "false123" + } + } + let indexEvent = { + eventId: 207, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1800 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1800 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1800 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.autoPlay).assertEqual('false'); + console.info('swiperTest_1800 END'); + done(); + }); + + it('swiperTest_1900', 0, async function (done) { + console.info('swiperTest_1900 START'); + try { + let eventData = { + data: { + "duration": "nan" + } + } + let indexEvent = { + eventId: 210, + priority: events_emitter.EventPriority.LOW + } + console.info("swiperTest_1900 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("swiperTest_1900 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('swiper'); + let objNew = JSON.parse(strJsonNew); + console.info("swiperTest_1900 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.duration).assertEqual('nan'); + console.info('swiperTest_1900 END'); + done(); + }); + }) } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextStyleJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextStyleJsunit.test.ets index 67a43ebe2e993625c6558ff8e2e15a5302f7d9d9..5dfa3bcea4233039bccd6535fe0b93e31fbebd2d 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextStyleJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TextStyleJsunit.test.ets @@ -1,233 +1,571 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils.ets'; - -export default function textStyleJsunit() { - describe('textStyleTest', function () { - beforeEach(async function (done) { - let options = { - uri: 'pages/textStyle', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get textStyle state pages:" + JSON.stringify(pages)); - if (!("textStyle" == pages.name)) { - console.info("get textStyle state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push textStyle page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push textStyle page error:" + err); - } - done(); - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("textStyle after each called"); - }); - - it('testTextStyle001', 0, async function (done) { - console.info('[testTextStyle001] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('fontColor'); - console.info("[testTextStyle001] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle001] fontColor: " + obj.$attrs.fontColor); - expect(obj.$attrs.fontColor).assertEqual('#FFFF0000'); - done(); - }); - - it('testTextStyle002', 0, async function (done) { - console.info('[testTextStyle002] START'); - try { - let eventData = { - data: { - "fontColor": Color.Blue - } - } - let indexEvent = { - eventId: 37, - priority: events_emitter.EventPriority.LOW - } - console.info("[testTextStyle002] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testTextStyle002] change component data error: " + err.message); - } - await Utils.sleep(3000); - let strJson = getInspectorByKey('fontColor'); - console.info("[testTextStyle002] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle002] fontColor: " + obj.$attrs.fontColor); - expect(obj.$attrs.fontColor).assertEqual('#FF0000FF'); - done(); - }); - - it('testTextStyle003', 0, async function (done) { - console.info('[testTextStyle003] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('fontSize'); - console.info("[testTextStyle003] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle003] fontSize: " + obj.$attrs.fontSize); - expect(obj.$attrs.fontSize).assertEqual('20.00fp'); - done(); - }); - - it('testTextStyle004', 0, async function (done) { - console.info('[testTextStyle004] START'); - try { - let eventData = { - data: { - "fontSize": 30 - } - } - let indexEvent = { - eventId: 38, - priority: events_emitter.EventPriority.LOW - } - console.info("[testTextStyle004] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testTextStyle004] change component data error: " + err.message); - } - await Utils.sleep(4000); - let strJson = getInspectorByKey('fontSize'); - console.info("[testTextStyle004] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle004] fontSize: " + obj.$attrs.fontSize); - expect(obj.$attrs.fontSize).assertEqual('30.00fp'); - done(); - }); - - it('testTextStyle005', 0, async function (done) { - console.info('[testTextStyle005] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('fontStyle'); - console.info("[testTextStyle005] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle005] fontStyle: " + obj.$attrs.fontStyle); - expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Italic'); - done(); - }); - - it('testTextStyle006', 0, async function (done) { - console.info('[testTextStyle006] START'); - try { - let eventData = { - data: { - "fontStyle": FontStyle.Normal - } - } - let indexEvent = { - eventId: 39, - priority: events_emitter.EventPriority.LOW - } - console.info("[testTextStyle006] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testTextStyle006] change component data error: " + err.message); - } - await Utils.sleep(3000); - let strJson = getInspectorByKey('fontStyle'); - console.info("[testTextStyle006] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle006] fontStyle: " + obj.$attrs.fontStyle); - expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); - done(); - }); - - it('testTextStyle007', 0, async function (done) { - console.info('[testTextStyle007] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('fontWeight'); - console.info("[testTextStyle007] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle007] fontWeight: " + obj.$attrs.fontWeight); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.700'); - done(); - }); - - it('testTextStyle008', 0, async function (done) { - console.info('[testTextStyle008] START'); - try { - let eventData = { - data: { - "fontWeight": 400 - } - } - let indexEvent = { - eventId: 40, - priority: events_emitter.EventPriority.LOW - } - console.info("[testTextStyle008] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testTextStyle008] change component data error: " + err.message); - } - await Utils.sleep(3000); - let strJson = getInspectorByKey('fontWeight'); - console.info("[testTextStyle008] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle008] fontWeight: " + obj.$attrs.fontWeight); - expect(obj.$attrs.fontWeight).assertEqual('FontWeight.400'); - done(); - }); - - it('testTextStyle009', 0, async function (done) { - console.info('[testTextStyle009] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('fontFamily'); - console.info("[testTextStyle009] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle009] fontFamily: " + obj.$attrs.fontFamily); - expect(obj.$attrs.fontFamily).assertEqual('sans-serif'); - done(); - }); - - it('testTextStyle0010', 0, async function (done) { - console.info('[testTextStyle0010] START'); - try { - let eventData = { - data: { - "fontFamily": 'Arial' - } - } - let indexEvent = { - eventId: 41, - priority: events_emitter.EventPriority.LOW - } - console.info("[testTextStyle0010] start to publish emit"); - events_emitter.emit(indexEvent, eventData); - } catch (err) { - console.log("[testTextStyle0010] change component data error: " + err.message); - } - await Utils.sleep(3000); - let strJson = getInspectorByKey('fontFamily'); - console.info("[testTextStyle0010] component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("[testTextStyle0010] fontFamily: " + obj.$attrs.fontFamily); - expect(obj.$attrs.fontFamily).assertEqual('Arial'); - done(); - }); - }); +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function textStyleJsunit() { + describe('textStyleTest', function () { + beforeEach(async function (done) { + let options = { + uri: 'pages/textStyle', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get textStyle state pages:" + JSON.stringify(pages)); + if (!("textStyle" == pages.name)) { + console.info("get textStyle state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push textStyle page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push textStyle page error:" + err); + } + done(); + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("textStyle after each called"); + }); + + it('testTextStyle001', 0, async function (done) { + console.info('[testTextStyle001] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testTextStyle001] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle001] fontColor: " + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#FFFF0000'); + done(); + }); + + it('testTextStyle002', 0, async function (done) { + console.info('[testTextStyle002] START'); + try { + let eventData = { + data: { + "fontColor": Color.Blue + } + } + let indexEvent = { + eventId: 37, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle002] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle002] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testTextStyle002] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle002] fontColor: " + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#FF0000FF'); + done(); + }); + + it('testTextStyle003', 0, async function (done) { + console.info('[testTextStyle003] START'); + try { + let eventData = { + data: { + "fontColor": 0x80000000 + } + } + let indexEvent = { + eventId: 37, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle003] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle003] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testTextStyle003] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle003] fontColor: " + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#80000000'); + done(); + }); + + it('testTextStyle004', 0, async function (done) { + console.info('[testTextStyle004] START'); + try { + let eventData = { + data: { + "fontColor": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 37, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle004] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle004] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testTextStyle004] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle004] fontColor: " + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#7FFFFFFF'); + done(); + }); + + it('testTextStyle005', 0, async function (done) { + console.info('[testTextStyle005] START'); + try { + let eventData = { + data: { + "fontColor": 'error' + } + } + let indexEvent = { + eventId: 37, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle005] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle005] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testTextStyle005] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle005] fontColor: " + obj.$attrs.fontColor); + expect(obj.$attrs.fontColor).assertEqual('#FF000000'); + done(); + }); + + it('testTextStyle006', 0, async function (done) { + console.info('[testTextStyle006] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('fontSize'); + console.info("[testTextStyle006] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle006] fontSize: " + obj.$attrs.fontSize); + expect(obj.$attrs.fontSize).assertEqual('20.00fp'); + done(); + }); + + it('testTextStyle007', 0, async function (done) { + console.info('[testTextStyle007] START'); + try { + let eventData = { + data: { + "fontSize": 30 + } + } + let indexEvent = { + eventId: 38, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle007] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle007] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontSize'); + console.info("[testTextStyle007] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle007] fontSize: " + obj.$attrs.fontSize); + expect(obj.$attrs.fontSize).assertEqual('30.00fp'); + done(); + }); + + it('testTextStyle008', 0, async function (done) { + console.info('[testTextStyle008] START'); + try { + let eventData = { + data: { + "fontSize": 0x80000000 + } + } + let indexEvent = { + eventId: 38, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle008] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle008] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontSize'); + console.info("[testTextStyle008] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle008] fontSize: " + obj.$attrs.fontSize); + expect(obj.$attrs.fontSize).assertEqual('-2147483648.00fp'); + done(); + }); + + it('testTextStyle009', 0, async function (done) { + console.info('[testTextStyle009] START'); + try { + let eventData = { + data: { + "fontSize": 'error' + } + } + let indexEvent = { + eventId: 38, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle009] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle009] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontSize'); + console.info("[testTextStyle009] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle009] fontSize: " + obj.$attrs.fontSize); + expect(obj.$attrs.fontSize).assertEqual('0.00fp'); + done(); + }); + + it('testTextStyle010', 0, async function (done) { + console.info('[testTextStyle010] START'); + try { + let eventData = { + data: { + "fontSize": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 38, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle010] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle010] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontSize'); + console.info("[testTextStyle010] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle010] fontSize: " + obj.$attrs.fontSize); + expect(obj.$attrs.fontSize).assertEqual('2147483647.00fp'); + done(); + }); + + it('testTextStyle011', 0, async function (done) { + console.info('[testTextStyle011] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('fontStyle'); + console.info("[testTextStyle011] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle011] fontStyle: " + obj.$attrs.fontStyle); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Italic'); + done(); + }); + + it('testTextStyle012', 0, async function (done) { + console.info('[testTextStyle012] START'); + try { + let eventData = { + data: { + "fontStyle": FontStyle.Normal + } + } + let indexEvent = { + eventId: 39, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle012] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle012] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontStyle'); + console.info("[testTextStyle012] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle012] fontStyle: " + obj.$attrs.fontStyle); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); + done(); + }); + + it('testTextStyle013', 0, async function (done) { + console.info('[testTextStyle013] START'); + try { + let eventData = { + data: { + "fontStyle": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 39, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle013] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle013] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontStyle'); + console.info("[testTextStyle013] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle013] fontStyle: " + obj.$attrs.fontStyle); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); + done(); + }); + + it('testTextStyle014', 0, async function (done) { + console.info('[testTextStyle014] START'); + try { + let eventData = { + data: { + "fontStyle": 'error' + } + } + let indexEvent = { + eventId: 39, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle014] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle014] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontStyle'); + console.info("[testTextStyle014] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle014] fontStyle: " + obj.$attrs.fontStyle); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); + done(); + }); + + it('testTextStyle015', 0, async function (done) { + console.info('[testTextStyle015] START'); + try { + let eventData = { + data: { + "fontStyle": 0x80000000 + } + } + let indexEvent = { + eventId: 39, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle015] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle015] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontStyle'); + console.info("[testTextStyle015] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle015] fontStyle: " + obj.$attrs.fontStyle); + expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); + done(); + }); + + it('testTextStyle016', 0, async function (done) { + console.info('[testTextStyle016] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('fontWeight'); + console.info("[testTextStyle016] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle016] fontWeight: " + obj.$attrs.fontWeight); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.700'); + done(); + }); + + it('testTextStyle017', 0, async function (done) { + console.info('[testTextStyle017] START'); + try { + let eventData = { + data: { + "fontWeight": 400 + } + } + let indexEvent = { + eventId: 40, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle017] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle017] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontWeight'); + console.info("[testTextStyle017] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle017] fontWeight: " + obj.$attrs.fontWeight); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.400'); + done(); + }); + + it('testTextStyle018', 0, async function (done) { + console.info('[testTextStyle018] START'); + try { + let eventData = { + data: { + "fontWeight": 'error' + } + } + let indexEvent = { + eventId: 40, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle018] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle018] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontWeight'); + console.info("[testTextStyle018] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle018] fontWeight: " + obj.$attrs.fontWeight); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); + done(); + }); + + it('testTextStyle019', 0, async function (done) { + console.info('[testTextStyle019] START'); + try { + let eventData = { + data: { + "fontWeight": 0x80000000 + } + } + let indexEvent = { + eventId: 40, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle019] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle019] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontWeight'); + console.info("[testTextStyle019] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle019] fontWeight: " + obj.$attrs.fontWeight); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); + done(); + }); + + it('testTextStyle020', 0, async function (done) { + console.info('[testTextStyle020] START'); + try { + let eventData = { + data: { + "fontWeight": 0x7FFFFFFF + } + } + let indexEvent = { + eventId: 40, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle020] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle020] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontWeight'); + console.info("[testTextStyle020] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle020] fontWeight: " + obj.$attrs.fontWeight); + expect(obj.$attrs.fontWeight).assertEqual('FontWeight.Normal'); + done(); + }); + + it('testTextStyle021', 0, async function (done) { + console.info('[testTextStyle021] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('fontFamily'); + console.info("[testTextStyle021] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle021] fontFamily: " + obj.$attrs.fontFamily); + expect(obj.$attrs.fontFamily).assertEqual('sans-serif'); + done(); + }); + + it('testTextStyle022', 0, async function (done) { + console.info('[testTextStyle022] START'); + try { + let eventData = { + data: { + "fontFamily": 'Arial' + } + } + let indexEvent = { + eventId: 41, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle022] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle022] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontFamily'); + console.info("[testTextStyle022] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle022] fontFamily: " + obj.$attrs.fontFamily); + expect(obj.$attrs.fontFamily).assertEqual('Arial'); + done(); + }); + + it('testTextStyle023', 0, async function (done) { + console.info('[testTextStyle023] START'); + try { + let eventData = { + data: { + "fontFamily": 'error' + } + } + let indexEvent = { + eventId: 41, + priority: events_emitter.EventPriority.LOW + } + console.info("[testTextStyle023] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testTextStyle023] change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJson = getInspectorByKey('fontFamily'); + console.info("[testTextStyle023] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testTextStyle023] fontFamily: " + obj.$attrs.fontFamily); + expect(obj.$attrs.fontFamily).assertEqual('error'); + done(); + }); + }); } \ No newline at end of file diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchAbleJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchAbleJsunit.test.ets index 0bdc5f0c8fef5322bc553b8a98ad4709fd494adc..6348bf2e9035c70f21de0c2db42e14243b69f836 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchAbleJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchAbleJsunit.test.ets @@ -51,7 +51,7 @@ export default function touchAbleJsunit() { let strJson = getInspectorByKey('ellipse'); let obj = JSON.parse(strJson); console.info("[testTouchAble001] component obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.focusable).assertEqual(false); + expect(obj.$attrs.focusable).assertEqual(true); done(); }); diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchJsunit.test.ets index c2aa4df21ad2070fe5dfbeac5c352ba387743b73..edf284addd141e697f10b319068170fd30495277 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/TouchJsunit.test.ets @@ -1,72 +1,72 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter' -import Utils from './Utils.ets'; - -export default function touchJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("touch beforeEach start"); - let options = { - uri: 'pages/touch', - } - let result; - try{ - router.clear(); - let pages = router.getState(); - console.info("get touch state pages: " + JSON.stringify(pages)); - if(!("touch" == pages.name)){ - console.info("get touch state pages.name: " + JSON.stringify(pages.name)); - result = await router.push(options); - await Utils.sleep(2000); - console.info("push touch page result: " + JSON.stringify(result)); - } - }catch(err){ - console.error("push touch page error: " + err); - } - done() - }); - - afterEach(async function(){ - await Utils.sleep(1000); - console.info("touch after each called"); - }) - - it('testTouch01', 0, async function (done) { - console.info('[testTouch01] START'); - await Utils.sleep(1000); - try { - let callBackTouch = (backData) => { - console.info("testTouch01 get backEvent result is: " + JSON.stringify(backEvent)); - console.info("testTouch01 get flag result is: " + JSON.stringify(backData.data.ACTION)); - expect(backData.data.ACTION).assertEqual(true); - } - var backEvent = { - eventId: 43, - priority: events_emitter.EventPriority.LOW - } - events_emitter.on(backEvent, callBackTouch); - }catch(err) { - console.info("testTouch01 on touchEvent err : " + JSON.stringify(err)); - } - console.info("testTouch01 click result is: " + JSON.stringify(sendEventByKey('touch',10,""))); - console.info('[testTouch01] END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter' +import Utils from './Utils.ets'; + +export default function touchJsunit() { + describe('touchTest', function () { + beforeEach(async function (done) { + console.info("touch beforeEach start"); + let options = { + uri: 'pages/touch', + } + let result; + try { + router.clear(); + let pages = router.getState(); + console.info("get touch state pages: " + JSON.stringify(pages)); + if (!("touch" == pages.name)) { + console.info("get touch state pages.name: " + JSON.stringify(pages.name)); + result = await router.push(options); + await Utils.sleep(2000); + console.info("push touch page result: " + JSON.stringify(result)); + } + } catch (err) { + console.error("push touch page error: " + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("touch after each called"); + }) + + it('testTouch01', 0, async function (done) { + console.info('[testTouch01] START'); + await Utils.sleep(1000); + try { + let callBackTouch = (backData) => { + console.info("testTouch01 get backEvent result is: " + JSON.stringify(backEvent)); + console.info("testTouch01 get flag result is: " + JSON.stringify(backData.data.ACTION)); + expect(backData.data.ACTION).assertEqual(true); + } + var backEvent = { + eventId: 43, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(backEvent, callBackTouch); + } catch (err) { + console.info("testTouch01 on touchEvent err : " + JSON.stringify(err)); + } + console.info("testTouch01 click result is: " + JSON.stringify(sendEventByKey('touch', 10, ""))); + console.info('[testTouch01] END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/VisibilityJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/VisibilityJsunit.test.ets index 483d2dc329d9a43694cc9a37e39740c7f8eb857b..69dc301d050e897f632aa5e40535da7b903c010c 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/VisibilityJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/VisibilityJsunit.test.ets @@ -1,112 +1,164 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function visibilityJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("visibility beforeEach start"); - let options = { - uri: 'pages/visibility', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get visibility state pages:" + JSON.stringify(pages)); - if (!("visibility" == pages.name)) { - console.info("get visibility state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push visibility page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push visibility page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(1000); - console.info("visibility after each called"); - }); - - it('testVisibility01', 0, async function (done) { - console.info('[testVisibility01] START'); - await Utils.sleep(1000); - let strJson = getInspectorByKey('box'); - let obj = JSON.parse(strJson); - console.info("[testVisibility01] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.visibility).assertEqual('Visibility.Visible'); - console.info('[testVisibility01] END'); - done(); - }); - - it('testVisibility02', 0, async function (done) { - console.info('[testVisibility02] START'); - try { - var eventData = { - data: { - "visibility": Visibility.Hidden, - } - } - var innerEvent = { - eventId: 47, - priority: events_emitter.EventPriority.LOW - } - console.info("[testVisibility02] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testVisibility02] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('box'); - let obj = JSON.parse(strJson); - console.info("[testVisibility02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.visibility).assertEqual('Visibility.Hidden'); - console.info('[testVisibility02] END'); - done(); - }); - - it('testVisibility03', 0, async function (done) { - console.info('[testVisibility03] START'); - try { - var eventData = { - data: { - "visibility": Visibility.None, - } - } - var innerEvent = { - eventId: 48, - priority: events_emitter.EventPriority.LOW - } - console.info("[testVisibility03] start to publish emit:" + JSON.stringify(eventData.data)); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testVisibility03] change component data error: " + err.message); - } - await Utils.sleep(1000); - let strJson = getInspectorByKey('box'); - let obj = JSON.parse(strJson); - console.info("[testVisibility03] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.visibility).assertEqual('Visibility.None'); - console.info('[testVisibility03] END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; + +export default function visibilityJsunit() { + describe('visibilityTest', function () { + beforeEach(async function (done) { + console.info("visibility beforeEach start"); + let options = { + uri: 'pages/visibility', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get visibility state pages:" + JSON.stringify(pages)); + if (!("visibility" == pages.name)) { + console.info("get visibility state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push visibility page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push visibility page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(1000); + console.info("visibility after each called"); + }); + + it('testVisibility01', 0, async function (done) { + console.info('[testVisibility01] START'); + await Utils.sleep(1000); + let strJson = getInspectorByKey('box'); + let obj = JSON.parse(strJson); + console.info("[testVisibility01] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.visibility).assertEqual('Visibility.Visible'); + console.info('[testVisibility01] END'); + done(); + }); + + it('testVisibility02', 0, async function (done) { + console.info('[testVisibility02] START'); + try { + var eventData = { + data: { + "visibility": Visibility.Hidden, + } + } + var innerEvent = { + eventId: 47, + priority: events_emitter.EventPriority.LOW + } + console.info("[testVisibility02] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testVisibility02] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('box'); + let obj = JSON.parse(strJson); + console.info("[testVisibility02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.visibility).assertEqual('Visibility.Hidden'); + console.info('[testVisibility02] END'); + done(); + }); + + it('testVisibility03', 0, async function (done) { + console.info('[testVisibility03] START'); + try { + var eventData = { + data: { + "visibility": Visibility.None, + } + } + var innerEvent = { + eventId: 48, + priority: events_emitter.EventPriority.LOW + } + console.info("[testVisibility03] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testVisibility03] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('box'); + let obj = JSON.parse(strJson); + console.info("[testVisibility03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.visibility).assertEqual('Visibility.None'); + console.info('[testVisibility03] END'); + done(); + }); + + it('testVisibility04', 0, async function (done) { + console.info('[testVisibility04] START'); + try { + var eventData = { + data: { + "visibility": 0.11111 + } + } + var innerEvent = { + eventId: 1116, + priority: events_emitter.EventPriority.LOW + } + console.info("[testVisibility04] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testVisibility04] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('box'); + let obj = JSON.parse(strJson); + console.info("[testVisibility04] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.visibility).assertEqual('Visibility.None'); + console.info('[testVisibility04] END'); + done(); + }); + + it('testVisibility05', 0, async function (done) { + console.info('[testVisibility05] START'); + try { + var eventData = { + data: { + "visibility": 'nothing', + } + } + var innerEvent = { + eventId: 1116, + priority: events_emitter.EventPriority.LOW + } + console.info("[testVisibility05] start to publish emit:" + JSON.stringify(eventData.data)); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testVisibility05] change component data error: " + err.message); + } + await Utils.sleep(1000); + let strJson = getInspectorByKey('box'); + let obj = JSON.parse(strJson); + console.info("[testVisibility05] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.visibility).assertEqual('Visibility.None'); + console.info('[testVisibility05] END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets index b03f60189cace3b3ca40a9995271d72e44b4dffa..31c9584acac461ebdb1f5945d69a9d65d3108764 100755 --- a/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets +++ b/ace/ace_ets_component/entry/src/main/ets/MainAbility/test/ZIndexJsunit.test.ets @@ -1,112 +1,137 @@ -// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" -import router from '@system.router'; -import events_emitter from '@ohos.events.emitter'; -import Utils from './Utils'; - -export default function zIndexJsunit() { - describe('appInfoTest', function () { - beforeEach(async function (done) { - console.info("zIndex beforeEach start"); - let options = { - uri: 'pages/zIndex', - } - try { - router.clear(); - let pages = router.getState(); - console.info("get zIndex state pages: " + JSON.stringify(pages)); - if (!("zIndex" == pages.name)) { - console.info("get zIndex state pages.name:" + JSON.stringify(pages.name)); - let result = await router.push(options); - await Utils.sleep(2000); - console.info("push zIndex page result:" + JSON.stringify(result)); - } - } catch (err) { - console.error("push zIndex page error:" + err); - } - done() - }); - - afterEach(async function () { - await Utils.sleep(2000); - console.info("zIndex after each called"); - }); - - it('testZIndex01', 0, async function (done) { - console.info('[testZIndex01] START'); - await Utils.sleep(2000); - let strJson = getInspectorByKey('zIndex'); - let obj = JSON.parse(strJson); - console.info("[testZIndex01] obj is: " + JSON.stringify(obj.$attrs)); - expect(obj.$attrs.zIndex).assertEqual(1); - console.info('[testZIndex01] END'); - done(); - }); - - it('testZIndex02', 0, async function (done) { - console.info('[testZIndex02] START'); - try { - var eventData = { - data: { - "zIndex": 4 - } - } - var innerEvent = { - eventId: 236, - priority: events_emitter.EventPriority.LOW - } - console.info("[testZIndex02] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testZIndex02] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJson = getInspectorByKey('zIndex'); - let obj = JSON.parse(strJson); - console.info("[testZIndex02] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.zIndex).assertEqual(4); - console.info('testZIndex02 END'); - done(); - }); - - it('testZIndex03', 0, async function (done) { - console.info('[testZIndex03] START'); - try { - var eventData = { - data: { - "zIndex": -5 - } - } - var innerEvent = { - eventId: 236, - priority: events_emitter.EventPriority.LOW - } - console.info("[testZIndex03] start to publish emit"); - events_emitter.emit(innerEvent, eventData); - } catch (err) { - console.log("[testZIndex03] change component data error: " + err.message); - } - await Utils.sleep(2000); - let strJson = getInspectorByKey('zIndex'); - let obj = JSON.parse(strJson); - console.info("[testZIndex03] obj is: " + JSON.stringify(obj)); - expect(obj.$attrs.zIndex).assertEqual(-5); - console.info('testZIndex03 END'); - done(); - }); - }) -} +// @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 {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" +import router from '@system.router'; +import events_emitter from '@ohos.events.emitter'; +import Utils from './Utils.ets'; +export default function zIndexJsunit() { + describe('zIndexTest', function () { + beforeEach(async function (done) { + console.info("zIndex beforeEach start"); + let options = { + uri: 'pages/zIndex', + } + try { + router.clear(); + let pages = router.getState(); + console.info("get zIndex state pages: " + JSON.stringify(pages)); + if (!("zIndex" == pages.name)) { + console.info("get zIndex state pages.name:" + JSON.stringify(pages.name)); + let result = await router.push(options); + await Utils.sleep(2000); + console.info("push zIndex page result:" + JSON.stringify(result)); + } + } catch (err) { + console.error("push zIndex page error:" + err); + } + done() + }); + + afterEach(async function () { + await Utils.sleep(2000); + console.info("zIndex after each called"); + }); + + it('testZIndex01', 0, async function (done) { + console.info('[testZIndex01] START'); + await Utils.sleep(2000); + let strJson = getInspectorByKey('zIndex'); + let obj = JSON.parse(strJson); + console.info("[testZIndex01] obj is: " + JSON.stringify(obj.$attrs)); + expect(obj.$attrs.zIndex).assertEqual(1); + console.info('[testZIndex01] END'); + done(); + }); + + it('testZIndex02', 0, async function (done) { + console.info('[testZIndex02] START'); + try { + var eventData = { + data: { + "zIndex": 4 + } + } + var innerEvent = { + eventId: 236, + priority: events_emitter.EventPriority.LOW + } + console.info("[testZIndex02] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testZIndex02] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('zIndex'); + let obj = JSON.parse(strJson); + console.info("[testZIndex02] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.zIndex).assertEqual(4); + console.info('testZIndex02 END'); + done(); + }); + + it('testZIndex03', 0, async function (done) { + console.info('[testZIndex03] START'); + try { + var eventData = { + data: { + "zIndex": -5 + } + } + var innerEvent = { + eventId: 236, + priority: events_emitter.EventPriority.LOW + } + console.info("[testZIndex03] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testZIndex03] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('zIndex'); + let obj = JSON.parse(strJson); + console.info("[testZIndex03] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.zIndex).assertEqual(-5); + console.info('testZIndex03 END'); + done(); + }); + + it('testZIndex04', 0, async function (done) { + console.info('[testZIndex04] START'); + try { + var eventData = { + data: { + "zIndex": 889900444 + } + } + var innerEvent = { + eventId: 1113, + priority: events_emitter.EventPriority.LOW + } + console.info("[testZIndex04] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testZIndex04] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('zIndex'); + let obj = JSON.parse(strJson); + console.info("[testZIndex04] obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.zIndex).assertEqual(889900444); + console.info('testZIndex04 END'); + done(); + }); + }) +} diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets index e8abbe95dc539be30b8cae97d3abb117da350586..8e0cae58157e1a422b756c69d3214ac9f2b5d89d 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/QrCode.ets @@ -22,7 +22,6 @@ struct QrCode { @State qrCodeBackgroundColor: Color = "#FF008000"; @State qrCodeColor: Color = "#FF0000FF"; @State qrCodeValue: string = 'qrCodeValue'; - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("qrCode page state change called:" + JSON.stringify(eventData)); @@ -30,14 +29,13 @@ struct QrCode { if (colorValue != null && colorValue.length != 0) { this.qrCodeColor = colorValue; console.info("qrCodeColor:" + qrCodeColor); - }else{ + } else { console.info("qrCodeColor is null or empty " + qrCodeColor); } } else { console.info("qrCode page color not change called:" + JSON.stringify(eventData)); } } - private stateChangCallBackTwo = (eventData) => { if (eventData != null) { console.info("qrCode page state change called:" + JSON.stringify(eventData)); @@ -45,7 +43,7 @@ struct QrCode { if (backgroundColorValue != null && backgroundColorValue.length != 0) { this.qrCodeBackgroundColor = backgroundColorValue; console.info("qrCodeBackgroundColor:" + qrCodeBackgroundColor); - }else{ + } else { console.info("backgroundColorValue is null or empty " + qrCodeColor); } } else { @@ -66,6 +64,30 @@ struct QrCode { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBackTwo); + + var stateChangeEvent = { + eventId: 1023, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent = { + eventId: 1024, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBack); + + var stateChangeEvent = { + eventId: 1025, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBackTwo); + + var stateChangeEvent = { + eventId: 1026, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent, this.stateChangCallBackTwo); } build() { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets index 4874ccc0650f51ccf70179af500409f1c7f0be20..d373f02ad0c43241a39d0d483e5ac59485286741 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/aboutToDisappear.ets @@ -19,21 +19,22 @@ import events_emitter from '@ohos.emitter' @Component struct ParentComp { @State isCountDown: boolean = true + build() { Column() { Text(this.isCountDown ? 'Count Down' : 'Stopwatch') if (this.isCountDown) { Image($rawfile('ic_health_heart.png')).width(50).height(50) - TimerComponent({counter: 10, changePerSec: -1, showInColor: Color.Red}) + TimerComponent({ counter: 10, changePerSec: -1, showInColor: Color.Red }) } else { Image($rawfile('ic_health_heart.png')).width(150).height(150) - TimerComponent({counter: 0, changePerSec: +1, showInColor: Color.Black }) + TimerComponent({ counter: 0, changePerSec: +1, showInColor: Color.Black }) } Button(this.isCountDown ? 'Swtich to Stopwatch' : 'Switch to Count Down') .onClick(() => { this.isCountDown = !this.isCountDown }) - .key('button1') + .key('button1') } } } @@ -43,8 +44,8 @@ struct TimerComponent { @State counter: number = 0 private changePerSec: number = -1 private showInColor: Color = Color.Black - private timerId : number = -1 - @State onActionCalled :boolean = false + private timerId: number = -1 + @State onActionCalled: boolean = false build() { Text(`${this.counter}sec`) @@ -52,7 +53,9 @@ struct TimerComponent { } aboutToAppear() { - this.timerId = setInterval(() => {this.counter += this.changePerSec}, 1000) + this.timerId = setInterval(() => { + this.counter += this.changePerSec + }, 1000) } aboutToDisappear() { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/animate.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/animate.ets index f85cc77ae5f0a927581d83d95825e490ca315ded..ead619b2032ef7f34d1d3b55ecec627f377a231e 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/animate.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/animate.ets @@ -19,19 +19,79 @@ import events_emitter from '@ohos.emitter' @Component struct AnimationExample { @State btn1: boolean = false - @State duration:number = 100 - @State curve:string = 'Ease' - @State iteration:number = 1 - @State tempo:number= 1000 - @State playmode:PlayMode = PlayMode.Normal + @State duration: number = 100 + @State curve: string = 'Ease' + @State iteration: number = 1 + @State tempo: number= 1000 + @State playmode: PlayMode = PlayMode.Normal - onPageShow(){ + onPageShow() { console.info('animate page show called'); var stateChangeEvent = { eventId: 50, - priority:events_emitter.EventPriority.LOW + priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBack) + + var stateChangeEventa = { + eventId: 1011, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventa, this.stateChangCallBack) + + var stateChangeEventb = { + eventId: 1012, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventb, this.stateChangCallBack) + + var stateChangeEventc = { + eventId: 1013, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventc, this.stateChangCallBack) + + var stateChangeEventd = { + eventId: 1014, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventd, this.stateChangCallBack) + + var stateChangeEvente = { + eventId: 1015, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvente, this.stateChangCallBack) + + var stateChangeEventf = { + eventId: 1016, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventf, this.stateChangCallBack) + + var stateChangeEventg = { + eventId: 1017, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventg, this.stateChangCallBack) + + var stateChangeEventh = { + eventId: 1018, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventh, this.stateChangCallBack) + + var stateChangeEventi = { + eventId: 1019, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventi, this.stateChangCallBack) + + var stateChangeEventj = { + eventId: 1020, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventj, this.stateChangCallBack) } private stateChangCallBack = (eventData) => { @@ -56,8 +116,12 @@ struct AnimationExample { } build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,}) { - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:20}) + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }) { + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) .key('button1') .onClick(() => { try { @@ -77,11 +141,15 @@ struct AnimationExample { } console.info("button1 animateTo START") console.info("button1 duration value is : " + this.duration) - animateTo({duration:this.duration}, () => { - console.info("button1 duration test animateTo START") + animateTo({ duration: this.duration }, () => { + console.info("button1 duration test animateTo START") }) }) - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:20}) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) .key('button2') .onClick(() => { try { @@ -101,11 +169,15 @@ struct AnimationExample { } console.info("button2 animateTo START") console.info("button2 curve value is : " + this.curve) - animateTo({ curve:this.curve }, () => { + animateTo({ curve: this.curve }, () => { console.info("button2 curve test animateTo START") }) }) - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:20}) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) .key('button3') .onClick(() => { try { @@ -125,11 +197,15 @@ struct AnimationExample { } console.info("button3 animateTo START") console.info("button3 iteration value is : " + this.iteration) - animateTo({ iterations:this.iteration }, () => { + animateTo({ iterations: this.iteration }, () => { console.info("button3 iterations test animateTo START") }) }) - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:20}) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) .key('button4') .onClick(() => { try { @@ -149,11 +225,15 @@ struct AnimationExample { } console.info("button4 animateTo START") console.info("button4 tempo value is : " + this.duration) - animateTo({ tempo:this.tempo }, () => { + animateTo({ tempo: this.tempo }, () => { console.info("button4 tempo test animateTo START") }) }) - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:20}) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) .key('button5') .onClick(() => { try { @@ -173,10 +253,290 @@ struct AnimationExample { } console.info("button5 animateTo START") console.info("button5 playmode value is : " + this.playmode) - animateTo({ PlayMode:this.playmode }, () => { + animateTo({ PlayMode: this.playmode }, () => { console.info("button5 playMode test animateTo START") }) }) - }.height(400).width("100%").padding({top:100}) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button6') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1001, + priority: events_emitter.EventPriority.LOW + } + console.info("button6 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button6 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button6 animateTo START") + console.info("button6 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button6 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button7') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1002, + priority: events_emitter.EventPriority.LOW + } + console.info("button7 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button7 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button7 animateTo START") + console.info("button7 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button7 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button8') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1003, + priority: events_emitter.EventPriority.LOW + } + console.info("button8 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button8 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button8 animateTo START") + console.info("button8 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button8 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button9') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1004, + priority: events_emitter.EventPriority.LOW + } + console.info("button9 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button9 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button9 animateTo START") + console.info("button9 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button9 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button10') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1005, + priority: events_emitter.EventPriority.LOW + } + console.info("button10 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button10 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button10 animateTo START") + console.info("button10 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button10 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button11') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1006, + priority: events_emitter.EventPriority.LOW + } + console.info("button11 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button11 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button11 animateTo START") + console.info("button11 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button11 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button12') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1007, + priority: events_emitter.EventPriority.LOW + } + console.info("button12 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button12 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button12 animateTo START") + console.info("button12 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button12 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button13') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1008, + priority: events_emitter.EventPriority.LOW + } + console.info("button13 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button13 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button13 animateTo START") + console.info("button13 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button13 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button14') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1009, + priority: events_emitter.EventPriority.LOW + } + console.info("button14 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button14 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button14 animateTo START") + console.info("button14 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button14 duration test animateTo START") + }) + }) + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 20 }) + .key('button15') + .onClick(() => { + try { + var backData = { + data: { + "duration": this.duration, + } + } + var backEvent = { + eventId: 1010, + priority: events_emitter.EventPriority.LOW + } + console.info("button15 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button15 emit action state err: " + JSON.stringify(err.message)) + } + console.info("button15 animateTo START") + console.info("button15 duration value is : " + this.duration) + animateTo({ duration: this.duration }, () => { + console.info("button15 duration test animateTo START") + }) + }) + }.height(400).width("100%").padding({ top: 100 }) } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/background.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/background.ets index ffacec28f99bf2bc3e735a7fcd87fe3ec6041ba3..68f46093f24ff1278b3c5d8706228ea071e3f3dd 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/background.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/background.ets @@ -21,38 +21,36 @@ struct BackgroundExample { @State width: string = "200px"; @State height: string = "200px"; @State color: Array = [[0x080808], [0xEEEE00], [0xFF0000]]; - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("gauge page state change called:" + JSON.stringify(eventData)); - if(eventData.data.colorValues != null) { + if (eventData.data.colorValues != null) { this.colorValues = JSON.parse(eventData.data.colorValues); } - if(eventData.data.width != null) { + if (eventData.data.width != null) { this.width = eventData.data.width; } - if(eventData.data.height != null) { + if (eventData.data.height != null) { this.height = eventData.data.height; } - if(eventData.data.srcValue != null) { + if (eventData.data.srcValue != null) { this.srcValue = eventData.data.srcValue; } } } - private stateChangCallBackTwo = (eventData) => { if (eventData != null) { console.info("Background page state change called:" + JSON.stringify(eventData)); - if(eventData.data.backgroundColor != null) { + if (eventData.data.backgroundColor != null) { this.backgroundColor = eventData.data.backgroundColor; } - if(eventData.data.backgroundImage != null) { + if (eventData.data.backgroundImage != null) { this.backgroundImage = eventData.data.backgroundImage; } - if(eventData.data.backgroundImageSize != null) { + if (eventData.data.backgroundImageSize != null) { this.backgroundImageSize = eventData.data.backgroundImageSize; } - if(eventData.data.backgroundImagePosition != null) { + if (eventData.data.backgroundImagePosition != null) { this.backgroundImagePosition = eventData.data.backgroundImagePosition; } } @@ -76,7 +74,12 @@ struct BackgroundExample { build() { Column({ space: 5 }) { Text('background color').fontSize(9).width('90%').fontColor(0xFF0000).key("fontColor") - Row().width('90%').height(50).backgroundColor(0xEEEE00).key("backgroundColor").border({ width: 1 }) + Row() + .width('90%') + .height(50) + .backgroundColor(0xEEEE00) + .key("backgroundColor") + .border({ width: 1 }) Text('background image repeat along X').fontSize(9).width('90%').fontColor(0xCCCCCC) Row() .backgroundImage('/images/bg.jpg', ImageRepeat.X) @@ -93,7 +96,8 @@ struct BackgroundExample { .border({ width: 1 }) Text('background image size').fontSize(9).width('90%').fontColor(0xFF0000) Row() - .width('90%').height(150) + .width('90%') + .height(150) .backgroundImage('/images/bg.jpg', ImageRepeat.NoRepeat) .backgroundImageSize({ width: 1000, height: 500 }) .border({ width: 1 }) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/badge.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/badge.ets index ab5d881c974a092cde4602a1ad480a416c717bb1..5689112e307eb864df7e6a11fb5cc9b544426c3d 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/badge.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/badge.ets @@ -22,7 +22,6 @@ struct BadgeExample { @State message: string = 'new'; @State fontSizeValue: number = 20; @State colorValue: Color = Color.Red; - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Badge page state change called:" + JSON.stringify(eventData)); @@ -45,6 +44,16 @@ struct BadgeExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBack); + var stateChangeEventOne = { + eventId: 64, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack); + var stateChangeEventTwo = { + eventId: 65, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack); } build() { @@ -58,7 +67,10 @@ struct BadgeExample { .onClick(() => { this.counts++ }) - .width(200).height(100).backgroundColor(0x317aff).fontSize(20) + .width(200) + .height(100) + .backgroundColor(0x317aff) + .fontSize(20) }.width(100).height(50).key('badge') Badge({ @@ -66,8 +78,13 @@ struct BadgeExample { style: { color: this.colorValue, fontSize: 9, badgeSize: 20, badgeColor: Color.Red } }) { Text('message') - .width(80).height(50).fontSize(16).lineHeight(37) - .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) + .width(80) + .height(50) + .fontSize(16) + .lineHeight(37) + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(0xF3F4ED) }.width(80).height(50).key('badge2') Badge({ @@ -76,8 +93,13 @@ struct BadgeExample { style: { badgeSize: 6, badgeColor: Color.Red } }) { Text('message') - .width(90).height(50).fontSize(16).lineHeight(37) - .borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) + .width(90) + .height(50) + .fontSize(16) + .lineHeight(37) + .borderRadius(10) + .textAlign(TextAlign.Center) + .backgroundColor(0xF3F4ED) }.width(90).height(50) }.width('100%').margin({ top: 5 }) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/blank.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/blank.ets index c79701d659222fdea085eac9d662447e3628f68f..03ca647fa8247d98e199bfc80977812b29837f8c 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/blank.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/blank.ets @@ -19,7 +19,6 @@ import events_emitter from '@ohos.emitter'; @Component struct BlankExample { @State colorValue: Color = Color.Blue; - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Blank page state change called:" + JSON.stringify(eventData)); @@ -30,7 +29,7 @@ struct BlankExample { } onPageShow() { - console.info('Blank page show called'); + console.info('Blank page1 show called'); var stateChangeEvent = { eventId: 69, priority: events_emitter.EventPriority.LOW @@ -44,7 +43,10 @@ struct BlankExample { Text('Bluetooth').fontSize(18) Blank().color(this.colorValue).key('blank') Toggle({ type: ToggleType.Switch }) - }.width('100%').backgroundColor(0xFFFFFF).borderRadius(15).padding({ left: 12 }) + }.width('100%') + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .padding({ left: 12 }) }.backgroundColor(0xEFEFEF).padding(20) } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/button.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/button.ets index 95fe6076cb47385deee3f8b6986c9534e2672e2e..b27d27c5ebca07d06cf8cb06b29dac0d91de8f80 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/button.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/button.ets @@ -23,7 +23,6 @@ struct ButtonExample { @State fontColorValue: Color = Color.Black; @State text: string = ''; @State onClickValue: boolean = false; - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("Button page state change called:" + JSON.stringify(eventData)); @@ -46,76 +45,105 @@ struct ButtonExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBack); + var stateChangeEventOne = { + eventId: 74, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack); + var stateChangeEventTwo = { + eventId: 75, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack); + var stateChangeEventThree = { + eventId: 76, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventThree, this.stateChangCallBack); } build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { - Button('Ok', { type: this.buttonTypeValue, stateEffect: true }) - .borderRadius(8).backgroundColor(0x317aff).width(90).key('button') - Button('ok').type(`${this.buttonTypeValue}`).key('button1') - .backgroundColor(0x317aff).width(90) - Button('ok').type(this.buttonTypeValue).key('button2').fontSize(this.fontSizeValue) - .backgroundColor(0x317aff).width(90).fontColor(this.fontColorValue) - .onClick(() => { - try { - var backData = { - data: { - "fontColorValue": this.fontColorValue, - } - } - var backEvent = { - eventId: 71, - priority: events_emitter.EventPriority.LOW - } - console.info("button2 start to emit action state") - events_emitter.emit(backEvent, backData) - } catch (err) { - console.info("button2 emit action state err: " + JSON.stringify(err.message)) - } - }) - Button('ok!').type(this.buttonTypeValue).key('button3').fontColor(this.fontColorValue) - .backgroundColor(0x317aff).width(90) - .onClick(() => { - try { - var backData = { - data: { - "fontColorValue": this.fontColorValue, - } - } - var backEvent = { - eventId: 72, - priority: events_emitter.EventPriority.LOW - } - console.info("button3 start to emit action state") - events_emitter.emit(backEvent, backData) - } catch (err) { - console.info("button3 emit action state err: " + JSON.stringify(err.message)) - } - }) - Button('Click').backgroundColor(0x2788D9).width(200).height(100).fontSize(20) - .onClick((event: ClickEvent) => { - console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY - + '\n x :' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' - + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' - + event.target.area.width + '\n height:' + event.target.area.height); - this.onClickValue = true; - try { - var backData = { - data: { - "ACTION": this.onClickValue, - "event": JSON.stringify(event) - } - } - var backEvent = { - eventId: 4, - priority: events_emitter.EventPriority.LOW - } - console.info("click to emit action state") - events_emitter.emit(backEvent, backData) - } catch (err) { - console.info("click action state err: " + JSON.stringify(err.message)) - } - }).key('buttonClick') + Button('Ok', { type: this.buttonTypeValue, stateEffect: true }) + .borderRadius(8).backgroundColor(0x317aff).width(90).key('button') + Button('ok').type(`${this.buttonTypeValue}`).key('button1') + .backgroundColor(0x317aff).width(90) + Button('ok') + .type(this.buttonTypeValue) + .key('button2') + .fontSize(this.fontSizeValue) + .backgroundColor(0x317aff) + .width(90) + .fontColor(this.fontColorValue) + .onClick(() => { + try { + var backData = { + data: { + "fontColorValue": this.fontColorValue, + } + } + var backEvent = { + eventId: 71, + priority: events_emitter.EventPriority.LOW + } + console.info("button2 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button2 emit action state err: " + JSON.stringify(err.message)) + } + }) + Button('ok!') + .type(this.buttonTypeValue) + .key('button3') + .fontColor(this.fontColorValue) + .backgroundColor(0x317aff) + .width(90) + .onClick(() => { + try { + var backData = { + data: { + "fontColorValue": this.fontColorValue, + } + } + var backEvent = { + eventId: 72, + priority: events_emitter.EventPriority.LOW + } + console.info("button3 start to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("button3 emit action state err: " + JSON.stringify(err.message)) + } + }) + Button('Click') + .backgroundColor(0x2788D9) + .width(200) + .height(100) + .fontSize(20) + .onClick((event: ClickEvent) => { + console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY + + '\n x :' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:(' + + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' + + event.target.area.width + '\n height:' + event.target.area.height); + this.onClickValue = true; + try { + var backData = { + data: { + "ACTION": this.onClickValue, + "event": JSON.stringify(event) + } + } + var backEvent = { + eventId: 4, + priority: events_emitter.EventPriority.LOW + } + console.info("click to emit action state") + events_emitter.emit(backEvent, backData) + } catch (err) { + console.info("click action state err: " + JSON.stringify(err.message)) + } + }) + .key('buttonClick') }.height(400).padding({ left: 35, right: 35, top: 35 }) } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas.ets index ea4f5bd8a48219c0a23f769187415cd9ffe4bb77..ec3b88f33d50571aadf86702741b68c699dc4f91 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas.ets @@ -93,21 +93,26 @@ struct CanvasExample { .width('100%') .height('100%') } + onPageShow() { } + fillStyle() { this.context.fillStyle = '#0000ff'; this.context.fillRect(20, 120, 75, 55); } + lineWidth() { this.context.lineWidth = 5; this.context.strokeRect(25, 25, 55, 75); } + strokeStyle() { this.context.lineWidth = 10; this.context.strokeStyle = '#0000ff'; this.context.strokeRect(115, 25, 75, 55); } + lineCap() { this.context.lineWidth = 8; this.context.beginPath(); @@ -116,6 +121,7 @@ struct CanvasExample { this.context.lineTo(320, 50); this.context.stroke(); } + lineJoin() { this.context.beginPath(); this.context.lineWidth = 8; @@ -125,6 +131,7 @@ struct CanvasExample { this.context.lineTo(370, 75); this.context.stroke(); } + miterLimit() { this.context.lineWidth = 8; this.context.lineJoin = 'miter'; @@ -134,10 +141,12 @@ struct CanvasExample { this.context.lineTo(130, 162); this.context.stroke(); } + font() { this.context.font = '20px sans-serif'; this.context.fillText("Hello World", 250, 170); } + textAlign() { let height = 230; this.context.strokeStyle = '#0000ff'; @@ -156,6 +165,7 @@ struct CanvasExample { this.context.textAlign = 'right'; this.context.fillText('textAlign=right', 210, 200 + height); } + textBaseline() { let height = 550; this.context.strokeStyle = '#0000ff'; @@ -174,6 +184,7 @@ struct CanvasExample { this.context.textBaseline = 'hanging'; this.context.fillText('Hanging', 450, height + 10); } + globalAlpha() { this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillRect(0, 620, 50, 50); @@ -181,14 +192,16 @@ struct CanvasExample { this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillRect(50, 670, 50, 50); } + lineDashOffset() { this.context.globalAlpha = 1; this.context.beginPath(); this.context.arc(180, 650, 50, 0, 6.28); - this.context.setLineDash([10,20]); + this.context.setLineDash([10, 20]); this.context.stroke(); this.context.setLineDash([0, 0]); } + globalCompositeOperation() { let height = 600; let width = 260; @@ -204,18 +217,21 @@ struct CanvasExample { this.context.fillRect(150 + width, 50 + height, 50, 50); this.context.globalCompositeOperation = 'source-over'; } + shadowBlur() { this.context.shadowBlur = 30; this.context.shadowColor = 'rgb(0,0,0)'; this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillRect(10, 800, 100, 80); } + shadowColor() { this.context.shadowBlur = 30; this.context.shadowColor = 'rgb(0,0,255)'; this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillRect(150, 800, 80, 100); } + shadowOffsetX() { this.context.shadowBlur = 10; this.context.shadowOffsetX = 20; @@ -224,6 +240,7 @@ struct CanvasExample { this.context.fillRect(250, 800, 80, 80); this.resetShadow(true); } + shadowOffsetY() { this.context.shadowBlur = 10; this.context.shadowOffsetY = 20; @@ -232,6 +249,7 @@ struct CanvasExample { this.context.fillRect(360, 800, 80, 80); this.resetShadow(false); } + resetShadow(isX) { this.context.shadowBlur = 0; if (isX) { @@ -240,40 +258,49 @@ struct CanvasExample { this.context.shadowOffsetY = 0; } } + imageSmoothingEnabled() { let img = new ImageBitmap('/images/img.jpeg'); this.context.imageSmoothingEnabled = false; - this.context.drawImage( img, 30, 950, 160, 100); + this.context.drawImage(img, 30, 950, 160, 100); } + imageSmoothingQuality() { let img = new ImageBitmap('/images/img.jpeg'); this.context.imageSmoothingQuality('high'); - this.context.drawImage( img, 30, 950, 160, 100); + this.context.drawImage(img, 30, 950, 160, 100); } + fillRect() { this.context.fillRect(10, 1080, 80, 80); } + strokeRect() { this.context.strokeRect(110, 1080, 100, 60); } + clearRect() { this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillRect(240, 950, 200, 200); this.context.clearRect(260, 970, 100, 60); } + fillText() { this.context.font = '20px sans-serif'; this.context.fillText("Hello World!", 120, 1200); } + strokeText() { this.context.font = '20px sans-serif'; this.context.strokeText("Hello World!", 260, 1195); } + measureText() { this.context.font = '20px sans-serif'; this.context.fillText("Hello World!", 120, 1250); this.context.fillText("width:" + this.context.measureText("Hello World!").width, 310, 1250); } + beginPath() { this.context.beginPath(); this.context.lineWidth = 6; @@ -282,6 +309,7 @@ struct CanvasExample { this.context.lineTo(450, 1260); this.context.stroke(); } + closePath() { this.context.beginPath(); this.context.moveTo(30, 1300); @@ -290,12 +318,14 @@ struct CanvasExample { this.context.closePath(); this.context.stroke(); } + createPattern() { let img = new ImageBitmap('/images/ic_health_heart.png'); let pattern = this.context.createPattern(img, 'repeat'); this.context.fillStyle = pattern; this.context.fillRect(140, 1300, 250, 100); } + bezierCurveTo() { let height = 1400; this.context.beginPath(); @@ -303,6 +333,7 @@ struct CanvasExample { this.context.bezierCurveTo(20, 100 + height, 200, 100 + height, 200, 20 + height); this.context.stroke(); } + quadraticCurveTo() { let height = 1400; let width = 210; @@ -311,20 +342,24 @@ struct CanvasExample { this.context.quadraticCurveTo(100 + width, 100 + height, 200 + width, 20 + height); this.context.stroke(); } + arcTo() { this.context.moveTo(30, 20 + 1500); this.context.arcTo(80, 20 + 1500, 80, 70 + 1500, 50); this.context.stroke(); } + rect() { this.context.rect(130, 20 + 1500, 80, 80); this.context.stroke(); } + rotate() { this.context.rotate(45 * Math.PI / 180); this.context.fillRect(180, 20, 50, 50); this.context.rotate(-45 * Math.PI / 180); } + transform() { this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillRect(250, 1500, 100, 100); @@ -335,6 +370,7 @@ struct CanvasExample { this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillRect(250, 1500, 100, 100); } + setTransform() { this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillRect(0, 1650, 100, 100); @@ -343,46 +379,56 @@ struct CanvasExample { this.context.fillRect(0, 1650, 100, 100); this.context.setTransform(1, 0, 0, 1, 0, 0); } + getTransform() { let data = this.context.getTransform(); console.info("[canvas] get transform----" + data); } + resetTransform() { this.context.resetTransform(); } + translate() { this.context.fillRect(180, 1650, 50, 50); this.context.translate(50, 50); this.context.fillRect(180, 1650, 50, 50); } + drawImage() { let img = new ImageBitmap('/images/img.jpeg'); this.context.drawImage(img, 0, 0, 500, 500, 0, 1780, 200, 100); } + createImageData() { let imageData = this.context.createImageData(100, 100); console.info("[canvas] create image data-----" + JSON.stringify(imageData)); } + createImageDataByImageData() { let imageData = this.context.createImageData(50, 50); let imgData = this.context.createImageData(imageData); console.info("[canvas] create image data by image data----" + JSON.stringify(imgData)); } + getImageData() { let imageData = this.context.getImageData(10, 10, 80, 80); let data = imageData.data; console.info("[canvas] get image data-----" + JSON.stringify(data)); } + getImageWidth() { let imageData = this.context.getImageData(10, 10, 80, 80); let width = imageData.width; console.info("[canvas] get image width-----" + width); } + getImageHeight() { let imageData = this.context.getImageData(10, 10, 80, 80); let height = imageData.height; console.info("[canvas] get image height-----" + height); } + putImageData() { let imageData = this.context.createImageData(80, 80); for (var i = 0; i < imageData.data.length; i += 4) { @@ -393,6 +439,7 @@ struct CanvasExample { } this.context.putImageData(imageData, 250, 1660); } + createLinearGradient() { let grad = this.context.createLinearGradient(50, 1900, 150, 2000); grad.addColorStop(0.0, 'red'); @@ -401,6 +448,7 @@ struct CanvasExample { this.context.fillStyle = grad; this.context.fillRect(10, 1900, 150, 150); } + createRadialGradient() { let grad = this.context.createRadialGradient(280, 1970, 40, 280, 1970, 80); grad.addColorStop(0.0, 'red'); @@ -410,60 +458,73 @@ struct CanvasExample { this.context.fillRect(200, 1900, 150, 150); this.context.closePath(); } + restore() { this.context.restore(); } + save() { this.context.save(); } + addPath() { let path2Da = new Path2D("M250 150 L150 350 L350 350 Z"); let path2Db = new Path2D(); path2Db.addPath(path2Da); this.context.stroke(path2Db); } + lineDash() { this.context.beginPath(); this.context.arc(20, 2130, 50, 0, 6.28); this.context.setLineDash([10, 20]); this.context.stroke(); } + toDataURL() { let dataUrl = this.context.toDataURL(); console.info("[canvas] canvas rendering context2D toDataURL-----" + JSON.stringify(dataUrl)); } + getWidth() { let width = this.context.width; console.info("[canvas] canvas width---" + width); } + getHeight() { let height = this.context.height; console.info("[canvas] canvas height---" + height); } + fill() { this.context.beginPath(); this.context.rect(130, 2080, 100, 100); this.context.fill('nonzero'); } + direction() { this.context.direction('inherit'); } + textMetrics() { this.context.font = '20px sans-serif'; this.context.fillText("Hello World!", 120, 2150); let obj = this.context.measureText("Hello World!"); console.info("[canvas] textMetrics info---" + JSON.stringify(obj)); } + getBitImageSize() { let img = new ImageBitmap('/images/img.jpeg'); let width = img.width; let height = img.height; } + filter() { let img = new ImageBitmap('/images/img.jpeg'); this.context.filter('grayscale(50%)'); this.context.drawImage(img, 0, 0, 500, 500, 0, 2200, 200, 100); } + getLineDash() { this.context.beginPath(); this.context.setLineDash([10, 20]); @@ -472,9 +533,11 @@ struct CanvasExample { this.context.stroke(); let obj = this.context.getLineDash(); } + setPixelMap() { this.context.setPixelMap(); } + getPixelMap() { let pixelMap = this.context.getPixelMap(10, 10, 80, 80); console.info("[canvas] getPixelMap ----" + JSON.stringify(pixelMap)); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas2.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas2.ets index d8bed84410da0f12e3c1e9b9833bb2d9a0bf578f..4ded364a67810ca63d7cf9bf70b26542d0357a5f 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas2.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/canvas2.ets @@ -42,14 +42,17 @@ struct Canvas2Example { .width('100%') .height('100%') } + onPageShow() { } + transferFromImageBitmap() { this.offContext.fillStyle = '#0000ff'; this.offContext.fillRect(20, 160, 150, 100); let image = this.offContext.transferToImageBitmap(); this.context.transferFromImageBitmap(image); } + offScreenToDataURL() { let dataUrl = this.offContext.toDataURL(); console.info("[canvas] offContext canvas rendering context2D toDataURL-----" + JSON.stringify(dataUrl)); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/circle.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/circle.ets index be8adf01e138b31806692fb0c851d80b1814402b..465e99994d540fb4ee5236862b5334d1f3d4f352 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/circle.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/circle.ets @@ -20,6 +20,7 @@ import events_emitter from '@ohos.emitter'; struct CircleExample { @State width: string = "450px"; @State height: string = "450px"; + onPageShow() { console.info('[circle] page show called'); var stateChangeEvent = { @@ -29,18 +30,20 @@ struct CircleExample { console.info('[circle] page show calledA'); events_emitter.on(stateChangeEvent, this.stateChangCallBack); } + private stateChangCallBack = (eventData) => { console.info("[circle] page stateChangCallBack"); if (eventData != null) { console.info("[circle] page state change called:" + JSON.stringify(eventData)); - if(eventData.data.width != null) { - this.width = eventData.data.width; - } - if(eventData.data.height != null) { + if (eventData.data.height != null) { this.height = eventData.data.height; } + if (eventData.data.width != null) { + this.width = eventData.data.width; + } } } + build() { Flex({ justifyContent: FlexAlign.SpaceAround }) { Circle({ width: 150, height: 150 }) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/index.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/index.ets index a9c75c7154b8b5d6f5f76b1cf05cff275d4386f4..37b15e7fea935833b2cd00be9193343de3c94eb5 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/index.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/index.ets @@ -14,7 +14,6 @@ * limitations under the License. */ import file from '@system.file'; - import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; import testsuite from "../test/List.test.ets"; import featureAbility from "@ohos.ability.featureAbility"; diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/line.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/line.ets index f076af847697114279a039f2f144954e6049bd71..3b14d92b0f2817342d49ac1e0bf129c7453469cd 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/line.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/line.ets @@ -18,12 +18,13 @@ import events_emitter from '@ohos.emitter' @Entry @Component struct LineExample { - @State startPoint:Point = [0,0] - @State endPoint:Point = [50,100] + @State startPoint: Point = [0, 0] + @State endPoint: Point = [50, 100] + build() { Column() { Line({ width: 50, height: 100 }).startPoint(this.startPoint).endPoint(this.endPoint) - .key('line') + .key('line') }.margin({ top: 5 }) } @@ -36,12 +37,12 @@ struct LineExample { if (eventData.data.startPointOne != null) { this.startPoint[1] = eventData.data.startPointOne; } - if (eventData.data.endPoint != null) { - this.endPoint[0] = eventData.data.endPoint; - } if (eventData.data.endPointOne != null) { this.endPoint[1] = eventData.data.endPointOne; } + if (eventData.data.endPoint != null) { + this.endPoint[0] = eventData.data.endPoint; + } } } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/longPressGesture.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/longPressGesture.ets index 8f5a50f9f1f0810c3e080612cfd605362631611c..9b56f81a43531a7002ce43606d863a4cc41f981d 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/longPressGesture.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/longPressGesture.ets @@ -25,52 +25,56 @@ struct LongPressGestureExample { Text('LongPress onAction:' + this.eventString).fontSize(20) } .key('flex') - .height(200).width(300).padding(60).border({ width:1 }).margin(30) + .height(200) + .width(300) + .padding(60) + .border({ width: 1 }) + .margin(30) .gesture( - LongPressGesture({ repeat: true }) - .onAction(() => { - console.info("longPressGesture current action onAction") - this.eventString = 'onAction'; - console.info('onAction current action state is: ' + this.eventString); - try { - let backData = { - data: { - "ACTION": this.eventString, - } + LongPressGesture({ repeat: true }) + .onAction(() => { + console.info("longPressGesture current action onAction") + this.eventString = 'onAction'; + console.info('onAction current action state is: ' + this.eventString); + try { + let backData = { + data: { + "ACTION": this.eventString, } - let backEvent = { - eventId: 125, - priority: events_emitter.EventPriority.LOW - } - console.info("start to emit action state"); - events_emitter.emit(backEvent, backData); - } catch (err) { - console.info("emit action state err: " + JSON.stringify(err.message)); } - }) - .onActionEnd(() => { - console.info("longPressGesture current action end") - this.eventString = 'onActionEnd'; - console.info('onActionEnd current action state is: ' + this.eventString); - try { - let backData = { - data: { - "ACTION": this.eventString, - } - } - let backEvent = { - eventId: 126, - priority: events_emitter.EventPriority.LOW + let backEvent = { + eventId: 125, + priority: events_emitter.EventPriority.LOW + } + console.info("start to emit action state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit action state err: " + JSON.stringify(err.message)); + } + }) + .onActionEnd(() => { + console.info("longPressGesture current action end") + this.eventString = 'onActionEnd'; + console.info('onActionEnd current action state is: ' + this.eventString); + try { + let backData = { + data: { + "ACTION": this.eventString, } - console.info("start to emit action state"); - events_emitter.emit(backEvent, backData); - } catch (err) { - console.info("emit action state err: " + JSON.stringify(err.message)); } - }) - .onActionCancel(() => { - console.info("longPressGesture current action cancel"); - }) + let backEvent = { + eventId: 126, + priority: events_emitter.EventPriority.LOW + } + console.info("start to emit action state"); + events_emitter.emit(backEvent, backData); + } catch (err) { + console.info("emit action state err: " + JSON.stringify(err.message)); + } + }) + .onActionCancel(() => { + console.info("longPressGesture current action cancel"); + }) ) } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/motionPath.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/motionPath.ets index 0ef8f33d2997f1abf476865cfcc216d95c3890da..2214f6166adfd7c71efa9a153d7ba4958597428a 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/motionPath.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/motionPath.ets @@ -22,15 +22,15 @@ struct MotionPathExample { @State offsetY: number = 0 @State toggle: boolean = true @State rotatable: boolean = false - @State path:string='Mstart.x start.y L300 200 L300 500 Lend.x end.y' - @State fromX:number = 0 - @State toY:number = 1 + @State path: string= 'Mstart.x start.y L300 200 L300 500 Lend.x end.y' + @State fromX: number = 0 + @State toY: number = 1 build() { Column() { Button('click me') .key('button') - .motionPath({ path: this.path, from: this.fromX, to: this.toY, rotatable:this.rotatable }) + .motionPath({ path: this.path, from: this.fromX, to: this.toY, rotatable: this.rotatable }) .onClick(() => { this.rotatable = true; console.info('button rotate current action state is:' + this.rotatable); @@ -79,22 +79,22 @@ struct MotionPathExample { .width('100%').height('100%').alignItems(this.toggle ? HorizontalAlign.Start : HorizontalAlign.Center) } - onPageShow(){ + onPageShow() { console.info('motionPath page show called'); var stateChangeEvent = { - eventId:134, + eventId: 134, priority: events_emitter.EventPriority.LOW } - events_emitter.on(stateChangeEvent,this.stateChangeCallBack) + events_emitter.on(stateChangeEvent, this.stateChangeCallBack) } - private stateChangeCallBack = (eventData) =>{ - if(eventData != null){ + private stateChangeCallBack = (eventData) => { + if (eventData != null) { console.info('motionPath page state change called:' + JSON.stringify(eventData)); - if(eventData.data.fromX != null){ + if (eventData.data.fromX != null) { this.fromX == parseInt(eventData.data.fromX); } - if(eventData.data.toY != null){ + if (eventData.data.toY != null) { this.toY == parseInt(eventData.data.toY); } } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/parallelGesture.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/parallelGesture.ets index 8b8151cc00e562dc8483f18d4d89f87c0f75f07f..aaae520e91c376eec7f168eb069896478e9caa3c 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/parallelGesture.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/parallelGesture.ets @@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter' @Component struct GestureSettingsExample { @State value: string = '' + build() { Column() { Text('Click\n' + this.value).gesture(TapGesture() @@ -44,7 +45,11 @@ struct GestureSettingsExample { .key('tapGesture') } .key('parallelGesture') - .height(200).width(300).padding(60).border({ width: 1 }).margin(30) + .height(200) + .width(300) + .padding(60) + .border({ width: 1 }) + .margin(30) .priorityGesture( TapGesture() .onAction(() => { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/priorityGesture.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/priorityGesture.ets index e96f32efb1ff53cbae17cc8998c4acda65f00bca..c6af0405aee537beec93ae0ee379be1e69c3caab 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/priorityGesture.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/priorityGesture.ets @@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter' @Component struct GestureSettingsExample { @State value: string = '' + build() { Column() { Text('Click\n' + this.value).gesture(TapGesture() @@ -43,7 +44,11 @@ struct GestureSettingsExample { ) .key('tapGesture') } - .height(200).width(300).padding(60).border({ width: 1 }).margin(30) + .height(200) + .width(300) + .padding(60) + .border({ width: 1 }) + .margin(30) .priorityGesture( TapGesture() .onAction(() => { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/progress.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/progress.ets index b5c05681f18f9405f049039a22a20ed81cfc10cb..0b62097bae34987e0a109f3734e642d2bcef84c6 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/progress.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/progress.ets @@ -22,15 +22,14 @@ struct ProgressExample { @State value: number = 20 @State total: number = 100 @State style: ProgressStyle = ProgressStyle.Linear - private stateChangCallBack = (eventData) => { console.info("progress page stateChangCallBack"); if (eventData != null) { console.info("progress page state change called:" + JSON.stringify(eventData)); - if(eventData.data.value != null) { + if (eventData.data.value != null) { this.value = eventData.data.value; } - if(eventData.data.total != null) { + if (eventData.data.total != null) { this.total = eventData.data.total; } } @@ -73,6 +72,16 @@ struct ProgressExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEventSix, this.stateChangCallBack) + var stateChangeEventseven = { + eventId: 1021, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventseven, this.stateChangCallBack) + var stateChangeEventeight = { + eventId: 1022, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventeight, this.stateChangCallBack) } build() { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/rating.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/rating.ets index fc4ae6d4d6f1ad604ba9c2b2a7f78a5e5ada775d..ae38386664de532e1414a83806aa85359653eca4 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/rating.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/rating.ets @@ -21,13 +21,11 @@ import events_emitter from '@ohos.emitter' struct RatingExample { @State rating: number = 1 @State indicator: boolean = false - - private stateChangCallBack = (eventData) => { console.info("rating page stateChangCallBack"); if (eventData != null) { console.info("rating page state change called:" + JSON.stringify(eventData.data.rating)); - if(eventData.data.rating != null) { + if (eventData.data.rating != null) { this.rating = eventData.data.rating; } } @@ -63,13 +61,25 @@ struct RatingExample { eventId: 177, priority: events_emitter.EventPriority.LOW } - events_emitter.on(stateChangeEventSix , this.stateChangCallBack) + events_emitter.on(stateChangeEventSix, this.stateChangCallBack) var stateChangeEventSeven = { eventId: 178, priority: events_emitter.EventPriority.LOW } - events_emitter.on(stateChangeEventSeven , this.stateChangCallBack) + events_emitter.on(stateChangeEventSeven, this.stateChangCallBack) + + var stateChangeEventSeven = { + eventId: 1027, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventSeven, this.stateChangCallBack) + + var stateChangeEventSeven = { + eventId: 1028, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventSeven, this.stateChangCallBack) } build() { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/scrollCode.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/scrollCode.ets index 3092b5e4e5cb0bc82995dd18516a52c86606c701..0b6dd2fbb842a1ef22702268960a6330d28818ef 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/scrollCode.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/scrollCode.ets @@ -22,44 +22,41 @@ struct scrollCode { @State scrollBar: BarState = BarState.On; @State scrollBarColor: Color = "#FF0000FF"; @State scrollBarWidth: number = 30; - scroller: Scroller = new Scroller() - private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("scrollCode page state change called:" + JSON.stringify(eventData)); var scrollableValue = eventData.data.scrollable; console.info("scrollableValue:" + scrollableValue); - if (scrollableValue!= null && scrollableValue.length != 0) { + if (scrollableValue != null && scrollableValue.length != 0) { this.scrollable = scrollableValue; console.info("this.scrollable:" + this.scrollable); - }else{ + } else { console.info("scrollableValue is null or empty " + scrollableValue); } var scrollBarValue = eventData.data.scrollBar; console.info("scrollBarValue:" + scrollBarValue); - if (scrollBarValue!= null && scrollBarValue.length != 0) { + if (scrollBarValue != null && scrollBarValue.length != 0) { this.scrollBar = scrollBarValue; console.info("this.scrollBar:" + this.scrollBar); - }else{ + } else { console.info("scrollBarValue is null or empty " + scrollBarValue); } var scrollBarColorValue = eventData.data.scrollBarColor; console.info("scrollBarColorValue:" + scrollBarColorValue); - if (scrollBarColorValue!= null && scrollBarColorValue.length != 0) { + if (scrollBarColorValue != null && scrollBarColorValue.length != 0) { this.scrollBarColor = scrollBarColorValue; console.info("this.scrollBarColor:" + this.scrollBarColor); - }else{ + } else { console.info("scrollBarColorValue is null or empty " + scrollBarColorValue); } var scrollBarWidthValue = eventData.data.scrollBarWidth; console.info("scrollBarWidthValue:" + scrollBarWidthValue); - if (scrollBarWidthValue!= null && scrollBarWidthValue.length != 0) { + if (scrollBarWidthValue != null && scrollBarWidthValue.length != 0) { this.scrollBarWidth = scrollBarWidthValue; console.info("this.scrollBarWidth:" + this.scrollBarWidth); - }else{ + } else { console.info("scrollBarWidthValue is null or empty " + scrollBarWidthValue); } } else { @@ -100,8 +97,12 @@ struct scrollCode { Column() { ForEach(this.arr, (item) => { Text(item.toString()) - .width('90%').height(150).backgroundColor(0xFFFFFF) - .borderRadius(15).fontSize(16).textAlign(TextAlign.Center) + .width('90%') + .height(150) + .backgroundColor(0xFFFFFF) + .borderRadius(15) + .fontSize(16) + .textAlign(TextAlign.Center) .margin({ top: 10 }) }, item => item) }.width('100%') @@ -120,6 +121,7 @@ struct scrollCode { .onScrollEnd(() => { console.info('Scroll Stop') }) + Button('scroll 100') .onClick(() => { this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }) @@ -129,7 +131,9 @@ struct scrollCode { this.scroller.scrollEdge(Edge.Top) }) .margin({ top: 120, left: 20 }) - Button('next page').backgroundColor(0x2788D9).fontSize(20) + Button('next page') + .backgroundColor(0x2788D9) + .fontSize(20) .onClick((event: ClickEvent) => { this.onClickValue = true; try { @@ -148,7 +152,11 @@ struct scrollCode { console.info("click action state err: " + JSON.stringify(err.message)) } this.scroller.scrollPage({ next: true }) - }).key('button').margin({ top: 10, left: 20 }) - }.width('100%').height('100%').backgroundColor(0xDCDCDC) + }) + .key('button') + .margin({ top: 10, left: 20 }) + }.width('100%') + .height('100%') + .backgroundColor(0xDCDCDC) } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/shape.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/shape.ets index 2a1ecb9d80241be4b99463c3a6308e1ee9ca4693..76bb1488f299c28b22580b4f2a7d02e2f0f35d36 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/shape.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/shape.ets @@ -28,7 +28,6 @@ struct ShapeExample { @State strokeDashArray: Array = [20]; @State fillOpacity: number = 0; @State strokeValue: Color = '#FF000000'; - private stateChangCallBack = (eventData) => { if (eventData != null) { console.info("text page state change called:" + JSON.stringify(eventData)); @@ -98,7 +97,7 @@ struct ShapeExample { .strokeWidth(this.strokeWidth) .antiAlias(this.antiAlias) .fillOpacity(this.fillOpacity) - .mesh([],1,1) + .mesh([], 1, 1) }.width('100%').margin({ top: 15 }) } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/sharedTransition.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/sharedTransition.ets index 83bd6c36762b2a49969c6861850f9112a885200b..41b68389691da513c07235662623144f555c8471 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/sharedTransition.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/sharedTransition.ets @@ -31,7 +31,7 @@ struct SharedTransitionExample { Row() { Navigator({ target: 'pages/sharedTransition2', type: NavigationType.Push }) { Image($rawfile('ic_health_heart.png')).width(50).height(50) - .sharedTransition('sharedImage1', { duration:this.duration , delay: this.delay , type: this.type}) + .sharedTransition('sharedImage1', { duration: this.duration, delay: this.delay, type: this.type }) } .key('Navigator') .padding({ left: 10 }) @@ -41,9 +41,9 @@ struct SharedTransitionExample { try { var backData = { data: { - "duration" : this.duration, - "delay" : this.delay, - "type" : this.type + "duration": this.duration, + "delay": this.delay, + "type": this.type } } var backEvent = { @@ -56,6 +56,7 @@ struct SharedTransitionExample { console.info("SharedTransition emit action state err: " + JSON.stringify(err.message)) } }) + Text('SharedTransition').width(80).height(80).textAlign(TextAlign.Center) } } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/span.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/span.ets index e51f96b9c48604530ee5bcbf03fbbbaa669598a2..763544f23daf1d81ef07861ecc716908e0b0ec74 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/span.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/span.ets @@ -18,11 +18,10 @@ import events_emitter from '@ohos.emitter' @Entry @Component struct SpanExample { - @State decorationValue:object={ type: TextDecorationType.None, color: Color.Red } - @State textCaseValue:TextCase=TextCase.Normal - @State fontSizeValue:number=40 + @State decorationValue: object= { type: TextDecorationType.None, color: Color.Red } + @State textCaseValue: TextCase= TextCase.Normal + @State fontSizeValue: number= 40 @State fontColorValue: Color= 0xCCCCCC - private stateChangCallBack = (eventData) => { console.info("span page state change called:" + JSON.stringify(eventData)); if (eventData != null) { @@ -57,6 +56,30 @@ struct SpanExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent3, this.stateChangCallBack); + + var stateChangeEvent4 = { + eventId: 1029, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent4, this.stateChangCallBack); + + var stateChangeEvent5 = { + eventId: 1030, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent5, this.stateChangCallBack); + + var stateChangeEvent6 = { + eventId: 1031, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent6, this.stateChangCallBack); + + var stateChangeEvent7 = { + eventId: 1032, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEvent7, this.stateChangCallBack); } build() { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tabs.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tabs.ets index 0d656f0583a583b2c90e09ae12b6e138ff31fbe8..37552ec6fae3169a63975c9c0ef63cec8f233212 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tabs.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tabs.ets @@ -31,7 +31,7 @@ struct TabsExample { build() { Column() { - Tabs({ barPosition: this.barPosition, controller: this.controller,index: this.index }) { + Tabs({ barPosition: this.barPosition, controller: this.controller, index: this.index }) { TabContent() { Column().width('100%').height('100%').backgroundColor(Color.Pink) }.tabBar('pink').key('tabContent1') @@ -54,12 +54,15 @@ struct TabsExample { console.info("tabContent1 emit action state err: " + JSON.stringify(err.message)) } }) + TabContent() { Column().width('100%').height('100%').backgroundColor(Color.Yellow) }.tabBar('yellow') + TabContent() { Column().width('100%').height('100%').backgroundColor(Color.Blue) }.tabBar('blue') + TabContent() { Column().width('100%').height('100%').backgroundColor(Color.Green) }.tabBar('green') @@ -89,6 +92,18 @@ struct TabsExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEvent, this.stateChangCallBack) + + var stateChangeEventOne = { + eventId: 214, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventOne, this.stateChangCallBack) + + var stateChangeEventTwo = { + eventId: 215, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventTwo, this.stateChangCallBack) } private stateChangCallBack = (eventData) => { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tapGesture.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tapGesture.ets index d920ce9c3a4aa9262b28a034723cfba383706b5c..e26b96a7818fc49bcc88cbfa5d17cd036c0604e1 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tapGesture.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/tapGesture.ets @@ -27,7 +27,11 @@ struct TapGestureExample { Text('Click twice') Text(this.value) } - .height(200).width(300).padding(60).border({ width: 1 }).margin(30) + .height(200) + .width(300) + .padding(60) + .border({ width: 1 }) + .margin(30) .gesture( TapGesture({ count: 2 }) .onAction(() => { @@ -49,6 +53,7 @@ struct TapGestureExample { console.info("click action state err: " + JSON.stringify(err.message)) } }) - ).key('tapGesture') + ) + .key('tapGesture') } } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/text.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/text.ets index 0af6246fd1a12803251a6ccee18fc7b69848da83..890a50a90049b53ab7ddcc482a0b0d161efe5eed 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/text.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/text.ets @@ -21,8 +21,9 @@ struct TextExample { @State fontSize: number = 9; @State fontColor: string = "0xCCCCCC"; @State textAlign: TextAlign = TextAlign.Start; - @State textOverflow : TextOverflow = TextOverflow.Clip; + @State textOverflow: TextOverflow = TextOverflow.Clip; @State decoration: TextDecorationType = TextDecorationType.None; + build() { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Text('lineHeightt') @@ -30,7 +31,7 @@ struct TextExample { .fontColor(this.fontColor) .textAlign(this.textAlign) .textOverflow({ overflow: this.textOverflow }) - .decoration({ type: this.decoration, color:Color.Red }) + .decoration({ type: this.decoration, color: Color.Red }) .key('text') Image($rawfile('test.png')) .key('image') @@ -65,6 +66,30 @@ struct TextExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEventThree, this.stateChangCallBack) + + var stateChangeEventFour = { + eventId: 230, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventFour, this.stateChangCallBack) + + var stateChangeEventFive = { + eventId: 231, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventFive, this.stateChangCallBack) + + var stateChangeEventSix = { + eventId: 232, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventSix, this.stateChangCallBack) + + var stateChangeEventSeven = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventSeven, this.stateChangCallBack) } private stateChangCallBack = (eventData) => { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/timeStamp.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/timeStamp.ets index 2ee08aac738b06e6f4d02296aae852d00414314d..4ac6620f7ebcdda8f63d2ac73d086950086c2561 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/timeStamp.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/timeStamp.ets @@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter' @Component struct ClickExample { @State text: string = '' + build() { Column() { Button('Click').backgroundColor(0x2788D9) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/toggle.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/toggle.ets index 0380421b5753bb17cb24e1917125dcb3c88a42e1..4a5ae115148777c76824387e644ad6a164ea5f01 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/toggle.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/toggle.ets @@ -18,9 +18,9 @@ import events_emitter from '@ohos.emitter'; @Entry @Component struct ToggleExample { - @State selectedColor : Color = '#330A59F7'; - @State toggleType : ToggleType = ToggleType.Button; - @State isOn : boolean = false; + @State selectedColor: Color = '#330A59F7'; + @State toggleType: ToggleType = ToggleType.Button; + @State isOn: boolean = false; onPageShow() { console.info('[toggle] page show called'); @@ -35,19 +35,43 @@ struct ToggleExample { priority: events_emitter.EventPriority.LOW } events_emitter.on(stateChangeEventOne, this.stateChangCallBack); + + var stateChangeEventthree = { + eventId: 1033, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventthree, this.stateChangCallBack); + + var stateChangeEventfour = { + eventId: 1034, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventfour, this.stateChangCallBack); + + var stateChangeEventfive = { + eventId: 1035, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventfive, this.stateChangCallBack); + + var stateChangeEventsix = { + eventId: 1036, + priority: events_emitter.EventPriority.LOW + } + events_emitter.on(stateChangeEventsix, this.stateChangCallBack); } private stateChangCallBack = (eventData) => { console.info("[toggle] page stateChangCallBack"); if (eventData != null) { console.info("[toggle] page state change called:" + JSON.stringify(eventData)); - if(eventData.data.selectedColor != null) { + if (eventData.data.selectedColor != null) { this.selectedColor = eventData.data.selectedColor; } - if(eventData.data.toggleType != null) { + if (eventData.data.toggleType != null) { this.toggleType = eventData.data.toggleType; } - if(eventData.data.isOn != null) { + if (eventData.data.isOn != null) { this.isOn = eventData.data.isOn; } } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/transition.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/transition.ets index 00f32a24478e9c9a663708b9394877c56f0320d2..212a95831d64f3e58cdf9689e65df206a27cf263 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/transition.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/pages/transition.ets @@ -27,8 +27,14 @@ struct TransitionExample { @State transitionTypeThree: TransitionType = TransitionType.All build() { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,}) { - Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:50}).key('button').opacity(this.opacity) + Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }) { + Button(this.show) + .width(80) + .height(30) + .backgroundColor(0x317aff) + .margin({ bottom: 50 }) + .key('button') + .opacity(this.opacity) .onClick(() => { this.onActionCalled = true; try { @@ -48,9 +54,9 @@ struct TransitionExample { } animateTo({ duration: 3000 }, () => { this.btn1 = !this.btn1 - if(this.btn1){ + if (this.btn1) { this.show = "hide" - }else{ + } else { this.show = "show" } }) @@ -58,10 +64,11 @@ struct TransitionExample { if (this.btn1) { Button() { Image($rawfile('test.png')).width("80%").height(300).key('image') - }.transition({ type: this.transitionTypeOne, scale: {x:0,y:1.0,z:1.0} }).key('button1') - .transition({ type: this.transitionTypeTwo, scale: { x: 1.0, y: 0.0 } }) + }.transition({ type: this.transitionTypeOne, scale: { x: 0, y: 1.0, z: 1.0 }, opacity: this.opacity }) + .key('button1') + .transition({ type: this.transitionTypeTwo, scale: { x: 1.0, y: 0.0 }, opacity: this.opacity }) } - }.height(400).width("100%").padding({top:100}) + }.height(400).width("100%").padding({ top: 100 }) } onPageShow() { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets index 7b68cd33a130bec2423543b4b166d0b92afec909..2eb15ee54e80ffc1f7a1d462c03ac069872da188 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AboutToDisappearJsunit.test.ets @@ -62,7 +62,7 @@ export default function aboutToDisappearJsunit() { } catch (err) { console.info("aboutToDisappearTest_0100 on events_emitter err : " + JSON.stringify(err)); } - console.info("aboutToDisappearTest_0100 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); + console.info("aboutToDisappearTest_0100 click result is: " + JSON.stringify(sendEventByKey('button1', 10, ""))); await Utils.sleep(1000); console.info('aboutToDisappearTest_0100 END'); done(); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AnimateJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AnimateJsunit.test.ets index 05684cc3352af0e5f17dfe00eeeb5079e77533da..decdb652670483e0a5799324831ceef6a43937ce 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AnimateJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/AnimateJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' import Utils from './Utils'; export default function animateJsunit() { - describe('appInfoTest', function () { + describe('animateTest', function () { beforeEach(async function (done) { console.info("animate beforeEach start"); let options = { @@ -53,7 +53,7 @@ export default function animateJsunit() { eventId: 51, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0100 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.duration).assertEqual('100') } @@ -62,7 +62,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0100 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0100 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); + console.info("animateTest_0100 click result is: " + JSON.stringify(sendEventByKey('button1', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0100 END'); done(); @@ -75,7 +75,7 @@ export default function animateJsunit() { eventId: 52, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.curve).assertEqual('Ease') } @@ -84,7 +84,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0200 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0200 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); + console.info("animateTest_0200 click result is: " + JSON.stringify(sendEventByKey('button2', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0200 END'); done(); @@ -97,7 +97,7 @@ export default function animateJsunit() { eventId: 53, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.iteration).assertEqual('1') } @@ -106,7 +106,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0300 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0300 click result is: " + JSON.stringify(sendEventByKey('button3',10,""))); + console.info("animateTest_0300 click result is: " + JSON.stringify(sendEventByKey('button3', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0300 END'); done(); @@ -119,7 +119,7 @@ export default function animateJsunit() { eventId: 54, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0400 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.tempo).assertEqual(1000) } @@ -128,7 +128,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0400 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0400 click result is: " + JSON.stringify(sendEventByKey('button4',10,""))); + console.info("animateTest_0400 click result is: " + JSON.stringify(sendEventByKey('button4', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0400 END'); done(); @@ -141,7 +141,7 @@ export default function animateJsunit() { eventId: 55, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.playmode).assertEqual('normal') } @@ -150,7 +150,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0500 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0500 click result is: " + JSON.stringify(sendEventByKey('button5',10,""))); + console.info("animateTest_0500 click result is: " + JSON.stringify(sendEventByKey('button5', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0500 END'); done(); @@ -161,7 +161,7 @@ export default function animateJsunit() { try { let eventData = { data: { - "duration":'2000' + "duration": '2000' } } let indexEventOne = { @@ -177,7 +177,7 @@ export default function animateJsunit() { eventId: 51, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0600 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.duration).assertEqual('2000') } @@ -186,7 +186,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0600 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0600 click result is: " + JSON.stringify(sendEventByKey('button1',10 ,""))); + console.info("animateTest_0600 click result is: " + JSON.stringify(sendEventByKey('button1', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0600 END'); done(); @@ -213,7 +213,7 @@ export default function animateJsunit() { eventId: 52, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0700 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.curve).assertEqual('Linear') } @@ -222,7 +222,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0700 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0700 click result is: " + JSON.stringify(sendEventByKey('button2',10 ,""))); + console.info("animateTest_0700 click result is: " + JSON.stringify(sendEventByKey('button2', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0700 END'); done(); @@ -233,7 +233,7 @@ export default function animateJsunit() { try { let eventData = { data: { - "iteration":"2" + "iteration": "2" } } let indexEventOne = { @@ -249,7 +249,7 @@ export default function animateJsunit() { eventId: 53, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0800 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.iteration).assertEqual('2') } @@ -258,7 +258,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0800 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0800 click result is: " + JSON.stringify(sendEventByKey('button3',10 ,""))); + console.info("animateTest_0800 click result is: " + JSON.stringify(sendEventByKey('button3', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0800 END'); done(); @@ -285,7 +285,7 @@ export default function animateJsunit() { eventId: 54, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_0900 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.tempo).assertEqual('20000') } @@ -294,7 +294,7 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_0900 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_0900 click result is: " + JSON.stringify(sendEventByKey('button4',10 ,""))); + console.info("animateTest_0900 click result is: " + JSON.stringify(sendEventByKey('button4', 10, ""))); await Utils.sleep(2000); console.info('animateTest_0900 END'); done(); @@ -305,7 +305,7 @@ export default function animateJsunit() { try { let eventData = { data: { - "playmode":"PlayMode.Alternate" + "playmode": "PlayMode.Alternate" } } let indexEventOne = { @@ -321,7 +321,7 @@ export default function animateJsunit() { eventId: 55, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("animateTest_1000 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.playmode).assertEqual('alternate') } @@ -330,10 +330,370 @@ export default function animateJsunit() { } catch (err) { console.info("animateTest_1000 on events_emitter err : " + JSON.stringify(err)); } - console.info("animateTest_1000 click result is: " + JSON.stringify(sendEventByKey('button5',10 ,""))); + console.info("animateTest_1000 click result is: " + JSON.stringify(sendEventByKey('button5', 10, ""))); await Utils.sleep(2000); console.info('animateTest_1000 END'); done(); }); + + it('animateTest_1100', 0, async function (done) { + console.info('animateTest_1100 START'); + try { + let eventData = { + data: { + "duration": -1000 + } + } + let indexEventOne = { + eventId: 1011, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1100 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1100 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1001, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1100 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.duration).assertEqual('-1000') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1100 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1100 click result is: " + JSON.stringify(sendEventByKey('button6', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1100 END'); + done(); + }); + + it('animateTest_1200', 0, async function (done) { + console.info('animateTest_1200 START'); + try { + let eventData = { + data: { + "duration": 100000000 + } + } + let indexEventOne = { + eventId: 1012, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1200 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1200 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1002, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1200 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.duration).assertEqual('100000000') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1200 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1200 click result is: " + JSON.stringify(sendEventByKey('button7', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1200 END'); + done(); + }); + + it('animateTest_1300', 0, async function (done) { + console.info('animateTest_1300 START'); + try { + let eventData = { + data: { + "curve": 123 + } + } + let indexEventOne = { + eventId: 1013, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1300 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1300 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1003, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1300 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.curve).assertEqual('123') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1300 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1300 click result is: " + JSON.stringify(sendEventByKey('button8', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1300 END'); + done(); + }); + + it('animateTest_1400', 0, async function (done) { + console.info('animateTest_1400 START'); + try { + let eventData = { + data: { + "curve": 'abc' + } + } + let indexEventOne = { + eventId: 1014, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1400 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1400 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1004, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1400 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.curve).assertEqual('abc') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1400 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1400 click result is: " + JSON.stringify(sendEventByKey('button9', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1400 END'); + done(); + }); + + it('animateTest_1500', 0, async function (done) { + console.info('animateTest_1500 START'); + try { + let eventData = { + data: { + "iteration": "121212121212" + } + } + let indexEventOne = { + eventId: 1015, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1500 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1500 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1005, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1500 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.iteration).assertEqual('121212121212') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1500 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1500 click result is: " + JSON.stringify(sendEventByKey('button10', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1500 END'); + done(); + }); + + it('animateTest_1600', 0, async function (done) { + console.info('animateTest_1600 START'); + try { + let eventData = { + data: { + "iteration": "-5" + } + } + let indexEventOne = { + eventId: 1016, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1600 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1600 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1006, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1600 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.iteration).assertEqual('-5') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1600 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1600 click result is: " + JSON.stringify(sendEventByKey('button11', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1600 END'); + done(); + }); + + it('animateTest_1700', 0, async function (done) { + console.info('animateTest_1700 START'); + try { + let eventData = { + data: { + "tempo": "12121212121212" + } + } + let indexEventOne = { + eventId: 1017, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1700 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1700 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1007, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1700 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.tempo).assertEqual('12121212121212') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1700 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1700 click result is: " + JSON.stringify(sendEventByKey('button12', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1700 END'); + done(); + }); + + it('animateTest_1800', 0, async function (done) { + console.info('animateTest_1800 START'); + try { + let eventData = { + data: { + "tempo": "-5" + } + } + let indexEventOne = { + eventId: 1018, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1800 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1800 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1008, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1800 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.tempo).assertEqual('-5') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1800 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1800 click result is: " + JSON.stringify(sendEventByKey('button13', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1800 END'); + done(); + }); + + it('animateTest_1900', 0, async function (done) { + console.info('animateTest_1900 START'); + try { + let eventData = { + data: { + "playmode": "aaa" + } + } + let indexEventOne = { + eventId: 1019, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_1900 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_1900 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1009, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_1900 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.playmode).assertEqual('aaa') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_1900 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_1900 click result is: " + JSON.stringify(sendEventByKey('button14', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_1900 END'); + done(); + }); + + it('animateTest_2000', 0, async function (done) { + console.info('animateTest_2000 START'); + try { + let eventData = { + data: { + "playmode": "123456" + } + } + let indexEventOne = { + eventId: 1020, + priority: events_emitter.EventPriority.LOW + } + console.info("animateTest_2000 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("animateTest_2000 change component data error: " + err.message); + } + let indexEvent = { + eventId: 1010, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("animateTest_2000 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.playmode).assertEqual('123456') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("animateTest_2000 on events_emitter err : " + JSON.stringify(err)); + } + console.info("animateTest_2000 click result is: " + JSON.stringify(sendEventByKey('button15', 10, ""))); + await Utils.sleep(2000); + console.info('animateTest_2000 END'); + done(); + }); }) } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets index 162aebd0f659a4f2820c844028a5b19ea9ac64c4..1331d9ff7b847ee07a7ca432a39bc41dd3795e5b 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BadgeJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' import Utils from './Utils'; export default function badgeJsunit() { - describe('appInfoTest', function () { + describe('badgeTest', function () { beforeEach(async function (done) { console.info("badge beforeEach start"); let options = { @@ -244,5 +244,58 @@ export default function badgeJsunit() { done(); }); + it('testBadge10', 0, async function (done) { + console.info('[testBadge10] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "colorValue": ab88, + } + } + var innerEvent = { + eventId: 64, + priority: events_emitter.EventPriority.LOW + } + console.info("[testBadge10] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testBadge10] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('badge2'); + let objNew = JSON.parse(strJsonNew); + console.info("[testBadge10] component objNew is: " + JSON.stringify(objNew)); + let style = JSON.parse(objNew.$attrs.style); + expect(style.color).assertEqual('#FF0000FF'); + done(); + }); + + it('testBadge11', 0, async function (done) { + console.info('[testBadge11] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "colorValue": -300, + } + } + var innerEvent = { + eventId: 65, + priority: events_emitter.EventPriority.LOW + } + console.info("[testBadge11] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testBadge11] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('badge2'); + let objNew = JSON.parse(strJsonNew); + console.info("[testBadge11] component objNew is: " + JSON.stringify(objNew)); + let style = JSON.parse(objNew.$attrs.style); + expect(style.color).assertEqual('#FFFFFED4'); + done(); + }); }) -} +} \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets index c578e6fb462dd52e54cb01897bada1b8ce07caaa..432d9ddbb14a3337ef83a22c1723a41acd96bc08 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/BlankJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' import Utils from './Utils'; export default function blankJsunit() { - describe('appInfoTest', function () { + describe('blankTest', function () { beforeEach(async function (done) { console.info("blank beforeEach start"); let options = { @@ -81,8 +81,8 @@ export default function blankJsunit() { let strJsonNew = getInspectorByKey('blank'); let objNew = JSON.parse(strJsonNew); console.info("[testBlank02] component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$type).assertEqual('Blank'); expect(objNew.$attrs.color).assertEqual('#FFFF0000'); + expect(objNew.$type).assertEqual('Blank'); done(); }); }) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ButtonJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ButtonJsunit.test.ets index fa28d684d982267cc558d98d4d07fe8c1c1c1724..efa281a8554733081a535c2d6935b5e436061f90 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ButtonJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ButtonJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' import Utils from './Utils'; export default function buttonJsunit() { - describe('appInfoTest', function () { + describe('buttonTest', function () { beforeEach(async function (done) { console.info("button beforeEach start"); let options = { @@ -241,7 +241,7 @@ export default function buttonJsunit() { eventId: 72, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("testButton10 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.fontColorValue).assertEqual(Color.Pink) } @@ -250,7 +250,7 @@ export default function buttonJsunit() { } catch (err) { console.info("testButton10 on events_emitter err : " + JSON.stringify(err)); } - console.info("testButton10 click result is: " + JSON.stringify(sendEventByKey('button3',10 ,""))); + console.info("testButton10 click result is: " + JSON.stringify(sendEventByKey('button3', 10, ""))); await Utils.sleep(1000); console.info('[testButton10] END'); done(); @@ -278,7 +278,7 @@ export default function buttonJsunit() { eventId: 71, priority: events_emitter.EventPriority.LOW } - let callback= (indexEvent) => { + let callback = (indexEvent) => { console.info("testButton11 get state result is: " + JSON.stringify(indexEvent)) except(indexEvent.data.fontColorValue).assertEqual(332) } @@ -287,7 +287,7 @@ export default function buttonJsunit() { } catch (err) { console.info("testButton11 on events_emitter err : " + JSON.stringify(err)); } - console.info("testButton11 click result is: " + JSON.stringify(sendEventByKey('button2',10 ,""))); + console.info("testButton11 click result is: " + JSON.stringify(sendEventByKey('button2', 10, ""))); await Utils.sleep(1000); console.info('[testButton11] END'); done(); @@ -318,5 +318,94 @@ export default function buttonJsunit() { console.info('[testButton12] testSendTouchEvent END'); done(); }); + + it('testButton13', 0, async function (done) { + console.info('[testButton13] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "buttonTypeValue": qaq, + } + } + var innerEvent = { + eventId: 74, + priority: events_emitter.EventPriority.LOW + } + console.info("[testButton13] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testButton13] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('button'); + let objNew = JSON.parse(strJsonNew); + console.info("[testButton13] component objNew is: " + JSON.stringify(objNew.$attrs.type)); + expect(objNew.$attrs.type).assertEqual('ButtonType.Capsule'); + done(); + }); + + it('testButton14', 0, async function (done) { + console.info('[testButton14] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "buttonTypeValue": 41961, + } + } + var innerEvent = { + eventId: 75, + priority: events_emitter.EventPriority.LOW + } + console.info("[testButton14] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[testButton14] change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('button'); + let objNew = JSON.parse(strJsonNew); + console.info("[testButton14] component objNew is: " + JSON.stringify(objNew.$attrs.type)); + expect(objNew.$attrs.type).assertEqual(''); + done(); + }); + + it('testButton15', 0, async function (done) { + console.info('[testButton15] START'); + try { + let eventData = { + data: { + "fontColorValue": ab996 + } + } + let indexEventOne = { + eventId: 76, + priority: events_emitter.EventPriority.LOW + } + console.info("testButton15 start to publish emit"); + events_emitter.emit(indexEventOne, eventData); + } catch (err) { + console.log("testButton15 change component data error: " + err.message); + } + await Utils.sleep(1000); + let indexEvent = { + eventId: 77, + priority: events_emitter.EventPriority.LOW + } + let callback = (indexEvent) => { + console.info("testButton15 get state result is: " + JSON.stringify(indexEvent)) + except(indexEvent.data.fontColorValue).assertEqual('ab996') + } + try { + events_emitter.on(indexEvent, callback); + } catch (err) { + console.info("testButton15 on events_emitter err : " + JSON.stringify(err)); + } + console.info("testButton15 click result is: " + JSON.stringify(sendEventByKey('button4', 10, ""))); + await Utils.sleep(1000); + console.info('[testButton15] END'); + done(); + }); }) -} +} \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/Canvas2Jsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/Canvas2Jsunit.test.ets index 70c852a6d382fd210eb75ca8d37850911f97b70e..5e78a79665f79388bbcbb3833dd1a87569ce3001 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/Canvas2Jsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/Canvas2Jsunit.test.ets @@ -17,8 +17,8 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " import router from '@system.router'; import Utils from './Utils'; -export default function canvasJsunit() { - describe('canvasTest', function () { +export default function canvas2Jsunit() { + describe('canvas2Test', function () { beforeEach(async function (done) { console.info("canvas beforeEach start"); let options = { diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets index 75458152d636d328f1c6050b5b2a1a087b221d45..98aeebcfa881fd93b4a1a8ff023534fc1c778508 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/CircleJsunit.test.ets @@ -68,7 +68,7 @@ export default function circleJsunit() { } console.info('[circleTest_0200] START'); var innerEvent = { - eventId:77, + eventId: 77, priority: events_emitter.EventPriority.LOW } console.info("[circleTest_0200] start to publish emit"); @@ -97,20 +97,20 @@ export default function circleJsunit() { } console.info('[circleTest_0300] START'); var innerEvent = { - eventId:77, + eventId: 77, priority: events_emitter.EventPriority.LOW } - console.info("[circleTest_0300] start to publish emit"); + console.info("[circleTest_030] start to publish emit"); events_emitter.emit(innerEvent, eventData); } catch (err) { - console.log("[circleTest_0300] change component data error: " + err.message); + console.log("[circleTest_030] change component data error: " + err.message); } await Utils.sleep(1000); let strJson = getInspectorByKey('circle'); let obj = JSON.parse(strJson); console.info("[circleTest_0300] component objNew is: " + JSON.stringify(obj)); - expect(obj.$attrs.height).assertEqual('0.00px'); expect(obj.$attrs.width).assertEqual('0.00px'); + expect(obj.$attrs.height).assertEqual('0.00px'); console.info('circleTest_0300 END'); done(); }); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets index 52fb4eebefb0f96652efb8250633ad60b6be5374..688976200ca1bed7780c1ae439beadb9128cc048 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/LineJsunit.test.ets @@ -18,7 +18,7 @@ import router from '@system.router'; import Utils from './Utils'; import events_emitter from '@ohos.events.emitter'; -export default function LineJsunit(){ +export default function LineJsunit() { describe('LineTest', function () { beforeEach(async function (done) { let options = { @@ -195,10 +195,10 @@ export default function LineJsunit(){ await Utils.sleep(2000); var strJson = getInspectorByKey('line'); var obj = JSON.parse(strJson); - console.info("lineTest_0800 component obj is: " + JSON.stringify(obj.$attrs.endPoint[0])); console.info("lineTest_0800 component objOne is: " + JSON.stringify(obj.$attrs.endPoint[1])); - expect(obj.$attrs.endPoint[0]).assertEqual(0); + console.info("lineTest_0800 component obj is: " + JSON.stringify(obj.$attrs.endPoint[0])); expect(obj.$attrs.endPoint[1]).assertEqual(0); + expect(obj.$attrs.endPoint[0]).assertEqual(0); done(); }); }) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/MotionPathJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/MotionPathJsunit.test.ets index b7780ad73abcff7f61a3539659a0bfba3585d94e..8226bd2d07715c42765f6591f3816bc0cd609c78 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/MotionPathJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/MotionPathJsunit.test.ets @@ -72,7 +72,7 @@ export default function motionPathJsunit() { } catch (err) { console.info("motionPathTest_0200 on events_emitter err : " + JSON.stringify(err)); } - console.info("motionPathTest_0200 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); + console.info("motionPathTest_0200 click result is: " + JSON.stringify(sendEventByKey('button1', 10, ""))); await Utils.sleep(1000); console.info('motionPathTest_0200 END'); done(); @@ -94,7 +94,7 @@ export default function motionPathJsunit() { } catch (err) { console.info("motionPathTest_0300 on events_emitter err : " + JSON.stringify(err)); } - console.info("motionPathTest_0300 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); + console.info("motionPathTest_0300 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); await Utils.sleep(1000); console.info('motionPathTest_0300 END'); done(); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PanGestureJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PanGestureJsunit.test.ets index e7c97d51b02872d1d20646b339e3ab3284ee5c06..d7ea18986a93cc8647141c74a1fd54b23d363c80 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PanGestureJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PanGestureJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function PanGestureJsunit() { - describe('appInfoTest', function () { + describe('PanGestureTest', function () { var x_value; var y_value; diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ParallelGestureJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ParallelGestureJsunit.test.ets index e0c2ee2fe858d12d04a24393e1f90c67bfd66257..f254f45988938757a6bc9c72dd09c2e4258c0b6f 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ParallelGestureJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ParallelGestureJsunit.test.ets @@ -53,7 +53,9 @@ export default function parallelGestureJsunit() { let x_value = rect.left + (rect.right - rect.left) / 2; let y_value = rect.top + (rect.bottom - rect.top) / 2; console.info("parallelGestureTest_0100 onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); - let point: TouchObject = { id: 11, x: x_value, y: y_value, type: TouchType.DOWN} + let point: TouchObject = { + id: 11, x: x_value, y: y_value, type: TouchType.DOWN + } var callback = (eventData) => { console.info("parallelGestureTest_0100 get event state result is: " + JSON.stringify(eventData)); expect(eventData.data.value).assertEqual('gesture onAction') diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PriorityGestureJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PriorityGestureJsunit.test.ets index b6284724b21ce39f98091f2470ab24424f24367b..7b1e95727f9c6a8479afdc4411441917f9bca953 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PriorityGestureJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/PriorityGestureJsunit.test.ets @@ -19,7 +19,7 @@ import Utils from './Utils'; import events_emitter from '@ohos.events.emitter'; export default function priorityGestureJsunit() { - describe('PriorityGestureTest', function () { + describe('priorityGestureTest', function () { beforeEach(async function (done) { let options = { uri: 'pages/priorityGesture', @@ -52,7 +52,9 @@ export default function priorityGestureJsunit() { let x_value = rect.left + (rect.right - rect.left) / 2; let y_value = rect.top + (rect.bottom - rect.top) / 2; console.info("priorityGestureTest_0100 onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); - let point: TouchObject = { id: 11, x: x_value, y: y_value, type: TouchType.Move} + let point: TouchObject = { + id: 11, x: x_value, y: y_value, type: TouchType.Move + } var callback = (eventData) => { console.info("priorityGestureTest_0100 get event state result is: " + JSON.stringify(eventData)); expect(eventData.data.value).assertEqual('gesture onAction') diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ProgressJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ProgressJsunit.test.ets index 6ba9c00a4df2b2cb716ad423997f60219fc370a3..39b07234ede7653a131c4cfc74be3bec71a64a0b 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ProgressJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ProgressJsunit.test.ets @@ -257,5 +257,65 @@ export default function progressJsunit() { console.info('testProgress_900 END'); done(); }); + + it('testProgress_1000', 0, async function (done) { + console.info('testProgress_1000 START'); + let strJson1 = getInspectorByKey('LPValue'); + let objLP = JSON.parse(strJson1); + console.info("testProgress_1000 component objLP is: " + objLP.$attrs.value); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "value": -5 + } + } + var innerEvent = { + eventId: 1021, + priority: events_emitter.EventPriority.LOW + } + console.info("testProgress_1000 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testProgress_1000 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('LPValue'); + let obj = JSON.parse(strJson); + console.info("testProgress_1000 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.value).assertEqual("-5.000000"); + console.info('testProgress_1000 END'); + done(); + }); + + it('testProgress_1100', 0, async function (done) { + console.info('testProgress_1100 START'); + let strJson1 = getInspectorByKey('LPValue'); + let objLP = JSON.parse(strJson1); + console.info("testProgress_1100 component objLP is: " + objLP.$attrs.value); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "value": 121212121 + } + } + var innerEvent = { + eventId: 1022, + priority: events_emitter.EventPriority.LOW + } + console.info("testProgress_1100 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testProgress_1100 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('LPValue'); + let obj = JSON.parse(strJson); + console.info("testProgress_1100 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.value).assertEqual("121212121.000000"); + console.info('testProgress_1100 END'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/QrCodeJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/QrCodeJsunit.test.ets index 5056a38ab35815b9e68422bc2f4dbbe7a0dac2cb..608b31d07f92625caf921e18ea39c8fd70f98dfb 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/QrCodeJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/QrCodeJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function qrCodeJsunit() { - describe('appInfoTest', function () { + describe('qrCodeTest', function () { beforeEach(async function (done) { let options = { uri: 'pages/QrCode', @@ -108,5 +108,109 @@ export default function qrCodeJsunit() { expect(obj.$attrs.backgroundColor).assertEqual('#FFFFB6C1'); done(); }); + + it('test_qrCode_004', 0, async function (done) { + console.info('[test_qrCode_004] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "color": 'a' + } + } + var innerEvent = { + eventId: 1023, + priority: events_emitter.EventPriority.LOW + } + console.info("[test_qrCode_004] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[test_qrCode_004] change component color error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('QrCodeColor'); + var obj = JSON.parse(strJson); + console.info("[test_qrCode_004] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#FF000000'); + done(); + }); + + it('test_qrCode_005', 0, async function (done) { + console.info('[test_qrCode_005] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "color": 332 + } + } + var innerEvent = { + eventId: 1024, + priority: events_emitter.EventPriority.LOW + } + console.info("[test_qrCode_005] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[test_qrCode_005] change component color error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('QrCodeColor'); + var obj = JSON.parse(strJson); + console.info("[test_qrCode_005] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.color).assertEqual('#0000014C'); + done(); + }); + + it('test_qrCode_006', 0, async function (done) { + console.info('[test_qrCode_006] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "backgroundColor": 'b' + } + } + var innerEvent = { + eventId: 1025, + priority: events_emitter.EventPriority.LOW + } + console.info("[test_qrCode_006] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[test_qrCode_006] change component color error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('QrCodeColor'); + var obj = JSON.parse(strJson); + console.info("[test_qrCode_006] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.backgroundColor).assertEqual('#FF000000'); + done(); + }); + + it('test_qrCode_007', 0, async function (done) { + console.info('[test_qrCode_007] START'); + await Utils.sleep(1000); + try { + var eventData = { + data: { + "backgroundColor": 333 + } + } + var innerEvent = { + eventId: 1026, + priority: events_emitter.EventPriority.LOW + } + console.info("[test_qrCode_007] start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("[test_qrCode_007] change component color error: " + err.message); + } + await Utils.sleep(2000); + var strJson = getInspectorByKey('QrCodeColor'); + var obj = JSON.parse(strJson); + console.info("[test_qrCode_007] component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.backgroundColor).assertEqual('#0000014D'); + done(); + }); }) } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/RatingJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/RatingJsunit.test.ets index 29a6bc8bea2c50eb40f74ad838c8355e5efb5d67..cc376c6832954d75c6d797b41de933940137d705 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/RatingJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/RatingJsunit.test.ets @@ -218,5 +218,59 @@ export default function ratingJsunit() { console.info('testRating_700 END'); done(); }); + + it('testRating_800', 0, async function (done) { + console.info('testRating_800 START'); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "rating": -1 + } + } + var innerEvent = { + eventId: 1027, + priority: events_emitter.EventPriority.LOW + } + console.info("testRating_800 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testRating_800 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('Rating'); + let obj = JSON.parse(strJson); + console.info("testRating_800 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.rating).assertEqual("0.000000"); + console.info('testRating_800 END'); + done(); + }); + + it('testRating_900', 0, async function (done) { + console.info('testRating_900 START'); + await Utils.sleep(1000); + try { + let eventData = { + data: { + "rating": 'a' + } + } + var innerEvent = { + eventId: 1028, + priority: events_emitter.EventPriority.LOW + } + console.info("testRating_900 start to publish emit"); + events_emitter.emit(innerEvent, eventData); + } catch (err) { + console.log("testRating_900 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJson = getInspectorByKey('Rating'); + let obj = JSON.parse(strJson); + console.info("testRating_900 component obj is: " + JSON.stringify(obj)); + expect(obj.$attrs.rating).assertEqual("0.000000"); + console.info('testRating_900 END'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ResponseRegionJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ResponseRegionJsunit.test.ets index 4f5092e56dda0aa00375f97c1773d24685bb2460..b0c0bec2a6b1d6695fc5e2514b878903fd844e09 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ResponseRegionJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ResponseRegionJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function ResponseRegionJsunit() { - describe('appInfoTest', function () { + describe('responseRegionTest', function () { var x_value; var y_value; diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets index 43b561dbf44628850eb423025446ac61b0ebc5c1..2abef58e9f6cbc246b282617f83f11790b8763fa 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ScrollCodeJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function scrollCodeJsunit() { - describe('appInfoTest', function () { + describe('scrollCodeTest', function () { beforeEach(async function (done) { let options = { uri: 'pages/scrollCode', @@ -167,7 +167,7 @@ export default function scrollCodeJsunit() { it('test_scrollCode_006', 0, async function (done) { await Utils.sleep(1000) var callback = (eventData) => { - console.info("[test_scrollCode_006] get event state result is: " + JSON.stringify(eventData)); + console.info("[test_scrollCode_06] get event state result is: " + JSON.stringify(eventData)); expect(eventData.data.scrollToIndex).assertEqual(10) } var innerEvent = { @@ -177,7 +177,7 @@ export default function scrollCodeJsunit() { try { events_emitter.on(innerEvent, callback) } catch (err) { - console.info("[test_scrollCode_006] on events_emitter err : " + JSON.stringify(err)); + console.info("[test_scrollCode_06] on events_emitter err : " + JSON.stringify(err)); } console.info('[test_scrollCode_006] sendEventByKey ' + JSON.stringify(sendEventByKey('button', 10, ""))); await Utils.sleep(1000) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets index e3ef62cdf4deb1b27c80c64eaedf3c383bad17be..7d2369f6dad5060725474c7c15ed9e375c129b5d 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SharedTransitionJsunit.test.ets @@ -112,7 +112,7 @@ export default function sharedTransitionJsunit() { } catch (err) { console.info("sharedTransitionTest_0400 on events_emitter err : " + JSON.stringify(err)); } - console.info("sharedTransitionTest_0400 click result is: " + JSON.stringify(sendEventByKey('Navigator',10,""))); + console.info("sharedTransitionTest_0400 click result is: " + JSON.stringify(sendEventByKey('Navigator', 10, ""))); await Utils.sleep(2000); console.info('sharedTransitionTest_0400 END'); done(); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets index 84df05a37298c0fcb028c49c407c04cea8ef7557..15315b99fa22d60e2b4c30784e04d20429bc495c 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/SpanJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function spanJsunit() { - describe('appInfoTest', function () { + describe('spanTest', function () { beforeEach(async function (done) { let options = { uri: 'pages/span', @@ -130,5 +130,109 @@ export default function spanJsunit() { expect(obj.$attrs.fontColor).assertEqual('#FF000990'); done(); }); + + it('testSpan006', 0, async function (done) { + console.info('[testSpan006] START'); + try { + let eventData = { + data: { + "textCaseValue": a + } + } + let indexEvent = { + eventId: 1029, + priority: events_emitter.EventPriority.LOW + } + console.info("[testSpan006] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testSpan006] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('decoration'); + console.info("[testSpan006] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testSpan006] textCase:" + obj); + expect(obj.$attrs.textCase).assertEqual('TextCase.UpperCase'); + done(); + }); + + it('testSpan007', 0, async function (done) { + console.info('[testSpan007] START'); + try { + let eventData = { + data: { + "textCaseValue": -1 + } + } + let indexEvent = { + eventId: 1030, + priority: events_emitter.EventPriority.LOW + } + console.info("[testSpan007] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testSpan007] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('decoration'); + console.info("[testSpan007] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testSpan007] textCase:" + obj); + expect(obj.$attrs.textCase).assertEqual('TextCase.Normal'); + done(); + }); + + it('testSpan008', 0, async function (done) { + console.info('[testSpan008] START'); + try { + let eventData = { + data: { + "fontColorValue": 'abc' + } + } + let indexEvent = { + eventId: 1031, + priority: events_emitter.EventPriority.LOW + } + console.info("[testSpan008] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testSpan008] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testSpan008] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testSpan008] fontColor:" + obj); + expect(obj.$attrs.fontColor).assertEqual('#FF000000'); + done(); + }); + + it('testSpan009', 0, async function (done) { + console.info('[testSpan009] START'); + try { + let eventData = { + data: { + "fontColorValue": '-1' + } + } + let indexEvent = { + eventId: 1032, + priority: events_emitter.EventPriority.LOW + } + console.info("[testSpan009] start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("[testSpan009] change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJson = getInspectorByKey('fontColor'); + console.info("[testSpan009] component strJson:" + strJson); + let obj = JSON.parse(strJson); + console.info("[testSpan009] fontColor:" + obj); + expect(obj.$attrs.fontColor).assertEqual('#FFFFFFFF'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TabsJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TabsJsunit.test.ets index 5aaa4db47eec17de7d0ee232bcc016f44fa4c9f6..e011be4b268f1fd53591c3b58e4a14ed05a22f66 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TabsJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TabsJsunit.test.ets @@ -19,7 +19,7 @@ import Utils from './Utils'; import events_emitter from '@ohos.events.emitter'; export default function tabsJsunit() { - describe('appInfoTest', function () { + describe('tabsTest', function () { beforeEach(async function (done) { console.info("tabs beforeEach start"); let options = { @@ -126,12 +126,26 @@ export default function tabsJsunit() { it('testTabs_0800', 0, async function (done) { console.info('testTabs_0800 START'); - let strJson = getInspectorByKey('tabContent1'); - console.info("testTabs_0800 component strJson:" + strJson); - let obj = JSON.parse(strJson); - console.info("testTabs_0800 component obj is: " + JSON.stringify(obj)); - expect(obj.$type).assertEqual('TabContent'); - expect(obj.$attrs.tabBar).assertEqual('pink'); + try { + let eventData = { + data: { + "vertical": "false", + } + } + let indexEvent = { + eventId: 213, + priority: events_emitter.EventPriority.LOW + } + console.info("testTabs_0800 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testTabs_0800 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('tabs'); + let objNew = JSON.parse(strJsonNew); + console.info("testTabs_0800 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.vertical).assertEqual('false'); console.info('testTabs_0800 END'); done(); }); @@ -141,7 +155,7 @@ export default function tabsJsunit() { try { let eventData = { data: { - "vertical": "false", + "scrollable": "false", } } let indexEvent = { @@ -157,7 +171,7 @@ export default function tabsJsunit() { let strJsonNew = getInspectorByKey('tabs'); let objNew = JSON.parse(strJsonNew); console.info("testTabs_0900 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.vertical).assertEqual('false'); + expect(objNew.$attrs.scrollable).assertEqual(false); console.info('testTabs_0900 END'); done(); }); @@ -167,7 +181,7 @@ export default function tabsJsunit() { try { let eventData = { data: { - "scrollable": "false", + "scrollable": "false53", } } let indexEvent = { @@ -193,7 +207,7 @@ export default function tabsJsunit() { try { let eventData = { data: { - "scrollable": "false53", + "vertical": "39284", } } let indexEvent = { @@ -219,11 +233,11 @@ export default function tabsJsunit() { try { let eventData = { data: { - "vertical": "39284", + "vertical": "abc123", } } let indexEvent = { - eventId: 213, + eventId: 214, priority: events_emitter.EventPriority.LOW } console.info("testTabs_1200 start to publish emit"); @@ -235,16 +249,42 @@ export default function tabsJsunit() { let strJsonNew = getInspectorByKey('tabs'); let objNew = JSON.parse(strJsonNew); console.info("testTabs_1200 component objNew is: " + JSON.stringify(objNew)); - expect(objNew.$attrs.scrollable).assertEqual(false); + expect(objNew.$attrs.vertical).assertEqual('false'); console.info('testTabs_1200 END'); done(); }); it('testTabs_1300', 0, async function (done) { console.info('testTabs_1300 START'); + try { + let eventData = { + data: { + "scrollable": "avc12321", + } + } + let indexEvent = { + eventId: 215, + priority: events_emitter.EventPriority.LOW + } + console.info("testTabs_1300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testTabs_1300 change component data error: " + err.message); + } + await Utils.sleep(2000); + let strJsonNew = getInspectorByKey('tabs'); + let objNew = JSON.parse(strJsonNew); + console.info("testTabs_1300 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.scrollable).assertEqual(false); + console.info('testTabs_1300 END'); + done(); + }); + + it('testTabs_1400', 0, async function (done) { + console.info('testTabs_1400 START'); await Utils.sleep(1500); let callback = (indexEvent) => { - console.info("testTabs_1300 get state result is: " + JSON.stringify(indexEvent)); + console.info("testTabs_1400 get state result is: " + JSON.stringify(indexEvent)); expect(indexEvent.data.ACTION).assertEqual(true); } let indexEvent = { @@ -254,11 +294,11 @@ export default function tabsJsunit() { try { events_emitter.on(indexEvent, callback); } catch (err) { - console.info("testTabs_1300 on events_emitter err : " + JSON.stringify(err)); + console.info("testTabs_1400 on events_emitter err : " + JSON.stringify(err)); } - console.info("testTabs_1300 click result is: " + JSON.stringify(sendEventByKey('tabContent1',10,""))); + console.info("testTabs_1400 click result is: " + JSON.stringify(sendEventByKey('tabContent1', 10, ""))); await Utils.sleep(1000); - console.info('testTabs_1300 END'); + console.info('testTabs_1400 END'); done(); }); }) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TapGesture.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TapGesture.test.ets index f0fff984c581f90eeeed05367eb3d8f9e82485e7..71afe04d92b077795c70711091d32837bc92dcdb 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TapGesture.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TapGesture.test.ets @@ -55,8 +55,12 @@ export default function longPressGestureJsunit() { let x_value_two = rect.left + (rect.right - rect.left) / 20; let y_value_two = rect.top + (rect.bottom - rect.top) / 20; console.info("[testTapGesture01] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); - let point: TouchObject = { id: 1, x: x_value, y: y_value, type: TouchType.Move} - let point2: TouchObject = { id: 2, x: x_value_two, y: y_value_two, type: TouchType.Move} + let point: TouchObject = { + id: 1, x: x_value, y: y_value, type: TouchType.Move + } + let point2: TouchObject = { + id: 2, x: x_value_two, y: y_value_two, type: TouchType.Move + } var callback = (eventData) => { console.info("[testTapGesture01] get event state result is: " + JSON.stringify(eventData)); expect(eventData.data.ACTION).assertEqual(true) diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets index dcb06dcb61813b31435830b7455ac28678845c40..97901f1638c21e5660650b5399c9c51bea1ca331 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TextJsunit.test.ets @@ -66,10 +66,10 @@ export default function textJsunit() { console.info("testText_0200 component obj is: " + JSON.stringify(obj)); var res = obj.$attrs.src.indexOf('rawfile/test.png'); console.info("testText_0200 result is: " + res); - var sres = obj.$attrs.src.slice(res,res + 16); + var sres = obj.$attrs.src.slice(res, res + 16); console.info("testText_0200 slice result is: " + sres); expect(obj.$type).assertEqual('Image'); - expect(obj.$attrs.src.slice(res,res + 16)).assertEqual('rawfile/test.png'); + expect(obj.$attrs.src.slice(res, res + 16)).assertEqual('rawfile/test.png'); console.info('testText_0200 END'); done(); }); @@ -123,7 +123,7 @@ export default function textJsunit() { let indexEvent = { eventId: 227, priority: events_emitter.EventPriority.LOW - } + } console.info("testText_0500 start to publish emit"); events_emitter.emit(indexEvent, eventData); } catch (err) { @@ -222,5 +222,109 @@ export default function textJsunit() { console.info('testText_1000 END'); done(); }); + + it('testText_1100', 0, async function (done) { + console.info('testText_1100 START'); + try { + let eventData = { + data: { + "fontColor": "-a", + } + } + let indexEvent = { + eventId: 230, + priority: events_emitter.EventPriority.LOW + } + console.info("testText_1100 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testText_1100 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('text'); + let objNew = JSON.parse(strJsonNew); + console.info("testText_1100 component objNew is: " + JSON.stringify(objNew.$attrs.fontColor)); + expect(objNew.$attrs.fontColor).assertEqual('#FF000000'); + console.info('testText_1100 END'); + done(); + }); + + it('testText_1200', 0, async function (done) { + console.info('testText_1200 START'); + try { + let eventData = { + data: { + "fontColor": "12321321", + } + } + let indexEvent = { + eventId: 231, + priority: events_emitter.EventPriority.LOW + } + console.info("testText_1200 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testText_1200 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('text'); + let objNew = JSON.parse(strJsonNew); + console.info("testText_1200 component objNew is: " + JSON.stringify(objNew.$attrs.fontColor)); + expect(objNew.$attrs.fontColor).assertEqual('#00BC0229'); + console.info('testText_1200 END'); + done(); + }); + + it('testText_1300', 0, async function (done) { + console.info('testText_1300 START'); + try { + let eventData = { + data: { + "fontSize": "-a", + } + } + let indexEvent = { + eventId: 232, + priority: events_emitter.EventPriority.LOW + } + console.info("testText_1300 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testText_1300 change component data error: " + err.message); + } + await Utils.sleep(3000); + let strJsonNew = getInspectorByKey('text'); + let objNew = JSON.parse(strJsonNew); + console.info("testText_1300 component objNew is: " + JSON.stringify(objNew.$attrs.fontSize)); + expect(objNew.$attrs.fontSize).assertEqual('nanfp'); + console.info('testText_1300 END'); + done(); + }); + + it('testText_1400', 0, async function (done) { + console.info('testText_1400 START'); + try { + let eventData = { + data: { + "fontSize": "-20", + } + } + let indexEvent = { + eventId: 233, + priority: events_emitter.EventPriority.LOW + } + console.info("testText_1400 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testText_1400 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('text'); + let objNew = JSON.parse(strJsonNew); + console.info("testText_1400 component objNew is: " + JSON.stringify(objNew.$attrs.fontSize)); + expect(objNew.$attrs.fontSize).assertEqual('-20.00fp'); + console.info('testText_1400 END'); + done(); + }); }) } \ No newline at end of file diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets index 83d6a9a13c5f5d78bb84f4f09fd0f01566f126ee..b3220aaf29650fa9e639026ce53028a69adf4c6e 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TimeStampJsunit.test.ets @@ -18,8 +18,8 @@ import router from '@system.router'; import Utils from './Utils'; import events_emitter from '@ohos.events.emitter'; -export default function timeStampJsunit(){ - describe('timeStampTest', function (){ +export default function timeStampJsunit() { + describe('timeStampTest', function () { beforeEach(async function (done) { let options = { uri: 'pages/timeStamp', @@ -61,7 +61,7 @@ export default function timeStampJsunit(){ } catch (err) { console.info("timeStampTest_0100 on events_emitter err : " + JSON.stringify(err)); } - console.info("timeStampTest_0100 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); + console.info("timeStampTest_0100 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); await Utils.sleep(1500); console.info('timeStampTest_0100 END'); done(); diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets index 514fa8a658ef0b53710cbf4193e278fb97059883..7c10a98f217c292ae9c78109d29a9f1ead9b9c56 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/ToggleJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function ToggleJsunit() { - describe('appInfoTest', function () { + describe('toggleTest', function () { beforeEach(async function (done) { console.info("toggle beforeEach start"); let options = { @@ -131,5 +131,109 @@ export default function ToggleJsunit() { console.info('testToggle05 END'); done(); }); + + it('testToggle06', 0, async function (done) { + console.info('testToggle06 START'); + try { + let eventData = { + data: { + "selectedColor": '-a', + } + } + let indexEvent = { + eventId: 1033, + priority: events_emitter.EventPriority.LOW + } + console.info("testToggle06 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testToggle06 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('toggle'); + let objNew = JSON.parse(strJsonNew); + console.info("testToggle06 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.selectedColor).assertEqual('#FF000000'); + console.info('testToggle06 END'); + done(); + }); + + it('testToggle07', 0, async function (done) { + console.info('testToggle07 START'); + try { + let eventData = { + data: { + "selectedColor": '-0.1', + } + } + let indexEvent = { + eventId: 1034, + priority: events_emitter.EventPriority.LOW + } + console.info("testToggle07 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testToggle07 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('toggle'); + let objNew = JSON.parse(strJsonNew); + console.info("testToggle07 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.selectedColor).assertEqual('#FF000000'); + console.info('testToggle07 END'); + done(); + }); + + it('testToggle08', 0, async function (done) { + console.info('testToggle04 START'); + try { + let eventData = { + data: { + "isOn": 'aaa', + } + } + let indexEvent = { + eventId: 1035, + priority: events_emitter.EventPriority.LOW + } + console.info("testToggle04 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testToggle04 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('toggle'); + let objNew = JSON.parse(strJsonNew); + console.info("testToggle04 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.isOn).assertEqual('false'); + console.info('testToggle04 END'); + done(); + }); + + it('testToggle09', 0, async function (done) { + console.info('testToggle04 START'); + try { + let eventData = { + data: { + "isOn": -1, + } + } + let indexEvent = { + eventId: 1036, + priority: events_emitter.EventPriority.LOW + } + console.info("testToggle04 start to publish emit"); + events_emitter.emit(indexEvent, eventData); + } catch (err) { + console.log("testToggle04 change component data error: " + err.message); + } + await Utils.sleep(4000); + let strJsonNew = getInspectorByKey('toggle'); + let objNew = JSON.parse(strJsonNew); + console.info("testToggle04 component objNew is: " + JSON.stringify(objNew)); + expect(objNew.$attrs.isOn).assertEqual('false'); + console.info('testToggle04 END'); + done(); + }); }) } diff --git a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets index dc9e0a78bd173ef5c0de4b8b363d2ea37c61be9c..c7cf2f5d8df57a71febea38965cb753ce59535aa 100755 --- a/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets +++ b/ace/ace_ets_component_three/entry/src/main/ets/MainAbility/test/TransitionJsunit.test.ets @@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; import Utils from './Utils'; export default function transitionJsunit() { - describe('appInfoTest', function () { + describe('transitionTest', function () { beforeEach(async function (done) { console.info("text beforeEach start"); let options = { @@ -74,7 +74,7 @@ export default function transitionJsunit() { } catch (err) { console.info("transitionTest_0200 on events_emitter err : " + JSON.stringify(err)); } - console.info("transitionTest_0200 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); + console.info("transitionTest_0200 click result is: " + JSON.stringify(sendEventByKey('button', 10, ""))); await Utils.sleep(1000); console.info('transitionTest_0200 END'); done(); @@ -126,7 +126,7 @@ export default function transitionJsunit() { await Utils.sleep(4000); let strJsonNew = getInspectorByKey('button'); let objNew = JSON.parse(strJsonNew); - console.info("transitionTest_0400 component objNew is: " + JSON.stringify(objNew)); + console.info("transitionTest_040 component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.opacity).assertEqual(null); console.info('transitionTest_0400 END'); done();