未验证 提交 894f86f6 编写于 作者: O openharmony_ci 提交者: Gitee

!7708 add List_Space_ListItemChange xts_acts testcase

Merge pull request !7708 from 王闻天/List_ListItemChange
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_InSertChange {
@State testWidth: string = '100%'
@State testHeight: string = '100%'
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_InSertChange Page"
onPageShow() {
console.info('ListItem_InSertChange page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'width') {
this.testWidth = message.value;
}
if (message.name == 'height') {
this.testHeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_InSertChange page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width(this.testWidth)
.height(this.testHeight)
.fontSize(16)
.key('InSertChangeText1')
}.width(300).height(100).key('ListItemTest71').editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
.key('InSertChangeText2')
}.width(300).height(100).key('ListItemTest72').editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
.key('InSertChangeText3')
}.width(300).height(100).key('ListItemTest73').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
.key('InSertChangeText4')
}.width(300).height(100).key('ListItemTest74').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemInSertChange1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_Margin {
@State testMargin: number = 0
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_Margin Page"
onPageShow() {
console.info('ListItem_Margin page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'margin') {
this.testMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_Margin page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
.key('MarginText1')
}.margin(this.testMargin).width(300).height(100).key('ListItemTest11').editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
.key('MarginText2')
}.width(300).height(100).key('ListItemTest12').editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
.key('MarginText3')
}.width(300).height(100).key('ListItemTest13').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
.key('MarginText4')
}.width(300).height(100).key('ListItemTest14').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemMargin1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_Offset {
@State testOffsetX: number = 0
@State testOffsetY: number = 0
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_Offset Page"
onPageShow() {
console.info('ListItem_Offset page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'x') {
this.testOffsetX = message.value;
}
if (message.name == 'y') {
this.testOffsetY = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_Offset page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest61').editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
}.offset({ x: this.testOffsetX, y: this.testOffsetY }).width(300).height(100).key('ListItemTest62')
.editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest63').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest64').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemOffset1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_PadMar {
@State testPadding: number = 0
@State testMargin: number = 0
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_PadMar Page"
onPageShow() {
console.info('ListItem_PadMar page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'padding') {
this.testPadding = message.value;
}
if (message.name == 'margin') {
this.testMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_PadMar page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
.key('PadMarText1')
}.padding(this.testPadding).margin(this.testMargin).width(300).height(100).key('ListItemTest31')
.editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
.key('PadMarText2')
}.width(300).height(100).key('ListItemTest32').editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
.key('PadMarText3')
}.width(300).height(100).key('ListItemTest33').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
.key('PadMarText4')
}.width(300).height(100).key('ListItemTest34').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemPadMar1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_Padding {
@State testPadding: number = 0
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_Padding Page"
onPageShow() {
console.info('ListItem_Padding page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'padding') {
this.testPadding = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_Padding page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
.key('PaddingText1')
}.padding(this.testPadding).width(300).height(100).key('ListItemTest21').editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
.key('PaddingText2')
}.width(300).height(100).key('ListItemTest22').editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
.key('PaddingText3')
}.width(300).height(100).key('ListItemTest23').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
.key('PaddingText4')
}.width(300).height(100).key('ListItemTest24').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemPadding1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_Position {
@State testPositionX: number = 0
@State testPositionY: number = 0
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_Position Page"
onPageShow() {
console.info('ListItem_Position page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'x') {
this.testPositionX = message.value;
}
if (message.name == 'y') {
this.testPositionY = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_Position page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
}.position({ x: this.testPositionX, y: this.testPositionY }).width(300).height(100).key('ListItemTest51')
.editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest52').editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest53').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest54').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemPosition1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_SizeChange {
@State testWidth: number = 300
@State testHeight: number = 100
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_SizeChange Page"
onPageShow() {
console.info('ListItem_SizeChange page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'width') {
this.testWidth = message.value;
}
if (message.name == 'height') {
this.testHeight = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_SizeChange page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
}.width(this.testWidth).height(this.testHeight).key('ListItemTest1').editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest2').editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest3').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(100).key('ListItemTest4').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemSizeChange1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/**
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 { MessageManager, Callback } from '../../../../common/MessageManager';
@Entry
@Component
struct ListItem_Visibility {
@State testVisibilityFirst: number = Visibility.Visible
@State testVisibilitySecond: number = Visibility.Visible
private arr: number[] = [0, 1, 2, 3, 4]
messageManager:MessageManager = new MessageManager()
private content: string = "ListItem_Visibility Page"
onPageShow() {
console.info('ListItem_Visibility page show called');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'testVisibilityFirst') {
this.testVisibilityFirst = message.value;
}
if (message.name == 'testVisibilitySecond') {
this.testVisibilitySecond = message.value;
}
}
this.messageManager.registerCallback(callback);
}
onBuildDone() {
console.info('ListItem_Visibility page build done called');
}
build() {
Column() {
List({ space: 20, initialIndex: 0 }) {
ListItem() {
Text('1')
.width('100%')
.height('100%')
.fontSize(16)
}.visibility(this.testVisibilityFirst).width(300).height(120).key('ListItemTest41')
.editable(true).backgroundColor(0xF5DEB3)
ListItem() {
Text('2')
.width('100%')
.height('100%')
.fontSize(16)
}.visibility(this.testVisibilitySecond).width(300).height(120).key('ListItemTest42')
.editable(true).backgroundColor(0xD2B48C)
ListItem() {
Text('3')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(120).key('ListItemTest43').editable(true).backgroundColor(0xffa500)
ListItem() {
Text('4')
.width('100%')
.height('100%')
.fontSize(16)
}.width(300).height(120).key('ListItemTest44').editable(true).backgroundColor(0xFFFFFF)
}
.height(500)
.width(350)
.key('ListItemVisibility1')
.backgroundColor(0xAFEEEE)
.editMode(true)
.scrollBar(BarState.On)
.onScrollIndex((firstIndex: number, lastIndex: number) => {
console.info('first' + firstIndex)
console.info('last' + lastIndex)
})
}.width('100%').height('100%').backgroundColor(0xDCDCDC)
}
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_InSertChange() {
describe('ListItem_InSertChangeTest', function () {
beforeEach(async function (done) {
console.info("ListItem_InSertChange beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_InSertChange',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_InSertChange state pages:" + JSON.stringify(pages));
if (!("ListItem_InSertChange" == pages.name)) {
console.info("get ListItem_InSertChange state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_InSertChange page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_InSertChange page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_InSertChange afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_INSERTCHANGE_TEST_0100
* @tc.name testListItemInSertChangeFiftyPercent
* @tc.desc The size of the text component in the ListItem subcomponent changes 50%
*/
it('testListItemInSertChangeFiftyPercent', 0, async function (done) {
console.info('new testListItemInSertChangeFiftyPercent START');
globalThis.value.message.notify({name:'width', value:'50%'})
globalThis.value.message.notify({name:'height', value:'50%'})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemInSertChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest71');
let locationText2 = CommonFunc.getComponentRect('ListItemTest72');
let locationText3 = CommonFunc.getComponentRect('ListItemTest73');
let locationText4 = CommonFunc.getComponentRect('ListItemTest74');
let locationList = CommonFunc.getComponentRect('ListItemInSertChange1');
let TextTest1 = CommonFunc.getComponentRect('InSertChangeText1');
let TextTest2 = CommonFunc.getComponentRect('InSertChangeText2');
let TextTest3 = CommonFunc.getComponentRect('InSertChangeText3');
let TextTest4 = CommonFunc.getComponentRect('InSertChangeText4');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
expect(Math.round(TextTest1.left - locationText1.left))
.assertEqual(Math.round(locationText1.right - TextTest1.right));
expect(Math.round(TextTest1.top - locationText1.top))
.assertEqual(Math.round(locationText1.bottom - TextTest1.bottom));
expect(Math.round(TextTest1.right - TextTest1.left)).assertEqual(vp2px(150));
expect(Math.round(TextTest1.bottom - TextTest1.top)).assertEqual(vp2px(50));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest74');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemInSertChangeFiftyPercent END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_INSERTCHANGE_TEST_0200
* @tc.name testListItemInSertChangeOneHundredAndTenPercent
* @tc.desc The size of the text component in the ListItem subcomponent changes 110%
*/
it('testListItemInSertChangeOneHundredAndTenPercent', 0, async function (done) {
console.info('new testListItemInSertChangeOneHundredAndTenPercent START');
globalThis.value.message.notify({name:'width', value:'110%'})
globalThis.value.message.notify({name:'height', value:'110%'})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemInSertChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest71');
let locationText2 = CommonFunc.getComponentRect('ListItemTest72');
let locationText3 = CommonFunc.getComponentRect('ListItemTest73');
let locationText4 = CommonFunc.getComponentRect('ListItemTest74');
let locationList = CommonFunc.getComponentRect('ListItemInSertChange1');
let TextTest1 = CommonFunc.getComponentRect('InSertChangeText1');
let TextTest2 = CommonFunc.getComponentRect('InSertChangeText2');
let TextTest3 = CommonFunc.getComponentRect('InSertChangeText3');
let TextTest4 = CommonFunc.getComponentRect('InSertChangeText4');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
expect(locationText1.left).assertEqual(TextTest1.left);
expect(locationText1.top).assertEqual(TextTest1.top);
expect(Math.round(TextTest1.right - locationText1.right)).assertEqual(vp2px(30));
expect(Math.round(TextTest1.bottom - locationText1.bottom)).assertEqual(vp2px(10));
expect(Math.round(TextTest1.right - TextTest1.left)).assertEqual(vp2px(330));
expect(Math.round(TextTest1.bottom - TextTest1.top)).assertEqual(vp2px(110));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest74');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemInSertChangeOneHundredAndTenPercent END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_Margin() {
describe('ListItem_MarginTest', function () {
beforeEach(async function (done) {
console.info("ListItem_Margin beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_Margin',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_Margin state pages:" + JSON.stringify(pages));
if (!("ListItem_Margin" == pages.name)) {
console.info("get ListItem_Margin state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_Margin page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_Margin page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_Margin afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_MARGIN_TEST_0100
* @tc.name testListItemMargin
* @tc.desc ListItem subcomponent binding margin property
*/
it('testListItemMargin', 0, async function (done) {
console.info('new testListItemMargin START');
globalThis.value.message.notify({name:'margin', value:10})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemMargin1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest11');
let locationText2 = CommonFunc.getComponentRect('ListItemTest12');
let locationText3 = CommonFunc.getComponentRect('ListItemTest13');
let locationText4 = CommonFunc.getComponentRect('ListItemTest14');
let locationList = CommonFunc.getComponentRect('ListItemMargin1');
let TextTest1 = CommonFunc.getComponentRect('MarginText1');
let TextTest2 = CommonFunc.getComponentRect('MarginText2');
let TextTest3 = CommonFunc.getComponentRect('MarginText3');
let TextTest4 = CommonFunc.getComponentRect('MarginText4');
expect(locationText1.left - locationList.left).assertEqual(vp2px(10));
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(Math.round(locationText1.top - locationList.top)).assertEqual(vp2px(10));
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(30));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
expect(locationText1.left).assertEqual(TextTest1.left);
expect(locationText1.top).assertEqual(TextTest1.top);
expect(locationText1.right).assertEqual(TextTest1.right);
expect(locationText1.bottom).assertEqual(TextTest1.bottom);
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest14');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemMargin END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_Offset() {
describe('ListItem_OffsetTest', function () {
beforeEach(async function (done) {
console.info("ListItem_Offset beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_Offset',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_Offset state pages:" + JSON.stringify(pages));
if (!("ListItem_Offset" == pages.name)) {
console.info("get ListItem_Offset state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_Offset page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_Offset page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_Offset afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_OFFSET_TEST_0100
* @tc.name testListItemOffset
* @tc.desc ListItem subcomponent binding offset property
*/
it('testListItemOffset', 0, async function (done) {
console.info('new testListItemOffset START');
globalThis.value.message.notify({name:'x', value:10})
globalThis.value.message.notify({name:'y', value:10})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemOffset1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest61');
let locationText2 = CommonFunc.getComponentRect('ListItemTest62');
let locationText3 = CommonFunc.getComponentRect('ListItemTest63');
let locationText4 = CommonFunc.getComponentRect('ListItemTest64');
let locationList = CommonFunc.getComponentRect('ListItemOffset1');
expect(Math.round(locationText2.left - locationList.left)).assertEqual(vp2px(10));
expect(locationText1.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(Math.round(locationText2.top - locationText1.bottom) - vp2px(20)).assertEqual(vp2px(10));
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(30));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(10));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest64');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemOffset END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_PadMar() {
describe('ListItem_PadMarTest', function () {
beforeEach(async function (done) {
console.info("ListItem_PadMar beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_PadMar',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_PadMar state pages:" + JSON.stringify(pages));
if (!("ListItem_PadMar" == pages.name)) {
console.info("get ListItem_PadMar state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_PadMar page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_PadMar page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_PadMar afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_PADMAR_TEST_0100
* @tc.name testListItemPadMar
* @tc.desc ListItem subcomponent binding padding and margin properties
*/
it('testListItemPadMar', 0, async function (done) {
console.info('new testListItemPadMar START');
globalThis.value.message.notify({name:'margin', value:10})
globalThis.value.message.notify({name:'padding', value:10})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemPadMar1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest31');
let locationText2 = CommonFunc.getComponentRect('ListItemTest32');
let locationText3 = CommonFunc.getComponentRect('ListItemTest33');
let locationText4 = CommonFunc.getComponentRect('ListItemTest34');
let locationList = CommonFunc.getComponentRect('ListItemPadMar1');
let TextTest1 = CommonFunc.getComponentRect('PadMarText1');
let TextTest2 = CommonFunc.getComponentRect('PadMarText2');
let TextTest3 = CommonFunc.getComponentRect('PadMarText3');
let TextTest4 = CommonFunc.getComponentRect('PadMarText4');
expect(Math.round(locationText1.left - locationList.left)).assertEqual(vp2px(10));
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(Math.round(locationText1.top - locationList.top)).assertEqual(vp2px(10));
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(30));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
expect(Math.round(TextTest1.left - locationText1.left)).assertEqual(vp2px(10));
expect(Math.round(TextTest1.top - locationText1.top)).assertEqual(vp2px(10));
expect(Math.round(locationText1.right - TextTest1.right)).assertEqual(vp2px(10));
expect(Math.round(locationText1.bottom - TextTest1.bottom)).assertEqual(vp2px(10));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest34');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemPadMar END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_Padding() {
describe('ListItem_PaddingTest', function () {
beforeEach(async function (done) {
console.info("ListItem_Padding beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_Padding',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_Padding state pages:" + JSON.stringify(pages));
if (!("ListItem_Padding" == pages.name)) {
console.info("get ListItem_Padding state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_Padding page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_Padding page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_Padding afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_PADDING_TEST_0100
* @tc.name testListItemPadding
* @tc.desc ListItem subcomponent binding padding property
*/
it('testListItemPadding', 0, async function (done) {
console.info('new testListItemPadding START');
globalThis.value.message.notify({name:'padding', value:10})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemPadding1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest21');
let locationText2 = CommonFunc.getComponentRect('ListItemTest22');
let locationText3 = CommonFunc.getComponentRect('ListItemTest23');
let locationText4 = CommonFunc.getComponentRect('ListItemTest24');
let locationList = CommonFunc.getComponentRect('ListItemPadding1');
let TextTest1 = CommonFunc.getComponentRect('PaddingText1');
let TextTest2 = CommonFunc.getComponentRect('PaddingText2');
let TextTest3 = CommonFunc.getComponentRect('PaddingText3');
let TextTest4 = CommonFunc.getComponentRect('PaddingText4');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
expect(Math.round(TextTest1.left - locationText1.left)).assertEqual(vp2px(10));
expect(Math.round(TextTest1.top - locationText1.top)).assertEqual(vp2px(10));
expect(Math.round(locationText1.right - TextTest1.right)).assertEqual(vp2px(10));
expect(Math.round(locationText1.bottom - TextTest1.bottom)).assertEqual(vp2px(10));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest24');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemPadding END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_Position() {
describe('ListItem_PositionTest', function () {
beforeEach(async function (done) {
console.info("ListItem_Position beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_Position',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_Position state pages:" + JSON.stringify(pages));
if (!("ListItem_Position" == pages.name)) {
console.info("get ListItem_Position state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_Position page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_Position page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_Position afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_POSITION_TEST_0100
* @tc.name testListItemPosition
* @tc.desc ListItem subcomponent binding position property
*/
it('testListItemPosition', 0, async function (done) {
console.info('new testListItemPosition START');
globalThis.value.message.notify({name:'x', value:10})
globalThis.value.message.notify({name:'y', value:10})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemPosition1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest51');
let locationText2 = CommonFunc.getComponentRect('ListItemTest52');
let locationText3 = CommonFunc.getComponentRect('ListItemTest53');
let locationText4 = CommonFunc.getComponentRect('ListItemTest54');
let locationList = CommonFunc.getComponentRect('ListItemPosition1');
expect(Math.round(locationText1.left - locationList.left)).assertEqual(vp2px(10));
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(Math.round(locationText1.top - locationList.top)).assertEqual(vp2px(10));
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(10));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest54');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemPosition END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_SizeChange() {
describe('ListItem_SizeChangeTest', function () {
beforeEach(async function (done) {
console.info("ListItem_SizeChange beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_SizeChange',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_SizeChange state pages:" + JSON.stringify(pages));
if (!("ListItem_SizeChange" == pages.name)) {
console.info("get ListItem_SizeChange state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_SizeChange page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_SizeChange page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_SizeChange afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_SIZECHANGE_TEST_0100
* @tc.name testListItemSizeChangeHeight120Width300
* @tc.desc The ListItem subcomponent changes the width 300 and height 120 attributes
*/
it('testListItemSizeChangeHeight120Width300', 0, async function (done) {
console.info('new testListItemSizeChangeHeight120Width300 START');
globalThis.value.message.notify({name:'height', value:120})
globalThis.value.message.notify({name:'width', value:300})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemSizeChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest1');
let locationText2 = CommonFunc.getComponentRect('ListItemTest2');
let locationText3 = CommonFunc.getComponentRect('ListItemTest3');
let locationText4 = CommonFunc.getComponentRect('ListItemTest4');
let locationList = CommonFunc.getComponentRect('ListItemSizeChange1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(120));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest4');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemSizeChangeHeight120Width300 END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_SIZECHANGE_TEST_0200
* @tc.name testListItemSizeChangeHeight160Width300
* @tc.desc The ListItem subcomponent changes the width 300 and height 160 attributes
*/
it('testListItemSizeChangeHeight160Width300', 0, async function (done) {
console.info('new testListItemSizeChangeHeight160Width300 START');
globalThis.value.message.notify({name:'height', value:160})
globalThis.value.message.notify({name:'width', value:300})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemSizeChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest1');
let locationText2 = CommonFunc.getComponentRect('ListItemTest2');
let locationText3 = CommonFunc.getComponentRect('ListItemTest3');
let locationText4 = CommonFunc.getComponentRect('ListItemTest4');
let locationList = CommonFunc.getComponentRect('ListItemSizeChange1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(160));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.bottom - locationList.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
await CommonFunc.sleep(1000);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest4');
expect(locationText4Again.bottom).assertEqual(locationList.bottom);
console.info('new testListItemSizeChangeHeight160Width300 END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_SIZECHANGE_TEST_0300
* @tc.name testListItemSizeChangeHeight100Width100
* @tc.desc The ListItem subcomponent changes the width 100 and height 100 attributes
*/
it('testListItemSizeChangeHeight100Width100', 0, async function (done) {
console.info('new testListItemSizeChangeHeight100Width100 START');
globalThis.value.message.notify({name:'height', value:100})
globalThis.value.message.notify({name:'width', value:100})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemSizeChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest1');
let locationText2 = CommonFunc.getComponentRect('ListItemTest2');
let locationText3 = CommonFunc.getComponentRect('ListItemTest3');
let locationText4 = CommonFunc.getComponentRect('ListItemTest4');
let locationList = CommonFunc.getComponentRect('ListItemSizeChange1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(100));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest4');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemSizeChangeHeight100Width100 END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_SIZECHANGE_TEST_0400
* @tc.name testListItemSizeChangeHeight100Width380
* @tc.desc The ListItem subcomponent changes the width 380 and height 100 attributes
*/
it('testListItemSizeChangeHeight100Width380', 0, async function (done) {
console.info('new testListItemSizeChangeHeight100Width380 START');
globalThis.value.message.notify({name:'height', value:100})
globalThis.value.message.notify({name:'width', value:380})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemSizeChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest1');
let locationText2 = CommonFunc.getComponentRect('ListItemTest2');
let locationText3 = CommonFunc.getComponentRect('ListItemTest3');
let locationText4 = CommonFunc.getComponentRect('ListItemTest4');
let locationList = CommonFunc.getComponentRect('ListItemSizeChange1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(380));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest4');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemSizeChangeHeight100Width380 END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_SIZECHANGE_TEST_0500
* @tc.name testListItemSizeChangeHeight160Width380
* @tc.desc The ListItem subcomponent changes the width 380 and height 100 attributes
*/
it('testListItemSizeChangeHeight160Width380', 0, async function (done) {
console.info('new testListItemSizeChangeHeight160Width380 START');
globalThis.value.message.notify({name:'height', value:160})
globalThis.value.message.notify({name:'width', value:380})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemSizeChange1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let locationText1 = CommonFunc.getComponentRect('ListItemTest1');
let locationText2 = CommonFunc.getComponentRect('ListItemTest2');
let locationText3 = CommonFunc.getComponentRect('ListItemTest3');
let locationText4 = CommonFunc.getComponentRect('ListItemTest4');
let locationList = CommonFunc.getComponentRect('ListItemSizeChange1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(380));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(160));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(100));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(100));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(100));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.bottom - locationList.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
await CommonFunc.sleep(1000);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest4');
expect(locationText4Again.bottom).assertEqual(locationList.bottom);
console.info('new testListItemSizeChangeHeight160Width380 END');
done();
});
})
}
\ No newline at end of file
/*
* Copyright (c) 2023 iSoftStone Information Technology (Group) 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 "@ohos/hypium";
import router from '@system.router';
import CommonFunc from '../../../../MainAbility/common/Common';
import { MessageManager, Callback } from '../../../../MainAbility/common/MessageManager';
import { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection,
WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function listItem_Visibility() {
describe('ListItem_VisibilityTest', function () {
beforeEach(async function (done) {
console.info("ListItem_Visibility beforeEach called");
let options = {
uri: 'MainAbility/pages/List/List_Space/ListItemChange/ListItem_Visibility',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get ListItem_Visibility state pages:" + JSON.stringify(pages));
if (!("ListItem_Visibility" == pages.name)) {
console.info("get ListItem_Visibility state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push ListItem_Visibility page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push ListItem_Visibility page error:" + JSON.stringify(err));
}
await CommonFunc.sleep(2000);
done()
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("ListItem_Visibility afterEach called");
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_VISIBILITY_TEST_0100
* @tc.name testListItemVisibilityFirstNone
* @tc.desc ListItem subcomponent binding Visibility property,first None
*/
it('testListItemVisibilityFirstNone', 0, async function (done) {
console.info('new testListItemVisibilityFirstNone START');
globalThis.value.message.notify({name:'testVisibilityFirst', value:Visibility.None})
globalThis.value.message.notify({name:'testVisibilitySecond', value:Visibility.Visible})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemVisibility1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let strJson2 = getInspectorByKey('ListItemTest41');
let obj2 = JSON.parse(strJson2);
expect(obj2.$attrs.visibility).assertEqual('Visibility.None');
let locationText1 = CommonFunc.getComponentRect('ListItemTest41');
let locationText2 = CommonFunc.getComponentRect('ListItemTest42');
let locationText3 = CommonFunc.getComponentRect('ListItemTest43');
let locationText4 = CommonFunc.getComponentRect('ListItemTest44');
let locationList = CommonFunc.getComponentRect('ListItemVisibility1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(locationText1.left).assertEqual(locationText1.right);
expect(locationText1.top).assertEqual(locationText1.bottom);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(0));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(0));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(120));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(120));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(120));
expect(Math.round(locationText1.top - locationList.top)).assertEqual(vp2px(0));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(80));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest44');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemVisibilityFirstNone END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_VISIBILITY_TEST_0200
* @tc.name testListItemVisibilitySecondNone
* @tc.desc ListItem subcomponent binding Visibility property,second None
*/
it('testListItemVisibilitySecondNone', 0, async function (done) {
console.info('new testListItemVisibilitySecondNone START');
globalThis.value.message.notify({name:'testVisibilityFirst', value:Visibility.Visible})
globalThis.value.message.notify({name:'testVisibilitySecond', value:Visibility.None})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemVisibility1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let strJson2 = getInspectorByKey('ListItemTest42');
let obj2 = JSON.parse(strJson2);
expect(obj2.$attrs.visibility).assertEqual('Visibility.None');
let locationText1 = CommonFunc.getComponentRect('ListItemTest41');
let locationText2 = CommonFunc.getComponentRect('ListItemTest42');
let locationText3 = CommonFunc.getComponentRect('ListItemTest43');
let locationText4 = CommonFunc.getComponentRect('ListItemTest44');
let locationList = CommonFunc.getComponentRect('ListItemVisibility1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(locationText2.left).assertEqual(locationText2.right);
expect(locationText2.top).assertEqual(locationText2.bottom);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(120));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(0));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(0));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(120));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(120));
expect(Math.round(locationText1.top - locationList.top)).assertEqual(vp2px(0));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationList.bottom - locationText4.bottom)).assertEqual(vp2px(80));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest44');
expect(locationText4.top).assertEqual(locationText4Again.top);
console.info('new testListItemVisibilitySecondNone END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_VISIBILITY_TEST_0300
* @tc.name testListItemVisibilityFirstHidden
* @tc.desc ListItem subcomponent binding Visibility property,first Hidden
*/
it('testListItemVisibilityFirstHidden', 0, async function (done) {
console.info('new testListItemVisibilityFirstHidden START');
globalThis.value.message.notify({name:'testVisibilityFirst', value:Visibility.Hidden})
globalThis.value.message.notify({name:'testVisibilitySecond', value:Visibility.Visible})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemVisibility1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let strJson2 = getInspectorByKey('ListItemTest41');
let obj2 = JSON.parse(strJson2);
expect(obj2.$attrs.visibility).assertEqual('Visibility.Hidden');
let locationText1 = CommonFunc.getComponentRect('ListItemTest41');
let locationText2 = CommonFunc.getComponentRect('ListItemTest42');
let locationText3 = CommonFunc.getComponentRect('ListItemTest43');
let locationText4 = CommonFunc.getComponentRect('ListItemTest44');
let locationList = CommonFunc.getComponentRect('ListItemVisibility1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(120));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(120));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(120));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(120));
expect(Math.round(locationText2.top - locationList.top)).assertEqual(vp2px(140));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.bottom - locationList.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
await CommonFunc.sleep(1000);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest44');
expect(locationText4Again.bottom).assertEqual(locationList.bottom);
await driver.swipe(360, 150, 360, 690);
await CommonFunc.sleep(2000);
console.info('new testListItemVisibilityFirstHidden END');
done();
});
/**
* @tc.number SUB_ACE_LIST_LISTITEM_VISIBILITY_TEST_0400
* @tc.name testListItemVisibilityFirstVisibile
* @tc.desc ListItem subcomponent binding Visibility property,first Visible
*/
it('testListItemVisibilityFirstVisibile', 0, async function (done) {
console.info('new testListItemVisibilityFirstVisibile START');
globalThis.value.message.notify({name:'testVisibilityFirst', value:Visibility.Visible})
globalThis.value.message.notify({name:'testVisibilitySecond', value:Visibility.Visible})
await CommonFunc.sleep(3000);
let strJson = getInspectorByKey('ListItemVisibility1');
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('List');
let strJson2 = getInspectorByKey('ListItemTest41');
let obj2 = JSON.parse(strJson2);
expect(obj2.$attrs.visibility).assertEqual('Visibility.Visible');
let locationText1 = CommonFunc.getComponentRect('ListItemTest41');
let locationText2 = CommonFunc.getComponentRect('ListItemTest42');
let locationText3 = CommonFunc.getComponentRect('ListItemTest43');
let locationText4 = CommonFunc.getComponentRect('ListItemTest44');
let locationList = CommonFunc.getComponentRect('ListItemVisibility1');
expect(locationText1.left).assertEqual(locationText2.left);
expect(locationText2.left).assertEqual(locationText3.left);
expect(locationText3.left).assertEqual(locationText4.left);
expect(locationText4.left).assertEqual(locationList.left);
expect(locationText1.top).assertEqual(locationList.top);
expect(Math.round(locationText1.right - locationText1.left)).assertEqual(vp2px(300));
expect(Math.round(locationText1.bottom - locationText1.top)).assertEqual(vp2px(120));
expect(Math.round(locationText2.right - locationText2.left)).assertEqual(vp2px(300));
expect(Math.round(locationText2.bottom - locationText2.top)).assertEqual(vp2px(120));
expect(Math.round(locationText3.right - locationText3.left)).assertEqual(vp2px(300));
expect(Math.round(locationText3.bottom - locationText3.top)).assertEqual(vp2px(120));
expect(Math.round(locationText4.right - locationText4.left)).assertEqual(vp2px(300));
expect(Math.round(locationText4.bottom - locationText4.top)).assertEqual(vp2px(120));
expect(Math.round(locationText2.top - locationText1.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText3.top - locationText2.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.top - locationText3.bottom)).assertEqual(vp2px(20));
expect(Math.round(locationText4.bottom - locationList.bottom)).assertEqual(vp2px(40));
expect(Math.round(locationList.right - locationList.left)).assertEqual(vp2px(350));
expect(Math.round(locationList.bottom - locationList.top)).assertEqual(vp2px(500));
let driver = await Driver.create();
await driver.swipe(360, 690, 360, 30);
await CommonFunc.sleep(1000);
let locationText4Again = CommonFunc.getComponentRect('ListItemTest44');
expect(locationText4Again.bottom).assertEqual(locationList.bottom);
await driver.swipe(360, 150, 360, 690);
await CommonFunc.sleep(1000);
console.info('new testListItemVisibilityFirstVisibile END');
done();
});
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册