提交 ccff4e87 编写于 作者: Z zhangrao

add component

Signed-off-by: Nzhangrao <zhangrao@huawei.com>
上级 40524396
...@@ -20,7 +20,7 @@ import prompt from '@system.prompt' ...@@ -20,7 +20,7 @@ import prompt from '@system.prompt'
@Entry @Entry
@Preview @Preview
@Component @Component
struct AppearExample { struct AppearExample {
@State isShow: boolean = true @State isShow: boolean = true
@State appearFlag: boolean = false @State appearFlag: boolean = false
@State disAppearFlag: boolean = false @State disAppearFlag: boolean = false
...@@ -40,7 +40,7 @@ struct AppearExample { ...@@ -40,7 +40,7 @@ struct AppearExample {
console.info("[appear] page stateChangCallBack"); console.info("[appear] page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
console.info("[appear] page state change called:" + JSON.stringify(eventData)); 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; this.isShow = eventData.data.isShow;
} }
} }
...@@ -60,7 +60,7 @@ struct AppearExample { ...@@ -60,7 +60,7 @@ struct AppearExample {
this.changeAppear = 'Show Text' this.changeAppear = 'Show Text'
console.info('appearFlag current action state is: ' + this.appearFlag); console.info('appearFlag current action state is: ' + this.appearFlag);
prompt.showToast({ message: 'The text is shown', duration: 2000 }) prompt.showToast({ message: 'The text is shown', duration: 2000 })
try{ try {
var backData = { var backData = {
data: { data: {
"ACTION": this.appearFlag, "ACTION": this.appearFlag,
...@@ -72,7 +72,7 @@ struct AppearExample { ...@@ -72,7 +72,7 @@ struct AppearExample {
} }
console.info("appearFlag start to emit action state") console.info("appearFlag start to emit action state")
events_emitter.emit(backEvent, backData) events_emitter.emit(backEvent, backData)
}catch{ } catch {
console.info("appearFlag emit action state err: " + JSON.stringify(err.message)) console.info("appearFlag emit action state err: " + JSON.stringify(err.message))
} }
}) })
...@@ -81,7 +81,7 @@ struct AppearExample { ...@@ -81,7 +81,7 @@ struct AppearExample {
this.changeAppear = 'Hide Text' this.changeAppear = 'Hide Text'
console.info('disAppearFlag current action state is: ' + this.disAppearFlag); console.info('disAppearFlag current action state is: ' + this.disAppearFlag);
prompt.showToast({ message: 'The text is hidden', duration: 2000 }) prompt.showToast({ message: 'The text is hidden', duration: 2000 })
try{ try {
var backData = { var backData = {
data: { data: {
"ACTION": this.disAppearFlag, "ACTION": this.disAppearFlag,
...@@ -93,7 +93,7 @@ struct AppearExample { ...@@ -93,7 +93,7 @@ struct AppearExample {
} }
console.info("disAppearFlag start to emit action state") console.info("disAppearFlag start to emit action state")
events_emitter.emit(backEvent, backData) events_emitter.emit(backEvent, backData)
}catch{ } catch {
console.info("disAppearFlag emit action state err: " + JSON.stringify(err.message)) console.info("disAppearFlag emit action state err: " + JSON.stringify(err.message))
} }
}) })
......
// @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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter'; import events_emitter from '@ohos.emitter';
@Entry @Entry
@Component @Component
struct EllipseExample { struct EllipseExample {
@State width: string = "200px"; @State width: string = "200px";
@State height: string = "200px"; @State height: string = "200px";
onPageShow() { onPageShow() {
console.info('[ellipse] page show called'); console.info('[ellipse] page show called');
var stateChangeEvent = { var stateChangeEvent = {
eventId: 92, eventId: 92,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack); events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
var stateChangeEventTwo = {
private stateChangCallBack = (eventData) => { eventId: 907,
console.info("[ellipse] page stateChangCallBack"); priority: events_emitter.EventPriority.LOW
if (eventData != null) { }
console.info("[ellipse] page state change called:" + JSON.stringify(eventData)); events_emitter.on(stateChangeEventTwo, this.stateChangCallBack);
if(eventData.data.width != null) {
this.width = eventData.data.width; var stateChangeEventThree = {
} eventId: 908,
if(eventData.data.height != null) { priority: events_emitter.EventPriority.LOW
this.height = eventData.data.height; }
} events_emitter.on(stateChangeEventThree, this.stateChangCallBack);
} }
}
private stateChangCallBack = (eventData) => {
build() { console.info("[ellipse] page stateChangCallBack");
Flex({ direction: FlexDirection.Row, alignItems: ItemAlign.Center,justifyContent: FlexAlign.Center}) { if (eventData != null) {
Ellipse().width(`${this.width}`).height(`${this.height}`).key('ellipse') console.info("[ellipse] page state change called:" + JSON.stringify(eventData));
}.width('100%').height('100%') 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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter'
@Entry import events_emitter from '@ohos.emitter'
@Component
struct EnabledExample { @Entry
@State enabled: boolean = true; @Component
@State text: string = "enable"; struct EnabledExample {
@State enabled: boolean = true;
onPageShow() { @State text: string = "enable";
console.info('[enabled] page show called ');
var stateChangeEvent = { onPageShow() {
eventId: 93, console.info('[enabled] page show called ');
priority: events_emitter.EventPriority.LOW var stateChangeEvent = {
} eventId: 93,
events_emitter.on(stateChangeEvent, this.stateChangCallBack); priority: events_emitter.EventPriority.LOW
}
} events_emitter.on(stateChangeEvent, this.stateChangCallBack);
private stateChangCallBack = (eventData) => { var stateChangeEvent2 = {
console.info("[stateChangCallBack] stateChangCallBack "); eventId: 1111,
if (eventData != null) { priority: events_emitter.EventPriority.LOW
console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); }
if (eventData.data.enabled != null) { events_emitter.on(stateChangeEvent2, this.stateChangCallBack);
this.enabled = eventData.data.enabled
} }
if (eventData.data.text != null) {
this.text = eventData.data.text private stateChangCallBack = (eventData) => {
} console.info("[stateChangCallBack] stateChangCallBack ");
} if (eventData != null) {
} console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData));
if (eventData.data.enabled != null) {
build() { this.enabled = eventData.data.enabled
Flex({ justifyContent: FlexAlign.SpaceAround }) { }
Button('disable') if (eventData.data.text != null) {
.enabled(false) this.text = eventData.data.text
.backgroundColor(0x317aff) }
.opacity(0.4) }
Button(this.text) }
.key('enabled')
.backgroundColor(0x317aff) build() {
.enabled(this.enabled) Flex({ justifyContent: FlexAlign.SpaceAround }) {
} Button('disable')
.width('100%') .enabled(false)
.padding({ top: 5 }) .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
...@@ -23,25 +23,24 @@ struct FlexExample { ...@@ -23,25 +23,24 @@ struct FlexExample {
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("Flex page state change called:" + JSON.stringify(eventData)); 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; this.flexBasis = eventData.data.flexBasis;
} }
if(eventData.data.flexGrow != null) { if (eventData.data.flexGrow != null) {
this.flexGrow = eventData.data.flexGrow; this.flexGrow = eventData.data.flexGrow;
} }
if(eventData.data.flexShrink != null) { if (eventData.data.flexShrink != null) {
this.flexShrink = eventData.data.flexShrink; this.flexShrink = eventData.data.flexShrink;
} }
if(eventData.data.alignSelf != null) { if (eventData.data.alignSelf != null) {
this.alignSelf = eventData.data.alignSelf; this.alignSelf = eventData.data.alignSelf;
} }
} }
} }
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("Flex page state change called:" + JSON.stringify(eventData)); console.info("Flex page state change called:" + JSON.stringify(eventData));
switch(eventData.data.alignSelf) { switch (eventData.data.alignSelf) {
case 'Auto': case 'Auto':
this.alignSelf = ItemAlign.Auto; this.alignSelf = ItemAlign.Auto;
break; break;
...@@ -80,33 +79,60 @@ struct FlexExample { ...@@ -80,33 +79,60 @@ struct FlexExample {
Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('flexBasis').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex() { Flex() {
Text('flexBasis("auto")') Text('flexBasis("auto")')
.flexBasis('auto').key("flexBasis").width('60%').height(100).lineHeight(70) .flexBasis('auto')
.backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .key("flexBasis")
.width('60%')
.height(100)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
Text('flexBasis(100)') Text('flexBasis(100)')
.flexBasis('100').height(100).lineHeight(70) .flexBasis('100')
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
Text('flexGrow').key("flexGrow").fontSize(9).fontColor(0xCCCCCC).width('90%') Text('flexGrow').key("flexGrow").fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex() { Flex() {
Text('flexGrow(2)') Text('flexGrow(2)')
.flexGrow(2).height(100).lineHeight(70) .flexGrow(2)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
Text('flexGrow(1)') Text('flexGrow(1)')
.flexGrow(1).height(100).lineHeight(70) .flexGrow(1)
.backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .height(100)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
Text('flexShrink').fontSize(9).fontColor(0xCCCCCC).width('90%') Text('flexShrink').fontSize(9).fontColor(0xCCCCCC).width('90%')
Flex({ direction: FlexDirection.Row }) { Flex({ direction: FlexDirection.Row }) {
Text('flexShrink(0)') Text('flexShrink(0)')
.flexShrink(0).key("flexShrink").width('50%').height(100).lineHeight(70) .flexShrink(0)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .key("flexShrink")
.width('50%')
.height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
Text('no flexShrink') 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)') Text('flexShrink(2)')
.flexShrink(2).width('40%').height(100) .lineHeight(70) .flexShrink(2)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .width('40%')
.height(100)
.lineHeight(70)
.backgroundColor(0xF5DEB3)
.textAlign(TextAlign.Center)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
Text('alignSelf').key("alignSelf").fontSize(9).fontColor(0xCCCCCC).width('90%') Text('alignSelf').key("alignSelf").fontSize(9).fontColor(0xCCCCCC).width('90%')
...@@ -114,11 +140,20 @@ struct FlexExample { ...@@ -114,11 +140,20 @@ struct FlexExample {
Text('no alignSelf,height:80').width('33%').height(80) Text('no alignSelf,height:80').width('33%').height(80)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .backgroundColor(0xF5DEB3).textAlign(TextAlign.Center)
Text('alignSelf stretch') Text('alignSelf stretch')
.alignSelf(ItemAlign.Stretch).width('33%').height(80).lineHeight(70) .alignSelf(ItemAlign.Stretch)
.backgroundColor(0xD2B48C).textAlign(TextAlign.Center) .width('33%')
.height(80)
.lineHeight(70)
.backgroundColor(0xD2B48C)
.textAlign(TextAlign.Center)
Text('no alignSelf,height:100').width('34%').height(100) Text('no alignSelf,height:100').width('34%').height(100)
.backgroundColor(0xF5DEB3).textAlign(TextAlign.Center) .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 }) }.width('100%').margin({ top: 5 })
} }
} }
\ No newline at end of file
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter'; import events_emitter from '@ohos.emitter';
@Entry @Entry
@Component @Component
struct GaugeExample { struct GaugeExample {
@State gaugeValue: string = 50; @State gaugeValue: string = 50;
@State strokeWidthValue: string = 20; @State strokeWidthValue: string = 20;
@State startAngleValue: string = 210; @State startAngleValue: string = 210;
@State endAngleValue: string = 150; @State endAngleValue: string = 150;
@State colorValues: Array = [[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]]; @State colorValues: Array = [[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1], [0x9C554B, 1], [0xD94838, 1]];
private stateChangCallBack = (eventData) => {
private stateChangCallBack = (eventData) => { if (eventData != null) {
if (eventData != null) { console.info("gauge page state change called:" + JSON.stringify(eventData));
console.info("gauge page state change called:" + JSON.stringify(eventData)); if (eventData.data.gaugeValue != null) {
if(eventData.data.gaugeValue != null) { this.gaugeValue = eventData.data.gaugeValue;
this.gaugeValue = eventData.data.gaugeValue; }
} if (eventData.data.strokeWidthValue != null) {
if(eventData.data.strokeWidthValue != null) { this.strokeWidthValue = eventData.data.strokeWidthValue;
this.strokeWidthValue = eventData.data.strokeWidthValue; }
} if (eventData.data.startAngleValue != null) {
if(eventData.data.startAngleValue != null) { this.startAngleValue = eventData.data.startAngleValue;
this.startAngleValue = eventData.data.startAngleValue; }
} if (eventData.data.endAngleValue != null) {
if(eventData.data.endAngleValue != null) { this.endAngleValue = eventData.data.endAngleValue;
this.endAngleValue = eventData.data.endAngleValue; }
} if (eventData.data.colorValues != null) {
if(eventData.data.colorValues != null) { this.colorValues = JSON.parse(eventData.data.colorValues);
this.colorValues = JSON.parse(eventData.data.colorValues); }
} }
} }
}
onPageShow() {
onPageShow() { console.info('gauge page show called');
console.info('gauge page show called'); var stateChangeEvent = {
var stateChangeEvent = { eventId: 102,
eventId: 102, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} events_emitter.on(stateChangeEvent, this.stateChangCallBack);
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
var stateChangeEventTwo = {
var stateChangeEventTwo = { eventId: 103,
eventId: 103, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} events_emitter.on(stateChangeEventTwo, this.stateChangCallBack);
events_emitter.on(stateChangeEventTwo, this.stateChangCallBack);
} var stateChangeEvent3 = {
eventId: 904,
build() { priority: events_emitter.EventPriority.LOW
Column() { }
Gauge({ value: 0, min: 0, max: 100 }) events_emitter.on(stateChangeEvent3, this.stateChangCallBack);
.key("gauge")
.value(`${this.gaugeValue}`) var stateChangeEvent4 = {
.startAngle(`${this.startAngleValue}`) eventId: 905,
.endAngle(`${this.endAngleValue}`) priority: events_emitter.EventPriority.LOW
.colors(this.colorValues) }
.strokeWidth(`${this.strokeWidthValue}`) events_emitter.on(stateChangeEvent4, this.stateChangCallBack);
.width(200).height(200)
}.width('100%').margin({ top: 300 }) 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 })
}
}
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
@Entry @Entry
@Component @Component
struct GlobalExample { struct GlobalExample {
onPageShow() { onPageShow() {
} }
...@@ -44,9 +43,9 @@ struct GlobalExample { ...@@ -44,9 +43,9 @@ struct GlobalExample {
let width = img.width; let width = img.width;
let height = img.height; let height = img.height;
this.context.imageSmoothingEnabled = false; this.context.imageSmoothingEnabled = false;
this.context.drawImage( img, 30, 950, 160, 100); this.context.drawImage(img, 30, 950, 160, 100);
console.log("imagebitmap_width="+width); console.log("imagebitmap_width=" + width);
console.log("imagebitmap_height="+height); console.log("imagebitmap_height=" + height);
} }
testOffscreenCanvas() { testOffscreenCanvas() {
...@@ -63,17 +62,19 @@ struct GlobalExample { ...@@ -63,17 +62,19 @@ struct GlobalExample {
testImageData() { testImageData() {
var offscreen = new OffscreenCanvas(300, 300); var offscreen = new OffscreenCanvas(300, 300);
var offCanvas2 = offscreen.getContext("2d"); var offCanvas2 = offscreen.getContext("2d");
var imageData = offCanvas2.createImageData(100,100); var imageData = offCanvas2.createImageData(100, 100);
var imgData = imageData.data; var imgData = imageData.data;
console.log("imageData_width="+imageData.width); console.log("imageData_width=" + imageData.width);
console.log("imageData_height="+imageData.height); console.log("imageData_height=" + imageData.height);
} }
testImage(){ testImage() {
var img = new Image("/images/bg.jpg",100,100) var img = new Image("/images/bg.jpg", 100, 100)
.onload(()=>{}) .onload(() => {
.onerror(()=>{}); })
console.log("img_width="+img.width); .onerror(() => {
console.log("img_height="+img.height); });
console.log("img_width=" + img.width);
console.log("img_height=" + img.height);
} }
} }
\ No newline at end of file
...@@ -24,8 +24,8 @@ struct GridSetting { ...@@ -24,8 +24,8 @@ struct GridSetting {
@State gridSpan: number = 1; @State gridSpan: number = 1;
@State gridOffset: number = 0; @State gridOffset: number = 0;
build(){ build() {
GridContainer({sizeType: SizeType.SM}) { GridContainer({ sizeType: SizeType.SM }) {
Row({}) { Row({}) {
Row() { Row() {
Text('Left').fontSize(25) Text('Left').fontSize(25)
...@@ -34,6 +34,7 @@ struct GridSetting { ...@@ -34,6 +34,7 @@ struct GridSetting {
.height("100%") .height("100%")
.backgroundColor(0x66bbb2cb) .backgroundColor(0x66bbb2cb)
.key('gridOffset') .key('gridOffset')
Row() { Row() {
Text('Center').fontSize(25) Text('Center').fontSize(25)
} }
...@@ -44,6 +45,7 @@ struct GridSetting { ...@@ -44,6 +45,7 @@ struct GridSetting {
.height("100%") .height("100%")
.backgroundColor(0x66b6c5d1) .backgroundColor(0x66b6c5d1)
.key('gridRow') .key('gridRow')
Row() { Row() {
Text('Right').fontSize(25) Text('Right').fontSize(25)
} }
...@@ -58,6 +60,7 @@ struct GridSetting { ...@@ -58,6 +60,7 @@ struct GridSetting {
.margin({ top: 10 }) .margin({ top: 10 })
.key('gridContainer') .key('gridContainer')
} }
onPageShow() { onPageShow() {
let smChangeEvent = { let smChangeEvent = {
eventId: 9, eventId: 9,
...@@ -75,6 +78,7 @@ struct GridSetting { ...@@ -75,6 +78,7 @@ struct GridSetting {
} }
events_emitter.on(spanChangeEvent, this.stateChangCallBack); events_emitter.on(spanChangeEvent, this.stateChangCallBack);
} }
stateChangCallBack = (eventData) => { stateChangCallBack = (eventData) => {
console.info("GridSetting page stateChangCallBack" + JSON.stringify(eventData)); console.info("GridSetting page stateChangCallBack" + JSON.stringify(eventData));
if (eventData && eventData.data) { if (eventData && eventData.data) {
......
...@@ -28,7 +28,6 @@ struct ImageEffectsExample { ...@@ -28,7 +28,6 @@ struct ImageEffectsExample {
@State contrastValue: string= 20; @State contrastValue: string= 20;
@State invertValue: string= 10; @State invertValue: string= 10;
@State hueRotateValue: string= 10 @State hueRotateValue: string= 10
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("imageEffects page state change called:" + JSON.stringify(eventData)); console.info("imageEffects page state change called:" + JSON.stringify(eventData));
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets"; import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
......
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter'; import events_emitter from '@ohos.emitter';
class ContainerInfo { class ContainerInfo {
label : string = '' label: string = ''
size : string = '' size: string = ''
}; };
class ChildInfo { class ChildInfo {
text : string = '' text: string = ''
priority : number = 0 priority: number = 0
}; };
@Entry @Entry
@Component @Component
struct LayoutConstraints { struct LayoutConstraints {
private children : string[] = ['1', '2', '3', '4', '5', '6']; private children: string[] = ['1', '2', '3', '4', '5', '6'];
@State aspectRatio: number = 1.5; @State aspectRatio: number = 1.5;
private container: ContainerInfo[] = [ private container: ContainerInfo[] = [
{label: 'Big container', size: '97%'}, { label: 'Big container', size: '97%' },
{label: 'Small container', size: '30%'}]; { label: 'Small container', size: '30%' }];
@State priorityChildren: any[] = [ @State priorityChildren: any[] = [
{text: '1\n(priority:1)', priority: 1}, { text: '1\n(priority:1)', priority: 1 },
{text: '2\n(priority:2)', priority: 2}, { text: '2\n(priority:2)', priority: 2 },
{text: '3\n(priority:3)', priority: 3}, { text: '3\n(priority:3)', priority: 3 },
{text: '4\n(priority:4)', priority: 4}]; { text: '4\n(priority:4)', priority: 4 }];
@State currentIndex : number = 0; @State currentIndex: number = 0;
build() { build() {
Column({ space: 20 }) { Column({ space: 20 }) {
Text('using container: row').fontSize(20).fontColor(Color.Black).width('100%') Text('using container: row').fontSize(20).fontColor(Color.Black).width('100%')
Row({space: 10}) { Row({ space: 10 }) {
ForEach(this.children, (item) => { ForEach(this.children, (item) => {
Text(item) Text(item)
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
.fontSize(20) .fontSize(20)
.aspectRatio(this.aspectRatio) .aspectRatio(this.aspectRatio)
.height(60) .height(60)
Text(item) Text(item)
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
.fontSize(20) .fontSize(20)
.aspectRatio(this.aspectRatio) .aspectRatio(this.aspectRatio)
.width(60) .width(60)
.key('aspectRatio') .key('aspectRatio')
}, item=>item) }, item => item)
} }
.size({width: "100%", height: 100}) .size({ width: "100%", height: 100 })
.backgroundColor(0xd2cab3) .backgroundColor(0xd2cab3)
.clip(true) .clip(true)
Text('using container: grid').fontSize(20).fontColor(Color.Black).width('100%') Text('using container: grid').fontSize(20).fontColor(Color.Black).width('100%')
Grid() { Grid() {
ForEach(this.children, (item) => { ForEach(this.children, (item) => {
GridItem() { GridItem() {
Text(item) Text(item)
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
.fontSize(40) .fontSize(40)
.aspectRatio(this.aspectRatio) .aspectRatio(this.aspectRatio)
} }
}, item=>item) }, item => item)
} }
.columnsTemplate('1fr 1fr 1fr') .columnsTemplate('1fr 1fr 1fr')
.columnsGap(10) .columnsGap(10)
.rowsGap(10) .rowsGap(10)
.size({width: "100%", height: 165}) .size({ width: "100%", height: 165 })
.backgroundColor(0xd2cab3) .backgroundColor(0xd2cab3)
Text('displayPriority 4').fontSize(20).fontColor(Color.Black).width('100%') Text('displayPriority 4').fontSize(20).fontColor(Color.Black).width('100%')
Flex({justifyContent: FlexAlign.SpaceBetween}) { Flex({ justifyContent: FlexAlign.SpaceBetween }) {
ForEach(this.priorityChildren, (item)=>{ ForEach(this.priorityChildren, (item) => {
if (item.priority === 1 || item.priority === 5) { if (item.priority === 1 || item.priority === 5) {
Text(`1\n(priority:${item.priority})`) Text(`1\n(priority:${item.priority})`)
.width(135) .width(135)
.height(60) .height(60)
.fontSize(18) .fontSize(18)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
.displayPriority(item.priority) .displayPriority(item.priority)
.key('displayPriority') .key('displayPriority')
} else { } else {
Text(item.text) Text(item.text)
.width(135) .width(135)
.height(60) .height(60)
.fontSize(18) .fontSize(18)
.textAlign(TextAlign.Center) .textAlign(TextAlign.Center)
.backgroundColor(0xbbb2cb) .backgroundColor(0xbbb2cb)
.displayPriority(item.priority) .displayPriority(item.priority)
} }
}, item=>item.text) }, item => item.text)
} }
.width(this.container[this.currentIndex].size) .width(this.container[this.currentIndex].size)
.backgroundColor(0xd2cab3) .backgroundColor(0xd2cab3)
}.padding(10) }.padding(10)
} }
onPageShow() {
let aspectRatioChangeEvent = { onPageShow() {
eventId: 20, let aspectRatioChangeEvent = {
priority: events_emitter.EventPriority.LOW eventId: 20,
} priority: events_emitter.EventPriority.LOW
events_emitter.on(aspectRatioChangeEvent, this.stateChangCallBack); }
events_emitter.on(aspectRatioChangeEvent, this.stateChangCallBack);
let priorityChangeEvent = {
eventId: 21, let priorityChangeEvent = {
priority: events_emitter.EventPriority.LOW eventId: 21,
} priority: events_emitter.EventPriority.LOW
events_emitter.on(priorityChangeEvent, this.stateChangCallBack); }
} events_emitter.on(priorityChangeEvent, this.stateChangCallBack);
stateChangCallBack = (eventData) => {
console.info("LayoutConstraints page stateChangCallBack" + JSON.stringify(eventData)); let priorityChangeEvent2 = {
if (eventData) { eventId: 1112,
if (eventData.data.aspectRatio) { priority: events_emitter.EventPriority.LOW
this.aspectRatio = eventData.data.aspectRatio; }
} else if (eventData.data.displayPriority) { events_emitter.on(priorityChangeEvent2, this.stateChangCallBack);
let priority = JSON.parse(JSON.stringify(this.priorityChildren)); }
priority[0].priority = eventData.data.displayPriority;
this.priorityChildren = []; stateChangCallBack = (eventData) => {
this.priorityChildren = priority; 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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter'; import events_emitter from '@ohos.emitter';
@Entry @Entry
@Component @Component
struct ListExample { struct ListExample {
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
@State listDirection: Axis = Axis.Vertical; @State listDirection: Axis = Axis.Vertical;
@State editMode: boolean = false; @State editMode: boolean = false;
@State edgeEffect: EdgeEffect = EdgeEffect.None; @State edgeEffect: EdgeEffect = EdgeEffect.None;
@State chainAnimation: boolean = false; @State chainAnimation: boolean = false;
@State strokeWidth: number = 2.000000; @State strokeWidth: number = 2.000000;
@State color: string = 0xFFFFFF; @State color: string = 0xFFFFFF;
@State startMargin: number = 20.000000; @State startMargin: number = 20.000000;
@State endMargin: number = 20.000000; @State endMargin: number = 20.000000;
onPageShow() { onPageShow() {
console.info('[list] page show called'); console.info('[list] page show called');
var stateChangeEvent = { var stateChangeEvent = {
eventId: 124, eventId: 124,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack); events_emitter.on(stateChangeEvent, this.stateChangCallBack);
var stateChangeEventTwo = { var stateChangeEventTwo = {
eventId: 125, eventId: 125,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEventTwo, this.stateChangCallBackTwo); events_emitter.on(stateChangeEventTwo, this.stateChangCallBackTwo);
}
var stateChangeEvent3 = {
private stateChangCallBack = (eventData) => { eventId: 901,
console.info("[stateChangCallBack] stateChangCallBack"); priority: events_emitter.EventPriority.LOW
if (eventData != null) { }
console.info("[stateChangCallBack] state change called:" + JSON.stringify(eventData)); events_emitter.on(stateChangeEvent3, this.stateChangCallBackTwo);
if(eventData.data.listDirection != null) {
this.listDirection = eventData.data.listDirection; var stateChangeEvent4 = {
} eventId: 902,
if(eventData.data.editMode != null) { priority: events_emitter.EventPriority.LOW
this.editMode = eventData.data.editMode; }
} events_emitter.on(stateChangeEvent4, this.stateChangCallBackTwo);
if(eventData.data.edgeEffect != null) {
this.edgeEffect = eventData.data.edgeEffect; var stateChangeEvent5 = {
} eventId: 903,
if(eventData.data.chainAnimation != null) { priority: events_emitter.EventPriority.LOW
this.chainAnimation = eventData.data.chainAnimation; }
} events_emitter.on(stateChangeEvent5, this.stateChangCallBackTwo);
} }
}
private stateChangCallBack = (eventData) => {
private stateChangCallBackTwo = (eventData) => { console.info("[stateChangCallBack] stateChangCallBack");
console.info("[stateChangCallBackTwo] stateChangCallBack"); if (eventData != null) {
if (eventData != null) { console.info("[stateChangCallBack] state change called:" + JSON.stringify(eventData));
console.info("[stateChangCallBackTwo] state change called:" + JSON.stringify(eventData)); if (eventData.data.listDirection != null) {
if(eventData.data.strokeWidth != null) { this.listDirection = eventData.data.listDirection;
this.strokeWidth = eventData.data.strokeWidth; }
} if (eventData.data.editMode != null) {
if(eventData.data.color != null) { this.editMode = eventData.data.editMode;
this.color = eventData.data.color; }
} if (eventData.data.edgeEffect != null) {
if(eventData.data.startMargin != null) { this.edgeEffect = eventData.data.edgeEffect;
this.startMargin = eventData.data.startMargin; }
} if (eventData.data.chainAnimation != null) {
if(eventData.data.endMargin != null) { this.chainAnimation = eventData.data.chainAnimation;
this.endMargin = eventData.data.endMargin; }
} }
} }
} private stateChangCallBackTwo = (eventData) => {
console.info("[stateChangCallBackTwo] stateChangCallBack");
build() { if (eventData != null) {
Stack({ alignContent: Alignment.TopStart }) { console.info("[stateChangCallBackTwo] state change called:" + JSON.stringify(eventData));
Column() { if (eventData.data.strokeWidth != null) {
List({ space: 20, initialIndex: 0 }) { this.strokeWidth = eventData.data.strokeWidth;
ForEach(this.arr, (item) => { }
ListItem() { if (eventData.data.color != null) {
Text('' + item) this.color = eventData.data.color;
.width('100%').height(100).fontSize(16) }
.textAlign(TextAlign.Center).borderRadius(10).backgroundColor(0xFFFFFF) if (eventData.data.startMargin != null) {
}.editable(true) this.startMargin = eventData.data.startMargin;
}, item => item) }
} if (eventData.data.endMargin != null) {
.key('list') this.endMargin = eventData.data.endMargin;
.listDirection(this.listDirection) }
.divider({ strokeWidth: this.strokeWidth, color: this.color, startMargin: this.startMargin, endMargin: this.endMargin }) }
.edgeEffect(this.edgeEffect) }
.chainAnimation(this.chainAnimation)
.multiSelectable(true) build() {
.onScrollIndex((firstIndex: number, lastIndex: number) => { Stack({ alignContent: Alignment.TopStart }) {
console.info('first' + firstIndex) Column() {
console.info('last' + lastIndex) List({ space: 20, initialIndex: 0 }) {
}) ForEach(this.arr, (item) => {
.onScroll((scrollOffset: number, scrollState: ScrollState) => { ListItem() {
console.info('scrollOffset:' + scrollOffset) Text('' + item)
console.info('scrollState:' + scrollState) .width('100%')
}) .height(100)
.editMode(this.editMode) .fontSize(16)
.onItemDelete((index: number) => { .textAlign(TextAlign.Center)
console.info(this.arr[index] + 'Delete') .borderRadius(10)
this.arr.splice(index, 1) .backgroundColor(0xFFFFFF)
console.info(JSON.stringify(this.arr)) }.editable(true)
this.editFlag = false }, item => item)
return true }
}).width('90%') .key('list')
}.width('100%') .listDirection(this.listDirection)
Button('edit list') .divider({
.onClick(() => { strokeWidth: this.strokeWidth,
this.editMode = !this.editMode color: this.color,
}).margin({ top: 5, left: 20 }) startMargin: this.startMargin,
}.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) 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
...@@ -44,7 +44,7 @@ struct MarqueeExample { ...@@ -44,7 +44,7 @@ struct MarqueeExample {
.allowScale(false) .allowScale(false)
.fontWeight(FontWeight.Bold) .fontWeight(FontWeight.Bold)
.backgroundColor(Color.Black) .backgroundColor(Color.Black)
.margin({bottom:40}) .margin({ bottom: 40 })
.onStart(() => { .onStart(() => {
console.log('Marquee animation complete onStart') console.log('Marquee animation complete onStart')
console.info('Onstart current action state is: ' + this.fontColor); console.info('Onstart current action state is: ' + this.fontColor);
...@@ -125,7 +125,7 @@ struct MarqueeExample { ...@@ -125,7 +125,7 @@ struct MarqueeExample {
}) })
.width(200) .width(200)
.height(60) .height(60)
.margin({bottom:20}) .margin({ bottom: 20 })
} }
.width('100%') .width('100%')
.height('100%') .height('100%')
......
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter' import events_emitter from '@ohos.emitter'
@Entry @Entry
@Component @Component
struct OverlayExample { struct OverlayExample {
@State title: string = 'old title' @State title: string = 'old title'
@State x: number = 0 @State x: number = 0
@State y: number = -15 @State y: number = -15
@State alignment: Alignment = Alignment.Bottom @State alignment: Alignment = Alignment.Bottom
onPageShow() { onPageShow() {
console.info('[overlay] page show called '); console.info('[overlay] page show called ');
var stateChangeEvent = { var stateChangeEvent = {
eventId: 143, eventId: 143,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack); events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
var stateChangeEvent2 = {
private stateChangCallBack = (eventData) => { eventId: 1110,
console.info("[stateChangCallBack] stateChangCallBack "); priority: events_emitter.EventPriority.LOW
if (eventData != null) { }
console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData)); events_emitter.on(stateChangeEvent2, this.stateChangCallBack);
if (eventData.data.align != null) { }
this.alignment = eventData.data.align
} private stateChangCallBack = (eventData) => {
if (eventData.data.title != null) { console.info("[stateChangCallBack] stateChangCallBack ");
this.title = eventData.data.title if (eventData != null) {
} console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData));
if (eventData.data.x != null) { if (eventData.data.align != null) {
this.x = eventData.data.x this.alignment = eventData.data.align
} }
if (eventData.data.y != null) { if (eventData.data.title != null) {
this.y = eventData.data.y this.title = eventData.data.title
} }
if (eventData.data.x != null) {
} this.x = eventData.data.x
} }
if (eventData.data.y != null) {
build() { this.y = eventData.data.y
Column() { }
Column() {
Text('floating layer') }
.fontSize(12).fontColor(0xCCCCCC).maxLines(1) }
Column() {
Image('/images/img.jpeg') build() {
.width(340).height(240) Column() {
.key('overlay') Column() {
.overlay(this.title, Text('floating layer')
{ align: this.alignment, offset: { x: this.x, y: this.y } }) .fontSize(12).fontColor(0xCCCCCC).maxLines(1)
}.border({ color: Color.Black, width: 2 }) Column() {
}.width('100%') Image('/images/img.jpeg')
}.padding({ top: 20 }) .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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter' import events_emitter from '@ohos.emitter'
@Entry @Entry
@Component @Component
struct StepperExample { struct StepperExample {
@State currentIndex: number = 0 @State currentIndex: number = 0
@State firstState: ItemState = ItemState.Normal @State firstState: ItemState = ItemState.Normal
@State secondState: ItemState = ItemState.Normal @State secondState: ItemState = ItemState.Normal
@State disabled: ItemState = ItemState.Normal @State disabled: ItemState = ItemState.Normal
build() { build() {
Stepper({ Stepper({
index: this.currentIndex index: this.currentIndex
}) { }) {
StepperItem() { StepperItem() {
Text('Page One') Text('Page One')
.fontSize(35) .fontSize(35)
.fontColor(Color.Blue) .fontColor(Color.Blue)
.width(200) .width(200)
.lineHeight(50) .lineHeight(50)
.margin({top:250}) .margin({ top: 250 })
} }
.nextLabel('') .nextLabel('')
.position({x: '35%', y: 0}) .position({ x: '35%', y: 0 })
.key('stepperItem1') .key('stepperItem1')
StepperItem() {
Text('Page Two') StepperItem() {
.fontSize(35) Text('Page Two')
.fontColor(Color.Blue) .fontSize(35)
.width(200) .fontColor(Color.Blue)
.lineHeight(50) .width(200)
.margin({top:250}) .lineHeight(50)
.key('text1') .margin({ top: 250 })
.onClick(()=>{ .key('text1')
this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip .onClick(() => {
}) this.firstState = this.firstState === ItemState.Skip ? ItemState.Normal : ItemState.Skip
} })
.nextLabel('Next') }
.prevLabel('Previous') .nextLabel('Next')
.status(this.firstState) .prevLabel('Previous')
.position({x: '35%', y: 0}) .status(this.firstState)
.key('stepperItem2') .position({ x: '35%', y: 0 })
StepperItem() { .key('stepperItem2')
Text('Page Three')
.fontSize(35) StepperItem() {
.fontColor(Color.Blue) Text('Page Three')
.width(200) .fontSize(35)
.lineHeight(50) .fontColor(Color.Blue)
.margin({top:250}) .width(200)
.key('text2') .lineHeight(50)
.onClick(()=>{ .margin({ top: 250 })
this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting .key('text2')
}) .onClick(() => {
} this.secondState = this.secondState === ItemState.Waiting ? ItemState.Normal : ItemState.Waiting
.position({x: '35%', y: 0}) })
.status(this.secondState) }
.key('stepperItem3') .position({ x: '35%', y: 0 })
StepperItem() { .status(this.secondState)
Text('Page four') .key('stepperItem3')
.fontSize(35)
.fontColor(Color.Blue) StepperItem() {
.width(200) Text('Page four')
.lineHeight(50) .fontSize(35)
.margin({top:250}) .fontColor(Color.Blue)
} .width(200)
.position({x: '35%', y: 0}) .lineHeight(50)
.nextLabel('Finish') .margin({ top: 250 })
.key('stepperItem4') }
} .position({ x: '35%', y: 0 })
.onFinish(() => { .nextLabel('Finish')
console.log('onFinish') .key('stepperItem4')
}) }
.onSkip(() => { .onFinish(() => {
console.log('onSkip') console.log('onFinish')
}) })
.onChange((prevIndex: number, index: number) => { .onSkip(() => {
this.currentIndex = index console.log('onSkip')
}) })
.align(Alignment.Center) .onChange((prevIndex: number, index: number) => {
.key('stepper') this.currentIndex = index
} })
.align(Alignment.Center)
onPageShow() { .key('stepper')
console.info('stepper page show called'); }
var stateChangeEvent = {
eventId: 202, onPageShow() {
priority: events_emitter.EventPriority.LOW console.info('stepper page show called');
} var stateChangeEvent = {
events_emitter.on(stateChangeEvent, this.stateChangCallBack) eventId: 202,
} priority: events_emitter.EventPriority.LOW
}
private stateChangCallBack = (eventData) => { events_emitter.on(stateChangeEvent, this.stateChangCallBack)
console.info("stepper page stateChangCallBack" + JSON.stringify(eventData));
if (eventData != null) { var stateChangeEventTwo = {
console.info("stepper page state change called:" + JSON.stringify(eventData)); eventId: 909,
if(eventData.data.currentIndex != null) { priority: events_emitter.EventPriority.LOW
this.currentIndex = parseInt(eventData.data.currentIndex); }
} events_emitter.on(stateChangeEventTwo, this.stateChangCallBack);
if(eventData.data.disabled != null) {
this.disabled = eventData.data.disabled; 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
...@@ -92,7 +92,7 @@ struct SwiperExample { ...@@ -92,7 +92,7 @@ struct SwiperExample {
.displayMode(this.displayMode) .displayMode(this.displayMode)
.displayCount(this.displayCount) .displayCount(this.displayCount)
.effectMode(this.edgeEffect) .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') .key('swiper')
.onChange((index: number) => { .onChange((index: number) => {
console.info(index.toString()) console.info(index.toString())
......
...@@ -68,8 +68,9 @@ struct TextStyle { ...@@ -68,8 +68,9 @@ struct TextStyle {
.fontStyle(FontStyle.Normal) .fontStyle(FontStyle.Normal)
.fontWeight(400) .fontWeight(400)
.fontFamily('source-sans-pro,cursive,sans-serif') .fontFamily('source-sans-pro,cursive,sans-serif')
}.width('100%').margin({top: 20}) }.width('100%').margin({ top: 20 })
} }
onPageShow() { onPageShow() {
let fontColorChangeEvent = { let fontColorChangeEvent = {
eventId: 37, eventId: 37,
...@@ -97,6 +98,7 @@ struct TextStyle { ...@@ -97,6 +98,7 @@ struct TextStyle {
} }
events_emitter.on(fontFamilyChangeEvent, this.textStyleChangCallBack); events_emitter.on(fontFamilyChangeEvent, this.textStyleChangCallBack);
} }
textStyleChangCallBack = (eventData) => { textStyleChangCallBack = (eventData) => {
console.info("textStyle page stateChangCallBack" + JSON.stringify(eventData)); console.info("textStyle page stateChangCallBack" + JSON.stringify(eventData));
if (eventData && eventData.data) { if (eventData && eventData.data) {
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.emitter' ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.emitter'
@Entry @Entry
@Preview @Preview
@Component @Component
struct TouchExample { struct TouchExample {
@State text: string = '' @State text: string = ''
@State eventType: string = '' @State eventType: string = ''
@State touchFlag: boolean = false @State touchFlag: boolean = false
...@@ -37,13 +37,13 @@ struct TouchExample { ...@@ -37,13 +37,13 @@ struct TouchExample {
console.info("[touch] page stateChangCallBack"); console.info("[touch] page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
console.info("[touch] page state change called:" + JSON.stringify(eventData)); 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; this.text = eventData.data.text;
} }
if(eventData.data.eventType != null) { if (eventData.data.eventType != null) {
this.eventType = eventData.data.eventType; this.eventType = eventData.data.eventType;
} }
if(eventData.data.touchFlag != null) { if (eventData.data.touchFlag != null) {
this.touchFlag = eventData.data.touchFlag this.touchFlag = eventData.data.touchFlag
} }
} }
...@@ -51,7 +51,10 @@ struct TouchExample { ...@@ -51,7 +51,10 @@ struct TouchExample {
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) { 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') .key('touch')
.onTouch((event: Touch) => { .onTouch((event: Touch) => {
if (event.type === TouchType.Down) { if (event.type === TouchType.Down) {
...@@ -72,7 +75,7 @@ struct TouchExample { ...@@ -72,7 +75,7 @@ struct TouchExample {
stopPropagation: () => { stopPropagation: () => {
console.info('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 console.info(this.text = 'TouchType:' + this.eventType
+ '\nDistance between touch point and touch element:\nx: ' + '\nDistance between touch point and touch element:\nx: '
+ event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:(' + event.touches[0].x + '\n' + 'y: ' + event.touches[0].y + '\ncomponent globalPos:('
...@@ -84,7 +87,7 @@ struct TouchExample { ...@@ -84,7 +87,7 @@ struct TouchExample {
+ event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:' + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\nwidth:'
+ event.target.area.width + '\nheight:' + event.target.area.height) + event.target.area.width + '\nheight:' + event.target.area.height)
console.log('fang--->A') console.log('fang--->A')
try{ try {
console.log('fang--->B') console.log('fang--->B')
var backData = { var backData = {
data: { data: {
...@@ -99,7 +102,7 @@ struct TouchExample { ...@@ -99,7 +102,7 @@ struct TouchExample {
console.log('fang--->D') console.log('fang--->D')
console.info("touchFlag start to emit action state") console.info("touchFlag start to emit action state")
events_emitter.emit(backEvent, backData) events_emitter.emit(backEvent, backData)
}catch{ } catch {
console.info("touchFlag emit action state err: " + JSON.stringify(err.message)) console.info("touchFlag emit action state err: " + JSON.stringify(err.message))
} }
}) })
......
...@@ -23,7 +23,6 @@ struct TouchAbleExample { ...@@ -23,7 +23,6 @@ struct TouchAbleExample {
@State text1: string = ''; @State text1: string = '';
@State text2: string = ''; @State text2: string = '';
@State touchableValue: boolean = false; @State touchableValue: boolean = false;
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
console.info("[TouchAble] page stateChangCallBack"); console.info("[TouchAble] page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
...@@ -46,13 +45,17 @@ struct TouchAbleExample { ...@@ -46,13 +45,17 @@ struct TouchAbleExample {
build() { build() {
Stack() { Stack() {
Rect() Rect()
.fill(Color.Gray).width(150).height(150) .fill(Color.Gray)
.width(150)
.height(150)
.onClick(() => { .onClick(() => {
console.info(this.text1 = 'Rect Clicked') console.info(this.text1 = 'Rect Clicked')
}) })
.overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } }) .overlay(this.text1, { align: Alignment.Bottom, offset: { x: 0, y: 20 } })
Ellipse() Ellipse()
.fill(Color.Pink).width(150).height(80) .fill(Color.Pink)
.width(150)
.height(80)
.key('ellipse') .key('ellipse')
.touchable(this.touchableValue) .touchable(this.touchableValue)
.onClick(() => { .onClick(() => {
......
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter'; import events_emitter from '@ohos.emitter';
@Entry @Entry
@Component @Component
struct VisibilityExample { struct VisibilityExample {
@State visibility: Visibility = Visibility.Visible; @State visibility: Visibility = Visibility.Visible;
onPageShow() { onPageShow() {
let hiddenChangeEvent = { let hiddenChangeEvent = {
eventId: 47, eventId: 47,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(hiddenChangeEvent, this.hiddenChangCallBack) events_emitter.on(hiddenChangeEvent, this.hiddenChangCallBack)
let noneChangeEvent = { let noneChangeEvent = {
eventId: 48, eventId: 48,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(noneChangeEvent, this.noneChangCallBack) events_emitter.on(noneChangeEvent, this.noneChangCallBack)
}
var stateChangeEvent2 = {
private hiddenChangCallBack = (eventData) => { eventId: 1116,
console.info("[hiddenChangCallBack] stateChangCallBack"); priority: events_emitter.EventPriority.LOW
if (eventData != null) { }
console.info("[hiddenChangCallBack] state change called:" + JSON.stringify(eventData)); events_emitter.on(stateChangeEvent2, this.stateChangCallBack);
if(eventData.data.visibility != null) { }
this.visibility = eventData.data.visibility;
} private hiddenChangCallBack = (eventData) => {
} console.info("[hiddenChangCallBack] stateChangCallBack");
} if (eventData != null) {
console.info("[hiddenChangCallBack] state change called:" + JSON.stringify(eventData));
private noneChangCallBack = (eventData) => { if (eventData.data.visibility != null) {
console.info("[noneChangCallBack] stateChangCallBack"); this.visibility = eventData.data.visibility;
if (eventData != null) { }
console.info("[noneChangCallBack] 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) {
build() { this.visibility = eventData.data.visibility;
Column() { }
Column() { }
Text('BoxOne').fontSize(9).width('90%').fontColor(0xCCCCCC) }
Row().visibility(this.visibility).width('90%').height(80).backgroundColor(0xAFEEEE).padding(20).key('box')
build() {
Text('BoxTwo').fontSize(9).width('90%').fontColor(0xCCCCCC) Column() {
Row().visibility(Visibility.Visible).width('90%').height(80).backgroundColor(0xAFEEEE).padding(20) Column() {
}.width('90%').border({ width: 1 }) Text('BoxOne').fontSize(9).width('90%').fontColor(0xCCCCCC)
}.width('100%').margin({ top: 5 }) 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 // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.emitter' import events_emitter from '@ohos.emitter'
@Entry @Entry
@Component @Component
struct zIndexExample { struct zIndexExample {
@State zIndex: number = 1; @State zIndex: number = 1;
onPageShow() { onPageShow() {
console.info('[zIndex] page show called '); console.info('[zIndex] page show called ');
var stateChangeEvent = { var stateChangeEvent = {
eventId: 236, eventId: 236,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack); events_emitter.on(stateChangeEvent, this.stateChangCallBack);
} var stateChangeEvent2 = {
eventId: 1113,
private stateChangCallBack = (eventData) => { priority: events_emitter.EventPriority.LOW
console.info("[stateChangCallBack] stateChangCallBack "); }
if (eventData != null) { events_emitter.on(stateChangeEvent2, this.stateChangCallBack);
console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData));
if (eventData.data.zIndex != null) { }
this.zIndex = eventData.data.zIndex
} private stateChangCallBack = (eventData) => {
} console.info("[stateChangCallBack] stateChangCallBack ");
} if (eventData != null) {
console.info("[stateChangCallBack] state change called: " + JSON.stringify(eventData));
build() { if (eventData.data.zIndex != null) {
Column() { this.zIndex = eventData.data.zIndex
Stack() { }
Text('first child, zIndex(2)') }
.size({ width: '40%', height: '60%' }).backgroundColor(0xbbb2cb) }
.zIndex(2)
Text('second child, default zIndex(0)') build() {
.size({ width: '90%', height: '80%' }).backgroundColor(0xd2cab3).align(Alignment.TopStart) Column() {
Text('third child, zIndex(1)') Stack() {
.size({ width: '70%', height: '50%' }) Text('first child, zIndex(2)')
.backgroundColor(0xc1cbac) .size({ width: '40%', height: '60%' }).backgroundColor(0xbbb2cb)
.align(Alignment.TopStart) .zIndex(2)
.zIndex(this.zIndex) Text('second child, default zIndex(0)')
.key('zIndex') .size({ width: '90%', height: '80%' }).backgroundColor(0xd2cab3).align(Alignment.TopStart)
} Text('third child, zIndex(1)')
}.width('100%').height(200) .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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter' import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils.ets';
export default function appearJsunit() {
describe('appInfoTest', function () { export default function appearJsunit() {
beforeEach(async function (done) { describe('appearTest', function () {
console.info("appear beforeEach start"); beforeEach(async function (done) {
let options = { console.info("appear beforeEach start");
uri: 'pages/appear', let options = {
} uri: 'pages/appear',
let result; }
try { let result;
router.clear(); try {
let pages = router.getState(); router.clear();
console.info("get appear state pages: " + JSON.stringify(pages)); let pages = router.getState();
if (!("appear" == pages.name)) { console.info("get appear state pages: " + JSON.stringify(pages));
console.info("get appear state pages.name: " + JSON.stringify(pages.name)); if (!("appear" == pages.name)) {
result = await router.push(options); console.info("get appear state pages.name: " + JSON.stringify(pages.name));
await Utils.sleep(2000); result = await router.push(options);
console.info("push appear page result: " + JSON.stringify(result)); await Utils.sleep(2000);
} console.info("push appear page result: " + JSON.stringify(result));
} catch (err) { }
console.error("push appear page error: " + err); } catch (err) {
} console.error("push appear page error: " + err);
done() }
}); done()
});
afterEach(async function () {
await Utils.sleep(1000); afterEach(async function () {
console.info("appear after each called"); await Utils.sleep(1000);
}) console.info("appear after each called");
})
it('testAppear01', 0, async function (done) {
console.info('[testAppear01] START'); it('testAppear01', 0, async function (done) {
await Utils.sleep(1000); console.info('[testAppear01] START');
try { await Utils.sleep(1000);
let callBackAppear = (backData) => { try {
console.info("testAppear01 get appearEvent result is: " + JSON.stringify(appearEvent)); let callBackAppear = (backData) => {
expect(backData.data.ACTION).assertEqual(true); console.info("testAppear01 get appearEvent result is: " + JSON.stringify(appearEvent));
} expect(backData.data.ACTION).assertEqual(true);
var appearEvent = { }
eventId: 58, var appearEvent = {
priority: events_emitter.EventPriority.LOW eventId: 58,
} priority: events_emitter.EventPriority.LOW
events_emitter.on(appearEvent, callBackAppear); }
} catch (err) { events_emitter.on(appearEvent, callBackAppear);
console.info("testAppear01 on appearEvent err : " + JSON.stringify(err)); } 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'); console.info("testAppear01 click result is: " + JSON.stringify(sendEventByKey('appear', 10, "")));
done(); console.info('[testAppear01] END');
}); done();
});
it('testAppear02', 0, async function (done) {
console.info('[testAppear02] START'); it('testAppear02', 0, async function (done) {
await Utils.sleep(1000); console.info('[testAppear02] START');
try { await Utils.sleep(1000);
let callBackAppear = (backData) => { try {
console.info("testAppear02 get appearEvent result is: " + JSON.stringify(appearEvent)); let callBackAppear = (backData) => {
expect(backData.data.ACTION).assertEqual(true); console.info("testAppear02 get appearEvent result is: " + JSON.stringify(appearEvent));
} expect(backData.data.ACTION).assertEqual(true);
var appearEvent = { }
eventId: 59, var appearEvent = {
priority: events_emitter.EventPriority.LOW eventId: 59,
} priority: events_emitter.EventPriority.LOW
events_emitter.on(appearEvent, callBackAppear); }
} catch (err) { events_emitter.on(appearEvent, callBackAppear);
console.info("testAppear02 on appearEvent err : " + JSON.stringify(err)); } catch (err) {
} console.info("testAppear02 on appearEvent err : " + JSON.stringify(err));
console.info("testAppear02 appearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, ""))); }
console.info("testAppear02 appearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, "")));
try {
let callBackDisAppear = (backData) => { try {
console.info("testAppear02 get disAppearEvent result is: " + JSON.stringify(disAppearEvent)); let callBackDisAppear = (backData) => {
expect(backData.data.ACTION).assertEqual(true); console.info("testAppear02 get disAppearEvent result is: " + JSON.stringify(disAppearEvent));
} expect(backData.data.ACTION).assertEqual(true);
var disAppearEvent = { }
eventId: 60, var disAppearEvent = {
priority: events_emitter.EventPriority.LOW eventId: 60,
} priority: events_emitter.EventPriority.LOW
events_emitter.on(disAppearEvent, callBackDisAppear); }
} catch (err) { events_emitter.on(disAppearEvent, callBackDisAppear);
console.info("testAppear02 on disAppearEvent err : " + JSON.stringify(err)); } 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'); console.info("testAppear02 disAppearEvent click result is: " + JSON.stringify(sendEventByKey('appear', 10, "")));
done(); console.info('[testAppear02] END');
}); done();
});
})
} })
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter' import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils.ets';
export default function areaChangeJsunit() {
describe('areaChange', function () { export default function areaChangeJsunit() {
beforeEach(async function (done) { describe('areaChangeTest', function () {
let options = { beforeEach(async function (done) {
uri: 'pages/areaChange', let options = {
} uri: 'pages/areaChange',
try { }
router.clear(); try {
let pages = router.getState(); router.clear();
console.info("get areaChange state success " + JSON.stringify(pages)); let pages = router.getState();
if (!("areaChange" == pages.name)) { console.info("get areaChange state success " + JSON.stringify(pages));
console.info("get areaChange state success " + JSON.stringify(pages.name)); if (!("areaChange" == pages.name)) {
let result = await router.push(options); console.info("get areaChange state success " + JSON.stringify(pages.name));
await Utils.sleep(1000); let result = await router.push(options);
console.info("push areaChange page success " + JSON.stringify(result)); await Utils.sleep(1000);
} console.info("push areaChange page success " + JSON.stringify(result));
} catch (err) { }
console.error("push areaChange page error: " + err); } catch (err) {
} console.error("push areaChange page error: " + err);
done() }
}); done()
});
afterEach(async function () {
await Utils.sleep(1000); afterEach(async function () {
console.info("areaChange after each called"); await Utils.sleep(1000);
}); console.info("areaChange after each called");
});
it('areaChangeTest_0100', 0, async function (done) {
console.info('areaChangeTest_0100 START'); it('areaChangeTest_0100', 0, async function (done) {
let strJson = getInspectorByKey('text1'); console.info('areaChangeTest_0100 START');
console.info("areaChangeTest_0100 component strJson:" + strJson); let strJson = getInspectorByKey('text1');
let obj = JSON.parse(strJson); console.info("areaChangeTest_0100 component strJson:" + strJson);
console.info("areaChangeTest_0100 component obj is: " + JSON.stringify(obj)); let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text'); console.info("areaChangeTest_0100 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.width).assertEqual('42.000000'); expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.height).assertEqual('23.000000'); expect(obj.$attrs.width).assertEqual('42.000000');
console.info('areaChangeTest_0100 END'); expect(obj.$attrs.height).assertEqual('23.000000');
done(); console.info('areaChangeTest_0100 END');
}); done();
});
it('areaChangeTest_0200', 0, async function (done) {
console.info('areaChangeTest_0200 START'); it('areaChangeTest_0200', 0, async function (done) {
let strJson = getInspectorByKey('text2'); console.info('areaChangeTest_0200 START');
console.info("areaChangeTest_0200 component strJson:" + strJson); let strJson = getInspectorByKey('text2');
let obj = JSON.parse(strJson); console.info("areaChangeTest_0200 component strJson:" + strJson);
console.info("areaChangeTest_0200 component obj is: " + JSON.stringify(obj)); let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text'); console.info("areaChangeTest_0200 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.width).assertEqual('519.000000'); expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.height).assertEqual('140.000000'); expect(obj.$attrs.width).assertEqual('519.000000');
console.info('areaChangeTest_0200 END'); expect(obj.$attrs.height).assertEqual('210.000000');
done(); console.info('areaChangeTest_0200 END');
}); done();
});
it('areaChangeTest_0300', 0, async function (done) {
console.info('areaChangeTest_0300 START'); it('areaChangeTest_0300', 0, async function (done) {
await Utils.sleep(1000); console.info('areaChangeTest_0300 START');
let callback = (indexEvent) => { await Utils.sleep(1000);
console.info("areaChangeTest_0300 get state result is: " + JSON.stringify(indexEvent)); let callback = (indexEvent) => {
expect(indexEvent.data.value).assertEqual('TextText'); console.info("areaChangeTest_0300 get state result is: " + JSON.stringify(indexEvent));
} expect(indexEvent.data.value).assertEqual('TextText');
let indexEvent = { }
eventId: 61, let indexEvent = {
priority: events_emitter.EventPriority.LOW eventId: 61,
} priority: events_emitter.EventPriority.LOW
try { }
events_emitter.on(indexEvent, callback); try {
} catch (err) { events_emitter.on(indexEvent, callback);
console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err)); } 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 = { console.info("areaChangeTest_0300 click result is: " + JSON.stringify(sendEventByKey('text1', 10, "")));
eventId: 62, var innerEventOne = {
priority: events_emitter.EventPriority.LOW eventId: 62,
} priority: events_emitter.EventPriority.LOW
await Utils.sleep(1500); }
var callback1 = (eventData) => { await Utils.sleep(1500);
console.info("areaChangeTest_0300 get event state result is: " + JSON.stringify(eventData)); var callback1 = (eventData) => {
expect(eventData.data.ACTION).assertEqual(true); console.info("areaChangeTest_0300 get event state result is: " + JSON.stringify(eventData));
} expect(eventData.data.ACTION).assertEqual(true);
try { }
events_emitter.on(innerEventOne, callback1); try {
} catch (err) { events_emitter.on(innerEventOne, callback1);
console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err)); } catch (err) {
} console.info("areaChangeTest_0300 on events_emitter err : " + JSON.stringify(err));
console.info('areaChangeTest_0300 END'); }
done(); console.info('areaChangeTest_0300 END');
}); done();
});
it('areaChangeTest_0400', 0, async function (done) {
console.info('areaChangeTest_0400 START'); it('areaChangeTest_0400', 0, async function (done) {
await Utils.sleep(1000); console.info('areaChangeTest_0400 START');
let callback = (indexEvent) => { await Utils.sleep(1000);
console.info("areaChangeTest_0400 get state result is: " + JSON.stringify(indexEvent)); let callback = (indexEvent) => {
expect(indexEvent.data.value).assertEqual('TextTextText'); console.info("areaChangeTest_0400 get state result is: " + JSON.stringify(indexEvent));
} expect(indexEvent.data.value).assertEqual('TextTextText');
let indexEvent = { }
eventId: 62, let indexEvent = {
priority: events_emitter.EventPriority.LOW eventId: 62,
} priority: events_emitter.EventPriority.LOW
try { }
events_emitter.on(indexEvent, callback); try {
} catch (err) { events_emitter.on(indexEvent, callback);
console.info("areaChangeTest_0400 on events_emitter err : " + JSON.stringify(err)); } 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'); console.info("areaChangeTest_0400 click result is: " + JSON.stringify(sendEventByKey('text1', 10, "")));
done(); 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 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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function ellipseJsunit() { export default function ellipseJsunit() {
describe('appInfoTest', function () { describe('ellipseTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("ellipse beforeEach start"); console.info("ellipse beforeEach start");
let options = { let options = {
uri: 'pages/ellipse', uri: 'pages/ellipse',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get ellipse state pages:" + JSON.stringify(pages)); console.info("get ellipse state pages:" + JSON.stringify(pages));
if (!("ellipse" == pages.name)) { if (!("ellipse" == pages.name)) {
console.info("get ellipse state pages.name:" + JSON.stringify(pages.name)); console.info("get ellipse state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push ellipse page result:" + JSON.stringify(result)); console.info("push ellipse page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push ellipse page error:" + err); console.error("push ellipse page error:" + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("ellipse after each called"); console.info("ellipse after each called");
}); });
it('testEllipse01', 0, async function (done) { it('testEllipse01', 0, async function (done) {
console.info('[testEllipse01] START'); console.info('[testEllipse01] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('ellipse'); let strJson = getInspectorByKey('ellipse');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); console.info("[testEllipse02] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.height).assertEqual('200.00px'); expect(obj.$attrs.height).assertEqual('200.00px');
expect(obj.$attrs.width).assertEqual('200.00px'); expect(obj.$attrs.width).assertEqual('200.00px');
console.info('testEllipse02 END'); console.info('testEllipse02 END');
done(); done();
}); });
it('testEllipse02', 0, async function (done) { it('testEllipse02', 0, async function (done) {
console.info('[testEllipse02] START'); console.info('[testEllipse02] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"width": '100px' "width": '100px'
} }
} }
var innerEvent = { var innerEvent = {
eventId: 92, eventId: 92,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testEllipse02] start to publish emit"); console.info("[testEllipse02] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testEllipse02] change component data error: " + err.message); console.log("[testEllipse02] change component data error: " + err.message);
} }
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('ellipse'); let strJson = getInspectorByKey('ellipse');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testEllipse02] obj is: " + JSON.stringify(obj)); console.info("[testEllipse02] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.width).assertEqual('100.00px'); expect(obj.$attrs.width).assertEqual('100.00px');
console.info('testEllipse02 END'); console.info('testEllipse02 END');
done(); done();
}); });
it('testEllipse03', 0, async function (done) { it('testEllipse03', 0, async function (done) {
console.info('[testEllipse03] START'); console.info('[testEllipse03] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"height": '500px' "height": '500px'
} }
} }
var innerEvent = { var innerEvent = {
eventId: 92, eventId: 92,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testEllipse03] start to publish emit"); console.info("[testEllipse03] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testEllipse03] change component data error: " + err.message); console.log("[testEllipse03] change component data error: " + err.message);
} }
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('ellipse'); let strJson = getInspectorByKey('ellipse');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testEllipse03] obj is: " + JSON.stringify(obj)); console.info("[testEllipse03] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.height).assertEqual('500.00px'); expect(obj.$attrs.height).assertEqual('500.00px');
console.info('testEllipse03 END'); console.info('testEllipse03 END');
done(); 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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter' import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils.ets';
export default function enableJsunit() {
export default function enableJsunit() { describe('enableTest', function () {
describe('appInfoTest', function () { beforeEach(async function (done) {
beforeEach(async function (done) { console.info("enable beforeEach start");
console.info("enable beforeEach start"); let options = {
let options = { uri: 'pages/enable',
uri: 'pages/enable', }
} try {
try { router.clear();
router.clear(); let pages = router.getState();
let pages = router.getState(); console.info("get enable state pages: " + JSON.stringify(pages));
console.info("get enable state pages: " + JSON.stringify(pages)); if (!("enable" == pages.name)) {
if (!("enable" == pages.name)) { console.info("get enable state pages.name:" + JSON.stringify(pages.name));
console.info("get enable state pages.name:" + JSON.stringify(pages.name)); let result = await router.push(options);
let result = await router.push(options); await Utils.sleep(2000);
await Utils.sleep(2000); console.info("push enable page result:" + JSON.stringify(result));
console.info("push enable page result:" + JSON.stringify(result)); }
} } catch (err) {
} catch (err) { console.error("push enable page error:" + err);
console.error("push enable page error:" + err); }
} done()
done() });
});
afterEach(async function () {
afterEach(async function () { await Utils.sleep(1000);
await Utils.sleep(1000); console.info("enable after each called");
console.info("enable after each called"); });
});
it('testEnable01', 0, async function (done) {
it('testEnable01', 0, async function (done) { console.info('[testEnable01] START');
console.info('[testEnable01] START'); await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('enabled');
let strJson = getInspectorByKey('enabled'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testEnable01] obj is: " + JSON.stringify(obj));
console.info("[testEnable01] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.enabled).assertEqual(true);
expect(obj.$attrs.enabled).assertEqual(true); console.info('[testEnable01] END');
console.info('[testEnable01] END'); done();
done(); });
});
it('testEnable02', 0, async function (done) {
it('testEnable02', 0, async function (done) { console.info('[testEnable02] START');
console.info('[testEnable02] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "enabled": false,
"enabled": false, "text": "disable"
"text": "disable" }
} }
} var innerEvent = {
var innerEvent = { eventId: 93,
eventId: 93, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testEnable02] start to publish emit");
console.info("[testEnable02] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testEnable02] change component data error: " + err.message);
console.log("[testEnable02] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJson = getInspectorByKey('enabled');
let strJson = getInspectorByKey('enabled'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testEnable02] obj is: " + JSON.stringify(obj.$attrs.enabled));
console.info("[testEnable02] obj is: " + JSON.stringify(obj.$attrs.enabled)); expect(obj.$attrs.enabled).assertEqual(false);
expect(obj.$attrs.enabled).assertEqual(false); console.info('testEnable02 END');
console.info('testEnable02 END'); done();
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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function gaugeJsunit() {
export default function gaugeJsunit() { describe('gaugeTest', function () {
describe('appInfoTest', function () { beforeEach(async function (done) {
beforeEach(async function (done) { let options = {
let options = { uri: 'pages/gauge',
uri: 'pages/gauge', }
} try {
try { router.clear();
router.clear(); let pages = router.getState();
let pages = router.getState(); console.info("get gauge state success " + JSON.stringify(pages));
console.info("get gauge state success " + JSON.stringify(pages)); if (!("gauge" == pages.name)) {
if (!("gauge" == pages.name)) { console.info("get gauge state success " + JSON.stringify(pages.name));
console.info("get gauge state success " + JSON.stringify(pages.name)); let result = await router.push(options);
let result = await router.push(options); await Utils.sleep(2000);
await Utils.sleep(2000); console.info("push gauge page success " + JSON.stringify(result));
console.info("push gauge page success " + JSON.stringify(result)); }
} } catch (err) {
} catch (err) { console.error("push gauge page error " + err);
console.error("push gauge page error " + err); }
} done()
done() });
});
afterEach(async function () {
afterEach(async function () { await Utils.sleep(2000);
await Utils.sleep(2000); console.info("gauge after each called");
console.info("gauge after each called"); });
});
it('testGauge001', 0, async function (done) {
it('testGauge001', 0, async function (done) { console.info('[testGauge001] START');
console.info('[testGauge001] START'); await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('gauge');
let strJson = getInspectorByKey('gauge'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testGauge001] component obj is: " + JSON.stringify(obj));
console.info("[testGauge001] component obj is: " + JSON.stringify(obj)); expect(obj.$type).assertEqual('Gauge');
expect(obj.$type).assertEqual('Gauge'); expect(obj.$attrs.strokeWidth).assertEqual('20.00vp');
expect(obj.$attrs.strokeWidth).assertEqual('20.00vp'); expect(obj.$attrs.width).assertEqual('200.00vp');
expect(obj.$attrs.width).assertEqual('200.00vp'); expect(obj.$attrs.height).assertEqual('200.00vp');
expect(obj.$attrs.height).assertEqual('200.00vp'); expect(obj.$attrs.value).assertEqual('50.00');
expect(obj.$attrs.value).assertEqual('50.00'); done();
done(); });
});
it('testGauge002', 0, async function (done) {
it('testGauge002', 0, async function (done) { console.info('[testGauge002] START');
console.info('[testGauge002] START'); await Utils.sleep(1000);
await Utils.sleep(1000); try {
try { var eventData = {
var eventData = { data: {
data: { "gaugeValue": "10"
"gaugeValue": "10" }
} }
} var innerEvent = {
var innerEvent = { eventId: 102,
eventId: 102, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testGauge002] start to publish emit");
console.info("[testGauge002] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testGauge002] change component data error: " + err.message);
console.log("[testGauge002] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJsonNew = getInspectorByKey('gauge');
let strJsonNew = getInspectorByKey('gauge'); let objNew = JSON.parse(strJsonNew);
let objNew = JSON.parse(strJsonNew); console.info("[testGauge002] component objNew is: " + JSON.stringify(objNew));
console.info("[testGauge002] component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.value).assertEqual('10.00');
expect(objNew.$attrs.value).assertEqual('10.00'); done();
done(); });
});
it('testGauge003', 0, async function (done) {
it('testGauge003', 0, async function (done) { console.info('[testGauge003] START');
console.info('[testGauge003] START'); await Utils.sleep(1000);
await Utils.sleep(1000); try {
try { var eventData = {
var eventData = { data: {
data: { "strokeWidthValue": "30",
"strokeWidthValue": "30", }
} }
} var innerEvent = {
var innerEvent = { eventId: 102,
eventId: 102, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testGauge003] start to publish emit");
console.info("[testGauge003] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testGauge003] change component data error: " + err.message);
console.log("[testGauge003] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJsonNew = getInspectorByKey('gauge');
let strJsonNew = getInspectorByKey('gauge'); let objNew = JSON.parse(strJsonNew);
let objNew = JSON.parse(strJsonNew); console.info("[testGauge003] component objNew is: " + JSON.stringify(objNew));
console.info("[testGauge003] component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.strokeWidth).assertEqual('30.00vp');
expect(objNew.$attrs.strokeWidth).assertEqual('30.00vp'); done();
done(); });
});
it('testGauge004', 0, async function (done) {
it('testGauge004', 0, async function (done) { console.info('[testGauge004] START');
console.info('[testGauge004] START'); await Utils.sleep(1000);
await Utils.sleep(1000); try {
try { var eventData = {
var eventData = { data: {
data: { "startAngleValue": "200"
"startAngleValue": "200" }
} }
} var innerEvent = {
var innerEvent = { eventId: 102,
eventId: 102, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testGauge004] start to publish emit");
console.info("[testGauge004] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testGauge004] change component data error: " + err.message);
console.log("[testGauge004] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJsonNew = getInspectorByKey('gauge');
let strJsonNew = getInspectorByKey('gauge'); let objNew = JSON.parse(strJsonNew);
let objNew = JSON.parse(strJsonNew); console.info("[testGauge004] component objNew is: " + JSON.stringify(objNew));
console.info("[testGauge004] component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.startAngle).assertEqual('200.00');
expect(objNew.$attrs.startAngle).assertEqual('200.00'); done();
done(); });
});
it('testGauge005', 0, async function (done) {
it('testGauge005', 0, async function (done) { console.info('[testGauge005] START');
console.info('[testGauge005] START'); await Utils.sleep(1000);
await Utils.sleep(1000); try {
try { var eventData = {
var eventData = { data: {
data: { "endAngleValue": "200"
"endAngleValue": "200" }
} }
} var innerEvent = {
var innerEvent = { eventId: 102,
eventId: 102, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testGauge005] start to publish emit");
console.info("[testGauge005] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testGauge005] change component data error: " + err.message);
console.log("[testGauge005] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJsonNew = getInspectorByKey('gauge');
let strJsonNew = getInspectorByKey('gauge'); let objNew = JSON.parse(strJsonNew);
let objNew = JSON.parse(strJsonNew); console.info("[testGauge005] component objNew is: " + JSON.stringify(objNew));
console.info("[testGauge005] component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.endAngle).assertEqual('200.00');
expect(objNew.$attrs.endAngle).assertEqual('200.00'); done();
done(); });
});
it('testGauge006', 0, async function (done) {
it('testGauge006', 0, async function (done) { console.info('[testGauge006] START');
console.info('[testGauge006] START'); await Utils.sleep(1000);
await Utils.sleep(1000); try {
try { var eventData = {
var eventData = { data: {
data: { "colorValues": JSON.stringify([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1]])
"colorValues": JSON.stringify([[0x317AF7, 1], [0x5BA854, 1], [0xE08C3A, 1]]) }
} }
} var innerEvent = {
var innerEvent = { eventId: 103,
eventId: 103, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testGauge006] start to publish emit");
console.info("[testGauge006] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testGauge006] change component data error: " + err.message);
console.log("[testGauge006] change component data error: " + err.message); }
} done();
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();
});
})
}
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function globalJsunit() { export default function globalJsunit() {
describe('globalJsunit', function () { describe('globalJsunit', function () {
...@@ -50,7 +50,7 @@ export default function globalJsunit() { ...@@ -50,7 +50,7 @@ export default function globalJsunit() {
* @tc.desc Test setTimeout * @tc.desc Test setTimeout
*/ */
it('ACE_global_setTimeout', 0, function (done) { it('ACE_global_setTimeout', 0, function (done) {
let caseName:string = "ACE_global_setTimeout" let caseName: string = "ACE_global_setTimeout"
console.info(`${caseName} START`); console.info(`${caseName} START`);
setTimeout(() => { setTimeout(() => {
expect(true).assertTrue(); expect(true).assertTrue();
...@@ -65,9 +65,9 @@ export default function globalJsunit() { ...@@ -65,9 +65,9 @@ export default function globalJsunit() {
* @tc.desc Test canIUse * @tc.desc Test canIUse
*/ */
it('ACE_global_canIUse', 0, function (done) { it('ACE_global_canIUse', 0, function (done) {
let caseName:string = "ACE_global_canIUse" let caseName: string = "ACE_global_canIUse"
console.info(`${caseName} START`); console.info(`${caseName} START`);
let syscapName:string = ""; let syscapName: string = "";
var result = canIUse(syscapName); var result = canIUse(syscapName);
expect(result === false).assertTrue(); expect(result === false).assertTrue();
console.info(`${caseName} END`); console.info(`${caseName} END`);
...@@ -80,11 +80,12 @@ export default function globalJsunit() { ...@@ -80,11 +80,12 @@ export default function globalJsunit() {
* @tc.desc Test getApp * @tc.desc Test getApp
*/ */
it('ACE_global_getApp', 0, function (done) { it('ACE_global_getApp', 0, function (done) {
let caseName:string = "ACE_global_getApp" let caseName: string = "ACE_global_getApp"
console.info(`${caseName} START`); console.info(`${caseName} START`);
try{ try {
var info = getApp(); var info = getApp();
}catch(err){} } catch (err) {
}
console.info(`${caseName} END`); console.info(`${caseName} END`);
done(); done();
}); });
...@@ -95,11 +96,12 @@ export default function globalJsunit() { ...@@ -95,11 +96,12 @@ export default function globalJsunit() {
* @tc.desc Test createLocalParticleAbility * @tc.desc Test createLocalParticleAbility
*/ */
it('ACE_global_createLocalParticleAbility', 0, function (done) { it('ACE_global_createLocalParticleAbility', 0, function (done) {
let caseName:string = "ACE_global_createLocalParticleAbility" let caseName: string = "ACE_global_createLocalParticleAbility"
console.info(`${caseName} START`); console.info(`${caseName} START`);
try{ try {
var info = createLocalParticleAbility(100); var info = createLocalParticleAbility(100);
}catch(err){} } catch (err) {
}
console.info(`${caseName} END`); console.info(`${caseName} END`);
done(); done();
}); });
...@@ -166,6 +168,5 @@ export default function globalJsunit() { ...@@ -166,6 +168,5 @@ export default function globalJsunit() {
}); });
}) })
} }
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function girdContainerJsunit() { export default function girdContainerJsunit() {
describe('appInfoTest', function () { describe('girdContainerTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("girdContainer beforeEach start"); console.info("girdContainer beforeEach start");
let options = { let options = {
uri: 'pages/gridContainer', uri: 'pages/gridContainer',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get girdContainer state pages:" + JSON.stringify(pages)); console.info("get girdContainer state pages:" + JSON.stringify(pages));
if (!("gridContainer" == pages.name)) { if (!("gridContainer" == pages.name)) {
console.info("get girdContainer state pages.name:" + JSON.stringify(pages.name)); console.info("get girdContainer state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push girdContainer page result:" + JSON.stringify(result)); console.info("push girdContainer page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push girdContainer page error:" + err); console.error("push girdContainer page error:" + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("girdContainer after each called"); console.info("girdContainer after each called");
}); });
it('testGirdContainer01', 0, async function (done) { it('testGirdContainer01', 0, async function (done) {
console.info('[testGirdContainer01] START'); console.info('[testGirdContainer01] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('gridContainer'); let strJson = getInspectorByKey('gridContainer');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testGirdContainer01] obj is: " + JSON.stringify(obj)); console.info("[testGirdContainer01] obj is: " + JSON.stringify(obj));
expect(obj.$type).assertEqual('GridContainer'); expect(obj.$type).assertEqual('GridContainer');
expect(obj.$attrs.constructor.columns).assertEqual('12'); expect(obj.$attrs.constructor.columns).assertEqual('12');
expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.XS'); expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.XS');
expect(obj.$attrs.constructor.gutter).assertEqual('10.00vp'); expect(obj.$attrs.constructor.gutter).assertEqual('10.00vp');
expect(obj.$attrs.constructor.margin).assertEqual('20.00vp'); expect(obj.$attrs.constructor.margin).assertEqual('20.00vp');
console.info('testGirdContainer01 END'); console.info('testGirdContainer01 END');
done(); done();
}); });
it('testGirdContainer02', 0, async function (done) { it('testGirdContainer02', 0, async function (done) {
console.info('[testEllipse02] START'); console.info('[testEllipse02] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"sizeType": 'SM' "sizeType": 'SM'
} }
} }
var innerEvent = { var innerEvent = {
eventId: 109, eventId: 109,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testGirdContainer02] start to publish emit"); console.info("[testGirdContainer02] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testGirdContainer02] change component data error: " + err.message); console.log("[testGirdContainer02] change component data error: " + err.message);
} }
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('gridContainer'); let strJson = getInspectorByKey('gridContainer');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testGirdContainer02] obj is: " + JSON.stringify(obj)); console.info("[testGirdContainer02] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.SM'); expect(obj.$attrs.constructor.sizeType).assertEqual('SizeType.SM');
console.info('testGirdContainer02 END'); console.info('testGirdContainer02 END');
done(); done();
}); });
}) })
} }
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets'; import Utils from './Utils.ets';
export default function gridSettingsJsunit() { export default function gridSettingsJsunit() {
describe('gridSettingsTest', function () { describe('gridSettingsTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/gridSettings', uri: 'pages/gridSettings',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get gridSettings state pages:" + JSON.stringify(pages)); console.info("get gridSettings state pages:" + JSON.stringify(pages));
if (!("gridSettings" == pages.name)) { if (!("textStyle" == pages.name)) {
console.info("get gridSettings state pages.name:" + JSON.stringify(pages.name)); console.info("get gridSettings state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push gridSettings page result:" + JSON.stringify(result)); console.info("push gridSettings page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push gridSettings page error:" + err); console.error("push gridSettings page error:" + err);
} }
done(); done();
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("gridSettings after each called"); console.info("gridSettings after each called");
}); });
it('testGridSettings001', 0, async function (done) { it('testGridSettings000', 0, async function (done) {
console.info('[testGridSettings001] START'); console.info('[testGridSettings000] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('gridRow'); let strJson = getInspectorByKey('gridContainer');
console.info("[testGridSettings001] component strJson:" + strJson); console.info("[testGridSettings000] component strJson:" + strJson);
let obj = JSON.parse(strJson); expect(true).assertEqual(true);
console.info("[testGridSettings001] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); done();
expect(obj.$attrs.useSizeType.sm.span).assertEqual(2); });
expect(obj.$attrs.useSizeType.sm.offset).assertEqual(1);
console.info('[testGridSettings001] END'); it('testGridSettings001', 0, async function (done) {
done(); console.info('[testGridSettings001] START');
}); await Utils.sleep(4000);
let strJson = getInspectorByKey('gridRow');
it('testGridSettings002', 0, async function (done) { console.info("[testGridSettings001] component strJson:" + strJson);
console.info('[testGridSettings002] START'); let obj = JSON.parse(strJson);
try { console.info("[testGridSettings001] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType));
let eventData = { expect(obj.$attrs.useSizeType.sm.span).assertEqual(2);
data: { expect(obj.$attrs.useSizeType.sm.offset).assertEqual(1);
"span": 1, done();
"offset": 2 });
}
} it('testGridSettings002', 0, async function (done) {
let indexEvent = { console.info('[testGridSettings002] START');
eventId: 9, try {
priority: events_emitter.EventPriority.LOW let eventData = {
} data: {
console.info("[testGridSettings002] start to publish emit"); "span": 1,
events_emitter.emit(indexEvent, eventData); "offset": 2
} catch (err) { }
console.log("[testGridSettings002] change component data error: " + err.message); }
} let indexEvent = {
await Utils.sleep(4000); eventId: 9,
let strJson = getInspectorByKey('gridRow'); priority: events_emitter.EventPriority.LOW
console.info("[testGridSettings002] component strJson:" + strJson); }
let obj = JSON.parse(strJson); console.info("[testGridSettings002] start to publish emit");
console.info("[testGridSettings002] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType)); events_emitter.emit(indexEvent, eventData);
expect(obj.$attrs.useSizeType.sm.span).assertEqual(1); } catch (err) {
expect(obj.$attrs.useSizeType.sm.offset).assertEqual(2); console.log("[testGridSettings002] change component data error: " + err.message);
console.info('[testGridSettings002] END'); }
done(); await Utils.sleep(4000);
}); let strJson = getInspectorByKey('gridRow');
console.info("[testGridSettings002] component strJson:" + strJson);
it('testGridSettings003', 0, async function (done) { let obj = JSON.parse(strJson);
console.info('[testGridSettings003] START'); console.info("[testGridSettings002] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType));
await Utils.sleep(1000); expect(obj.$attrs.useSizeType.sm.span).assertEqual(1);
let strJson = getInspectorByKey('gridOffset'); expect(obj.$attrs.useSizeType.sm.offset).assertEqual(2);
console.info("[testGridSettings003] component strJson:" + strJson); done();
let obj = JSON.parse(strJson); });
console.info("[testGridSettings003] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset));
expect(obj.$attrs.gridOffset).assertEqual(0); it('testGridSettings003', 0, async function (done) {
console.info('[testGridSettings003] END'); console.info('[testGridSettings003] START');
done(); try {
}); let eventData = {
data: {
it('testGridSettings004', 0, async function (done) { "span": 0x80000000,
console.info('[testGridSettings004] START'); "offset": 0x80000000
try { }
let eventData = { }
data: { let indexEvent = {
"gridOffset": 1 eventId: 9,
} priority: events_emitter.EventPriority.LOW
} }
let indexEvent = { console.info("[testGridSettings003] start to publish emit");
eventId: 10, events_emitter.emit(indexEvent, eventData);
priority: events_emitter.EventPriority.LOW } catch (err) {
} console.log("[testGridSettings003] change component data error: " + err.message);
console.info("[testGridSettings004] start to publish emit"); }
events_emitter.emit(indexEvent, eventData); await Utils.sleep(4000);
} catch (err) { let strJson = getInspectorByKey('gridRow');
console.log("[testGridSettings004] change component data error: " + err.message); console.info("[testGridSettings003] component strJson:" + strJson);
} let obj = JSON.parse(strJson);
await Utils.sleep(4000); console.info("[testGridSettings003] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType));
let strJson = getInspectorByKey('gridOffset'); expect(obj.$attrs.useSizeType.sm.span).assertEqual(-2147483648);
console.info("[testGridSettings004] component strJson:" + strJson); expect(obj.$attrs.useSizeType.sm.offset).assertEqual(-2147483648);
let obj = JSON.parse(strJson); done();
console.info("[testGridSettings004] gridOffset: " + JSON.stringify(obj.$attrs.gridOffset)); });
expect(obj.$attrs.gridOffset).assertEqual(1);
console.info('[testGridSettings004] END'); it('testGridSettings004', 0, async function (done) {
done(); console.info('[testGridSettings004] START');
}); try {
let eventData = {
it('testGridSettings005', 0, async function (done) { data: {
console.info('[testGridSettings005] START'); "span": 0x7FFFFFFF,
await Utils.sleep(1000); "offset": 0x7FFFFFFF
let strJson = getInspectorByKey('gridSpan'); }
console.info("[testGridSettings005] component strJson:" + strJson); }
let obj = JSON.parse(strJson); let indexEvent = {
console.info("[testGridSettings005] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); eventId: 9,
expect(obj.$attrs.gridSpan).assertEqual(1); priority: events_emitter.EventPriority.LOW
console.info('[testGridSettings005] END'); }
done(); console.info("[testGridSettings004] start to publish emit");
}); events_emitter.emit(indexEvent, eventData);
} catch (err) {
it('testGridSettings006', 0, async function (done) { console.log("[testGridSettings004] change component data error: " + err.message);
console.info('[testGridSettings006] START'); }
try { await Utils.sleep(4000);
let eventData = { let strJson = getInspectorByKey('gridRow');
data: { console.info("[testGridSettings004] component strJson:" + strJson);
"gridSpan": 2 let obj = JSON.parse(strJson);
} console.info("[testGridSettings004] gridRow useSizeType: " + JSON.stringify(obj.$attrs.useSizeType));
} expect(obj.$attrs.useSizeType.sm.span).assertEqual(0x7FFFFFFF);
let indexEvent = { expect(obj.$attrs.useSizeType.sm.offset).assertEqual(0x7FFFFFFF);
eventId: 11, done();
priority: events_emitter.EventPriority.LOW });
}
console.info("[testGridSettings006] start to publish emit"); it('testGridSettings005', 0, async function (done) {
events_emitter.emit(indexEvent, eventData); console.info('[testGridSettings005] START');
} catch (err) { try {
console.log("[testGridSettings006] change component data error: " + err.message); let eventData = {
} data: {
await Utils.sleep(4000); "span": 'error',
let strJson = getInspectorByKey('gridSpan'); "offset": 'error'
console.info("[testGridSettings006] component strJson:" + strJson); }
let obj = JSON.parse(strJson); }
console.info("[testGridSettings006] gridSpan: " + JSON.stringify(obj.$attrs.gridSpan)); let indexEvent = {
expect(obj.$attrs.gridSpan).assertEqual(2); eventId: 9,
console.info('[testGridSettings006] END'); priority: events_emitter.EventPriority.LOW
done(); }
}); 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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function imageEffectsJsunit() { export default function imageEffectsJsunit() {
describe('appInfoTest', function () { describe('imageEffectsTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/imageEffects', uri: 'pages/imageEffects',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get imageEffects state success " + JSON.stringify(pages)); console.info("get imageEffects state success " + JSON.stringify(pages));
if (!("imageEffects" == pages.name)) { if (!("imageEffects" == pages.name)) {
console.info("get imageEffects state success " + JSON.stringify(pages.name)); console.info("get imageEffects state success " + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push imageEffects page success " + JSON.stringify(result)); console.info("push imageEffects page success " + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push imageEffects page error: " + err); console.error("push imageEffects page error: " + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("imageEffects after each called"); console.info("imageEffects after each called");
}); });
it('testImageEffects001', 0, async function (done) { it('testImageEffects001', 0, async function (done) {
console.info('[testSizeSetting001] START'); console.info('[testSizeSetting001] START');
await Utils.sleep(2000); await Utils.sleep(2000);
let strJson = getInspectorByKey('centerRow'); let strJson = getInspectorByKey('centerRow');
console.info("[testImageEffects001] component strJson:" + strJson); console.info("[testImageEffects001] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text'); expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.blur).assertEqual(100); expect(obj.$attrs.blur).assertEqual(100);
done(); done();
}); });
it('testImageEffects002', 0, async function (done) { it('testImageEffects002', 0, async function (done) {
console.info('[testImageEffects002] START'); console.info('[testImageEffects002] START');
await Utils.sleep(1000); await Utils.sleep(1000);
try { try {
var eventData = { var eventData = {
data: { data: {
"blurValue": "10" "blurValue": "10"
} }
} }
var innerEvent = { var innerEvent = {
eventId: 12, eventId: 12,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testImageEffects002] start to publish emit"); console.info("[testImageEffects002] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testImageEffects002] change component data error: " + err.message); console.log("[testImageEffects002] change component data error: " + err.message);
} }
await Utils.sleep(2000); await Utils.sleep(2000);
let strJsonNew = getInspectorByKey('centerRow'); let strJsonNew = getInspectorByKey('centerRow');
let objNew = JSON.parse(strJsonNew); let objNew = JSON.parse(strJsonNew);
console.info("[testImageEffects002] component objNew is: " + JSON.stringify(objNew)); console.info("[testImageEffects002] component objNew is: " + JSON.stringify(objNew));
expect(objNew.$attrs.blur).assertEqual(10); expect(objNew.$attrs.blur).assertEqual(10);
done(); done();
}); });
it('testImageEffects003', 0, async function (done) { it('testImageEffects003', 0, async function (done) {
console.info('[testImageEffects003] START'); console.info('[testImageEffects003] START');
await Utils.sleep(2000); await Utils.sleep(1000);
let strJson = getInspectorByKey('centerRow3'); try {
let obj = JSON.parse(strJson); var eventData = {
console.info("[testImageEffects003] component strJson:" + obj.$attrs.shadow); data: {
expect(obj.$attrs.shadow.radius).assertEqual("10.000000"); "blurValue": 0x80000000
expect(obj.$attrs.shadow.color).assertEqual("#FF808080"); }
expect(obj.$attrs.shadow.offsetX).assertEqual("5.000000"); }
expect(obj.$attrs.shadow.offsetY).assertEqual("5.000000"); var innerEvent = {
done(); eventId: 12,
}); priority: events_emitter.EventPriority.LOW
}
it('testImageEffects004', 0, async function (done) { console.info("[testImageEffects003] start to publish emit");
console.info('[testImageEffects004] START'); events_emitter.emit(innerEvent, eventData);
await Utils.sleep(1000); } catch (err) {
let shadowValue = { radius: 20, color: Color.Gray, offsetX: 10, offsetY: 10 }; console.log("[testImageEffects003] change component data error: " + err.message);
try { }
var eventData = { await Utils.sleep(2000);
data: { let strJsonNew = getInspectorByKey('centerRow');
"shadowValue": JSON.stringify(shadowValue) let objNew = JSON.parse(strJsonNew);
} console.info("[testImageEffects003] component objNew is: " + JSON.stringify(objNew));
} expect(objNew.$attrs.blur).assertEqual(-2147483648);
var innerEvent = { done();
eventId: 13, });
priority: events_emitter.EventPriority.LOW
} it('testImageEffects004', 0, async function (done) {
console.info("[testImageEffects004] start to publish emit"); console.info('[testImageEffects004] START');
events_emitter.emit(innerEvent, eventData); await Utils.sleep(1000);
} catch (err) { try {
console.log("[testImageEffects004] change component data error: " + err.message); var eventData = {
} data: {
await Utils.sleep(2000); "blurValue": 0x7FFFFFFF
let strJsonNew = getInspectorByKey('centerRow3'); }
let objNew = JSON.parse(strJsonNew); }
console.info("[testImageEffects004] component objNew is: " + JSON.stringify(objNew)); var innerEvent = {
expect(objNew.$attrs.shadow.radius).assertEqual("20.000000"); eventId: 12,
expect(objNew.$attrs.shadow.color).assertEqual("#FF808080"); priority: events_emitter.EventPriority.LOW
expect(objNew.$attrs.shadow.offsetX).assertEqual("10.000000"); }
expect(objNew.$attrs.shadow.offsetY).assertEqual("10.000000"); console.info("[testImageEffects004] start to publish emit");
done(); events_emitter.emit(innerEvent, eventData);
}); } catch (err) {
console.log("[testImageEffects004] change component data error: " + err.message);
it('testImageEffects007', 0, async function (done) { }
console.info('[testSizeSetting007] START'); await Utils.sleep(2000);
await Utils.sleep(2000); let strJsonNew = getInspectorByKey('centerRow');
let strJson = getInspectorByKey('centerRow5'); let objNew = JSON.parse(strJsonNew);
console.info("[testImageEffects007] component strJson:" + strJson); console.info("[testImageEffects004] component objNew is: " + JSON.stringify(objNew));
let obj = JSON.parse(strJson); expect(objNew.$attrs.blur).assertEqual(2147483648);
expect(obj.$attrs.brightness).assertEqual(20); done();
done(); });
});
it('testImageEffects005', 0, async function (done) {
it('testImageEffects008', 0, async function (done) { console.info('[testImageEffects005] START');
console.info('[testImageEffects002] START'); await Utils.sleep(1000);
await Utils.sleep(1000); try {
try { var eventData = {
var eventData = { data: {
data: { "blurValue": 'error'
"brightnessValue": "15" }
} }
} var innerEvent = {
var innerEvent = { eventId: 12,
eventId: 15, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testImageEffects005] start to publish emit");
console.info("[testImageEffects008] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testImageEffects005] change component data error: " + err.message);
console.log("[testImageEffects008] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJsonNew = getInspectorByKey('centerRow');
let strJsonNew = getInspectorByKey('centerRow5'); let objNew = JSON.parse(strJsonNew);
let objNew = JSON.parse(strJsonNew); console.info("[testImageEffects005] component objNew is: " + JSON.stringify(objNew));
console.info("[testImageEffects008] component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.blur).assertEqual(0);
expect(objNew.$attrs.brightness).assertEqual(15); done();
done(); });
});
it('testImageEffects006', 0, async function (done) {
it('testImageEffects009', 0, async function (done) { console.info('[testImageEffects006] START');
console.info('[testImageEffects009] START'); await Utils.sleep(2000);
await Utils.sleep(2000); let strJson = getInspectorByKey('centerRow3');
let strJson = getInspectorByKey('centerRow6'); let obj = JSON.parse(strJson);
console.info("[testImageEffects009] component strJson:" + strJson); console.info("[testImageEffects006] component strJson:" + obj.$attrs.shadow);
let obj = JSON.parse(strJson); expect(obj.$attrs.shadow.radius).assertEqual("10.000000");
console.info("[testImageEffects009] component strJson:" + obj.$attrs.saturate); expect(obj.$attrs.shadow.color).assertEqual("#FF808080");
expect(obj.$attrs.saturate).assertEqual(50); expect(obj.$attrs.shadow.offsetX).assertEqual("5.000000");
done(); expect(obj.$attrs.shadow.offsetY).assertEqual("5.000000");
}); done();
});
it('testImageEffects010', 0, async function (done) {
console.info('[testImageEffects010] START'); it('testImageEffects007', 0, async function (done) {
await Utils.sleep(1000); console.info('[testImageEffects007] START');
try { await Utils.sleep(1000);
var eventData = { let shadowValue = {
data: { radius: 20, color: Color.Gray, offsetX: 10, offsetY: 10
"saturateValue": "40" };
} try {
} var eventData = {
var innerEvent = { data: {
eventId: 16, "shadowValue": JSON.stringify(shadowValue)
priority: events_emitter.EventPriority.LOW }
} }
console.info("[testImageEffects010] start to publish emit"); var innerEvent = {
events_emitter.emit(innerEvent, eventData); eventId: 13,
} catch (err) { priority: events_emitter.EventPriority.LOW
console.log("[testImageEffects010] change component data error: " + err.message); }
} console.info("[testImageEffects007] start to publish emit");
await Utils.sleep(2000); events_emitter.emit(innerEvent, eventData);
let strJsonNew = getInspectorByKey('centerRow6'); } catch (err) {
let objNew = JSON.parse(strJsonNew); console.log("[testImageEffects007] change component data error: " + err.message);
console.info("[testImageEffects010] component objNew is: " + JSON.stringify(objNew)); }
expect(objNew.$attrs.saturate).assertEqual(40); await Utils.sleep(2000);
done(); let strJsonNew = getInspectorByKey('centerRow3');
}); let objNew = JSON.parse(strJsonNew);
console.info("[testImageEffects007] component objNew is: " + JSON.stringify(objNew));
it('testImageEffects011', 0, async function (done) { expect(objNew.$attrs.shadow.radius).assertEqual("20.000000");
console.info('[testSizeSetting011] START'); expect(objNew.$attrs.shadow.color).assertEqual("#FF808080");
await Utils.sleep(2000); expect(objNew.$attrs.shadow.offsetX).assertEqual("10.000000");
let strJson = getInspectorByKey('centerRow7'); expect(objNew.$attrs.shadow.offsetY).assertEqual("10.000000");
console.info("[testImageEffects011] component strJson:" + strJson); done();
let obj = JSON.parse(strJson); });
expect(obj.$attrs.contrast).assertEqual(20);
done(); it('testImageEffects008', 0, async function (done) {
}); console.info('[testImageEffects008] START');
await Utils.sleep(1000);
it('testImageEffects012', 0, async function (done) { let shadowValue = { radius: 0x80000000, color: 0x80000000, offsetX: 0x80000000, offsetY: 0x80000000 };
console.info('[testImageEffects012] START'); try {
await Utils.sleep(1000); var eventData = {
try { data: {
var eventData = { "shadowValue": JSON.stringify(shadowValue)
data: { }
"contrastValue": "10" }
} var innerEvent = {
} eventId: 13,
var innerEvent = { priority: events_emitter.EventPriority.LOW
eventId: 17, }
priority: events_emitter.EventPriority.LOW console.info("[testImageEffects008] start to publish emit");
} events_emitter.emit(innerEvent, eventData);
console.info("[testImageEffects012] start to publish emit"); } catch (err) {
events_emitter.emit(innerEvent, eventData); console.log("[testImageEffects008] change component data error: " + err.message);
} catch (err) { }
console.log("[testImageEffects012] change component data error: " + err.message); await Utils.sleep(2000);
} let strJsonNew = getInspectorByKey('centerRow3');
await Utils.sleep(2000); let objNew = JSON.parse(strJsonNew);
let strJsonNew = getInspectorByKey('centerRow7'); console.info("[testImageEffects008] component objNew is: " + JSON.stringify(objNew));
let objNew = JSON.parse(strJsonNew); expect(objNew.$attrs.shadow.radius).assertEqual("2147483648.000000");
console.info("[testImageEffects012] component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.shadow.color).assertEqual("#80000000");
expect(objNew.$attrs.contrast).assertEqual(10); expect(objNew.$attrs.shadow.offsetX).assertEqual("2147483648.000000");
done(); expect(objNew.$attrs.shadow.offsetY).assertEqual("2147483648.000000");
}); done();
});
it('testImageEffects013', 0, async function (done) {
console.info('[testSizeSetting0013] START'); it('testImageEffects009', 0, async function (done) {
await Utils.sleep(2000); console.info('[testImageEffects009] START');
let strJson = getInspectorByKey('centerRow8'); await Utils.sleep(1000);
console.info("[testImageEffects013] component strJson:" + strJson); let shadowValue = { radius: 0x7FFFFFFF, color: 0x7FFFFFFF, offsetX: 0x7FFFFFFF, offsetY: 0x7FFFFFFF };
let obj = JSON.parse(strJson); try {
expect(obj.$attrs.invert).assertEqual(10); var eventData = {
done(); data: {
}); "shadowValue": JSON.stringify(shadowValue)
}
it('testImageEffects014', 0, async function (done) { }
console.info('[testImageEffects014] START'); var innerEvent = {
await Utils.sleep(1000); eventId: 13,
try { priority: events_emitter.EventPriority.LOW
var eventData = { }
data: { console.info("[testImageEffects009] start to publish emit");
"invertValue": "20" events_emitter.emit(innerEvent, eventData);
} } catch (err) {
} console.log("[testImageEffects009] change component data error: " + err.message);
var innerEvent = { }
eventId: 18, await Utils.sleep(2000);
priority: events_emitter.EventPriority.LOW let strJsonNew = getInspectorByKey('centerRow3');
} let objNew = JSON.parse(strJsonNew);
console.info("[testImageEffects014] start to publish emit"); console.info("[testImageEffects009] component objNew is: " + JSON.stringify(objNew));
events_emitter.emit(innerEvent, eventData); expect(objNew.$attrs.shadow.radius).assertEqual("2147483647.000000");
} catch (err) { expect(objNew.$attrs.shadow.color).assertEqual("#7FFFFFFF");
console.log("[testImageEffects014] change component data error: " + err.message); expect(objNew.$attrs.shadow.offsetX).assertEqual("2147483647.000000");
} expect(objNew.$attrs.shadow.offsetY).assertEqual("2147483647.000000");
await Utils.sleep(2000); done();
let strJsonNew = getInspectorByKey('centerRow8'); });
let objNew = JSON.parse(strJsonNew);
console.info("[testImageEffects014] component objNew is: " + JSON.stringify(objNew)); it('testImageEffects010', 0, async function (done) {
expect(objNew.$attrs.invert).assertEqual(20); console.info('[testImageEffects010] START');
done(); await Utils.sleep(1000);
}); let shadowValue = { radius: 'error', color: 'error', offsetX: 'error', offsetY: 'error' };
try {
it('testImageEffects015', 0, async function (done) { var eventData = {
console.info('[testImageEffects015] START'); data: {
await Utils.sleep(2000); "shadowValue": JSON.stringify(shadowValue)
let strJson = getInspectorByKey('centerRow9'); }
console.info("[testImageEffects015] component strJson:" + strJson); }
let obj = JSON.parse(strJson); var innerEvent = {
console.info("[testImageEffects015] component strJson:" + obj.$attrs.shadow); eventId: 13,
expect(obj.$attrs.hueRotate).assertEqual(10); priority: events_emitter.EventPriority.LOW
done(); }
}); console.info("[testImageEffects010] start to publish emit");
events_emitter.emit(innerEvent, eventData);
it('testImageEffects016', 0, async function (done) { } catch (err) {
console.info('[testImageEffects016] START'); console.log("[testImageEffects010] change component data error: " + err.message);
await Utils.sleep(1000); }
try { await Utils.sleep(2000);
var eventData = { let strJsonNew = getInspectorByKey('centerRow3');
data: { let objNew = JSON.parse(strJsonNew);
"hueRotateValue": "20" console.info("[testImageEffects010] component objNew is: " + JSON.stringify(objNew));
} expect(objNew.$attrs.shadow.radius).assertEqual("0.000000");
} expect(objNew.$attrs.shadow.color).assertEqual("#FF000000");
var innerEvent = { expect(objNew.$attrs.shadow.offsetX).assertEqual("0.000000");
eventId: 19, expect(objNew.$attrs.shadow.offsetY).assertEqual("0.000000");
priority: events_emitter.EventPriority.LOW done();
} });
console.info("[testImageEffects016] start to publish emit");
events_emitter.emit(innerEvent, eventData); it('testImageEffects011', 0, async function (done) {
} catch (err) { console.info('[testSizeSetting011] START');
console.log("[testImageEffects016] change component data error: " + err.message); await Utils.sleep(2000);
} let strJson = getInspectorByKey('centerRow5');
await Utils.sleep(2000); console.info("[testImageEffects011] component strJson:" + strJson);
let strJsonNew = getInspectorByKey('centerRow9'); let obj = JSON.parse(strJson);
let objNew = JSON.parse(strJsonNew); expect(obj.$attrs.brightness).assertEqual(20);
console.info("[testImageEffects016] component objNew is: " + JSON.stringify(objNew)); done();
expect(objNew.$attrs.hueRotate).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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets'; import Utils from './Utils.ets';
export default function layoutConstraintsJsunit() { export default function layoutConstraintsJsunit() {
describe('layoutConstraintsTest', function () { describe('layoutConstraintsTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("layoutConstraints beforeEach start"); console.info("layoutConstraints beforeEach start");
let options = { let options = {
uri: 'pages/layoutConstraints', uri: 'pages/layoutConstraints',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get layoutConstraints state pages:" + JSON.stringify(pages)); console.info("get layoutConstraints state pages:" + JSON.stringify(pages));
if (!("layoutConstraints" == pages.name)) { if (!("layoutConstraints" == pages.name)) {
console.info("get layoutConstraints state pages.name:" + JSON.stringify(pages.name)); console.info("get layoutConstraints state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push layoutConstraints page result:" + JSON.stringify(result)); console.info("push layoutConstraints page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push layoutConstraints page error:" + err); console.error("push layoutConstraints page error:" + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("layoutConstraints after each called"); console.info("layoutConstraints after each called");
}); });
it('testLayoutConstraints001', 0, async function (done) { it('testLayoutConstraints001', 0, async function (done) {
console.info('[testLayoutConstraints001] START'); console.info('[testLayoutConstraints001] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('aspectRatio'); let strJson = getInspectorByKey('aspectRatio');
console.info("[testLayoutConstraints001] component strJson:" + strJson); console.info("[testLayoutConstraints001] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testLayoutConstraints001] aspectRatio: " + obj.$attrs.aspectRatio); console.info("[testLayoutConstraints001] aspectRatio: " + obj.$attrs.aspectRatio);
expect(obj.$attrs.aspectRatio).assertEqual(1.5); expect(obj.$attrs.aspectRatio).assertEqual(1.5);
done(); done();
}); });
it('testLayoutConstraints002', 0, async function (done) { it('testLayoutConstraints002', 0, async function (done) {
console.info('[testLayoutConstraints002] START'); console.info('[testLayoutConstraints002] START');
try { try {
let eventData = { let eventData = {
data: { data: {
"aspectRatio": 2 "aspectRatio": 2
} }
} }
let indexEvent = { let indexEvent = {
eventId: 20, eventId: 20,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testLayoutConstraints002] start to publish emit"); console.info("[testLayoutConstraints002] start to publish emit");
events_emitter.emit(indexEvent, eventData); events_emitter.emit(indexEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testLayoutConstraints002] change component data error: " + err.message); console.log("[testLayoutConstraints002] change component data error: " + err.message);
} }
await Utils.sleep(4000); await Utils.sleep(4000);
let strJson = getInspectorByKey('aspectRatio'); let strJson = getInspectorByKey('aspectRatio');
console.info("[testLayoutConstraints002] component strJson:" + strJson); console.info("[testLayoutConstraints002] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testLayoutConstraints002] aspectRatio: " + obj.$attrs.aspectRatio); console.info("[testLayoutConstraints002] aspectRatio: " + obj.$attrs.aspectRatio);
expect(obj.$attrs.aspectRatio).assertEqual(2); expect(obj.$attrs.aspectRatio).assertEqual(2);
done(); done();
}); });
it('testLayoutConstraints003', 0, async function (done) { it('testLayoutConstraints003', 0, async function (done) {
console.info('[testLayoutConstraints003] START'); console.info('[testLayoutConstraints003] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('displayPriority'); let strJson = getInspectorByKey('displayPriority');
console.info("[testLayoutConstraints003] component strJson:" + strJson); console.info("[testLayoutConstraints003] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testLayoutConstraints003] displayPriority: " + obj.$attrs.displayPriority); console.info("[testLayoutConstraints003] displayPriority: " + obj.$attrs.displayPriority);
expect(obj.$attrs.displayPriority).assertEqual(1); expect(obj.$attrs.displayPriority).assertEqual(1);
done(); done();
}); });
it('testLayoutConstraints004', 0, async function (done) { it('testLayoutConstraints004', 0, async function (done) {
console.info('[testLayoutConstraints004] START'); console.info('[testLayoutConstraints004] START');
try { try {
let eventData = { let eventData = {
data: { data: {
"displayPriority": 5 "displayPriority": 5
} }
} }
let indexEvent = { let indexEvent = {
eventId: 21, eventId: 21,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testLayoutConstraints004] start to publish emit"); console.info("[testLayoutConstraints004] start to publish emit");
events_emitter.emit(indexEvent, eventData); events_emitter.emit(indexEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testLayoutConstraints004] change component data error: " + err.message); console.log("[testLayoutConstraints004] change component data error: " + err.message);
} }
await Utils.sleep(4000); await Utils.sleep(4000);
let strJson = getInspectorByKey('displayPriority'); let strJson = getInspectorByKey('displayPriority');
console.info("[testLayoutConstraints004] component strJson:" + strJson); console.info("[testLayoutConstraints004] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testLayoutConstraints004] displayPriority: " + obj.$attrs.displayPriority); console.info("[testLayoutConstraints004] displayPriority: " + obj.$attrs.displayPriority);
expect(obj.$attrs.displayPriority).assertEqual(5); expect(obj.$attrs.displayPriority).assertEqual(5);
done(); 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
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import appearJsunit from './AppearJsunit.test.ets'; import appearJsunit from './AppearJsunit.test.ets';
import areaChangeJsunit from './AreaChangeJsunit.test.ets'; import areaChangeJsunit from './AreaChangeJsunit.test.ets';
import ellipseJsunit from './EllipseJsunit.test.ets'; import ellipseJsunit from './EllipseJsunit.test.ets';
import enableJsunit from './EnableJsunit.test.ets'; import enableJsunit from './EnableJsunit.test.ets';
import flexJsunit from './FlexJsunit.test.ets'; import flexJsunit from './FlexJsunit.test.ets';
import gaugeJsunit from './GaugeJsunit.test.ets'; import gaugeJsunit from './GaugeJsunit.test.ets';
import globalJsunit from './GlobalJsunit.test.ets'; import globalJsunit from './GlobalJsunit.test.ets';
import girdContainerJsunit from './GridContainerJsunit.test.ets'; import girdContainerJsunit from './GridContainerJsunit.test.ets';
import gridSettingsJsunit from './GridSettingsJsunit.test.ets'; import gridSettingsJsunit from './GridSettingsJsunit.test.ets';
import imageEffectsJsunit from './ImageEffectsJsunit.test.ets'; import imageEffectsJsunit from './ImageEffectsJsunit.test.ets';
import layoutConstraintsJsunit from './LayoutConstraintsJsunit.test.ets'; import layoutConstraintsJsunit from './LayoutConstraintsJsunit.test.ets';
import listJsunit from './ListJsunit.test.ets'; import listJsunit from './ListJsunit.test.ets';
import marqueeJsunit from './MarqueeJsunit.test.ets'; import marqueeJsunit from './MarqueeJsunit.test.ets';
import overLayJsunit from './OverlayJsunit.test.ets'; import overLayJsunit from './OverlayJsunit.test.ets';
import stepperJsunit from './StepperJsunit.test.ets'; import stepperJsunit from './StepperJsunit.test.ets';
import swiperJsunit from './SwiperJsunit.test.ets'; import swiperJsunit from './SwiperJsunit.test.ets';
import textStyleJsunit from './TextStyleJsunit.test.ets'; import textStyleJsunit from './TextStyleJsunit.test.ets';
import touchAbleJsunit from './TouchAbleJsunit.test.ets'; import touchAbleJsunit from './TouchAbleJsunit.test.ets';
import touchJsunit from './TouchJsunit.test.ets'; import touchJsunit from './TouchJsunit.test.ets';
import visibilityJsunit from './VisibilityJsunit.test.ets'; import visibilityJsunit from './VisibilityJsunit.test.ets';
import zIndexJsunit from './ZIndexJsunit.test.ets'; import zIndexJsunit from './ZIndexJsunit.test.ets';
import columnJsunit from './ColumnJsunit.test.ets';
export default function testsuite() {
enableJsunit(); export default function testsuite() {
appearJsunit(); touchAbleJsunit();
zIndexJsunit(); columnJsunit();
ellipseJsunit(); enableJsunit();
flexJsunit(); appearJsunit();
gaugeJsunit(); zIndexJsunit();
globalJsunit(); ellipseJsunit();
visibilityJsunit(); flexJsunit();
girdContainerJsunit(); gaugeJsunit();
areaChangeJsunit(); globalJsunit();
gridSettingsJsunit(); visibilityJsunit();
imageEffectsJsunit(); girdContainerJsunit();
layoutConstraintsJsunit(); areaChangeJsunit();
listJsunit(); imageEffectsJsunit();
marqueeJsunit(); layoutConstraintsJsunit();
overLayJsunit(); listJsunit();
stepperJsunit(); marqueeJsunit();
swiperJsunit(); overLayJsunit();
textStyleJsunit(); stepperJsunit();
touchAbleJsunit(); swiperJsunit();
touchJsunit(); textStyleJsunit();
touchJsunit();
gridSettingsJsunit();
} }
\ No newline at end of file
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function listJsunit() {
export default function listJsunit() { describe('listTest', function () {
describe('appInfoTest', function () { beforeEach(async function (done) {
beforeEach(async function (done) { console.info("list beforeEach start");
console.info("list beforeEach start"); let options = {
let options = { uri: 'pages/list',
uri: 'pages/list', }
} try {
try { router.clear();
router.clear(); let pages = router.getState();
let pages = router.getState(); console.info("get list state pages:" + JSON.stringify(pages));
console.info("get list state pages:" + JSON.stringify(pages)); if (!("list" == pages.name)) {
if (!("list" == pages.name)) { console.info("get list state pages.name:" + JSON.stringify(pages.name));
console.info("get list state pages.name:" + JSON.stringify(pages.name)); let result = await router.push(options);
let result = await router.push(options); await Utils.sleep(2000);
await Utils.sleep(2000); console.info("push list page result:" + JSON.stringify(result));
console.info("push list page result:" + JSON.stringify(result)); }
} } catch (err) {
} catch (err) { console.error("push list page error:" + err);
console.error("push list page error:" + err); }
} done()
done() });
});
afterEach(async function () {
afterEach(async function () { await Utils.sleep(1000);
await Utils.sleep(1000); console.info("list after each called");
console.info("list after each called"); });
});
it('testList01', 0, async function (done) {
it('testList01', 0, async function (done) { console.info('[testList01] START');
console.info('[testList01] START'); await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList01] obj is: " + JSON.stringify(obj));
console.info("[testList01] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.listDirection).assertEqual('Axis.Vertical');
expect(obj.$attrs.listDirection).assertEqual('Axis.Vertical'); expect(obj.$attrs.editMode).assertEqual('false');
expect(obj.$attrs.editMode).assertEqual('false'); expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.None');
expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.None'); expect(obj.$attrs.chainAnimation).assertEqual('false');
expect(obj.$attrs.chainAnimation).assertEqual('false'); expect(obj.$attrs.divider.strokeWidth).assertEqual("2.00vp");
expect(obj.$attrs.divider.strokeWidth).assertEqual("2.00vp"); expect(obj.$attrs.divider.color).assertEqual("#FFFFFFFF");
expect(obj.$attrs.divider.color).assertEqual("#FFFFFFFF"); expect(obj.$attrs.divider.startMargin).assertEqual("20.00vp");
expect(obj.$attrs.divider.startMargin).assertEqual("20.00vp"); expect(obj.$attrs.divider.endMargin).assertEqual("20.00vp");
expect(obj.$attrs.divider.endMargin).assertEqual("20.00vp"); console.info('[testList01] END');
console.info('[testList01] END'); done();
done(); });
});
it('testList02', 0, async function (done) {
it('testList02', 0, async function (done) { console.info('[testList02] START');
console.info('[testList02] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "listDirection": Axis.Horizontal
"listDirection": Axis.Horizontal }
} }
} var innerEvent = {
var innerEvent = { eventId: 124,
eventId: 124, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList02] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList02] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList02] change component data error: " + err.message);
console.log("[testList02] change component data error: " + err.message); }
} await Utils.sleep(4000);
await Utils.sleep(4000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList02] obj is: " + JSON.stringify(obj));
console.info("[testList02] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.listDirection).assertEqual('Axis.Horizontal');
expect(obj.$attrs.listDirection).assertEqual('Axis.Horizontal'); console.info('testList02 END');
console.info('testList02 END'); done();
done(); });
});
it('testList03', 0, async function (done) {
it('testList03', 0, async function (done) { console.info('[testList03] START');
console.info('[testList03] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "editMode": true
"editMode": true }
} }
} var innerEvent = {
var innerEvent = { eventId: 124,
eventId: 124, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList03] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList03] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList03] change component data error: " + err.message);
console.log("[testList03] change component data error: " + err.message); }
} await Utils.sleep(4000);
await Utils.sleep(4000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList03] obj is: " + JSON.stringify(obj));
console.info("[testList03] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.editMode).assertEqual('true');
expect(obj.$attrs.editMode).assertEqual('true'); console.info('testList03 END');
console.info('testList03 END'); done();
done(); });
});
it('testList04', 0, async function (done) {
it('testList04', 0, async function (done) { console.info('[testList04] START');
console.info('[testList04] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "edgeEffect": EdgeEffect.Spring
"edgeEffect": EdgeEffect.Spring }
} }
} var innerEvent = {
var innerEvent = { eventId: 124,
eventId: 124, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList04] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList04] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList04] change component data error: " + err.message);
console.log("[testList04] change component data error: " + err.message); }
} await Utils.sleep(4000);
await Utils.sleep(4000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList04] obj is: " + JSON.stringify(obj));
console.info("[testList04] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.Spring');
expect(obj.$attrs.edgeEffect).assertEqual('EdgeEffect.Spring'); console.info('testList04 END');
console.info('testList04 END'); done();
done(); });
});
it('testList05', 0, async function (done) {
it('testList05', 0, async function (done) { console.info('[testList05] START');
console.info('[testList05] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "chainAnimation": true
"chainAnimation": true }
} }
} var innerEvent = {
var innerEvent = { eventId: 124,
eventId: 124, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList05] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList05] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList05] change component data error: " + err.message);
console.log("[testList05] change component data error: " + err.message); }
} await Utils.sleep(4000);
await Utils.sleep(4000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList05] obj is: " + JSON.stringify(obj));
console.info("[testList05] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.chainAnimation).assertEqual('true');
expect(obj.$attrs.chainAnimation).assertEqual('true'); console.info('testList05 END');
console.info('testList05 END'); done();
done(); });
});
it('testList06', 0, async function (done) {
it('testList06', 0, async function (done) { console.info('[testList06] START');
console.info('[testList06] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "strokeWidth": "3.000000vp"
"strokeWidth": "3.000000vp" }
} }
} var innerEvent = {
var innerEvent = { eventId: 125,
eventId: 125, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList06] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList06] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList06] change component data error: " + err.message);
console.log("[testList06] change component data error: " + err.message); }
} await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList06] obj is: " + JSON.stringify(obj));
console.info("[testList06] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.divider.strokeWidth).assertEqual("3.00vp");
expect(obj.$attrs.divider.strokeWidth).assertEqual("3.00vp"); console.info('testList06 END');
console.info('testList06 END'); done();
done(); });
});
it('testList07', 0, async function (done) {
it('testList07', 0, async function (done) { console.info('[testList07] START');
console.info('[testList07] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "color": "#FF0000FF"
"color": "#FF0000FF" }
} }
} var innerEvent = {
var innerEvent = { eventId: 125,
eventId: 125, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList07] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList07] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList07] change component data error: " + err.message);
console.log("[testList07] change component data error: " + err.message); }
} await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList07] obj is: " + JSON.stringify(obj));
console.info("[testList07] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.divider.color).assertEqual("#FF0000FF");
expect(obj.$attrs.divider.color).assertEqual("#FF0000FF"); console.info('testList07 END');
console.info('testList07 END'); done();
done(); });
});
it('testList08', 0, async function (done) {
it('testList08', 0, async function (done) { console.info('[testList08] START');
console.info('[testList08] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "startMargin": "30.000000vp"
"startMargin": "30.000000vp" }
} }
} var innerEvent = {
var innerEvent = { eventId: 125,
eventId: 125, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList08] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList08] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList08] change component data error: " + err.message);
console.log("[testList08] change component data error: " + err.message); }
} await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList08] obj is: " + JSON.stringify(obj));
console.info("[testList08] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.divider.startMargin).assertEqual("30.00vp");
expect(obj.$attrs.divider.startMargin).assertEqual("30.00vp"); console.info('testList08 END');
console.info('testList08 END'); done();
done(); });
});
it('testList09', 0, async function (done) {
it('testList09', 0, async function (done) { console.info('[testList09] START');
console.info('[testList09] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "endMargin": "30.000000vp"
"endMargin": "30.000000vp" }
} }
} var innerEvent = {
var innerEvent = { eventId: 125,
eventId: 125, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testList09] start to publish emit:" + JSON.stringify(eventData.data));
console.info("[testList09] start to publish emit:" + JSON.stringify(eventData.data)); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testList09] change component data error: " + err.message);
console.log("[testList09] change component data error: " + err.message); }
} await Utils.sleep(1000);
await Utils.sleep(1000); let strJson = getInspectorByKey('list');
let strJson = getInspectorByKey('list'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testList09] obj is: " + JSON.stringify(obj));
console.info("[testList09] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.divider.endMargin).assertEqual("30.00vp");
expect(obj.$attrs.divider.endMargin).assertEqual("30.00vp"); console.info('testList09 END');
console.info('testList09 END'); done();
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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils.ets';
import events_emitter from '@ohos.events.emitter';
import events_emitter from '@ohos.events.emitter';
export default function marqueeJsunit() { export default function marqueeJsunit() {
describe('marqueeTest', function () { describe('marqueeTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/marquee', uri: 'pages/marquee',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get marquee state success " + JSON.stringify(pages)); console.info("get marquee state success " + JSON.stringify(pages));
if (!("marquee" == pages.name)) { if (!("marquee" == pages.name)) {
console.info("get marquee state success " + JSON.stringify(pages.name)); console.info("get marquee state success " + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(4000); await Utils.sleep(4000);
console.info("push marquee page success " + JSON.stringify(result)); console.info("push marquee page success " + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push marquee page error " + JSON.stringify(result)); console.error("push marquee page error " + JSON.stringify(result));
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("marquee after each called"); console.info("marquee after each called");
}); });
it('testMarquee_0100', 0, async function (done) { it('testMarquee_0100', 0, async function (done) {
console.info('testMarquee_0100 START'); console.info('testMarquee_0100 START');
await Utils.sleep(1500); await Utils.sleep(1500);
let callback = (indexEvent) => { let callback = (indexEvent) => {
console.info("testMarquee_0100 get state result is: " + JSON.stringify(indexEvent)); console.info("testMarquee_0100 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.start).assertEqual(true); expect(indexEvent.data.start).assertEqual(true);
} }
let indexEvent = { let indexEvent = {
eventId: 130, eventId: 130,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
try { try {
events_emitter.on(indexEvent, callback); events_emitter.on(indexEvent, callback);
} catch (err) { } catch (err) {
console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err)); console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err));
} }
console.info("testMarquee_0100 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); console.info("testMarquee_0100 click result is: " + JSON.stringify(sendEventByKey('button', 10, "")));
await Utils.sleep(1000); await Utils.sleep(1000);
var callback1 = (eventData) => { var callback1 = (eventData) => {
console.info("testMarquee_0100 get event state result is: " + JSON.stringify(eventData)); console.info("testMarquee_0100 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.fontColor).assertEqual(Color.Blue); expect(eventData.data.fontColor).assertEqual(Color.Blue);
} }
var innerEventOne = { var innerEventOne = {
eventId: 127, eventId: 127,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
try { try {
events_emitter.on(innerEventOne, callback1); events_emitter.on(innerEventOne, callback1);
} catch (err) { } catch (err) {
console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err)); console.info("testMarquee_0100 on events_emitter err : " + JSON.stringify(err));
} }
console.info('testMarquee_0100 END'); console.info('testMarquee_0100 END');
done(); done();
}); });
it('testMarquee_0200', 0, async function (done) { it('testMarquee_0200', 0, async function (done) {
console.info('testMarquee_0200 START'); console.info('testMarquee_0200 START');
await Utils.sleep(1500); await Utils.sleep(1500);
let callback = (indexEvent) => { let callback = (indexEvent) => {
console.info("testMarquee_0200 get state result is: " + JSON.stringify(indexEvent)); console.info("testMarquee_0200 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.start).assertEqual(true); expect(indexEvent.data.start).assertEqual(true);
} }
let indexEvent = { let indexEvent = {
eventId: 130, eventId: 130,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
try { try {
events_emitter.on(indexEvent, callback); events_emitter.on(indexEvent, callback);
} catch (err) { } catch (err) {
console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err)); console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err));
} }
console.info("testMarquee_0200 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); console.info("testMarquee_0200 click result is: " + JSON.stringify(sendEventByKey('button', 10, "")));
await Utils.sleep(1000); await Utils.sleep(1000);
var callback1 = (eventData) => { var callback1 = (eventData) => {
console.info("testMarquee_0200 get event state result is: " + JSON.stringify(eventData)); console.info("testMarquee_0200 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.fontSize).assertEqual(50); expect(eventData.data.fontSize).assertEqual(50);
} }
var innerEventOne = { var innerEventOne = {
eventId: 128, eventId: 128,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
try { try {
events_emitter.on(innerEventOne, callback1) events_emitter.on(innerEventOne, callback1)
} catch (err) { } catch (err) {
console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err)); console.info("testMarquee_0200 on events_emitter err : " + JSON.stringify(err));
} }
console.info('testMarquee_0200 END'); console.info('testMarquee_0200 END');
done(); done();
}); });
it('testMarquee_0300', 0, async function (done) { it('testMarquee_0300', 0, async function (done) {
console.info('testMarquee_0300 START'); console.info('testMarquee_0300 START');
await Utils.sleep(1500); await Utils.sleep(1500);
let callback = (indexEvent) => { let callback = (indexEvent) => {
console.info("testMarquee_0300 get state result is: " + JSON.stringify(indexEvent)); console.info("testMarquee_0300 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.start).assertEqual(true); expect(indexEvent.data.start).assertEqual(true);
} }
let indexEvent = { let indexEvent = {
eventId: 130, eventId: 130,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
try { try {
events_emitter.on(indexEvent, callback); events_emitter.on(indexEvent, callback);
} catch (err) { } catch (err) {
console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err)); console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err));
} }
console.info("testMarquee_0300 click result is: " + JSON.stringify(sendEventByKey('button',10,""))); console.info("testMarquee_0300 click result is: " + JSON.stringify(sendEventByKey('button', 10, "")));
await Utils.sleep(1000); await Utils.sleep(1000);
var callback1 = (eventData) => { var callback1 = (eventData) => {
console.info("testMarquee_0300 get event state result is: " + JSON.stringify(eventData)); console.info("testMarquee_0300 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.ACTION).assertEqual(true); expect(eventData.data.ACTION).assertEqual(true);
} }
var innerEventOne = { var innerEventOne = {
eventId: 129, eventId: 129,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
try { try {
events_emitter.on(innerEventOne, callback1) events_emitter.on(innerEventOne, callback1)
} catch (err) { } catch (err) {
console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err)); console.info("testMarquee_0300 on events_emitter err : " + JSON.stringify(err));
} }
console.info('testMarquee_0300 END'); console.info('testMarquee_0300 END');
done(); done();
}); });
}) })
} }
\ No newline at end of file
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter' import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils.ets';
export default function overLayJsunit() { export default function overLayJsunit() {
describe('appInfoTest', function () { describe('overLayTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("overlay beforeEach start"); console.info("overlay beforeEach start");
let options = { let options = {
uri: 'pages/overlay', uri: 'pages/overlay',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get overlay state pages: " + JSON.stringify(pages)); console.info("get overlay state pages: " + JSON.stringify(pages));
if (!("overlay" == pages.name)) { if (!("overlay" == pages.name)) {
console.info("get overlay state pages.name:" + JSON.stringify(pages.name)); console.info("get overlay state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push overlay page result:" + JSON.stringify(result)); console.info("push overlay page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push overlay page error:" + err); console.error("push overlay page error:" + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("overlay after each called"); console.info("overlay after each called");
}); });
it('testOverlay01', 0, async function (done) { it('testOverlay01', 0, async function (done) {
console.info('[testOverlay01] START'); console.info('[testOverlay01] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testOverlay01] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[testOverlay01] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.title).assertEqual("old title"); expect(obj.$attrs.overlay.title).assertEqual("old title");
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.Bottom"); 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.x).assertEqual('0.00vp');
expect(obj.$attrs.overlay.options.offset.y).assertEqual('-15.00vp'); expect(obj.$attrs.overlay.options.offset.y).assertEqual('-15.00vp');
console.info('[testOverlay01] END'); console.info('[testOverlay01] END');
done(); done();
}); });
it('testOverlay02', 0, async function (done) { it('testOverlay02', 0, async function (done) {
console.info('[testOverlay02] START'); console.info('[testOverlay02] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"title": "new title" "title": "new title"
} }
} }
var innerEvent = { var innerEvent = {
eventId: 143, eventId: 143,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testOverlay02] start to publish emit"); console.info("[testOverlay02] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testOverlay02] change component data error: " + err.message); console.log("[testOverlay02] change component data error: " + err.message);
} }
await Utils.sleep(2000); await Utils.sleep(2000);
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testOverlay02] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[testOverlay02] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.title).assertEqual("new title"); expect(obj.$attrs.overlay.title).assertEqual("new title");
console.info('testOverlay02 END'); console.info('testOverlay02 END');
done(); done();
}); });
it('testOverlay03', 0, async function (done) { it('testOverlay03', 0, async function (done) {
console.info('[testOverlay03] START'); console.info('[testOverlay03] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"align": "Alignment.TopStart", "align": "Alignment.TopStart",
"x": 30, "x": 30,
"y": -30 "y": -30
} }
} }
var innerEvent = { var innerEvent = {
eventId: 143, eventId: 143,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testOverlay03] start to publish emit"); console.info("[testOverlay03] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testOverlay03] change component data error: " + err.message); console.log("[testOverlay03] change component data error: " + err.message);
} }
await Utils.sleep(2000); await Utils.sleep(2000);
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testOverlay03] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[testOverlay03] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart"); 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.x).assertEqual('30.00vp');
expect(obj.$attrs.overlay.options.offset.y).assertEqual('-30.00vp'); expect(obj.$attrs.overlay.options.offset.y).assertEqual('-30.00vp');
console.info('testOverlay03 END'); console.info('testOverlay03 END');
done(); done();
}); });
it('testOverlay04', 0, async function (done) { it('testOverlay04', 0, async function (done) {
console.info('[testOverlay04] START'); console.info('[testOverlay04] START');
await Utils.sleep(1000); await Utils.sleep(1000);
try { try {
var eventData = { var eventData = {
data: { data: {
"align": "Alignment.Center" "align": "Alignment.Center"
} }
} }
var innerEvent = { var innerEvent = {
eventId: 143, eventId: 143,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testOverlay04] start to publish emit"); console.info("[testOverlay04] start to publish emit");
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testOverlay04] change component data error: " + err.message); console.log("[testOverlay04] change component data error: " + err.message);
} }
await Utils.sleep(2000); await Utils.sleep(2000);
let strJson = getInspectorByKey('overlay'); let strJson = getInspectorByKey('overlay');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testOverlay04] obj is: " + JSON.stringify(obj.$attrs.overlay)); console.info("[testOverlay04] obj is: " + JSON.stringify(obj.$attrs.overlay));
expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart"); expect(obj.$attrs.overlay.options.align).assertEqual("Alignment.TopStart");
console.info('testOverlay04 END'); console.info('testOverlay04 END');
done(); 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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils.ets';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
export default function stepperJsunit() { export default function stepperJsunit() {
describe('stepperTest', function () { describe('stepperTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/stepper', uri: 'pages/stepper',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get stepper state success " + JSON.stringify(pages)); console.info("get stepper state success " + JSON.stringify(pages));
if (!("stepper" == pages.name)) { if (!("stepper" == pages.name)) {
console.info("get stepper state success " + JSON.stringify(pages.name)); console.info("get stepper state success " + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("push stepper page success " + JSON.stringify(result)); console.info("push stepper page success " + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push stepper page error: " + err); console.error("push stepper page error: " + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("stepper after each called"); console.info("stepper after each called");
}); });
it('stepperTest_0100', 0, async function (done) { it('stepperTest_0100', 0, async function (done) {
console.info('stepperTest_0100 START'); console.info('stepperTest_0100 START');
let strJson = getInspectorByKey('stepper'); let strJson = getInspectorByKey('stepper');
console.info("stepperTest_0100 component strJson:" + strJson); console.info("stepperTest_0100 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("stepperTest_0100 component obj is: " + JSON.stringify(obj)); console.info("stepperTest_0100 component obj is: " + JSON.stringify(obj));
expect(obj.$type).assertEqual('Stepper'); expect(obj.$type).assertEqual('Stepper');
expect(obj.$attrs.index).assertEqual('0'); expect(obj.$attrs.index).assertEqual('0');
console.info('stepperTest_0100 END'); console.info('stepperTest_0100 END');
done(); done();
}); });
it('stepperTest_0200', 0, async function (done) { it('stepperTest_0200', 0, async function (done) {
console.info('stepperTest_0200 START'); console.info('stepperTest_0200 START');
let strJson = getInspectorByKey('stepper'); let strJson = getInspectorByKey('stepper');
console.info("stepperTest_0200 component strJson:" + strJson); console.info("stepperTest_0200 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("stepperTest_0200 component obj is: " + JSON.stringify(obj)); console.info("stepperTest_0200 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.index).assertEqual('0'); expect(obj.$attrs.index).assertEqual('0');
try { try {
let eventData = { let eventData = {
data: { data: {
"currentIndex": "1", "currentIndex": "1",
} }
} }
let indexEvent = { let indexEvent = {
eventId: 202, eventId: 202,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("stepperTest_0200 start to publish emit"); console.info("stepperTest_0200 start to publish emit");
events_emitter.emit(indexEvent, eventData); events_emitter.emit(indexEvent, eventData);
} catch (err) { } catch (err) {
console.log("stepperTest_0200 change component data error: " + err.message); console.log("stepperTest_0200 change component data error: " + err.message);
} }
await Utils.sleep(3000); await Utils.sleep(3000);
let strJsonNew = getInspectorByKey('stepper'); let strJsonNew = getInspectorByKey('stepper');
let objNew = JSON.parse(strJsonNew); let objNew = JSON.parse(strJsonNew);
console.info("stepperTest_0200 component objNew is: " + JSON.stringify(objNew)); console.info("stepperTest_0200 component objNew is: " + JSON.stringify(objNew));
expect(objNew.$attrs.index).assertEqual('1'); expect(objNew.$attrs.index).assertEqual('1');
console.info('stepperTest_0200 END'); console.info('stepperTest_0200 END');
done(); 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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils.ets';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
export default function swiperJsunit() { export default function swiperJsunit() {
describe('swiperTest', function () { describe('swiperTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/swiper', uri: 'pages/swiper',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get swiper state success " + JSON.stringify(pages)); console.info("get swiper state success " + JSON.stringify(pages));
if (!("swiper" == pages.name)) { if (!("swiper" == pages.name)) {
console.info("get swiper state success " + JSON.stringify(pages.name)); console.info("get swiper state success " + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("push swiper page success " + JSON.stringify(result)); console.info("push swiper page success " + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push swiper page error: " + err); console.error("push swiper page error: " + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("swiper after each called"); console.info("swiper after each called");
}); });
it('swiperTest_0100', 0, async function (done) { it('swiperTest_0100', 0, async function (done) {
console.info('swiperTest_0100 START'); console.info('swiperTest_0100 START');
let strJson = getInspectorByKey('swiper'); let strJson = getInspectorByKey('swiper');
console.info("swiperTest_0100 component strJson:" + strJson); console.info("swiperTest_0100 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("swiperTest_0100 component obj is: " + JSON.stringify(obj)); 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.index: " + obj.$attrs.index);
console.info("swiperTest_0100 obj.$attrs.indicatorStyle: " + obj.$attrs.indicatorStyle); console.info("swiperTest_0100 obj.$attrs.indicatorStyle: " + obj.$attrs.indicatorStyle);
expect(obj.$type).assertEqual('Swiper'); expect(obj.$type).assertEqual('Swiper');
expect(obj.$attrs.index).assertEqual('1'); expect(obj.$attrs.index).assertEqual('1');
done(); done();
}); });
it('swiperTest_0200', 0, async function (done) { it('swiperTest_0200', 0, async function (done) {
console.info('swiperTest_0200 START'); console.info('swiperTest_0200 START');
let strJson = getInspectorByKey('swiper'); let strJson = getInspectorByKey('swiper');
console.info("swiperTest_0200 component strJson:" + strJson); console.info("swiperTest_0200 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("swiperTest_0200 component obj is: " + JSON.stringify(obj)); console.info("swiperTest_0200 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.indicator).assertEqual('true'); expect(obj.$attrs.indicator).assertEqual('true');
expect(obj.$attrs.loop).assertEqual('false'); expect(obj.$attrs.loop).assertEqual('false');
console.info('swiperTest_0200 END'); console.info('swiperTest_0200 END');
done(); done();
}); });
it('swiperTest_0300', 0, async function (done) { it('swiperTest_0300', 0, async function (done) {
console.info('swiperTest_0300 START'); console.info('swiperTest_0300 START');
let strJson = getInspectorByKey('swiper'); let strJson = getInspectorByKey('swiper');
console.info("swiperTest_0300 component strJson:" + strJson); console.info("swiperTest_0300 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("swiperTest_0300 component obj is: " + JSON.stringify(obj)); console.info("swiperTest_0300 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.duration).assertEqual('1000.000000'); expect(obj.$attrs.duration).assertEqual('1000.000000');
expect(obj.$attrs.vertical).assertEqual('false'); expect(obj.$attrs.vertical).assertEqual('false');
console.info('swiperTest_0300 END'); console.info('swiperTest_0300 END');
done(); done();
}); });
it('swiperTest_0400', 0, async function (done) { it('swiperTest_0400', 0, async function (done) {
console.info('swiperTest_0400 START'); console.info('swiperTest_0400 START');
let strJson = getInspectorByKey('swiper'); let strJson = getInspectorByKey('swiper');
console.info("swiperTest_0400 component strJson:" + strJson); console.info("swiperTest_0400 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("swiperTest_0400 component obj is: " + JSON.stringify(obj)); console.info("swiperTest_0400 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.autoPlay).assertEqual('true'); expect(obj.$attrs.autoPlay).assertEqual('true');
expect(obj.$attrs.interval).assertEqual('4000'); expect(obj.$attrs.interval).assertEqual('4000');
console.info('swiperTest_0400 END'); console.info('swiperTest_0400 END');
done(); done();
}); });
it('swiperTest_0500', 0, async function (done) { it('swiperTest_0500', 0, async function (done) {
console.info('swiperTest_0500 START'); console.info('swiperTest_0500 START');
let strJson = getInspectorByKey('swiper'); let strJson = getInspectorByKey('swiper');
console.info("swiperTest_0500 component strJson:" + strJson); console.info("swiperTest_0500 component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("swiperTest_0500 component obj is: " + JSON.stringify(obj)); console.info("swiperTest_0500 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.itemSpace).assertEqual('0.00vp'); expect(obj.$attrs.itemSpace).assertEqual('0.00vp');
expect(obj.$attrs.disableSwipe).assertEqual('false'); expect(obj.$attrs.disableSwipe).assertEqual('false');
console.info('swiperTest_0500 END'); console.info('swiperTest_0500 END');
done(); done();
}); });
it('swiperTest_0600', 0, async function (done) { it('swiperTest_0600', 0, async function (done) {
console.info('swiperTest_0600 START'); console.info('swiperTest_0600 START');
try { try {
let eventData = { let eventData = {
data: { data: {
"index": "3", "index": "3"
"autoPlay": "false", }
} }
} let indexEvent = {
let indexEvent = { eventId: 207,
eventId: 207, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("swiperTest_0600 start to publish emit");
console.info("swiperTest_0600 start to publish emit"); events_emitter.emit(indexEvent, eventData);
events_emitter.emit(indexEvent, eventData); } catch (err) {
} catch (err) { console.log("swiperTest_0600 change component data error: " + err.message);
console.log("swiperTest_0600 change component data error: " + err.message); }
} await Utils.sleep(4000);
await Utils.sleep(4000); let strJsonNew = getInspectorByKey('swiper');
let strJsonNew = getInspectorByKey('swiper'); let objNew = JSON.parse(strJsonNew);
let objNew = JSON.parse(strJsonNew); console.info("swiperTest_0600 component objNew is: " + JSON.stringify(objNew));
console.info("swiperTest_0600 component objNew is: " + JSON.stringify(objNew)); expect(objNew.$attrs.index).assertEqual('3');
expect(objNew.$attrs.index).assertEqual('3'); console.info('swiperTest_0600 END');
expect(objNew.$attrs.autoPlay).assertEqual('false'); done();
console.info('swiperTest_0600 END'); });
done();
}); it('swiperTest_0700', 0, async function (done) {
console.info('swiperTest_0700 START');
it('swiperTest_0700', 0, async function (done) { try {
console.info('swiperTest_0700 START'); let eventData = {
await Utils.sleep(1500); data: {
let callback = (indexEvent) => { "autoPlay": "false"
console.info("swiperTest_0700 get state result is: " + JSON.stringify(indexEvent)); }
expect(indexEvent.data.ACTION).assertEqual(true); }
} let indexEvent = {
let indexEvent = { eventId: 207,
eventId: 205, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("swiperTest_0700 start to publish emit");
try { events_emitter.emit(indexEvent, eventData);
events_emitter.on(indexEvent, callback); } catch (err) {
} catch (err) { console.log("swiperTest_0700 change component data error: " + err.message);
console.info("swiperTest_0700 on events_emitter err : " + JSON.stringify(err)); }
} await Utils.sleep(4000);
console.info("swiperTest_0700 click result is: " + JSON.stringify(sendEventByKey('button1',10,""))); let strJsonNew = getInspectorByKey('swiper');
await Utils.sleep(1000); let objNew = JSON.parse(strJsonNew);
console.info('swiperTest_0700 END'); console.info("swiperTest_0700 component objNew is: " + JSON.stringify(objNew));
done(); 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); it('swiperTest_0800', 0, async function (done) {
let callback = (indexEvent) => { console.info('swiperTest_0800 START');
console.info("swiperTest_0800 get state result is: " + JSON.stringify(indexEvent)); await Utils.sleep(1500);
expect(indexEvent.data.ACTION).assertEqual(true); let callback = (indexEvent) => {
} console.info("swiperTest_0800 get state result is: " + JSON.stringify(indexEvent));
let indexEvent = { expect(indexEvent.data.ACTION).assertEqual(true);
eventId: 206, }
priority: events_emitter.EventPriority.LOW let indexEvent = {
} eventId: 205,
try { priority: events_emitter.EventPriority.LOW
events_emitter.on(indexEvent, callback); }
} catch (err) { try {
console.info("swiperTest_0800 on events_emitter err : " + JSON.stringify(err)); events_emitter.on(indexEvent, callback);
} } catch (err) {
console.info("swiperTest_0800 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); console.info("swiperTest_0800 on events_emitter err : " + JSON.stringify(err));
await Utils.sleep(1000); }
console.info('swiperTest_0800 END'); console.info("swiperTest_0800 click result is: " + JSON.stringify(sendEventByKey('button1', 10, "")));
done(); 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); it('swiperTest_0900', 0, async function (done) {
let callbackOne = (indexEventOne) => { console.info('swiperTest_0900 START');
console.info("swiperTest_0900 get state result is: " + JSON.stringify(indexEventOne)); await Utils.sleep(1500);
expect(indexEventOne.data.ACTION).assertEqual(true); let callback = (indexEvent) => {
} console.info("swiperTest_0900 get state result is: " + JSON.stringify(indexEvent));
let indexEventOne = { expect(indexEvent.data.ACTION).assertEqual(true);
eventId: 206, }
priority: events_emitter.EventPriority.LOW let indexEvent = {
} eventId: 206,
try { priority: events_emitter.EventPriority.LOW
events_emitter.on(indexEventOne, callbackOne); }
} catch (err) { try {
console.info("swiperTest_0900 on events_emitter err : " + JSON.stringify(err)); events_emitter.on(indexEvent, callback);
} } catch (err) {
console.info("swiperTest_0900 click result is: " + JSON.stringify(sendEventByKey('button2',10,""))); console.info("swiperTest_0900 on events_emitter err : " + JSON.stringify(err));
await Utils.sleep(1500); }
let callback = (indexEvent) => { console.info("swiperTest_0900 click result is: " + JSON.stringify(sendEventByKey('button2', 10, "")));
console.info("swiperTest_0900 get state result is: " + JSON.stringify(indexEvent)); await Utils.sleep(1000);
expect(indexEvent.data.ACTION).assertEqual(true); console.info('swiperTest_0900 END');
} done();
let indexEvent = { });
eventId: 204,
priority: events_emitter.EventPriority.LOW it('swiperTest_1000', 0, async function (done) {
} console.info('swiperTest_1000 START');
try { await Utils.sleep(1500);
events_emitter.on(indexEvent, callback); let callbackOne = (indexEventOne) => {
} catch (err) { console.info("swiperTest_1000 get state result is: " + JSON.stringify(indexEventOne));
console.info("swiperTest_0900 on events_emitter err : " + JSON.stringify(err)); expect(indexEventOne.data.ACTION).assertEqual(true);
} }
console.info('swiperTest_0900 END'); let indexEventOne = {
done(); eventId: 206,
}); priority: events_emitter.EventPriority.LOW
}
it('swiperTest_1000', 0, async function (done) { try {
console.info('swiperTest_1000 START'); events_emitter.on(indexEventOne, callbackOne);
try { } catch (err) {
let eventData = { console.info("swiperTest_1000 on events_emitter err : " + JSON.stringify(err));
data: { }
"loop": true, console.info("swiperTest_1000 click result is: " + JSON.stringify(sendEventByKey('button2', 10, "")));
"vertical": true, await Utils.sleep(1500);
} let callback = (indexEvent) => {
} console.info("swiperTest_1000 get state result is: " + JSON.stringify(indexEvent));
let indexEvent = { expect(indexEvent.data.ACTION).assertEqual(true);
eventId: 208, }
priority: events_emitter.EventPriority.LOW let indexEvent = {
} eventId: 204,
console.info("swiperTest_1000 start to publish emit"); priority: events_emitter.EventPriority.LOW
events_emitter.emit(indexEvent, eventData); }
} catch (err) { try {
console.log("swiperTest_1000 change component data error: " + err.message); events_emitter.on(indexEvent, callback);
} } catch (err) {
await Utils.sleep(3000); console.info("swiperTest_1000 on events_emitter err : " + JSON.stringify(err));
let strJsonNew = getInspectorByKey('swiper'); }
let objNew = JSON.parse(strJsonNew); console.info('swiperTest_1000 END');
console.info("swiperTest_1000 component objNew is: " + JSON.stringify(objNew)); done();
expect(objNew.$attrs.loop).assertEqual('true'); });
expect(objNew.$attrs.vertical).assertEqual('true');
console.info('swiperTest_1000 END'); it('swiperTest_1100', 0, async function (done) {
done(); console.info('swiperTest_1100 START');
}); try {
let eventData = {
data: {
it('swiperTest_1100', 0, async function (done) { "loop": true
console.info('swiperTest_1100 START'); }
try { }
let eventData = { let indexEvent = {
data: { eventId: 208,
"interval": "3000", priority: events_emitter.EventPriority.LOW
"indicator": "false", }
} console.info("swiperTest_1100 start to publish emit");
} events_emitter.emit(indexEvent, eventData);
let indexEvent = { } catch (err) {
eventId: 209, console.log("swiperTest_1100 change component data error: " + err.message);
priority: events_emitter.EventPriority.LOW }
} await Utils.sleep(3000);
console.info("swiperTest_1100 start to publish emit"); let strJsonNew = getInspectorByKey('swiper');
events_emitter.emit(indexEvent, eventData); let objNew = JSON.parse(strJsonNew);
} catch (err) { console.info("swiperTest_1100 component objNew is: " + JSON.stringify(objNew));
console.log("swiperTest_1100 change component data error: " + err.message); expect(objNew.$attrs.loop).assertEqual('true');
} console.info('swiperTest_1100 END');
await Utils.sleep(4000); done();
let strJsonNew = getInspectorByKey('swiper'); });
let objNew = JSON.parse(strJsonNew);
console.info("swiperTest_1100 component objNew is: " + JSON.stringify(objNew)); it('swiperTest_1200', 0, async function (done) {
expect(objNew.$attrs.interval).assertEqual('3000'); console.info('swiperTest_1200 START');
expect(objNew.$attrs.indicator).assertEqual('false'); try {
console.info('swiperTest_1100 END'); let eventData = {
done(); data: {
}); "vertical": true
}
it('swiperTest_1200', 0, async function (done) { }
console.info('swiperTest_1200 START'); let indexEvent = {
try { eventId: 208,
let eventData = { priority: events_emitter.EventPriority.LOW
data: { }
"duration": "500", console.info("swiperTest_1200 start to publish emit");
"itemSpace": "1", events_emitter.emit(indexEvent, eventData);
} } catch (err) {
} console.log("swiperTest_1200 change component data error: " + err.message);
let indexEvent = { }
eventId: 210, await Utils.sleep(3000);
priority: events_emitter.EventPriority.LOW let strJsonNew = getInspectorByKey('swiper');
} let objNew = JSON.parse(strJsonNew);
console.info("swiperTest_1200 start to publish emit"); console.info("swiperTest_1200 component objNew is: " + JSON.stringify(objNew));
events_emitter.emit(indexEvent, eventData); expect(objNew.$attrs.vertical).assertEqual('true');
} catch (err) { console.info('swiperTest_1200 END');
console.log("swiperTest_1200 change component data error: " + err.message); done();
} });
await Utils.sleep(4000);
let strJsonNew = getInspectorByKey('swiper'); it('swiperTest_1300', 0, async function (done) {
let objNew = JSON.parse(strJsonNew); console.info('swiperTest_1300 START');
console.info("swiperTest_1200 component objNew is: " + JSON.stringify(objNew)); try {
expect(objNew.$attrs.duration).assertEqual('500.000000'); let eventData = {
expect(objNew.$attrs.itemSpace).assertEqual('1.00vp'); data: {
console.info('swiperTest_1200 END'); "interval": "3000"
done(); }
}); }
}) 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
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils.ets'; import Utils from './Utils.ets';
export default function textStyleJsunit() { export default function textStyleJsunit() {
describe('textStyleTest', function () { describe('textStyleTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/textStyle', uri: 'pages/textStyle',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get textStyle state pages:" + JSON.stringify(pages)); console.info("get textStyle state pages:" + JSON.stringify(pages));
if (!("textStyle" == pages.name)) { if (!("textStyle" == pages.name)) {
console.info("get textStyle state pages.name:" + JSON.stringify(pages.name)); console.info("get textStyle state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push textStyle page result:" + JSON.stringify(result)); console.info("push textStyle page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push textStyle page error:" + err); console.error("push textStyle page error:" + err);
} }
done(); done();
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("textStyle after each called"); console.info("textStyle after each called");
}); });
it('testTextStyle001', 0, async function (done) { it('testTextStyle001', 0, async function (done) {
console.info('[testTextStyle001] START'); console.info('[testTextStyle001] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('fontColor'); let strJson = getInspectorByKey('fontColor');
console.info("[testTextStyle001] component strJson:" + strJson); console.info("[testTextStyle001] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testTextStyle001] fontColor: " + obj.$attrs.fontColor); console.info("[testTextStyle001] fontColor: " + obj.$attrs.fontColor);
expect(obj.$attrs.fontColor).assertEqual('#FFFF0000'); expect(obj.$attrs.fontColor).assertEqual('#FFFF0000');
done(); done();
}); });
it('testTextStyle002', 0, async function (done) { it('testTextStyle002', 0, async function (done) {
console.info('[testTextStyle002] START'); console.info('[testTextStyle002] START');
try { try {
let eventData = { let eventData = {
data: { data: {
"fontColor": Color.Blue "fontColor": Color.Blue
} }
} }
let indexEvent = { let indexEvent = {
eventId: 37, eventId: 37,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testTextStyle002] start to publish emit"); console.info("[testTextStyle002] start to publish emit");
events_emitter.emit(indexEvent, eventData); events_emitter.emit(indexEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testTextStyle002] change component data error: " + err.message); console.log("[testTextStyle002] change component data error: " + err.message);
} }
await Utils.sleep(3000); await Utils.sleep(3000);
let strJson = getInspectorByKey('fontColor'); let strJson = getInspectorByKey('fontColor');
console.info("[testTextStyle002] component strJson:" + strJson); console.info("[testTextStyle002] component strJson:" + strJson);
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testTextStyle002] fontColor: " + obj.$attrs.fontColor); console.info("[testTextStyle002] fontColor: " + obj.$attrs.fontColor);
expect(obj.$attrs.fontColor).assertEqual('#FF0000FF'); expect(obj.$attrs.fontColor).assertEqual('#FF0000FF');
done(); done();
}); });
it('testTextStyle003', 0, async function (done) { it('testTextStyle003', 0, async function (done) {
console.info('[testTextStyle003] START'); console.info('[testTextStyle003] START');
await Utils.sleep(1000); try {
let strJson = getInspectorByKey('fontSize'); let eventData = {
console.info("[testTextStyle003] component strJson:" + strJson); data: {
let obj = JSON.parse(strJson); "fontColor": 0x80000000
console.info("[testTextStyle003] fontSize: " + obj.$attrs.fontSize); }
expect(obj.$attrs.fontSize).assertEqual('20.00fp'); }
done(); let indexEvent = {
}); eventId: 37,
priority: events_emitter.EventPriority.LOW
it('testTextStyle004', 0, async function (done) { }
console.info('[testTextStyle004] START'); console.info("[testTextStyle003] start to publish emit");
try { events_emitter.emit(indexEvent, eventData);
let eventData = { } catch (err) {
data: { console.log("[testTextStyle003] change component data error: " + err.message);
"fontSize": 30 }
} await Utils.sleep(3000);
} let strJson = getInspectorByKey('fontColor');
let indexEvent = { console.info("[testTextStyle003] component strJson:" + strJson);
eventId: 38, let obj = JSON.parse(strJson);
priority: events_emitter.EventPriority.LOW console.info("[testTextStyle003] fontColor: " + obj.$attrs.fontColor);
} expect(obj.$attrs.fontColor).assertEqual('#80000000');
console.info("[testTextStyle004] start to publish emit"); done();
events_emitter.emit(indexEvent, eventData); });
} catch (err) {
console.log("[testTextStyle004] change component data error: " + err.message); it('testTextStyle004', 0, async function (done) {
} console.info('[testTextStyle004] START');
await Utils.sleep(4000); try {
let strJson = getInspectorByKey('fontSize'); let eventData = {
console.info("[testTextStyle004] component strJson:" + strJson); data: {
let obj = JSON.parse(strJson); "fontColor": 0x7FFFFFFF
console.info("[testTextStyle004] fontSize: " + obj.$attrs.fontSize); }
expect(obj.$attrs.fontSize).assertEqual('30.00fp'); }
done(); let indexEvent = {
}); eventId: 37,
priority: events_emitter.EventPriority.LOW
it('testTextStyle005', 0, async function (done) { }
console.info('[testTextStyle005] START'); console.info("[testTextStyle004] start to publish emit");
await Utils.sleep(1000); events_emitter.emit(indexEvent, eventData);
let strJson = getInspectorByKey('fontStyle'); } catch (err) {
console.info("[testTextStyle005] component strJson:" + strJson); console.log("[testTextStyle004] change component data error: " + err.message);
let obj = JSON.parse(strJson); }
console.info("[testTextStyle005] fontStyle: " + obj.$attrs.fontStyle); await Utils.sleep(3000);
expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Italic'); let strJson = getInspectorByKey('fontColor');
done(); console.info("[testTextStyle004] component strJson:" + strJson);
}); let obj = JSON.parse(strJson);
console.info("[testTextStyle004] fontColor: " + obj.$attrs.fontColor);
it('testTextStyle006', 0, async function (done) { expect(obj.$attrs.fontColor).assertEqual('#7FFFFFFF');
console.info('[testTextStyle006] START'); done();
try { });
let eventData = {
data: { it('testTextStyle005', 0, async function (done) {
"fontStyle": FontStyle.Normal console.info('[testTextStyle005] START');
} try {
} let eventData = {
let indexEvent = { data: {
eventId: 39, "fontColor": 'error'
priority: events_emitter.EventPriority.LOW }
} }
console.info("[testTextStyle006] start to publish emit"); let indexEvent = {
events_emitter.emit(indexEvent, eventData); eventId: 37,
} catch (err) { priority: events_emitter.EventPriority.LOW
console.log("[testTextStyle006] change component data error: " + err.message); }
} console.info("[testTextStyle005] start to publish emit");
await Utils.sleep(3000); events_emitter.emit(indexEvent, eventData);
let strJson = getInspectorByKey('fontStyle'); } catch (err) {
console.info("[testTextStyle006] component strJson:" + strJson); console.log("[testTextStyle005] change component data error: " + err.message);
let obj = JSON.parse(strJson); }
console.info("[testTextStyle006] fontStyle: " + obj.$attrs.fontStyle); await Utils.sleep(3000);
expect(obj.$attrs.fontStyle).assertEqual('FontStyle.Normal'); let strJson = getInspectorByKey('fontColor');
done(); console.info("[testTextStyle005] component strJson:" + strJson);
}); let obj = JSON.parse(strJson);
console.info("[testTextStyle005] fontColor: " + obj.$attrs.fontColor);
it('testTextStyle007', 0, async function (done) { expect(obj.$attrs.fontColor).assertEqual('#FF000000');
console.info('[testTextStyle007] START'); done();
await Utils.sleep(1000); });
let strJson = getInspectorByKey('fontWeight');
console.info("[testTextStyle007] component strJson:" + strJson); it('testTextStyle006', 0, async function (done) {
let obj = JSON.parse(strJson); console.info('[testTextStyle006] START');
console.info("[testTextStyle007] fontWeight: " + obj.$attrs.fontWeight); await Utils.sleep(1000);
expect(obj.$attrs.fontWeight).assertEqual('FontWeight.700'); let strJson = getInspectorByKey('fontSize');
done(); console.info("[testTextStyle006] component strJson:" + strJson);
}); let obj = JSON.parse(strJson);
console.info("[testTextStyle006] fontSize: " + obj.$attrs.fontSize);
it('testTextStyle008', 0, async function (done) { expect(obj.$attrs.fontSize).assertEqual('20.00fp');
console.info('[testTextStyle008] START'); done();
try { });
let eventData = {
data: { it('testTextStyle007', 0, async function (done) {
"fontWeight": 400 console.info('[testTextStyle007] START');
} try {
} let eventData = {
let indexEvent = { data: {
eventId: 40, "fontSize": 30
priority: events_emitter.EventPriority.LOW }
} }
console.info("[testTextStyle008] start to publish emit"); let indexEvent = {
events_emitter.emit(indexEvent, eventData); eventId: 38,
} catch (err) { priority: events_emitter.EventPriority.LOW
console.log("[testTextStyle008] change component data error: " + err.message); }
} console.info("[testTextStyle007] start to publish emit");
await Utils.sleep(3000); events_emitter.emit(indexEvent, eventData);
let strJson = getInspectorByKey('fontWeight'); } catch (err) {
console.info("[testTextStyle008] component strJson:" + strJson); console.log("[testTextStyle007] change component data error: " + err.message);
let obj = JSON.parse(strJson); }
console.info("[testTextStyle008] fontWeight: " + obj.$attrs.fontWeight); await Utils.sleep(4000);
expect(obj.$attrs.fontWeight).assertEqual('FontWeight.400'); let strJson = getInspectorByKey('fontSize');
done(); console.info("[testTextStyle007] component strJson:" + strJson);
}); let obj = JSON.parse(strJson);
console.info("[testTextStyle007] fontSize: " + obj.$attrs.fontSize);
it('testTextStyle009', 0, async function (done) { expect(obj.$attrs.fontSize).assertEqual('30.00fp');
console.info('[testTextStyle009] START'); done();
await Utils.sleep(1000); });
let strJson = getInspectorByKey('fontFamily');
console.info("[testTextStyle009] component strJson:" + strJson); it('testTextStyle008', 0, async function (done) {
let obj = JSON.parse(strJson); console.info('[testTextStyle008] START');
console.info("[testTextStyle009] fontFamily: " + obj.$attrs.fontFamily); try {
expect(obj.$attrs.fontFamily).assertEqual('sans-serif'); let eventData = {
done(); data: {
}); "fontSize": 0x80000000
}
it('testTextStyle0010', 0, async function (done) { }
console.info('[testTextStyle0010] START'); let indexEvent = {
try { eventId: 38,
let eventData = { priority: events_emitter.EventPriority.LOW
data: { }
"fontFamily": 'Arial' console.info("[testTextStyle008] start to publish emit");
} events_emitter.emit(indexEvent, eventData);
} } catch (err) {
let indexEvent = { console.log("[testTextStyle008] change component data error: " + err.message);
eventId: 41, }
priority: events_emitter.EventPriority.LOW await Utils.sleep(4000);
} let strJson = getInspectorByKey('fontSize');
console.info("[testTextStyle0010] start to publish emit"); console.info("[testTextStyle008] component strJson:" + strJson);
events_emitter.emit(indexEvent, eventData); let obj = JSON.parse(strJson);
} catch (err) { console.info("[testTextStyle008] fontSize: " + obj.$attrs.fontSize);
console.log("[testTextStyle0010] change component data error: " + err.message); expect(obj.$attrs.fontSize).assertEqual('-2147483648.00fp');
} done();
await Utils.sleep(3000); });
let strJson = getInspectorByKey('fontFamily');
console.info("[testTextStyle0010] component strJson:" + strJson); it('testTextStyle009', 0, async function (done) {
let obj = JSON.parse(strJson); console.info('[testTextStyle009] START');
console.info("[testTextStyle0010] fontFamily: " + obj.$attrs.fontFamily); try {
expect(obj.$attrs.fontFamily).assertEqual('Arial'); let eventData = {
done(); 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
...@@ -51,7 +51,7 @@ export default function touchAbleJsunit() { ...@@ -51,7 +51,7 @@ export default function touchAbleJsunit() {
let strJson = getInspectorByKey('ellipse'); let strJson = getInspectorByKey('ellipse');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testTouchAble001] component obj is: " + JSON.stringify(obj)); console.info("[testTouchAble001] component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.focusable).assertEqual(false); expect(obj.$attrs.focusable).assertEqual(true);
done(); done();
}); });
......
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter' import events_emitter from '@ohos.events.emitter'
import Utils from './Utils.ets'; import Utils from './Utils.ets';
export default function touchJsunit() { export default function touchJsunit() {
describe('appInfoTest', function () { describe('touchTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("touch beforeEach start"); console.info("touch beforeEach start");
let options = { let options = {
uri: 'pages/touch', uri: 'pages/touch',
} }
let result; let result;
try{ try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get touch state pages: " + JSON.stringify(pages)); console.info("get touch state pages: " + JSON.stringify(pages));
if(!("touch" == pages.name)){ if (!("touch" == pages.name)) {
console.info("get touch state pages.name: " + JSON.stringify(pages.name)); console.info("get touch state pages.name: " + JSON.stringify(pages.name));
result = await router.push(options); result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push touch page result: " + JSON.stringify(result)); console.info("push touch page result: " + JSON.stringify(result));
} }
}catch(err){ } catch (err) {
console.error("push touch page error: " + err); console.error("push touch page error: " + err);
} }
done() done()
}); });
afterEach(async function(){ afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("touch after each called"); console.info("touch after each called");
}) })
it('testTouch01', 0, async function (done) { it('testTouch01', 0, async function (done) {
console.info('[testTouch01] START'); console.info('[testTouch01] START');
await Utils.sleep(1000); await Utils.sleep(1000);
try { try {
let callBackTouch = (backData) => { let callBackTouch = (backData) => {
console.info("testTouch01 get backEvent result is: " + JSON.stringify(backEvent)); console.info("testTouch01 get backEvent result is: " + JSON.stringify(backEvent));
console.info("testTouch01 get flag result is: " + JSON.stringify(backData.data.ACTION)); console.info("testTouch01 get flag result is: " + JSON.stringify(backData.data.ACTION));
expect(backData.data.ACTION).assertEqual(true); expect(backData.data.ACTION).assertEqual(true);
} }
var backEvent = { var backEvent = {
eventId: 43, eventId: 43,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(backEvent, callBackTouch); events_emitter.on(backEvent, callBackTouch);
}catch(err) { } catch (err) {
console.info("testTouch01 on touchEvent err : " + JSON.stringify(err)); console.info("testTouch01 on touchEvent err : " + JSON.stringify(err));
} }
console.info("testTouch01 click result is: " + JSON.stringify(sendEventByKey('touch',10,""))); console.info("testTouch01 click result is: " + JSON.stringify(sendEventByKey('touch', 10, "")));
console.info('[testTouch01] END'); console.info('[testTouch01] END');
done(); done();
}); });
}) })
} }
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"; import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function visibilityJsunit() { export default function visibilityJsunit() {
describe('appInfoTest', function () { describe('visibilityTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("visibility beforeEach start"); console.info("visibility beforeEach start");
let options = { let options = {
uri: 'pages/visibility', uri: 'pages/visibility',
} }
try { try {
router.clear(); router.clear();
let pages = router.getState(); let pages = router.getState();
console.info("get visibility state pages:" + JSON.stringify(pages)); console.info("get visibility state pages:" + JSON.stringify(pages));
if (!("visibility" == pages.name)) { if (!("visibility" == pages.name)) {
console.info("get visibility state pages.name:" + JSON.stringify(pages.name)); console.info("get visibility state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options); let result = await router.push(options);
await Utils.sleep(2000); await Utils.sleep(2000);
console.info("push visibility page result:" + JSON.stringify(result)); console.info("push visibility page result:" + JSON.stringify(result));
} }
} catch (err) { } catch (err) {
console.error("push visibility page error:" + err); console.error("push visibility page error:" + err);
} }
done() done()
}); });
afterEach(async function () { afterEach(async function () {
await Utils.sleep(1000); await Utils.sleep(1000);
console.info("visibility after each called"); console.info("visibility after each called");
}); });
it('testVisibility01', 0, async function (done) { it('testVisibility01', 0, async function (done) {
console.info('[testVisibility01] START'); console.info('[testVisibility01] START');
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('box'); let strJson = getInspectorByKey('box');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testVisibility01] obj is: " + JSON.stringify(obj)); console.info("[testVisibility01] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.visibility).assertEqual('Visibility.Visible'); expect(obj.$attrs.visibility).assertEqual('Visibility.Visible');
console.info('[testVisibility01] END'); console.info('[testVisibility01] END');
done(); done();
}); });
it('testVisibility02', 0, async function (done) { it('testVisibility02', 0, async function (done) {
console.info('[testVisibility02] START'); console.info('[testVisibility02] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"visibility": Visibility.Hidden, "visibility": Visibility.Hidden,
} }
} }
var innerEvent = { var innerEvent = {
eventId: 47, eventId: 47,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testVisibility02] start to publish emit:" + JSON.stringify(eventData.data)); console.info("[testVisibility02] start to publish emit:" + JSON.stringify(eventData.data));
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testVisibility02] change component data error: " + err.message); console.log("[testVisibility02] change component data error: " + err.message);
} }
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('box'); let strJson = getInspectorByKey('box');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testVisibility02] obj is: " + JSON.stringify(obj)); console.info("[testVisibility02] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.visibility).assertEqual('Visibility.Hidden'); expect(obj.$attrs.visibility).assertEqual('Visibility.Hidden');
console.info('[testVisibility02] END'); console.info('[testVisibility02] END');
done(); done();
}); });
it('testVisibility03', 0, async function (done) { it('testVisibility03', 0, async function (done) {
console.info('[testVisibility03] START'); console.info('[testVisibility03] START');
try { try {
var eventData = { var eventData = {
data: { data: {
"visibility": Visibility.None, "visibility": Visibility.None,
} }
} }
var innerEvent = { var innerEvent = {
eventId: 48, eventId: 48,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[testVisibility03] start to publish emit:" + JSON.stringify(eventData.data)); console.info("[testVisibility03] start to publish emit:" + JSON.stringify(eventData.data));
events_emitter.emit(innerEvent, eventData); events_emitter.emit(innerEvent, eventData);
} catch (err) { } catch (err) {
console.log("[testVisibility03] change component data error: " + err.message); console.log("[testVisibility03] change component data error: " + err.message);
} }
await Utils.sleep(1000); await Utils.sleep(1000);
let strJson = getInspectorByKey('box'); let strJson = getInspectorByKey('box');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[testVisibility03] obj is: " + JSON.stringify(obj)); console.info("[testVisibility03] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.visibility).assertEqual('Visibility.None'); expect(obj.$attrs.visibility).assertEqual('Visibility.None');
console.info('[testVisibility03] END'); console.info('[testVisibility03] END');
done(); 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();
});
})
}
// @ts-nocheck // @ts-nocheck
/** /**
* Copyright (c) 2021 Huawei Device Co., Ltd. * Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router'; import router from '@system.router';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils.ets';
export default function zIndexJsunit() {
export default function zIndexJsunit() { describe('zIndexTest', function () {
describe('appInfoTest', function () { beforeEach(async function (done) {
beforeEach(async function (done) { console.info("zIndex beforeEach start");
console.info("zIndex beforeEach start"); let options = {
let options = { uri: 'pages/zIndex',
uri: 'pages/zIndex', }
} try {
try { router.clear();
router.clear(); let pages = router.getState();
let pages = router.getState(); console.info("get zIndex state pages: " + JSON.stringify(pages));
console.info("get zIndex state pages: " + JSON.stringify(pages)); if (!("zIndex" == pages.name)) {
if (!("zIndex" == pages.name)) { console.info("get zIndex state pages.name:" + JSON.stringify(pages.name));
console.info("get zIndex state pages.name:" + JSON.stringify(pages.name)); let result = await router.push(options);
let result = await router.push(options); await Utils.sleep(2000);
await Utils.sleep(2000); console.info("push zIndex page result:" + JSON.stringify(result));
console.info("push zIndex page result:" + JSON.stringify(result)); }
} } catch (err) {
} catch (err) { console.error("push zIndex page error:" + err);
console.error("push zIndex page error:" + err); }
} done()
done() });
});
afterEach(async function () {
afterEach(async function () { await Utils.sleep(2000);
await Utils.sleep(2000); console.info("zIndex after each called");
console.info("zIndex after each called"); });
});
it('testZIndex01', 0, async function (done) {
it('testZIndex01', 0, async function (done) { console.info('[testZIndex01] START');
console.info('[testZIndex01] START'); await Utils.sleep(2000);
await Utils.sleep(2000); let strJson = getInspectorByKey('zIndex');
let strJson = getInspectorByKey('zIndex'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testZIndex01] obj is: " + JSON.stringify(obj.$attrs));
console.info("[testZIndex01] obj is: " + JSON.stringify(obj.$attrs)); expect(obj.$attrs.zIndex).assertEqual(1);
expect(obj.$attrs.zIndex).assertEqual(1); console.info('[testZIndex01] END');
console.info('[testZIndex01] END'); done();
done(); });
});
it('testZIndex02', 0, async function (done) {
it('testZIndex02', 0, async function (done) { console.info('[testZIndex02] START');
console.info('[testZIndex02] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "zIndex": 4
"zIndex": 4 }
} }
} var innerEvent = {
var innerEvent = { eventId: 236,
eventId: 236, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testZIndex02] start to publish emit");
console.info("[testZIndex02] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testZIndex02] change component data error: " + err.message);
console.log("[testZIndex02] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJson = getInspectorByKey('zIndex');
let strJson = getInspectorByKey('zIndex'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testZIndex02] obj is: " + JSON.stringify(obj));
console.info("[testZIndex02] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.zIndex).assertEqual(4);
expect(obj.$attrs.zIndex).assertEqual(4); console.info('testZIndex02 END');
console.info('testZIndex02 END'); done();
done(); });
});
it('testZIndex03', 0, async function (done) {
it('testZIndex03', 0, async function (done) { console.info('[testZIndex03] START');
console.info('[testZIndex03] START'); try {
try { var eventData = {
var eventData = { data: {
data: { "zIndex": -5
"zIndex": -5 }
} }
} var innerEvent = {
var innerEvent = { eventId: 236,
eventId: 236, priority: events_emitter.EventPriority.LOW
priority: events_emitter.EventPriority.LOW }
} console.info("[testZIndex03] start to publish emit");
console.info("[testZIndex03] start to publish emit"); events_emitter.emit(innerEvent, eventData);
events_emitter.emit(innerEvent, eventData); } catch (err) {
} catch (err) { console.log("[testZIndex03] change component data error: " + err.message);
console.log("[testZIndex03] change component data error: " + err.message); }
} await Utils.sleep(2000);
await Utils.sleep(2000); let strJson = getInspectorByKey('zIndex');
let strJson = getInspectorByKey('zIndex'); let obj = JSON.parse(strJson);
let obj = JSON.parse(strJson); console.info("[testZIndex03] obj is: " + JSON.stringify(obj));
console.info("[testZIndex03] obj is: " + JSON.stringify(obj)); expect(obj.$attrs.zIndex).assertEqual(-5);
expect(obj.$attrs.zIndex).assertEqual(-5); console.info('testZIndex03 END');
console.info('testZIndex03 END'); done();
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();
});
})
}
...@@ -22,7 +22,6 @@ struct QrCode { ...@@ -22,7 +22,6 @@ struct QrCode {
@State qrCodeBackgroundColor: Color = "#FF008000"; @State qrCodeBackgroundColor: Color = "#FF008000";
@State qrCodeColor: Color = "#FF0000FF"; @State qrCodeColor: Color = "#FF0000FF";
@State qrCodeValue: string = 'qrCodeValue'; @State qrCodeValue: string = 'qrCodeValue';
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("qrCode page state change called:" + JSON.stringify(eventData)); console.info("qrCode page state change called:" + JSON.stringify(eventData));
...@@ -30,14 +29,13 @@ struct QrCode { ...@@ -30,14 +29,13 @@ struct QrCode {
if (colorValue != null && colorValue.length != 0) { if (colorValue != null && colorValue.length != 0) {
this.qrCodeColor = colorValue; this.qrCodeColor = colorValue;
console.info("qrCodeColor:" + qrCodeColor); console.info("qrCodeColor:" + qrCodeColor);
}else{ } else {
console.info("qrCodeColor is null or empty " + qrCodeColor); console.info("qrCodeColor is null or empty " + qrCodeColor);
} }
} else { } else {
console.info("qrCode page color not change called:" + JSON.stringify(eventData)); console.info("qrCode page color not change called:" + JSON.stringify(eventData));
} }
} }
private stateChangCallBackTwo = (eventData) => { private stateChangCallBackTwo = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("qrCode page state change called:" + JSON.stringify(eventData)); console.info("qrCode page state change called:" + JSON.stringify(eventData));
...@@ -45,7 +43,7 @@ struct QrCode { ...@@ -45,7 +43,7 @@ struct QrCode {
if (backgroundColorValue != null && backgroundColorValue.length != 0) { if (backgroundColorValue != null && backgroundColorValue.length != 0) {
this.qrCodeBackgroundColor = backgroundColorValue; this.qrCodeBackgroundColor = backgroundColorValue;
console.info("qrCodeBackgroundColor:" + qrCodeBackgroundColor); console.info("qrCodeBackgroundColor:" + qrCodeBackgroundColor);
}else{ } else {
console.info("backgroundColorValue is null or empty " + qrCodeColor); console.info("backgroundColorValue is null or empty " + qrCodeColor);
} }
} else { } else {
...@@ -66,6 +64,30 @@ struct QrCode { ...@@ -66,6 +64,30 @@ struct QrCode {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBackTwo); 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() { build() {
......
...@@ -19,21 +19,22 @@ import events_emitter from '@ohos.emitter' ...@@ -19,21 +19,22 @@ import events_emitter from '@ohos.emitter'
@Component @Component
struct ParentComp { struct ParentComp {
@State isCountDown: boolean = true @State isCountDown: boolean = true
build() { build() {
Column() { Column() {
Text(this.isCountDown ? 'Count Down' : 'Stopwatch') Text(this.isCountDown ? 'Count Down' : 'Stopwatch')
if (this.isCountDown) { if (this.isCountDown) {
Image($rawfile('ic_health_heart.png')).width(50).height(50) 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 { } else {
Image($rawfile('ic_health_heart.png')).width(150).height(150) 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') Button(this.isCountDown ? 'Swtich to Stopwatch' : 'Switch to Count Down')
.onClick(() => { .onClick(() => {
this.isCountDown = !this.isCountDown this.isCountDown = !this.isCountDown
}) })
.key('button1') .key('button1')
} }
} }
} }
...@@ -43,8 +44,8 @@ struct TimerComponent { ...@@ -43,8 +44,8 @@ struct TimerComponent {
@State counter: number = 0 @State counter: number = 0
private changePerSec: number = -1 private changePerSec: number = -1
private showInColor: Color = Color.Black private showInColor: Color = Color.Black
private timerId : number = -1 private timerId: number = -1
@State onActionCalled :boolean = false @State onActionCalled: boolean = false
build() { build() {
Text(`${this.counter}sec`) Text(`${this.counter}sec`)
...@@ -52,7 +53,9 @@ struct TimerComponent { ...@@ -52,7 +53,9 @@ struct TimerComponent {
} }
aboutToAppear() { aboutToAppear() {
this.timerId = setInterval(() => {this.counter += this.changePerSec}, 1000) this.timerId = setInterval(() => {
this.counter += this.changePerSec
}, 1000)
} }
aboutToDisappear() { aboutToDisappear() {
......
...@@ -19,19 +19,79 @@ import events_emitter from '@ohos.emitter' ...@@ -19,19 +19,79 @@ import events_emitter from '@ohos.emitter'
@Component @Component
struct AnimationExample { struct AnimationExample {
@State btn1: boolean = false @State btn1: boolean = false
@State duration:number = 100 @State duration: number = 100
@State curve:string = 'Ease' @State curve: string = 'Ease'
@State iteration:number = 1 @State iteration: number = 1
@State tempo:number= 1000 @State tempo: number= 1000
@State playmode:PlayMode = PlayMode.Normal @State playmode: PlayMode = PlayMode.Normal
onPageShow(){ onPageShow() {
console.info('animate page show called'); console.info('animate page show called');
var stateChangeEvent = { var stateChangeEvent = {
eventId: 50, eventId: 50,
priority:events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack) 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) => { private stateChangCallBack = (eventData) => {
...@@ -56,8 +116,12 @@ struct AnimationExample { ...@@ -56,8 +116,12 @@ struct AnimationExample {
} }
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,}) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }) {
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('button1') .key('button1')
.onClick(() => { .onClick(() => {
try { try {
...@@ -77,11 +141,15 @@ struct AnimationExample { ...@@ -77,11 +141,15 @@ struct AnimationExample {
} }
console.info("button1 animateTo START") console.info("button1 animateTo START")
console.info("button1 duration value is : " + this.duration) console.info("button1 duration value is : " + this.duration)
animateTo({duration:this.duration}, () => { animateTo({ duration: this.duration }, () => {
console.info("button1 duration test animateTo START") 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') .key('button2')
.onClick(() => { .onClick(() => {
try { try {
...@@ -101,11 +169,15 @@ struct AnimationExample { ...@@ -101,11 +169,15 @@ struct AnimationExample {
} }
console.info("button2 animateTo START") console.info("button2 animateTo START")
console.info("button2 curve value is : " + this.curve) console.info("button2 curve value is : " + this.curve)
animateTo({ curve:this.curve }, () => { animateTo({ curve: this.curve }, () => {
console.info("button2 curve test animateTo START") 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') .key('button3')
.onClick(() => { .onClick(() => {
try { try {
...@@ -125,11 +197,15 @@ struct AnimationExample { ...@@ -125,11 +197,15 @@ struct AnimationExample {
} }
console.info("button3 animateTo START") console.info("button3 animateTo START")
console.info("button3 iteration value is : " + this.iteration) console.info("button3 iteration value is : " + this.iteration)
animateTo({ iterations:this.iteration }, () => { animateTo({ iterations: this.iteration }, () => {
console.info("button3 iterations test animateTo START") 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') .key('button4')
.onClick(() => { .onClick(() => {
try { try {
...@@ -149,11 +225,15 @@ struct AnimationExample { ...@@ -149,11 +225,15 @@ struct AnimationExample {
} }
console.info("button4 animateTo START") console.info("button4 animateTo START")
console.info("button4 tempo value is : " + this.duration) console.info("button4 tempo value is : " + this.duration)
animateTo({ tempo:this.tempo }, () => { animateTo({ tempo: this.tempo }, () => {
console.info("button4 tempo test animateTo START") 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') .key('button5')
.onClick(() => { .onClick(() => {
try { try {
...@@ -173,10 +253,290 @@ struct AnimationExample { ...@@ -173,10 +253,290 @@ struct AnimationExample {
} }
console.info("button5 animateTo START") console.info("button5 animateTo START")
console.info("button5 playmode value is : " + this.playmode) console.info("button5 playmode value is : " + this.playmode)
animateTo({ PlayMode:this.playmode }, () => { animateTo({ PlayMode: this.playmode }, () => {
console.info("button5 playMode test animateTo START") 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
...@@ -21,38 +21,36 @@ struct BackgroundExample { ...@@ -21,38 +21,36 @@ struct BackgroundExample {
@State width: string = "200px"; @State width: string = "200px";
@State height: string = "200px"; @State height: string = "200px";
@State color: Array = [[0x080808], [0xEEEE00], [0xFF0000]]; @State color: Array = [[0x080808], [0xEEEE00], [0xFF0000]];
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("gauge page state change called:" + JSON.stringify(eventData)); 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); this.colorValues = JSON.parse(eventData.data.colorValues);
} }
if(eventData.data.width != null) { if (eventData.data.width != null) {
this.width = eventData.data.width; this.width = eventData.data.width;
} }
if(eventData.data.height != null) { if (eventData.data.height != null) {
this.height = eventData.data.height; this.height = eventData.data.height;
} }
if(eventData.data.srcValue != null) { if (eventData.data.srcValue != null) {
this.srcValue = eventData.data.srcValue; this.srcValue = eventData.data.srcValue;
} }
} }
} }
private stateChangCallBackTwo = (eventData) => { private stateChangCallBackTwo = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("Background page state change called:" + JSON.stringify(eventData)); 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; this.backgroundColor = eventData.data.backgroundColor;
} }
if(eventData.data.backgroundImage != null) { if (eventData.data.backgroundImage != null) {
this.backgroundImage = eventData.data.backgroundImage; this.backgroundImage = eventData.data.backgroundImage;
} }
if(eventData.data.backgroundImageSize != null) { if (eventData.data.backgroundImageSize != null) {
this.backgroundImageSize = eventData.data.backgroundImageSize; this.backgroundImageSize = eventData.data.backgroundImageSize;
} }
if(eventData.data.backgroundImagePosition != null) { if (eventData.data.backgroundImagePosition != null) {
this.backgroundImagePosition = eventData.data.backgroundImagePosition; this.backgroundImagePosition = eventData.data.backgroundImagePosition;
} }
} }
...@@ -76,7 +74,12 @@ struct BackgroundExample { ...@@ -76,7 +74,12 @@ struct BackgroundExample {
build() { build() {
Column({ space: 5 }) { Column({ space: 5 }) {
Text('background color').fontSize(9).width('90%').fontColor(0xFF0000).key("fontColor") 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) Text('background image repeat along X').fontSize(9).width('90%').fontColor(0xCCCCCC)
Row() Row()
.backgroundImage('/images/bg.jpg', ImageRepeat.X) .backgroundImage('/images/bg.jpg', ImageRepeat.X)
...@@ -93,7 +96,8 @@ struct BackgroundExample { ...@@ -93,7 +96,8 @@ struct BackgroundExample {
.border({ width: 1 }) .border({ width: 1 })
Text('background image size').fontSize(9).width('90%').fontColor(0xFF0000) Text('background image size').fontSize(9).width('90%').fontColor(0xFF0000)
Row() Row()
.width('90%').height(150) .width('90%')
.height(150)
.backgroundImage('/images/bg.jpg', ImageRepeat.NoRepeat) .backgroundImage('/images/bg.jpg', ImageRepeat.NoRepeat)
.backgroundImageSize({ width: 1000, height: 500 }) .backgroundImageSize({ width: 1000, height: 500 })
.border({ width: 1 }) .border({ width: 1 })
......
...@@ -22,7 +22,6 @@ struct BadgeExample { ...@@ -22,7 +22,6 @@ struct BadgeExample {
@State message: string = 'new'; @State message: string = 'new';
@State fontSizeValue: number = 20; @State fontSizeValue: number = 20;
@State colorValue: Color = Color.Red; @State colorValue: Color = Color.Red;
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("Badge page state change called:" + JSON.stringify(eventData)); console.info("Badge page state change called:" + JSON.stringify(eventData));
...@@ -45,6 +44,16 @@ struct BadgeExample { ...@@ -45,6 +44,16 @@ struct BadgeExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack); 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() { build() {
...@@ -58,7 +67,10 @@ struct BadgeExample { ...@@ -58,7 +67,10 @@ struct BadgeExample {
.onClick(() => { .onClick(() => {
this.counts++ this.counts++
}) })
.width(200).height(100).backgroundColor(0x317aff).fontSize(20) .width(200)
.height(100)
.backgroundColor(0x317aff)
.fontSize(20)
}.width(100).height(50).key('badge') }.width(100).height(50).key('badge')
Badge({ Badge({
...@@ -66,8 +78,13 @@ struct BadgeExample { ...@@ -66,8 +78,13 @@ struct BadgeExample {
style: { color: this.colorValue, fontSize: 9, badgeSize: 20, badgeColor: Color.Red } style: { color: this.colorValue, fontSize: 9, badgeSize: 20, badgeColor: Color.Red }
}) { }) {
Text('message') Text('message')
.width(80).height(50).fontSize(16).lineHeight(37) .width(80)
.borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) .height(50)
.fontSize(16)
.lineHeight(37)
.borderRadius(10)
.textAlign(TextAlign.Center)
.backgroundColor(0xF3F4ED)
}.width(80).height(50).key('badge2') }.width(80).height(50).key('badge2')
Badge({ Badge({
...@@ -76,8 +93,13 @@ struct BadgeExample { ...@@ -76,8 +93,13 @@ struct BadgeExample {
style: { badgeSize: 6, badgeColor: Color.Red } style: { badgeSize: 6, badgeColor: Color.Red }
}) { }) {
Text('message') Text('message')
.width(90).height(50).fontSize(16).lineHeight(37) .width(90)
.borderRadius(10).textAlign(TextAlign.Center).backgroundColor(0xF3F4ED) .height(50)
.fontSize(16)
.lineHeight(37)
.borderRadius(10)
.textAlign(TextAlign.Center)
.backgroundColor(0xF3F4ED)
}.width(90).height(50) }.width(90).height(50)
}.width('100%').margin({ top: 5 }) }.width('100%').margin({ top: 5 })
......
...@@ -19,7 +19,6 @@ import events_emitter from '@ohos.emitter'; ...@@ -19,7 +19,6 @@ import events_emitter from '@ohos.emitter';
@Component @Component
struct BlankExample { struct BlankExample {
@State colorValue: Color = Color.Blue; @State colorValue: Color = Color.Blue;
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("Blank page state change called:" + JSON.stringify(eventData)); console.info("Blank page state change called:" + JSON.stringify(eventData));
...@@ -30,7 +29,7 @@ struct BlankExample { ...@@ -30,7 +29,7 @@ struct BlankExample {
} }
onPageShow() { onPageShow() {
console.info('Blank page show called'); console.info('Blank page1 show called');
var stateChangeEvent = { var stateChangeEvent = {
eventId: 69, eventId: 69,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
...@@ -44,7 +43,10 @@ struct BlankExample { ...@@ -44,7 +43,10 @@ struct BlankExample {
Text('Bluetooth').fontSize(18) Text('Bluetooth').fontSize(18)
Blank().color(this.colorValue).key('blank') Blank().color(this.colorValue).key('blank')
Toggle({ type: ToggleType.Switch }) 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) }.backgroundColor(0xEFEFEF).padding(20)
} }
} }
\ No newline at end of file
...@@ -23,7 +23,6 @@ struct ButtonExample { ...@@ -23,7 +23,6 @@ struct ButtonExample {
@State fontColorValue: Color = Color.Black; @State fontColorValue: Color = Color.Black;
@State text: string = ''; @State text: string = '';
@State onClickValue: boolean = false; @State onClickValue: boolean = false;
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("Button page state change called:" + JSON.stringify(eventData)); console.info("Button page state change called:" + JSON.stringify(eventData));
...@@ -46,76 +45,105 @@ struct ButtonExample { ...@@ -46,76 +45,105 @@ struct ButtonExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack); 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() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Button('Ok', { type: this.buttonTypeValue, stateEffect: true }) Button('Ok', { type: this.buttonTypeValue, stateEffect: true })
.borderRadius(8).backgroundColor(0x317aff).width(90).key('button') .borderRadius(8).backgroundColor(0x317aff).width(90).key('button')
Button('ok').type(`${this.buttonTypeValue}`).key('button1') Button('ok').type(`${this.buttonTypeValue}`).key('button1')
.backgroundColor(0x317aff).width(90) .backgroundColor(0x317aff).width(90)
Button('ok').type(this.buttonTypeValue).key('button2').fontSize(this.fontSizeValue) Button('ok')
.backgroundColor(0x317aff).width(90).fontColor(this.fontColorValue) .type(this.buttonTypeValue)
.onClick(() => { .key('button2')
try { .fontSize(this.fontSizeValue)
var backData = { .backgroundColor(0x317aff)
data: { .width(90)
"fontColorValue": this.fontColorValue, .fontColor(this.fontColorValue)
} .onClick(() => {
} try {
var backEvent = { var backData = {
eventId: 71, data: {
priority: events_emitter.EventPriority.LOW "fontColorValue": this.fontColorValue,
} }
console.info("button2 start to emit action state") }
events_emitter.emit(backEvent, backData) var backEvent = {
} catch (err) { eventId: 71,
console.info("button2 emit action state err: " + JSON.stringify(err.message)) priority: events_emitter.EventPriority.LOW
} }
}) console.info("button2 start to emit action state")
Button('ok!').type(this.buttonTypeValue).key('button3').fontColor(this.fontColorValue) events_emitter.emit(backEvent, backData)
.backgroundColor(0x317aff).width(90) } catch (err) {
.onClick(() => { console.info("button2 emit action state err: " + JSON.stringify(err.message))
try { }
var backData = { })
data: { Button('ok!')
"fontColorValue": this.fontColorValue, .type(this.buttonTypeValue)
} .key('button3')
} .fontColor(this.fontColorValue)
var backEvent = { .backgroundColor(0x317aff)
eventId: 72, .width(90)
priority: events_emitter.EventPriority.LOW .onClick(() => {
} try {
console.info("button3 start to emit action state") var backData = {
events_emitter.emit(backEvent, backData) data: {
} catch (err) { "fontColorValue": this.fontColorValue,
console.info("button3 emit action state err: " + JSON.stringify(err.message)) }
} }
}) var backEvent = {
Button('Click').backgroundColor(0x2788D9).width(200).height(100).fontSize(20) eventId: 72,
.onClick((event: ClickEvent) => { priority: events_emitter.EventPriority.LOW
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:(' console.info("button3 start to emit action state")
+ event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:' events_emitter.emit(backEvent, backData)
+ event.target.area.width + '\n height:' + event.target.area.height); } catch (err) {
this.onClickValue = true; console.info("button3 emit action state err: " + JSON.stringify(err.message))
try { }
var backData = { })
data: { Button('Click')
"ACTION": this.onClickValue, .backgroundColor(0x2788D9)
"event": JSON.stringify(event) .width(200)
} .height(100)
} .fontSize(20)
var backEvent = { .onClick((event: ClickEvent) => {
eventId: 4, console.info(this.text = 'Click Point:' + '\n screenX:' + event.screenX + '\n screenY:' + event.screenY
priority: events_emitter.EventPriority.LOW + '\n x :' + event.x + '\n y:' + event.y + '\ntarget:' + '\n component globalPos:('
} + event.target.area.globalPos.x + ',' + event.target.area.globalPos.y + ')\n width:'
console.info("click to emit action state") + event.target.area.width + '\n height:' + event.target.area.height);
events_emitter.emit(backEvent, backData) this.onClickValue = true;
} catch (err) { try {
console.info("click action state err: " + JSON.stringify(err.message)) var backData = {
} data: {
}).key('buttonClick') "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 }) }.height(400).padding({ left: 35, right: 35, top: 35 })
} }
} }
\ No newline at end of file
...@@ -93,21 +93,26 @@ struct CanvasExample { ...@@ -93,21 +93,26 @@ struct CanvasExample {
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
onPageShow() { onPageShow() {
} }
fillStyle() { fillStyle() {
this.context.fillStyle = '#0000ff'; this.context.fillStyle = '#0000ff';
this.context.fillRect(20, 120, 75, 55); this.context.fillRect(20, 120, 75, 55);
} }
lineWidth() { lineWidth() {
this.context.lineWidth = 5; this.context.lineWidth = 5;
this.context.strokeRect(25, 25, 55, 75); this.context.strokeRect(25, 25, 55, 75);
} }
strokeStyle() { strokeStyle() {
this.context.lineWidth = 10; this.context.lineWidth = 10;
this.context.strokeStyle = '#0000ff'; this.context.strokeStyle = '#0000ff';
this.context.strokeRect(115, 25, 75, 55); this.context.strokeRect(115, 25, 75, 55);
} }
lineCap() { lineCap() {
this.context.lineWidth = 8; this.context.lineWidth = 8;
this.context.beginPath(); this.context.beginPath();
...@@ -116,6 +121,7 @@ struct CanvasExample { ...@@ -116,6 +121,7 @@ struct CanvasExample {
this.context.lineTo(320, 50); this.context.lineTo(320, 50);
this.context.stroke(); this.context.stroke();
} }
lineJoin() { lineJoin() {
this.context.beginPath(); this.context.beginPath();
this.context.lineWidth = 8; this.context.lineWidth = 8;
...@@ -125,6 +131,7 @@ struct CanvasExample { ...@@ -125,6 +131,7 @@ struct CanvasExample {
this.context.lineTo(370, 75); this.context.lineTo(370, 75);
this.context.stroke(); this.context.stroke();
} }
miterLimit() { miterLimit() {
this.context.lineWidth = 8; this.context.lineWidth = 8;
this.context.lineJoin = 'miter'; this.context.lineJoin = 'miter';
...@@ -134,10 +141,12 @@ struct CanvasExample { ...@@ -134,10 +141,12 @@ struct CanvasExample {
this.context.lineTo(130, 162); this.context.lineTo(130, 162);
this.context.stroke(); this.context.stroke();
} }
font() { font() {
this.context.font = '20px sans-serif'; this.context.font = '20px sans-serif';
this.context.fillText("Hello World", 250, 170); this.context.fillText("Hello World", 250, 170);
} }
textAlign() { textAlign() {
let height = 230; let height = 230;
this.context.strokeStyle = '#0000ff'; this.context.strokeStyle = '#0000ff';
...@@ -156,6 +165,7 @@ struct CanvasExample { ...@@ -156,6 +165,7 @@ struct CanvasExample {
this.context.textAlign = 'right'; this.context.textAlign = 'right';
this.context.fillText('textAlign=right', 210, 200 + height); this.context.fillText('textAlign=right', 210, 200 + height);
} }
textBaseline() { textBaseline() {
let height = 550; let height = 550;
this.context.strokeStyle = '#0000ff'; this.context.strokeStyle = '#0000ff';
...@@ -174,6 +184,7 @@ struct CanvasExample { ...@@ -174,6 +184,7 @@ struct CanvasExample {
this.context.textBaseline = 'hanging'; this.context.textBaseline = 'hanging';
this.context.fillText('Hanging', 450, height + 10); this.context.fillText('Hanging', 450, height + 10);
} }
globalAlpha() { globalAlpha() {
this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(0, 620, 50, 50); this.context.fillRect(0, 620, 50, 50);
...@@ -181,14 +192,16 @@ struct CanvasExample { ...@@ -181,14 +192,16 @@ struct CanvasExample {
this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(50, 670, 50, 50); this.context.fillRect(50, 670, 50, 50);
} }
lineDashOffset() { lineDashOffset() {
this.context.globalAlpha = 1; this.context.globalAlpha = 1;
this.context.beginPath(); this.context.beginPath();
this.context.arc(180, 650, 50, 0, 6.28); this.context.arc(180, 650, 50, 0, 6.28);
this.context.setLineDash([10,20]); this.context.setLineDash([10, 20]);
this.context.stroke(); this.context.stroke();
this.context.setLineDash([0, 0]); this.context.setLineDash([0, 0]);
} }
globalCompositeOperation() { globalCompositeOperation() {
let height = 600; let height = 600;
let width = 260; let width = 260;
...@@ -204,18 +217,21 @@ struct CanvasExample { ...@@ -204,18 +217,21 @@ struct CanvasExample {
this.context.fillRect(150 + width, 50 + height, 50, 50); this.context.fillRect(150 + width, 50 + height, 50, 50);
this.context.globalCompositeOperation = 'source-over'; this.context.globalCompositeOperation = 'source-over';
} }
shadowBlur() { shadowBlur() {
this.context.shadowBlur = 30; this.context.shadowBlur = 30;
this.context.shadowColor = 'rgb(0,0,0)'; this.context.shadowColor = 'rgb(0,0,0)';
this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(10, 800, 100, 80); this.context.fillRect(10, 800, 100, 80);
} }
shadowColor() { shadowColor() {
this.context.shadowBlur = 30; this.context.shadowBlur = 30;
this.context.shadowColor = 'rgb(0,0,255)'; this.context.shadowColor = 'rgb(0,0,255)';
this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(150, 800, 80, 100); this.context.fillRect(150, 800, 80, 100);
} }
shadowOffsetX() { shadowOffsetX() {
this.context.shadowBlur = 10; this.context.shadowBlur = 10;
this.context.shadowOffsetX = 20; this.context.shadowOffsetX = 20;
...@@ -224,6 +240,7 @@ struct CanvasExample { ...@@ -224,6 +240,7 @@ struct CanvasExample {
this.context.fillRect(250, 800, 80, 80); this.context.fillRect(250, 800, 80, 80);
this.resetShadow(true); this.resetShadow(true);
} }
shadowOffsetY() { shadowOffsetY() {
this.context.shadowBlur = 10; this.context.shadowBlur = 10;
this.context.shadowOffsetY = 20; this.context.shadowOffsetY = 20;
...@@ -232,6 +249,7 @@ struct CanvasExample { ...@@ -232,6 +249,7 @@ struct CanvasExample {
this.context.fillRect(360, 800, 80, 80); this.context.fillRect(360, 800, 80, 80);
this.resetShadow(false); this.resetShadow(false);
} }
resetShadow(isX) { resetShadow(isX) {
this.context.shadowBlur = 0; this.context.shadowBlur = 0;
if (isX) { if (isX) {
...@@ -240,40 +258,49 @@ struct CanvasExample { ...@@ -240,40 +258,49 @@ struct CanvasExample {
this.context.shadowOffsetY = 0; this.context.shadowOffsetY = 0;
} }
} }
imageSmoothingEnabled() { imageSmoothingEnabled() {
let img = new ImageBitmap('/images/img.jpeg'); let img = new ImageBitmap('/images/img.jpeg');
this.context.imageSmoothingEnabled = false; this.context.imageSmoothingEnabled = false;
this.context.drawImage( img, 30, 950, 160, 100); this.context.drawImage(img, 30, 950, 160, 100);
} }
imageSmoothingQuality() { imageSmoothingQuality() {
let img = new ImageBitmap('/images/img.jpeg'); let img = new ImageBitmap('/images/img.jpeg');
this.context.imageSmoothingQuality('high'); this.context.imageSmoothingQuality('high');
this.context.drawImage( img, 30, 950, 160, 100); this.context.drawImage(img, 30, 950, 160, 100);
} }
fillRect() { fillRect() {
this.context.fillRect(10, 1080, 80, 80); this.context.fillRect(10, 1080, 80, 80);
} }
strokeRect() { strokeRect() {
this.context.strokeRect(110, 1080, 100, 60); this.context.strokeRect(110, 1080, 100, 60);
} }
clearRect() { clearRect() {
this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(240, 950, 200, 200); this.context.fillRect(240, 950, 200, 200);
this.context.clearRect(260, 970, 100, 60); this.context.clearRect(260, 970, 100, 60);
} }
fillText() { fillText() {
this.context.font = '20px sans-serif'; this.context.font = '20px sans-serif';
this.context.fillText("Hello World!", 120, 1200); this.context.fillText("Hello World!", 120, 1200);
} }
strokeText() { strokeText() {
this.context.font = '20px sans-serif'; this.context.font = '20px sans-serif';
this.context.strokeText("Hello World!", 260, 1195); this.context.strokeText("Hello World!", 260, 1195);
} }
measureText() { measureText() {
this.context.font = '20px sans-serif'; this.context.font = '20px sans-serif';
this.context.fillText("Hello World!", 120, 1250); this.context.fillText("Hello World!", 120, 1250);
this.context.fillText("width:" + this.context.measureText("Hello World!").width, 310, 1250); this.context.fillText("width:" + this.context.measureText("Hello World!").width, 310, 1250);
} }
beginPath() { beginPath() {
this.context.beginPath(); this.context.beginPath();
this.context.lineWidth = 6; this.context.lineWidth = 6;
...@@ -282,6 +309,7 @@ struct CanvasExample { ...@@ -282,6 +309,7 @@ struct CanvasExample {
this.context.lineTo(450, 1260); this.context.lineTo(450, 1260);
this.context.stroke(); this.context.stroke();
} }
closePath() { closePath() {
this.context.beginPath(); this.context.beginPath();
this.context.moveTo(30, 1300); this.context.moveTo(30, 1300);
...@@ -290,12 +318,14 @@ struct CanvasExample { ...@@ -290,12 +318,14 @@ struct CanvasExample {
this.context.closePath(); this.context.closePath();
this.context.stroke(); this.context.stroke();
} }
createPattern() { createPattern() {
let img = new ImageBitmap('/images/ic_health_heart.png'); let img = new ImageBitmap('/images/ic_health_heart.png');
let pattern = this.context.createPattern(img, 'repeat'); let pattern = this.context.createPattern(img, 'repeat');
this.context.fillStyle = pattern; this.context.fillStyle = pattern;
this.context.fillRect(140, 1300, 250, 100); this.context.fillRect(140, 1300, 250, 100);
} }
bezierCurveTo() { bezierCurveTo() {
let height = 1400; let height = 1400;
this.context.beginPath(); this.context.beginPath();
...@@ -303,6 +333,7 @@ struct CanvasExample { ...@@ -303,6 +333,7 @@ struct CanvasExample {
this.context.bezierCurveTo(20, 100 + height, 200, 100 + height, 200, 20 + height); this.context.bezierCurveTo(20, 100 + height, 200, 100 + height, 200, 20 + height);
this.context.stroke(); this.context.stroke();
} }
quadraticCurveTo() { quadraticCurveTo() {
let height = 1400; let height = 1400;
let width = 210; let width = 210;
...@@ -311,20 +342,24 @@ struct CanvasExample { ...@@ -311,20 +342,24 @@ struct CanvasExample {
this.context.quadraticCurveTo(100 + width, 100 + height, 200 + width, 20 + height); this.context.quadraticCurveTo(100 + width, 100 + height, 200 + width, 20 + height);
this.context.stroke(); this.context.stroke();
} }
arcTo() { arcTo() {
this.context.moveTo(30, 20 + 1500); this.context.moveTo(30, 20 + 1500);
this.context.arcTo(80, 20 + 1500, 80, 70 + 1500, 50); this.context.arcTo(80, 20 + 1500, 80, 70 + 1500, 50);
this.context.stroke(); this.context.stroke();
} }
rect() { rect() {
this.context.rect(130, 20 + 1500, 80, 80); this.context.rect(130, 20 + 1500, 80, 80);
this.context.stroke(); this.context.stroke();
} }
rotate() { rotate() {
this.context.rotate(45 * Math.PI / 180); this.context.rotate(45 * Math.PI / 180);
this.context.fillRect(180, 20, 50, 50); this.context.fillRect(180, 20, 50, 50);
this.context.rotate(-45 * Math.PI / 180); this.context.rotate(-45 * Math.PI / 180);
} }
transform() { transform() {
this.context.fillStyle = 'rgb(0,0,0)'; this.context.fillStyle = 'rgb(0,0,0)';
this.context.fillRect(250, 1500, 100, 100); this.context.fillRect(250, 1500, 100, 100);
...@@ -335,6 +370,7 @@ struct CanvasExample { ...@@ -335,6 +370,7 @@ struct CanvasExample {
this.context.fillStyle = 'rgb(0,0,255)'; this.context.fillStyle = 'rgb(0,0,255)';
this.context.fillRect(250, 1500, 100, 100); this.context.fillRect(250, 1500, 100, 100);
} }
setTransform() { setTransform() {
this.context.fillStyle = 'rgb(255,0,0)'; this.context.fillStyle = 'rgb(255,0,0)';
this.context.fillRect(0, 1650, 100, 100); this.context.fillRect(0, 1650, 100, 100);
...@@ -343,46 +379,56 @@ struct CanvasExample { ...@@ -343,46 +379,56 @@ struct CanvasExample {
this.context.fillRect(0, 1650, 100, 100); this.context.fillRect(0, 1650, 100, 100);
this.context.setTransform(1, 0, 0, 1, 0, 0); this.context.setTransform(1, 0, 0, 1, 0, 0);
} }
getTransform() { getTransform() {
let data = this.context.getTransform(); let data = this.context.getTransform();
console.info("[canvas] get transform----" + data); console.info("[canvas] get transform----" + data);
} }
resetTransform() { resetTransform() {
this.context.resetTransform(); this.context.resetTransform();
} }
translate() { translate() {
this.context.fillRect(180, 1650, 50, 50); this.context.fillRect(180, 1650, 50, 50);
this.context.translate(50, 50); this.context.translate(50, 50);
this.context.fillRect(180, 1650, 50, 50); this.context.fillRect(180, 1650, 50, 50);
} }
drawImage() { drawImage() {
let img = new ImageBitmap('/images/img.jpeg'); let img = new ImageBitmap('/images/img.jpeg');
this.context.drawImage(img, 0, 0, 500, 500, 0, 1780, 200, 100); this.context.drawImage(img, 0, 0, 500, 500, 0, 1780, 200, 100);
} }
createImageData() { createImageData() {
let imageData = this.context.createImageData(100, 100); let imageData = this.context.createImageData(100, 100);
console.info("[canvas] create image data-----" + JSON.stringify(imageData)); console.info("[canvas] create image data-----" + JSON.stringify(imageData));
} }
createImageDataByImageData() { createImageDataByImageData() {
let imageData = this.context.createImageData(50, 50); let imageData = this.context.createImageData(50, 50);
let imgData = this.context.createImageData(imageData); let imgData = this.context.createImageData(imageData);
console.info("[canvas] create image data by image data----" + JSON.stringify(imgData)); console.info("[canvas] create image data by image data----" + JSON.stringify(imgData));
} }
getImageData() { getImageData() {
let imageData = this.context.getImageData(10, 10, 80, 80); let imageData = this.context.getImageData(10, 10, 80, 80);
let data = imageData.data; let data = imageData.data;
console.info("[canvas] get image data-----" + JSON.stringify(data)); console.info("[canvas] get image data-----" + JSON.stringify(data));
} }
getImageWidth() { getImageWidth() {
let imageData = this.context.getImageData(10, 10, 80, 80); let imageData = this.context.getImageData(10, 10, 80, 80);
let width = imageData.width; let width = imageData.width;
console.info("[canvas] get image width-----" + width); console.info("[canvas] get image width-----" + width);
} }
getImageHeight() { getImageHeight() {
let imageData = this.context.getImageData(10, 10, 80, 80); let imageData = this.context.getImageData(10, 10, 80, 80);
let height = imageData.height; let height = imageData.height;
console.info("[canvas] get image height-----" + height); console.info("[canvas] get image height-----" + height);
} }
putImageData() { putImageData() {
let imageData = this.context.createImageData(80, 80); let imageData = this.context.createImageData(80, 80);
for (var i = 0; i < imageData.data.length; i += 4) { for (var i = 0; i < imageData.data.length; i += 4) {
...@@ -393,6 +439,7 @@ struct CanvasExample { ...@@ -393,6 +439,7 @@ struct CanvasExample {
} }
this.context.putImageData(imageData, 250, 1660); this.context.putImageData(imageData, 250, 1660);
} }
createLinearGradient() { createLinearGradient() {
let grad = this.context.createLinearGradient(50, 1900, 150, 2000); let grad = this.context.createLinearGradient(50, 1900, 150, 2000);
grad.addColorStop(0.0, 'red'); grad.addColorStop(0.0, 'red');
...@@ -401,6 +448,7 @@ struct CanvasExample { ...@@ -401,6 +448,7 @@ struct CanvasExample {
this.context.fillStyle = grad; this.context.fillStyle = grad;
this.context.fillRect(10, 1900, 150, 150); this.context.fillRect(10, 1900, 150, 150);
} }
createRadialGradient() { createRadialGradient() {
let grad = this.context.createRadialGradient(280, 1970, 40, 280, 1970, 80); let grad = this.context.createRadialGradient(280, 1970, 40, 280, 1970, 80);
grad.addColorStop(0.0, 'red'); grad.addColorStop(0.0, 'red');
...@@ -410,60 +458,73 @@ struct CanvasExample { ...@@ -410,60 +458,73 @@ struct CanvasExample {
this.context.fillRect(200, 1900, 150, 150); this.context.fillRect(200, 1900, 150, 150);
this.context.closePath(); this.context.closePath();
} }
restore() { restore() {
this.context.restore(); this.context.restore();
} }
save() { save() {
this.context.save(); this.context.save();
} }
addPath() { addPath() {
let path2Da = new Path2D("M250 150 L150 350 L350 350 Z"); let path2Da = new Path2D("M250 150 L150 350 L350 350 Z");
let path2Db = new Path2D(); let path2Db = new Path2D();
path2Db.addPath(path2Da); path2Db.addPath(path2Da);
this.context.stroke(path2Db); this.context.stroke(path2Db);
} }
lineDash() { lineDash() {
this.context.beginPath(); this.context.beginPath();
this.context.arc(20, 2130, 50, 0, 6.28); this.context.arc(20, 2130, 50, 0, 6.28);
this.context.setLineDash([10, 20]); this.context.setLineDash([10, 20]);
this.context.stroke(); this.context.stroke();
} }
toDataURL() { toDataURL() {
let dataUrl = this.context.toDataURL(); let dataUrl = this.context.toDataURL();
console.info("[canvas] canvas rendering context2D toDataURL-----" + JSON.stringify(dataUrl)); console.info("[canvas] canvas rendering context2D toDataURL-----" + JSON.stringify(dataUrl));
} }
getWidth() { getWidth() {
let width = this.context.width; let width = this.context.width;
console.info("[canvas] canvas width---" + width); console.info("[canvas] canvas width---" + width);
} }
getHeight() { getHeight() {
let height = this.context.height; let height = this.context.height;
console.info("[canvas] canvas height---" + height); console.info("[canvas] canvas height---" + height);
} }
fill() { fill() {
this.context.beginPath(); this.context.beginPath();
this.context.rect(130, 2080, 100, 100); this.context.rect(130, 2080, 100, 100);
this.context.fill('nonzero'); this.context.fill('nonzero');
} }
direction() { direction() {
this.context.direction('inherit'); this.context.direction('inherit');
} }
textMetrics() { textMetrics() {
this.context.font = '20px sans-serif'; this.context.font = '20px sans-serif';
this.context.fillText("Hello World!", 120, 2150); this.context.fillText("Hello World!", 120, 2150);
let obj = this.context.measureText("Hello World!"); let obj = this.context.measureText("Hello World!");
console.info("[canvas] textMetrics info---" + JSON.stringify(obj)); console.info("[canvas] textMetrics info---" + JSON.stringify(obj));
} }
getBitImageSize() { getBitImageSize() {
let img = new ImageBitmap('/images/img.jpeg'); let img = new ImageBitmap('/images/img.jpeg');
let width = img.width; let width = img.width;
let height = img.height; let height = img.height;
} }
filter() { filter() {
let img = new ImageBitmap('/images/img.jpeg'); let img = new ImageBitmap('/images/img.jpeg');
this.context.filter('grayscale(50%)'); this.context.filter('grayscale(50%)');
this.context.drawImage(img, 0, 0, 500, 500, 0, 2200, 200, 100); this.context.drawImage(img, 0, 0, 500, 500, 0, 2200, 200, 100);
} }
getLineDash() { getLineDash() {
this.context.beginPath(); this.context.beginPath();
this.context.setLineDash([10, 20]); this.context.setLineDash([10, 20]);
...@@ -472,9 +533,11 @@ struct CanvasExample { ...@@ -472,9 +533,11 @@ struct CanvasExample {
this.context.stroke(); this.context.stroke();
let obj = this.context.getLineDash(); let obj = this.context.getLineDash();
} }
setPixelMap() { setPixelMap() {
this.context.setPixelMap(); this.context.setPixelMap();
} }
getPixelMap() { getPixelMap() {
let pixelMap = this.context.getPixelMap(10, 10, 80, 80); let pixelMap = this.context.getPixelMap(10, 10, 80, 80);
console.info("[canvas] getPixelMap ----" + JSON.stringify(pixelMap)); console.info("[canvas] getPixelMap ----" + JSON.stringify(pixelMap));
......
...@@ -42,14 +42,17 @@ struct Canvas2Example { ...@@ -42,14 +42,17 @@ struct Canvas2Example {
.width('100%') .width('100%')
.height('100%') .height('100%')
} }
onPageShow() { onPageShow() {
} }
transferFromImageBitmap() { transferFromImageBitmap() {
this.offContext.fillStyle = '#0000ff'; this.offContext.fillStyle = '#0000ff';
this.offContext.fillRect(20, 160, 150, 100); this.offContext.fillRect(20, 160, 150, 100);
let image = this.offContext.transferToImageBitmap(); let image = this.offContext.transferToImageBitmap();
this.context.transferFromImageBitmap(image); this.context.transferFromImageBitmap(image);
} }
offScreenToDataURL() { offScreenToDataURL() {
let dataUrl = this.offContext.toDataURL(); let dataUrl = this.offContext.toDataURL();
console.info("[canvas] offContext canvas rendering context2D toDataURL-----" + JSON.stringify(dataUrl)); console.info("[canvas] offContext canvas rendering context2D toDataURL-----" + JSON.stringify(dataUrl));
......
...@@ -20,6 +20,7 @@ import events_emitter from '@ohos.emitter'; ...@@ -20,6 +20,7 @@ import events_emitter from '@ohos.emitter';
struct CircleExample { struct CircleExample {
@State width: string = "450px"; @State width: string = "450px";
@State height: string = "450px"; @State height: string = "450px";
onPageShow() { onPageShow() {
console.info('[circle] page show called'); console.info('[circle] page show called');
var stateChangeEvent = { var stateChangeEvent = {
...@@ -29,18 +30,20 @@ struct CircleExample { ...@@ -29,18 +30,20 @@ struct CircleExample {
console.info('[circle] page show calledA'); console.info('[circle] page show calledA');
events_emitter.on(stateChangeEvent, this.stateChangCallBack); events_emitter.on(stateChangeEvent, this.stateChangCallBack);
} }
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
console.info("[circle] page stateChangCallBack"); console.info("[circle] page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
console.info("[circle] page state change called:" + JSON.stringify(eventData)); console.info("[circle] page state change called:" + JSON.stringify(eventData));
if(eventData.data.width != null) { if (eventData.data.height != null) {
this.width = eventData.data.width;
}
if(eventData.data.height != null) {
this.height = eventData.data.height; this.height = eventData.data.height;
} }
if (eventData.data.width != null) {
this.width = eventData.data.width;
}
} }
} }
build() { build() {
Flex({ justifyContent: FlexAlign.SpaceAround }) { Flex({ justifyContent: FlexAlign.SpaceAround }) {
Circle({ width: 150, height: 150 }) Circle({ width: 150, height: 150 })
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file'; import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets"; import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets"; import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility"; import featureAbility from "@ohos.ability.featureAbility";
......
...@@ -18,12 +18,13 @@ import events_emitter from '@ohos.emitter' ...@@ -18,12 +18,13 @@ import events_emitter from '@ohos.emitter'
@Entry @Entry
@Component @Component
struct LineExample { struct LineExample {
@State startPoint:Point = [0,0] @State startPoint: Point = [0, 0]
@State endPoint:Point = [50,100] @State endPoint: Point = [50, 100]
build() { build() {
Column() { Column() {
Line({ width: 50, height: 100 }).startPoint(this.startPoint).endPoint(this.endPoint) Line({ width: 50, height: 100 }).startPoint(this.startPoint).endPoint(this.endPoint)
.key('line') .key('line')
}.margin({ top: 5 }) }.margin({ top: 5 })
} }
...@@ -36,12 +37,12 @@ struct LineExample { ...@@ -36,12 +37,12 @@ struct LineExample {
if (eventData.data.startPointOne != null) { if (eventData.data.startPointOne != null) {
this.startPoint[1] = eventData.data.startPointOne; this.startPoint[1] = eventData.data.startPointOne;
} }
if (eventData.data.endPoint != null) {
this.endPoint[0] = eventData.data.endPoint;
}
if (eventData.data.endPointOne != null) { if (eventData.data.endPointOne != null) {
this.endPoint[1] = eventData.data.endPointOne; this.endPoint[1] = eventData.data.endPointOne;
} }
if (eventData.data.endPoint != null) {
this.endPoint[0] = eventData.data.endPoint;
}
} }
} }
......
...@@ -25,52 +25,56 @@ struct LongPressGestureExample { ...@@ -25,52 +25,56 @@ struct LongPressGestureExample {
Text('LongPress onAction:' + this.eventString).fontSize(20) Text('LongPress onAction:' + this.eventString).fontSize(20)
} }
.key('flex') .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( .gesture(
LongPressGesture({ repeat: true }) LongPressGesture({ repeat: true })
.onAction(() => { .onAction(() => {
console.info("longPressGesture current action onAction") console.info("longPressGesture current action onAction")
this.eventString = 'onAction'; this.eventString = 'onAction';
console.info('onAction current action state is: ' + this.eventString); console.info('onAction current action state is: ' + this.eventString);
try { try {
let backData = { let backData = {
data: { data: {
"ACTION": this.eventString, "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));
} }
}) let backEvent = {
.onActionEnd(() => { eventId: 125,
console.info("longPressGesture current action end") priority: events_emitter.EventPriority.LOW
this.eventString = 'onActionEnd'; }
console.info('onActionEnd current action state is: ' + this.eventString); console.info("start to emit action state");
try { events_emitter.emit(backEvent, backData);
let backData = { } catch (err) {
data: { console.info("emit action state err: " + JSON.stringify(err.message));
"ACTION": this.eventString, }
} })
} .onActionEnd(() => {
let backEvent = { console.info("longPressGesture current action end")
eventId: 126, this.eventString = 'onActionEnd';
priority: events_emitter.EventPriority.LOW 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));
} }
}) let backEvent = {
.onActionCancel(() => { eventId: 126,
console.info("longPressGesture current action cancel"); 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
...@@ -22,15 +22,15 @@ struct MotionPathExample { ...@@ -22,15 +22,15 @@ struct MotionPathExample {
@State offsetY: number = 0 @State offsetY: number = 0
@State toggle: boolean = true @State toggle: boolean = true
@State rotatable: boolean = false @State rotatable: boolean = false
@State path:string='Mstart.x start.y L300 200 L300 500 Lend.x end.y' @State path: string= 'Mstart.x start.y L300 200 L300 500 Lend.x end.y'
@State fromX:number = 0 @State fromX: number = 0
@State toY:number = 1 @State toY: number = 1
build() { build() {
Column() { Column() {
Button('click me') Button('click me')
.key('button') .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(() => { .onClick(() => {
this.rotatable = true; this.rotatable = true;
console.info('button rotate current action state is:' + this.rotatable); console.info('button rotate current action state is:' + this.rotatable);
...@@ -79,22 +79,22 @@ struct MotionPathExample { ...@@ -79,22 +79,22 @@ struct MotionPathExample {
.width('100%').height('100%').alignItems(this.toggle ? HorizontalAlign.Start : HorizontalAlign.Center) .width('100%').height('100%').alignItems(this.toggle ? HorizontalAlign.Start : HorizontalAlign.Center)
} }
onPageShow(){ onPageShow() {
console.info('motionPath page show called'); console.info('motionPath page show called');
var stateChangeEvent = { var stateChangeEvent = {
eventId:134, eventId: 134,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent,this.stateChangeCallBack) events_emitter.on(stateChangeEvent, this.stateChangeCallBack)
} }
private stateChangeCallBack = (eventData) =>{ private stateChangeCallBack = (eventData) => {
if(eventData != null){ if (eventData != null) {
console.info('motionPath page state change called:' + JSON.stringify(eventData)); 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); this.fromX == parseInt(eventData.data.fromX);
} }
if(eventData.data.toY != null){ if (eventData.data.toY != null) {
this.toY == parseInt(eventData.data.toY); this.toY == parseInt(eventData.data.toY);
} }
} }
......
...@@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter' ...@@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter'
@Component @Component
struct GestureSettingsExample { struct GestureSettingsExample {
@State value: string = '' @State value: string = ''
build() { build() {
Column() { Column() {
Text('Click\n' + this.value).gesture(TapGesture() Text('Click\n' + this.value).gesture(TapGesture()
...@@ -44,7 +45,11 @@ struct GestureSettingsExample { ...@@ -44,7 +45,11 @@ struct GestureSettingsExample {
.key('tapGesture') .key('tapGesture')
} }
.key('parallelGesture') .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( .priorityGesture(
TapGesture() TapGesture()
.onAction(() => { .onAction(() => {
......
...@@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter' ...@@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter'
@Component @Component
struct GestureSettingsExample { struct GestureSettingsExample {
@State value: string = '' @State value: string = ''
build() { build() {
Column() { Column() {
Text('Click\n' + this.value).gesture(TapGesture() Text('Click\n' + this.value).gesture(TapGesture()
...@@ -43,7 +44,11 @@ struct GestureSettingsExample { ...@@ -43,7 +44,11 @@ struct GestureSettingsExample {
) )
.key('tapGesture') .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( .priorityGesture(
TapGesture() TapGesture()
.onAction(() => { .onAction(() => {
......
...@@ -22,15 +22,14 @@ struct ProgressExample { ...@@ -22,15 +22,14 @@ struct ProgressExample {
@State value: number = 20 @State value: number = 20
@State total: number = 100 @State total: number = 100
@State style: ProgressStyle = ProgressStyle.Linear @State style: ProgressStyle = ProgressStyle.Linear
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
console.info("progress page stateChangCallBack"); console.info("progress page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
console.info("progress page state change called:" + JSON.stringify(eventData)); 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; this.value = eventData.data.value;
} }
if(eventData.data.total != null) { if (eventData.data.total != null) {
this.total = eventData.data.total; this.total = eventData.data.total;
} }
} }
...@@ -73,6 +72,16 @@ struct ProgressExample { ...@@ -73,6 +72,16 @@ struct ProgressExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEventSix, this.stateChangCallBack) 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() { build() {
......
...@@ -21,13 +21,11 @@ import events_emitter from '@ohos.emitter' ...@@ -21,13 +21,11 @@ import events_emitter from '@ohos.emitter'
struct RatingExample { struct RatingExample {
@State rating: number = 1 @State rating: number = 1
@State indicator: boolean = false @State indicator: boolean = false
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
console.info("rating page stateChangCallBack"); console.info("rating page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
console.info("rating page state change called:" + JSON.stringify(eventData.data.rating)); 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; this.rating = eventData.data.rating;
} }
} }
...@@ -63,13 +61,25 @@ struct RatingExample { ...@@ -63,13 +61,25 @@ struct RatingExample {
eventId: 177, eventId: 177,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEventSix , this.stateChangCallBack) events_emitter.on(stateChangeEventSix, this.stateChangCallBack)
var stateChangeEventSeven = { var stateChangeEventSeven = {
eventId: 178, eventId: 178,
priority: events_emitter.EventPriority.LOW 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() { build() {
......
...@@ -22,44 +22,41 @@ struct scrollCode { ...@@ -22,44 +22,41 @@ struct scrollCode {
@State scrollBar: BarState = BarState.On; @State scrollBar: BarState = BarState.On;
@State scrollBarColor: Color = "#FF0000FF"; @State scrollBarColor: Color = "#FF0000FF";
@State scrollBarWidth: number = 30; @State scrollBarWidth: number = 30;
scroller: Scroller = new Scroller() scroller: Scroller = new Scroller()
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("scrollCode page state change called:" + JSON.stringify(eventData)); console.info("scrollCode page state change called:" + JSON.stringify(eventData));
var scrollableValue = eventData.data.scrollable; var scrollableValue = eventData.data.scrollable;
console.info("scrollableValue:" + scrollableValue); console.info("scrollableValue:" + scrollableValue);
if (scrollableValue!= null && scrollableValue.length != 0) { if (scrollableValue != null && scrollableValue.length != 0) {
this.scrollable = scrollableValue; this.scrollable = scrollableValue;
console.info("this.scrollable:" + this.scrollable); console.info("this.scrollable:" + this.scrollable);
}else{ } else {
console.info("scrollableValue is null or empty " + scrollableValue); console.info("scrollableValue is null or empty " + scrollableValue);
} }
var scrollBarValue = eventData.data.scrollBar; var scrollBarValue = eventData.data.scrollBar;
console.info("scrollBarValue:" + scrollBarValue); console.info("scrollBarValue:" + scrollBarValue);
if (scrollBarValue!= null && scrollBarValue.length != 0) { if (scrollBarValue != null && scrollBarValue.length != 0) {
this.scrollBar = scrollBarValue; this.scrollBar = scrollBarValue;
console.info("this.scrollBar:" + this.scrollBar); console.info("this.scrollBar:" + this.scrollBar);
}else{ } else {
console.info("scrollBarValue is null or empty " + scrollBarValue); console.info("scrollBarValue is null or empty " + scrollBarValue);
} }
var scrollBarColorValue = eventData.data.scrollBarColor; var scrollBarColorValue = eventData.data.scrollBarColor;
console.info("scrollBarColorValue:" + scrollBarColorValue); console.info("scrollBarColorValue:" + scrollBarColorValue);
if (scrollBarColorValue!= null && scrollBarColorValue.length != 0) { if (scrollBarColorValue != null && scrollBarColorValue.length != 0) {
this.scrollBarColor = scrollBarColorValue; this.scrollBarColor = scrollBarColorValue;
console.info("this.scrollBarColor:" + this.scrollBarColor); console.info("this.scrollBarColor:" + this.scrollBarColor);
}else{ } else {
console.info("scrollBarColorValue is null or empty " + scrollBarColorValue); console.info("scrollBarColorValue is null or empty " + scrollBarColorValue);
} }
var scrollBarWidthValue = eventData.data.scrollBarWidth; var scrollBarWidthValue = eventData.data.scrollBarWidth;
console.info("scrollBarWidthValue:" + scrollBarWidthValue); console.info("scrollBarWidthValue:" + scrollBarWidthValue);
if (scrollBarWidthValue!= null && scrollBarWidthValue.length != 0) { if (scrollBarWidthValue != null && scrollBarWidthValue.length != 0) {
this.scrollBarWidth = scrollBarWidthValue; this.scrollBarWidth = scrollBarWidthValue;
console.info("this.scrollBarWidth:" + this.scrollBarWidth); console.info("this.scrollBarWidth:" + this.scrollBarWidth);
}else{ } else {
console.info("scrollBarWidthValue is null or empty " + scrollBarWidthValue); console.info("scrollBarWidthValue is null or empty " + scrollBarWidthValue);
} }
} else { } else {
...@@ -100,8 +97,12 @@ struct scrollCode { ...@@ -100,8 +97,12 @@ struct scrollCode {
Column() { Column() {
ForEach(this.arr, (item) => { ForEach(this.arr, (item) => {
Text(item.toString()) Text(item.toString())
.width('90%').height(150).backgroundColor(0xFFFFFF) .width('90%')
.borderRadius(15).fontSize(16).textAlign(TextAlign.Center) .height(150)
.backgroundColor(0xFFFFFF)
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.margin({ top: 10 }) .margin({ top: 10 })
}, item => item) }, item => item)
}.width('100%') }.width('100%')
...@@ -120,6 +121,7 @@ struct scrollCode { ...@@ -120,6 +121,7 @@ struct scrollCode {
.onScrollEnd(() => { .onScrollEnd(() => {
console.info('Scroll Stop') console.info('Scroll Stop')
}) })
Button('scroll 100') Button('scroll 100')
.onClick(() => { .onClick(() => {
this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 }) this.scroller.scrollTo({ xOffset: 0, yOffset: this.scroller.currentOffset().yOffset + 100 })
...@@ -129,7 +131,9 @@ struct scrollCode { ...@@ -129,7 +131,9 @@ struct scrollCode {
this.scroller.scrollEdge(Edge.Top) this.scroller.scrollEdge(Edge.Top)
}) })
.margin({ top: 120, left: 20 }) .margin({ top: 120, left: 20 })
Button('next page').backgroundColor(0x2788D9).fontSize(20) Button('next page')
.backgroundColor(0x2788D9)
.fontSize(20)
.onClick((event: ClickEvent) => { .onClick((event: ClickEvent) => {
this.onClickValue = true; this.onClickValue = true;
try { try {
...@@ -148,7 +152,11 @@ struct scrollCode { ...@@ -148,7 +152,11 @@ struct scrollCode {
console.info("click action state err: " + JSON.stringify(err.message)) console.info("click action state err: " + JSON.stringify(err.message))
} }
this.scroller.scrollPage({ next: true }) 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
...@@ -28,7 +28,6 @@ struct ShapeExample { ...@@ -28,7 +28,6 @@ struct ShapeExample {
@State strokeDashArray: Array<Length> = [20]; @State strokeDashArray: Array<Length> = [20];
@State fillOpacity: number = 0; @State fillOpacity: number = 0;
@State strokeValue: Color = '#FF000000'; @State strokeValue: Color = '#FF000000';
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
if (eventData != null) { if (eventData != null) {
console.info("text page state change called:" + JSON.stringify(eventData)); console.info("text page state change called:" + JSON.stringify(eventData));
...@@ -98,7 +97,7 @@ struct ShapeExample { ...@@ -98,7 +97,7 @@ struct ShapeExample {
.strokeWidth(this.strokeWidth) .strokeWidth(this.strokeWidth)
.antiAlias(this.antiAlias) .antiAlias(this.antiAlias)
.fillOpacity(this.fillOpacity) .fillOpacity(this.fillOpacity)
.mesh([],1,1) .mesh([], 1, 1)
}.width('100%').margin({ top: 15 }) }.width('100%').margin({ top: 15 })
} }
} }
\ No newline at end of file
...@@ -31,7 +31,7 @@ struct SharedTransitionExample { ...@@ -31,7 +31,7 @@ struct SharedTransitionExample {
Row() { Row() {
Navigator({ target: 'pages/sharedTransition2', type: NavigationType.Push }) { Navigator({ target: 'pages/sharedTransition2', type: NavigationType.Push }) {
Image($rawfile('ic_health_heart.png')).width(50).height(50) 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') .key('Navigator')
.padding({ left: 10 }) .padding({ left: 10 })
...@@ -41,9 +41,9 @@ struct SharedTransitionExample { ...@@ -41,9 +41,9 @@ struct SharedTransitionExample {
try { try {
var backData = { var backData = {
data: { data: {
"duration" : this.duration, "duration": this.duration,
"delay" : this.delay, "delay": this.delay,
"type" : this.type "type": this.type
} }
} }
var backEvent = { var backEvent = {
...@@ -56,6 +56,7 @@ struct SharedTransitionExample { ...@@ -56,6 +56,7 @@ struct SharedTransitionExample {
console.info("SharedTransition emit action state err: " + JSON.stringify(err.message)) console.info("SharedTransition emit action state err: " + JSON.stringify(err.message))
} }
}) })
Text('SharedTransition').width(80).height(80).textAlign(TextAlign.Center) Text('SharedTransition').width(80).height(80).textAlign(TextAlign.Center)
} }
} }
......
...@@ -18,11 +18,10 @@ import events_emitter from '@ohos.emitter' ...@@ -18,11 +18,10 @@ import events_emitter from '@ohos.emitter'
@Entry @Entry
@Component @Component
struct SpanExample { struct SpanExample {
@State decorationValue:object={ type: TextDecorationType.None, color: Color.Red } @State decorationValue: object= { type: TextDecorationType.None, color: Color.Red }
@State textCaseValue:TextCase=TextCase.Normal @State textCaseValue: TextCase= TextCase.Normal
@State fontSizeValue:number=40 @State fontSizeValue: number= 40
@State fontColorValue: Color= 0xCCCCCC @State fontColorValue: Color= 0xCCCCCC
private stateChangCallBack = (eventData) => { private stateChangCallBack = (eventData) => {
console.info("span page state change called:" + JSON.stringify(eventData)); console.info("span page state change called:" + JSON.stringify(eventData));
if (eventData != null) { if (eventData != null) {
...@@ -57,6 +56,30 @@ struct SpanExample { ...@@ -57,6 +56,30 @@ struct SpanExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent3, this.stateChangCallBack); 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() { build() {
......
...@@ -31,7 +31,7 @@ struct TabsExample { ...@@ -31,7 +31,7 @@ struct TabsExample {
build() { build() {
Column() { Column() {
Tabs({ barPosition: this.barPosition, controller: this.controller,index: this.index }) { Tabs({ barPosition: this.barPosition, controller: this.controller, index: this.index }) {
TabContent() { TabContent() {
Column().width('100%').height('100%').backgroundColor(Color.Pink) Column().width('100%').height('100%').backgroundColor(Color.Pink)
}.tabBar('pink').key('tabContent1') }.tabBar('pink').key('tabContent1')
...@@ -54,12 +54,15 @@ struct TabsExample { ...@@ -54,12 +54,15 @@ struct TabsExample {
console.info("tabContent1 emit action state err: " + JSON.stringify(err.message)) console.info("tabContent1 emit action state err: " + JSON.stringify(err.message))
} }
}) })
TabContent() { TabContent() {
Column().width('100%').height('100%').backgroundColor(Color.Yellow) Column().width('100%').height('100%').backgroundColor(Color.Yellow)
}.tabBar('yellow') }.tabBar('yellow')
TabContent() { TabContent() {
Column().width('100%').height('100%').backgroundColor(Color.Blue) Column().width('100%').height('100%').backgroundColor(Color.Blue)
}.tabBar('blue') }.tabBar('blue')
TabContent() { TabContent() {
Column().width('100%').height('100%').backgroundColor(Color.Green) Column().width('100%').height('100%').backgroundColor(Color.Green)
}.tabBar('green') }.tabBar('green')
...@@ -89,6 +92,18 @@ struct TabsExample { ...@@ -89,6 +92,18 @@ struct TabsExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEvent, this.stateChangCallBack) 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) => { private stateChangCallBack = (eventData) => {
......
...@@ -27,7 +27,11 @@ struct TapGestureExample { ...@@ -27,7 +27,11 @@ struct TapGestureExample {
Text('Click twice') Text('Click twice')
Text(this.value) 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( .gesture(
TapGesture({ count: 2 }) TapGesture({ count: 2 })
.onAction(() => { .onAction(() => {
...@@ -49,6 +53,7 @@ struct TapGestureExample { ...@@ -49,6 +53,7 @@ struct TapGestureExample {
console.info("click action state err: " + JSON.stringify(err.message)) console.info("click action state err: " + JSON.stringify(err.message))
} }
}) })
).key('tapGesture') )
.key('tapGesture')
} }
} }
\ No newline at end of file
...@@ -21,8 +21,9 @@ struct TextExample { ...@@ -21,8 +21,9 @@ struct TextExample {
@State fontSize: number = 9; @State fontSize: number = 9;
@State fontColor: string = "0xCCCCCC"; @State fontColor: string = "0xCCCCCC";
@State textAlign: TextAlign = TextAlign.Start; @State textAlign: TextAlign = TextAlign.Start;
@State textOverflow : TextOverflow = TextOverflow.Clip; @State textOverflow: TextOverflow = TextOverflow.Clip;
@State decoration: TextDecorationType = TextDecorationType.None; @State decoration: TextDecorationType = TextDecorationType.None;
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Text('lineHeightt') Text('lineHeightt')
...@@ -30,7 +31,7 @@ struct TextExample { ...@@ -30,7 +31,7 @@ struct TextExample {
.fontColor(this.fontColor) .fontColor(this.fontColor)
.textAlign(this.textAlign) .textAlign(this.textAlign)
.textOverflow({ overflow: this.textOverflow }) .textOverflow({ overflow: this.textOverflow })
.decoration({ type: this.decoration, color:Color.Red }) .decoration({ type: this.decoration, color: Color.Red })
.key('text') .key('text')
Image($rawfile('test.png')) Image($rawfile('test.png'))
.key('image') .key('image')
...@@ -65,6 +66,30 @@ struct TextExample { ...@@ -65,6 +66,30 @@ struct TextExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEventThree, this.stateChangCallBack) 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) => { private stateChangCallBack = (eventData) => {
......
...@@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter' ...@@ -19,6 +19,7 @@ import events_emitter from '@ohos.emitter'
@Component @Component
struct ClickExample { struct ClickExample {
@State text: string = '' @State text: string = ''
build() { build() {
Column() { Column() {
Button('Click').backgroundColor(0x2788D9) Button('Click').backgroundColor(0x2788D9)
......
...@@ -18,9 +18,9 @@ import events_emitter from '@ohos.emitter'; ...@@ -18,9 +18,9 @@ import events_emitter from '@ohos.emitter';
@Entry @Entry
@Component @Component
struct ToggleExample { struct ToggleExample {
@State selectedColor : Color = '#330A59F7'; @State selectedColor: Color = '#330A59F7';
@State toggleType : ToggleType = ToggleType.Button; @State toggleType: ToggleType = ToggleType.Button;
@State isOn : boolean = false; @State isOn: boolean = false;
onPageShow() { onPageShow() {
console.info('[toggle] page show called'); console.info('[toggle] page show called');
...@@ -35,19 +35,43 @@ struct ToggleExample { ...@@ -35,19 +35,43 @@ struct ToggleExample {
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
events_emitter.on(stateChangeEventOne, this.stateChangCallBack); 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) => { private stateChangCallBack = (eventData) => {
console.info("[toggle] page stateChangCallBack"); console.info("[toggle] page stateChangCallBack");
if (eventData != null) { if (eventData != null) {
console.info("[toggle] page state change called:" + JSON.stringify(eventData)); 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; this.selectedColor = eventData.data.selectedColor;
} }
if(eventData.data.toggleType != null) { if (eventData.data.toggleType != null) {
this.toggleType = eventData.data.toggleType; this.toggleType = eventData.data.toggleType;
} }
if(eventData.data.isOn != null) { if (eventData.data.isOn != null) {
this.isOn = eventData.data.isOn; this.isOn = eventData.data.isOn;
} }
} }
......
...@@ -27,8 +27,14 @@ struct TransitionExample { ...@@ -27,8 +27,14 @@ struct TransitionExample {
@State transitionTypeThree: TransitionType = TransitionType.All @State transitionTypeThree: TransitionType = TransitionType.All
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,}) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, }) {
Button(this.show).width(80).height(30).backgroundColor(0x317aff).margin({bottom:50}).key('button').opacity(this.opacity) Button(this.show)
.width(80)
.height(30)
.backgroundColor(0x317aff)
.margin({ bottom: 50 })
.key('button')
.opacity(this.opacity)
.onClick(() => { .onClick(() => {
this.onActionCalled = true; this.onActionCalled = true;
try { try {
...@@ -48,9 +54,9 @@ struct TransitionExample { ...@@ -48,9 +54,9 @@ struct TransitionExample {
} }
animateTo({ duration: 3000 }, () => { animateTo({ duration: 3000 }, () => {
this.btn1 = !this.btn1 this.btn1 = !this.btn1
if(this.btn1){ if (this.btn1) {
this.show = "hide" this.show = "hide"
}else{ } else {
this.show = "show" this.show = "show"
} }
}) })
...@@ -58,10 +64,11 @@ struct TransitionExample { ...@@ -58,10 +64,11 @@ struct TransitionExample {
if (this.btn1) { if (this.btn1) {
Button() { Button() {
Image($rawfile('test.png')).width("80%").height(300).key('image') 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.transitionTypeOne, scale: { x: 0, y: 1.0, z: 1.0 }, opacity: this.opacity })
.transition({ type: this.transitionTypeTwo, scale: { x: 1.0, y: 0.0 } }) .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() { onPageShow() {
......
...@@ -62,7 +62,7 @@ export default function aboutToDisappearJsunit() { ...@@ -62,7 +62,7 @@ export default function aboutToDisappearJsunit() {
} catch (err) { } catch (err) {
console.info("aboutToDisappearTest_0100 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1000);
console.info('aboutToDisappearTest_0100 END'); console.info('aboutToDisappearTest_0100 END');
done(); done();
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils';
export default function animateJsunit() { export default function animateJsunit() {
describe('appInfoTest', function () { describe('animateTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("animate beforeEach start"); console.info("animate beforeEach start");
let options = { let options = {
...@@ -53,7 +53,7 @@ export default function animateJsunit() { ...@@ -53,7 +53,7 @@ export default function animateJsunit() {
eventId: 51, eventId: 51,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0100 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0100 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.duration).assertEqual('100') except(indexEvent.data.duration).assertEqual('100')
} }
...@@ -62,7 +62,7 @@ export default function animateJsunit() { ...@@ -62,7 +62,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0100 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0100 END'); console.info('animateTest_0100 END');
done(); done();
...@@ -75,7 +75,7 @@ export default function animateJsunit() { ...@@ -75,7 +75,7 @@ export default function animateJsunit() {
eventId: 52, eventId: 52,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.curve).assertEqual('Ease') except(indexEvent.data.curve).assertEqual('Ease')
} }
...@@ -84,7 +84,7 @@ export default function animateJsunit() { ...@@ -84,7 +84,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0200 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0200 END'); console.info('animateTest_0200 END');
done(); done();
...@@ -97,7 +97,7 @@ export default function animateJsunit() { ...@@ -97,7 +97,7 @@ export default function animateJsunit() {
eventId: 53, eventId: 53,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.iteration).assertEqual('1') except(indexEvent.data.iteration).assertEqual('1')
} }
...@@ -106,7 +106,7 @@ export default function animateJsunit() { ...@@ -106,7 +106,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0300 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0300 END'); console.info('animateTest_0300 END');
done(); done();
...@@ -119,7 +119,7 @@ export default function animateJsunit() { ...@@ -119,7 +119,7 @@ export default function animateJsunit() {
eventId: 54, eventId: 54,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0400 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0400 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.tempo).assertEqual(1000) except(indexEvent.data.tempo).assertEqual(1000)
} }
...@@ -128,7 +128,7 @@ export default function animateJsunit() { ...@@ -128,7 +128,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0400 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0400 END'); console.info('animateTest_0400 END');
done(); done();
...@@ -141,7 +141,7 @@ export default function animateJsunit() { ...@@ -141,7 +141,7 @@ export default function animateJsunit() {
eventId: 55, eventId: 55,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0500 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.playmode).assertEqual('normal') except(indexEvent.data.playmode).assertEqual('normal')
} }
...@@ -150,7 +150,7 @@ export default function animateJsunit() { ...@@ -150,7 +150,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0500 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0500 END'); console.info('animateTest_0500 END');
done(); done();
...@@ -161,7 +161,7 @@ export default function animateJsunit() { ...@@ -161,7 +161,7 @@ export default function animateJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"duration":'2000' "duration": '2000'
} }
} }
let indexEventOne = { let indexEventOne = {
...@@ -177,7 +177,7 @@ export default function animateJsunit() { ...@@ -177,7 +177,7 @@ export default function animateJsunit() {
eventId: 51, eventId: 51,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0600 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0600 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.duration).assertEqual('2000') except(indexEvent.data.duration).assertEqual('2000')
} }
...@@ -186,7 +186,7 @@ export default function animateJsunit() { ...@@ -186,7 +186,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0600 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0600 END'); console.info('animateTest_0600 END');
done(); done();
...@@ -213,7 +213,7 @@ export default function animateJsunit() { ...@@ -213,7 +213,7 @@ export default function animateJsunit() {
eventId: 52, eventId: 52,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0700 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0700 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.curve).assertEqual('Linear') except(indexEvent.data.curve).assertEqual('Linear')
} }
...@@ -222,7 +222,7 @@ export default function animateJsunit() { ...@@ -222,7 +222,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0700 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0700 END'); console.info('animateTest_0700 END');
done(); done();
...@@ -233,7 +233,7 @@ export default function animateJsunit() { ...@@ -233,7 +233,7 @@ export default function animateJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"iteration":"2" "iteration": "2"
} }
} }
let indexEventOne = { let indexEventOne = {
...@@ -249,7 +249,7 @@ export default function animateJsunit() { ...@@ -249,7 +249,7 @@ export default function animateJsunit() {
eventId: 53, eventId: 53,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0800 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0800 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.iteration).assertEqual('2') except(indexEvent.data.iteration).assertEqual('2')
} }
...@@ -258,7 +258,7 @@ export default function animateJsunit() { ...@@ -258,7 +258,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0800 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0800 END'); console.info('animateTest_0800 END');
done(); done();
...@@ -285,7 +285,7 @@ export default function animateJsunit() { ...@@ -285,7 +285,7 @@ export default function animateJsunit() {
eventId: 54, eventId: 54,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_0900 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_0900 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.tempo).assertEqual('20000') except(indexEvent.data.tempo).assertEqual('20000')
} }
...@@ -294,7 +294,7 @@ export default function animateJsunit() { ...@@ -294,7 +294,7 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_0900 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_0900 END'); console.info('animateTest_0900 END');
done(); done();
...@@ -305,7 +305,7 @@ export default function animateJsunit() { ...@@ -305,7 +305,7 @@ export default function animateJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"playmode":"PlayMode.Alternate" "playmode": "PlayMode.Alternate"
} }
} }
let indexEventOne = { let indexEventOne = {
...@@ -321,7 +321,7 @@ export default function animateJsunit() { ...@@ -321,7 +321,7 @@ export default function animateJsunit() {
eventId: 55, eventId: 55,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("animateTest_1000 get state result is: " + JSON.stringify(indexEvent)) console.info("animateTest_1000 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.playmode).assertEqual('alternate') except(indexEvent.data.playmode).assertEqual('alternate')
} }
...@@ -330,10 +330,370 @@ export default function animateJsunit() { ...@@ -330,10 +330,370 @@ export default function animateJsunit() {
} catch (err) { } catch (err) {
console.info("animateTest_1000 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('animateTest_1000 END'); console.info('animateTest_1000 END');
done(); 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();
});
}) })
} }
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils';
export default function badgeJsunit() { export default function badgeJsunit() {
describe('appInfoTest', function () { describe('badgeTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("badge beforeEach start"); console.info("badge beforeEach start");
let options = { let options = {
...@@ -244,5 +244,58 @@ export default function badgeJsunit() { ...@@ -244,5 +244,58 @@ export default function badgeJsunit() {
done(); 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
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils';
export default function blankJsunit() { export default function blankJsunit() {
describe('appInfoTest', function () { describe('blankTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("blank beforeEach start"); console.info("blank beforeEach start");
let options = { let options = {
...@@ -81,8 +81,8 @@ export default function blankJsunit() { ...@@ -81,8 +81,8 @@ export default function blankJsunit() {
let strJsonNew = getInspectorByKey('blank'); let strJsonNew = getInspectorByKey('blank');
let objNew = JSON.parse(strJsonNew); let objNew = JSON.parse(strJsonNew);
console.info("[testBlank02] component objNew is: " + JSON.stringify(objNew)); console.info("[testBlank02] component objNew is: " + JSON.stringify(objNew));
expect(objNew.$type).assertEqual('Blank');
expect(objNew.$attrs.color).assertEqual('#FFFF0000'); expect(objNew.$attrs.color).assertEqual('#FFFF0000');
expect(objNew.$type).assertEqual('Blank');
done(); done();
}); });
}) })
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter' ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'
import Utils from './Utils'; import Utils from './Utils';
export default function buttonJsunit() { export default function buttonJsunit() {
describe('appInfoTest', function () { describe('buttonTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("button beforeEach start"); console.info("button beforeEach start");
let options = { let options = {
...@@ -241,7 +241,7 @@ export default function buttonJsunit() { ...@@ -241,7 +241,7 @@ export default function buttonJsunit() {
eventId: 72, eventId: 72,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("testButton10 get state result is: " + JSON.stringify(indexEvent)) console.info("testButton10 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.fontColorValue).assertEqual(Color.Pink) except(indexEvent.data.fontColorValue).assertEqual(Color.Pink)
} }
...@@ -250,7 +250,7 @@ export default function buttonJsunit() { ...@@ -250,7 +250,7 @@ export default function buttonJsunit() {
} catch (err) { } catch (err) {
console.info("testButton10 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1000);
console.info('[testButton10] END'); console.info('[testButton10] END');
done(); done();
...@@ -278,7 +278,7 @@ export default function buttonJsunit() { ...@@ -278,7 +278,7 @@ export default function buttonJsunit() {
eventId: 71, eventId: 71,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
let callback= (indexEvent) => { let callback = (indexEvent) => {
console.info("testButton11 get state result is: " + JSON.stringify(indexEvent)) console.info("testButton11 get state result is: " + JSON.stringify(indexEvent))
except(indexEvent.data.fontColorValue).assertEqual(332) except(indexEvent.data.fontColorValue).assertEqual(332)
} }
...@@ -287,7 +287,7 @@ export default function buttonJsunit() { ...@@ -287,7 +287,7 @@ export default function buttonJsunit() {
} catch (err) { } catch (err) {
console.info("testButton11 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1000);
console.info('[testButton11] END'); console.info('[testButton11] END');
done(); done();
...@@ -318,5 +318,94 @@ export default function buttonJsunit() { ...@@ -318,5 +318,94 @@ export default function buttonJsunit() {
console.info('[testButton12] testSendTouchEvent END'); console.info('[testButton12] testSendTouchEvent END');
done(); 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
...@@ -17,8 +17,8 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from " ...@@ -17,8 +17,8 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "
import router from '@system.router'; import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils';
export default function canvasJsunit() { export default function canvas2Jsunit() {
describe('canvasTest', function () { describe('canvas2Test', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("canvas beforeEach start"); console.info("canvas beforeEach start");
let options = { let options = {
......
...@@ -68,7 +68,7 @@ export default function circleJsunit() { ...@@ -68,7 +68,7 @@ export default function circleJsunit() {
} }
console.info('[circleTest_0200] START'); console.info('[circleTest_0200] START');
var innerEvent = { var innerEvent = {
eventId:77, eventId: 77,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("[circleTest_0200] start to publish emit"); console.info("[circleTest_0200] start to publish emit");
...@@ -97,20 +97,20 @@ export default function circleJsunit() { ...@@ -97,20 +97,20 @@ export default function circleJsunit() {
} }
console.info('[circleTest_0300] START'); console.info('[circleTest_0300] START');
var innerEvent = { var innerEvent = {
eventId:77, eventId: 77,
priority: events_emitter.EventPriority.LOW 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); events_emitter.emit(innerEvent, eventData);
} catch (err) { } 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); await Utils.sleep(1000);
let strJson = getInspectorByKey('circle'); let strJson = getInspectorByKey('circle');
let obj = JSON.parse(strJson); let obj = JSON.parse(strJson);
console.info("[circleTest_0300] component objNew is: " + JSON.stringify(obj)); 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.width).assertEqual('0.00px');
expect(obj.$attrs.height).assertEqual('0.00px');
console.info('circleTest_0300 END'); console.info('circleTest_0300 END');
done(); done();
}); });
......
...@@ -18,7 +18,7 @@ import router from '@system.router'; ...@@ -18,7 +18,7 @@ import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
export default function LineJsunit(){ export default function LineJsunit() {
describe('LineTest', function () { describe('LineTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
...@@ -195,10 +195,10 @@ export default function LineJsunit(){ ...@@ -195,10 +195,10 @@ export default function LineJsunit(){
await Utils.sleep(2000); await Utils.sleep(2000);
var strJson = getInspectorByKey('line'); var strJson = getInspectorByKey('line');
var obj = JSON.parse(strJson); 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])); 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[1]).assertEqual(0);
expect(obj.$attrs.endPoint[0]).assertEqual(0);
done(); done();
}); });
}) })
......
...@@ -72,7 +72,7 @@ export default function motionPathJsunit() { ...@@ -72,7 +72,7 @@ export default function motionPathJsunit() {
} catch (err) { } catch (err) {
console.info("motionPathTest_0200 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1000);
console.info('motionPathTest_0200 END'); console.info('motionPathTest_0200 END');
done(); done();
...@@ -94,7 +94,7 @@ export default function motionPathJsunit() { ...@@ -94,7 +94,7 @@ export default function motionPathJsunit() {
} catch (err) { } catch (err) {
console.info("motionPathTest_0300 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1000);
console.info('motionPathTest_0300 END'); console.info('motionPathTest_0300 END');
done(); done();
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function PanGestureJsunit() { export default function PanGestureJsunit() {
describe('appInfoTest', function () { describe('PanGestureTest', function () {
var x_value; var x_value;
var y_value; var y_value;
......
...@@ -53,7 +53,9 @@ export default function parallelGestureJsunit() { ...@@ -53,7 +53,9 @@ export default function parallelGestureJsunit() {
let x_value = rect.left + (rect.right - rect.left) / 2; let x_value = rect.left + (rect.right - rect.left) / 2;
let y_value = rect.top + (rect.bottom - rect.top) / 2; let y_value = rect.top + (rect.bottom - rect.top) / 2;
console.info("parallelGestureTest_0100 onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); 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) => { var callback = (eventData) => {
console.info("parallelGestureTest_0100 get event state result is: " + JSON.stringify(eventData)); console.info("parallelGestureTest_0100 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('gesture onAction') expect(eventData.data.value).assertEqual('gesture onAction')
......
...@@ -19,7 +19,7 @@ import Utils from './Utils'; ...@@ -19,7 +19,7 @@ import Utils from './Utils';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
export default function priorityGestureJsunit() { export default function priorityGestureJsunit() {
describe('PriorityGestureTest', function () { describe('priorityGestureTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/priorityGesture', uri: 'pages/priorityGesture',
...@@ -52,7 +52,9 @@ export default function priorityGestureJsunit() { ...@@ -52,7 +52,9 @@ export default function priorityGestureJsunit() {
let x_value = rect.left + (rect.right - rect.left) / 2; let x_value = rect.left + (rect.right - rect.left) / 2;
let y_value = rect.top + (rect.bottom - rect.top) / 2; let y_value = rect.top + (rect.bottom - rect.top) / 2;
console.info("priorityGestureTest_0100 onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); 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) => { var callback = (eventData) => {
console.info("priorityGestureTest_0100 get event state result is: " + JSON.stringify(eventData)); console.info("priorityGestureTest_0100 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.value).assertEqual('gesture onAction') expect(eventData.data.value).assertEqual('gesture onAction')
......
...@@ -257,5 +257,65 @@ export default function progressJsunit() { ...@@ -257,5 +257,65 @@ export default function progressJsunit() {
console.info('testProgress_900 END'); console.info('testProgress_900 END');
done(); 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
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function qrCodeJsunit() { export default function qrCodeJsunit() {
describe('appInfoTest', function () { describe('qrCodeTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/QrCode', uri: 'pages/QrCode',
...@@ -108,5 +108,109 @@ export default function qrCodeJsunit() { ...@@ -108,5 +108,109 @@ export default function qrCodeJsunit() {
expect(obj.$attrs.backgroundColor).assertEqual('#FFFFB6C1'); expect(obj.$attrs.backgroundColor).assertEqual('#FFFFB6C1');
done(); 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();
});
}) })
} }
...@@ -218,5 +218,59 @@ export default function ratingJsunit() { ...@@ -218,5 +218,59 @@ export default function ratingJsunit() {
console.info('testRating_700 END'); console.info('testRating_700 END');
done(); 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
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function ResponseRegionJsunit() { export default function ResponseRegionJsunit() {
describe('appInfoTest', function () { describe('responseRegionTest', function () {
var x_value; var x_value;
var y_value; var y_value;
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function scrollCodeJsunit() { export default function scrollCodeJsunit() {
describe('appInfoTest', function () { describe('scrollCodeTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/scrollCode', uri: 'pages/scrollCode',
...@@ -167,7 +167,7 @@ export default function scrollCodeJsunit() { ...@@ -167,7 +167,7 @@ export default function scrollCodeJsunit() {
it('test_scrollCode_006', 0, async function (done) { it('test_scrollCode_006', 0, async function (done) {
await Utils.sleep(1000) await Utils.sleep(1000)
var callback = (eventData) => { 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) expect(eventData.data.scrollToIndex).assertEqual(10)
} }
var innerEvent = { var innerEvent = {
...@@ -177,7 +177,7 @@ export default function scrollCodeJsunit() { ...@@ -177,7 +177,7 @@ export default function scrollCodeJsunit() {
try { try {
events_emitter.on(innerEvent, callback) events_emitter.on(innerEvent, callback)
} catch (err) { } 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, ""))); console.info('[test_scrollCode_006] sendEventByKey ' + JSON.stringify(sendEventByKey('button', 10, "")));
await Utils.sleep(1000) await Utils.sleep(1000)
......
...@@ -112,7 +112,7 @@ export default function sharedTransitionJsunit() { ...@@ -112,7 +112,7 @@ export default function sharedTransitionJsunit() {
} catch (err) { } catch (err) {
console.info("sharedTransitionTest_0400 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(2000);
console.info('sharedTransitionTest_0400 END'); console.info('sharedTransitionTest_0400 END');
done(); done();
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function spanJsunit() { export default function spanJsunit() {
describe('appInfoTest', function () { describe('spanTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/span', uri: 'pages/span',
...@@ -130,5 +130,109 @@ export default function spanJsunit() { ...@@ -130,5 +130,109 @@ export default function spanJsunit() {
expect(obj.$attrs.fontColor).assertEqual('#FF000990'); expect(obj.$attrs.fontColor).assertEqual('#FF000990');
done(); 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
...@@ -19,7 +19,7 @@ import Utils from './Utils'; ...@@ -19,7 +19,7 @@ import Utils from './Utils';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
export default function tabsJsunit() { export default function tabsJsunit() {
describe('appInfoTest', function () { describe('tabsTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("tabs beforeEach start"); console.info("tabs beforeEach start");
let options = { let options = {
...@@ -126,12 +126,26 @@ export default function tabsJsunit() { ...@@ -126,12 +126,26 @@ export default function tabsJsunit() {
it('testTabs_0800', 0, async function (done) { it('testTabs_0800', 0, async function (done) {
console.info('testTabs_0800 START'); console.info('testTabs_0800 START');
let strJson = getInspectorByKey('tabContent1'); try {
console.info("testTabs_0800 component strJson:" + strJson); let eventData = {
let obj = JSON.parse(strJson); data: {
console.info("testTabs_0800 component obj is: " + JSON.stringify(obj)); "vertical": "false",
expect(obj.$type).assertEqual('TabContent'); }
expect(obj.$attrs.tabBar).assertEqual('pink'); }
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'); console.info('testTabs_0800 END');
done(); done();
}); });
...@@ -141,7 +155,7 @@ export default function tabsJsunit() { ...@@ -141,7 +155,7 @@ export default function tabsJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"vertical": "false", "scrollable": "false",
} }
} }
let indexEvent = { let indexEvent = {
...@@ -157,7 +171,7 @@ export default function tabsJsunit() { ...@@ -157,7 +171,7 @@ export default function tabsJsunit() {
let strJsonNew = getInspectorByKey('tabs'); let strJsonNew = getInspectorByKey('tabs');
let objNew = JSON.parse(strJsonNew); let objNew = JSON.parse(strJsonNew);
console.info("testTabs_0900 component objNew is: " + JSON.stringify(objNew)); 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'); console.info('testTabs_0900 END');
done(); done();
}); });
...@@ -167,7 +181,7 @@ export default function tabsJsunit() { ...@@ -167,7 +181,7 @@ export default function tabsJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"scrollable": "false", "scrollable": "false53",
} }
} }
let indexEvent = { let indexEvent = {
...@@ -193,7 +207,7 @@ export default function tabsJsunit() { ...@@ -193,7 +207,7 @@ export default function tabsJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"scrollable": "false53", "vertical": "39284",
} }
} }
let indexEvent = { let indexEvent = {
...@@ -219,11 +233,11 @@ export default function tabsJsunit() { ...@@ -219,11 +233,11 @@ export default function tabsJsunit() {
try { try {
let eventData = { let eventData = {
data: { data: {
"vertical": "39284", "vertical": "abc123",
} }
} }
let indexEvent = { let indexEvent = {
eventId: 213, eventId: 214,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("testTabs_1200 start to publish emit"); console.info("testTabs_1200 start to publish emit");
...@@ -235,16 +249,42 @@ export default function tabsJsunit() { ...@@ -235,16 +249,42 @@ export default function tabsJsunit() {
let strJsonNew = getInspectorByKey('tabs'); let strJsonNew = getInspectorByKey('tabs');
let objNew = JSON.parse(strJsonNew); let objNew = JSON.parse(strJsonNew);
console.info("testTabs_1200 component objNew is: " + JSON.stringify(objNew)); 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'); console.info('testTabs_1200 END');
done(); done();
}); });
it('testTabs_1300', 0, async function (done) { it('testTabs_1300', 0, async function (done) {
console.info('testTabs_1300 START'); 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); await Utils.sleep(1500);
let callback = (indexEvent) => { 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); expect(indexEvent.data.ACTION).assertEqual(true);
} }
let indexEvent = { let indexEvent = {
...@@ -254,11 +294,11 @@ export default function tabsJsunit() { ...@@ -254,11 +294,11 @@ export default function tabsJsunit() {
try { try {
events_emitter.on(indexEvent, callback); events_emitter.on(indexEvent, callback);
} catch (err) { } 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); await Utils.sleep(1000);
console.info('testTabs_1300 END'); console.info('testTabs_1400 END');
done(); done();
}); });
}) })
......
...@@ -55,8 +55,12 @@ export default function longPressGestureJsunit() { ...@@ -55,8 +55,12 @@ export default function longPressGestureJsunit() {
let x_value_two = rect.left + (rect.right - rect.left) / 20; let x_value_two = rect.left + (rect.right - rect.left) / 20;
let y_value_two = rect.top + (rect.bottom - rect.top) / 20; let y_value_two = rect.top + (rect.bottom - rect.top) / 20;
console.info("[testTapGesture01] onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value); 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 point: TouchObject = {
let point2: TouchObject = { id: 2, x: x_value_two, y: y_value_two, type: TouchType.Move} 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) => { var callback = (eventData) => {
console.info("[testTapGesture01] get event state result is: " + JSON.stringify(eventData)); console.info("[testTapGesture01] get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.ACTION).assertEqual(true) expect(eventData.data.ACTION).assertEqual(true)
......
...@@ -66,10 +66,10 @@ export default function textJsunit() { ...@@ -66,10 +66,10 @@ export default function textJsunit() {
console.info("testText_0200 component obj is: " + JSON.stringify(obj)); console.info("testText_0200 component obj is: " + JSON.stringify(obj));
var res = obj.$attrs.src.indexOf('rawfile/test.png'); var res = obj.$attrs.src.indexOf('rawfile/test.png');
console.info("testText_0200 result is: " + res); 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); console.info("testText_0200 slice result is: " + sres);
expect(obj.$type).assertEqual('Image'); 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'); console.info('testText_0200 END');
done(); done();
}); });
...@@ -123,7 +123,7 @@ export default function textJsunit() { ...@@ -123,7 +123,7 @@ export default function textJsunit() {
let indexEvent = { let indexEvent = {
eventId: 227, eventId: 227,
priority: events_emitter.EventPriority.LOW priority: events_emitter.EventPriority.LOW
} }
console.info("testText_0500 start to publish emit"); console.info("testText_0500 start to publish emit");
events_emitter.emit(indexEvent, eventData); events_emitter.emit(indexEvent, eventData);
} catch (err) { } catch (err) {
...@@ -222,5 +222,109 @@ export default function textJsunit() { ...@@ -222,5 +222,109 @@ export default function textJsunit() {
console.info('testText_1000 END'); console.info('testText_1000 END');
done(); 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
...@@ -18,8 +18,8 @@ import router from '@system.router'; ...@@ -18,8 +18,8 @@ import router from '@system.router';
import Utils from './Utils'; import Utils from './Utils';
import events_emitter from '@ohos.events.emitter'; import events_emitter from '@ohos.events.emitter';
export default function timeStampJsunit(){ export default function timeStampJsunit() {
describe('timeStampTest', function (){ describe('timeStampTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
let options = { let options = {
uri: 'pages/timeStamp', uri: 'pages/timeStamp',
...@@ -61,7 +61,7 @@ export default function timeStampJsunit(){ ...@@ -61,7 +61,7 @@ export default function timeStampJsunit(){
} catch (err) { } catch (err) {
console.info("timeStampTest_0100 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1500);
console.info('timeStampTest_0100 END'); console.info('timeStampTest_0100 END');
done(); done();
......
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function ToggleJsunit() { export default function ToggleJsunit() {
describe('appInfoTest', function () { describe('toggleTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("toggle beforeEach start"); console.info("toggle beforeEach start");
let options = { let options = {
...@@ -131,5 +131,109 @@ export default function ToggleJsunit() { ...@@ -131,5 +131,109 @@ export default function ToggleJsunit() {
console.info('testToggle05 END'); console.info('testToggle05 END');
done(); 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();
});
}) })
} }
...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter'; ...@@ -19,7 +19,7 @@ import events_emitter from '@ohos.events.emitter';
import Utils from './Utils'; import Utils from './Utils';
export default function transitionJsunit() { export default function transitionJsunit() {
describe('appInfoTest', function () { describe('transitionTest', function () {
beforeEach(async function (done) { beforeEach(async function (done) {
console.info("text beforeEach start"); console.info("text beforeEach start");
let options = { let options = {
...@@ -74,7 +74,7 @@ export default function transitionJsunit() { ...@@ -74,7 +74,7 @@ export default function transitionJsunit() {
} catch (err) { } catch (err) {
console.info("transitionTest_0200 on events_emitter err : " + JSON.stringify(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); await Utils.sleep(1000);
console.info('transitionTest_0200 END'); console.info('transitionTest_0200 END');
done(); done();
...@@ -126,7 +126,7 @@ export default function transitionJsunit() { ...@@ -126,7 +126,7 @@ export default function transitionJsunit() {
await Utils.sleep(4000); await Utils.sleep(4000);
let strJsonNew = getInspectorByKey('button'); let strJsonNew = getInspectorByKey('button');
let objNew = JSON.parse(strJsonNew); 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); expect(objNew.$attrs.opacity).assertEqual(null);
console.info('transitionTest_0400 END'); console.info('transitionTest_0400 END');
done(); done();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册