提交 61ea1591 编写于 作者: W wmlih

test:test:add grid_griditemchange xts_acts testcase

Signed-off-by: Nwmlih <wmlih@isoftstone.com>
上级 e8f139c5
/**
* 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 Grid_RowCol_ItemColumnStartEnd{
@State textNumber: String[] = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'];
@State testColumnStart: number = 0;
@State testColumnEnd: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemColumnStartEnd onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'ColumnStart') {
this.testColumnStart = message.value;
}
if (message.name == 'ColumnEnd') {
this.testColumnEnd = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.rowStart(0)
.rowEnd(0)
.columnStart(this.testColumnStart)
.columnEnd(this.testColumnEnd)
.key('Grid_RowCol_ItemColumnStartEnd1')
ForEach(this.textNumber, (item: string) => {
GridItem() {
Text(item)
.backgroundColor(0xF5DEB3)
.width('100%')
.height('100%')
}
.key('Grid_RowCol_ItemColumnStartEnd'+ item)
}, item => item)
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemColumnStartEnd_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 Grid_RowCol_ItemContentSize{
@State secondGridItemContentHeight: string = '%100';
@State secondGridItemContentWidth: string = '%100';
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemContentSize onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'secondGridItemContentHeight') {
this.secondGridItemContentHeight = message.value;
}
if (message.name == 'secondGridItemContentWidth') {
this.secondGridItemContentWidth = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemContentSize01')
GridItem() {
Text('2')
.width(this.secondGridItemContentWidth)
.height(this.secondGridItemContentHeight)
.backgroundColor(0xD2B48C)
.key('Grid_RowCol_ItemContentSize_Text02')
}
.backgroundColor(0xF5DEB3)
.key('Grid_RowCol_ItemContentSize02')
GridItem() {
Text('3').width('100%').height('100%').backgroundColor(0xD2B48C)
}
.key('Grid_RowCol_ItemContentSize03')
GridItem() {
Text('4').width('100%').height('100%').backgroundColor(0xF5DEB3)
}
.key('Grid_RowCol_ItemContentSize04')
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr')
.rowsTemplate('1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemContentSize_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 Grid_RowCol_ItemOffset{
@State secondGridItemOffset: object = {x:0,y:0};
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemOffset onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'secondGridItemOffset') {
this.secondGridItemOffset = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemOffset01')
GridItem() {
Text('2').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.offset(this.secondGridItemOffset)
.key('Grid_RowCol_ItemOffset02')
GridItem() {
Text('3').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.key('Grid_RowCol_ItemOffset03')
GridItem() {
Text('4').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemOffset04')
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr')
.rowsTemplate('1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemOffset_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 Grid_RowCol_ItemPadMar{
@State secondGridItemPadding: number = 0;
@State secondGridItemMargin: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemPadMar onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'secondGridItemPadding') {
this.secondGridItemPadding = message.value;
}
if (message.name == 'secondGridItemMargin') {
this.secondGridItemMargin = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemPadMar01')
GridItem() {
Text('2').width('100%').height('100%').backgroundColor(0xD2B48C).key('Grid_RowCol_ItemPadMar_Text02');
}
.padding(this.secondGridItemPadding)
.margin(this.secondGridItemMargin)
.backgroundColor(0xF5DEB3)
.key('Grid_RowCol_ItemPadMar02')
GridItem() {
Text('3').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.key('Grid_RowCol_ItemPadMar03')
GridItem() {
Text('4').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemPadMar04')
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr')
.rowsTemplate('1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemPadMar_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 Grid_RowCol_ItemPosition{
@State secondGridItemPosition: object = {x:0,y:0};
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemPosition onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'secondGridItemPosition') {
this.secondGridItemPosition = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemPosition01')
GridItem() {
Text('2').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.position(this.secondGridItemPosition)
.key('Grid_RowCol_ItemPosition02')
GridItem() {
Text('3').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.key('Grid_RowCol_ItemPosition03')
GridItem() {
Text('4').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemPosition04')
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr')
.rowsTemplate('1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemPosition_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 Grid_RowCol_ItemRowStartEnd{
@State textNumber: String[] = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'];
@State testRowStart: number = 0;
@State testRowEnd: number = 0;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemStartEnd onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'RowStart') {
this.testRowStart = message.value;
}
if (message.name == 'RowEnd') {
this.testRowEnd = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.rowStart(this.testRowStart)
.rowEnd(this.testRowEnd)
.columnStart(0)
.columnEnd(0)
.key('Grid_RowCol_ItemRowStartEnd1')
ForEach(this.textNumber, (item: string) => {
GridItem() {
Text(item)
.backgroundColor(0xF5DEB3)
.width('100%')
.height('100%')
}
.key('Grid_RowCol_ItemRowStartEnd'+ item)
}, item => item)
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemRowStartEnd_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 Grid_RowCol_ItemVisibility{
@State secondGridItemVisibility: number = Visibility.Visible;
messageManager:MessageManager = new MessageManager();
onPageShow() {
console.info('Grid_RowCol_ItemVisibility onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.log('message = ' + message.name + "--" + message.value);
if (message.name == 'secondGridItemVisibility') {
this.secondGridItemVisibility = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build(){
Column({space:30}){
Grid(){
GridItem() {
Text('1').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemVisibility01')
GridItem() {
Text('2').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.visibility(this.secondGridItemVisibility)
.key('Grid_RowCol_ItemVisibility02')
GridItem() {
Text('3').width('100%').height('100%').backgroundColor(0xD2B48C);
}
.key('Grid_RowCol_ItemVisibility03')
GridItem() {
Text('4').width('100%').height('100%').backgroundColor(0xF5DEB3);
}
.key('Grid_RowCol_ItemVisibility04')
}
.width(300)
.height(300)
.columnsTemplate('1fr 1fr')
.rowsTemplate('1fr 1fr')
.backgroundColor(0xAFEEEE)
.key('Grid_RowCol_ItemVisibility_Container01')
}
.width('100%')
.height('100%')
}
}
\ 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemColumnStartEndTest() {
describe('Grid_RowCol_ItemColumnStartEndTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemColumnStartEndTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemColumnStartEnd',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemColumnStartEnd state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemColumnStartEnd" == pages.name)) {
console.info("get Grid_RowCol_ItemColumnStartEnd state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemColumnStartEnd page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemColumnStartEnd page error:" + err);
}
console.info("Grid_RowCol_ItemColumnStartEndTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemColumnStartEndTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_1200
* @tc.name testGridRowColItemColumnStartToZeroEndToThree
* @tc.desc The first griditem set columnStart to 0,columnEnd to 3
*/
it('testGridRowColItemColumnStartToZeroEndToThree', 0, async function (done) {
console.info('[testGridRowColItemColumnStartToZeroEndToThree] START');
globalThis.value.message.notify({name:'ColumnStart', value:0});
globalThis.value.message.notify({name:'ColumnEnd', value:3});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd1');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd2');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd3');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd4');
let fifthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd5');
let sixthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd6');
let seventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd7');
let eighthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd8');
let ninthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd9');
let tenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd10');
let eleventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd11');
let twelfthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd12');
let thirteenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd13');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemColumnStartEnd_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(300));
expect(Math.round((firstGridItem.bottom - firstGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top); //firstGridItem
expect(Math.round((secondGridItem.right - secondGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((secondGridItem.bottom - secondGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(secondGridItem.left).assertEqual(gridContainer.left);
expect(secondGridItem.top).assertEqual(firstGridItem.bottom);
expect(Math.round((thirdGridItem.right - thirdGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirdGridItem.left).assertEqual(secondGridItem.right);
expect(thirdGridItem.top).assertEqual(secondGridItem.top);
expect(thirdGridItem.bottom).assertEqual(secondGridItem.bottom);
expect(Math.round((fourthGridItem.right - fourthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(secondGridItem.top);
expect(fourthGridItem.bottom).assertEqual(secondGridItem.bottom);
expect(Math.round((fifthGridItem.right - fifthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fifthGridItem.left).assertEqual(fourthGridItem.right);
expect(fifthGridItem.right).assertEqual(gridContainer.right);
expect(fifthGridItem.top).assertEqual(secondGridItem.top);
expect(fifthGridItem.bottom).assertEqual(secondGridItem.bottom); //first row
expect(Math.round((sixthGridItem.right - sixthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((sixthGridItem.bottom - sixthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(sixthGridItem.left).assertEqual(gridContainer.left);
expect(sixthGridItem.top).assertEqual(secondGridItem.bottom);
expect(Math.round((seventhGridItem.right - seventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(seventhGridItem.left).assertEqual(sixthGridItem.right);
expect(seventhGridItem.top).assertEqual(sixthGridItem.top);
expect(seventhGridItem.bottom).assertEqual(sixthGridItem.bottom);
expect(Math.round((eighthGridItem.right - eighthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eighthGridItem.left).assertEqual(seventhGridItem.right);
expect(eighthGridItem.top).assertEqual(sixthGridItem.top);
expect(eighthGridItem.bottom).assertEqual(sixthGridItem.bottom);
expect(Math.round((ninthGridItem.right - ninthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(ninthGridItem.left).assertEqual(eighthGridItem.right);
expect(ninthGridItem.top).assertEqual(sixthGridItem.top);
expect(ninthGridItem.bottom).assertEqual(sixthGridItem.bottom);
expect(Math.round((tenthGridItem.right - tenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((tenthGridItem.bottom - tenthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(tenthGridItem.left).assertEqual(gridContainer.left);
expect(tenthGridItem.top).assertEqual(sixthGridItem.bottom);
expect(Math.round((eleventhGridItem.right - eleventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eleventhGridItem.left).assertEqual(tenthGridItem.right);
expect(eleventhGridItem.top).assertEqual(tenthGridItem.top);
expect(eleventhGridItem.bottom).assertEqual(tenthGridItem.bottom);
expect(Math.round((twelfthGridItem.right - twelfthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(twelfthGridItem.left).assertEqual(eleventhGridItem.right);
expect(twelfthGridItem.top).assertEqual(tenthGridItem.top);
expect(twelfthGridItem.bottom).assertEqual(tenthGridItem.bottom);
expect(Math.round((thirteenthGridItem.right - thirteenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirteenthGridItem.left).assertEqual(twelfthGridItem.right);
expect(thirteenthGridItem.top).assertEqual(tenthGridItem.top);
expect(thirteenthGridItem.bottom).assertEqual(gridContainer.bottom); //third row
console.info('[testGridRowColItemColumnStartToZeroEndToThree] END');
done();
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_1300
* @tc.name testGridRowColItemColumnStartToZeroEndToTwo
* @tc.desc The first griditem set columnStart to 0,columnEnd to 2
*/
it('testGridRowColItemColumnStartToZeroEndToTwo', 0, async function (done) {
console.info('[testGridRowColItemColumnStartToZeroEndToTwo] START');
globalThis.value.message.notify({name:'ColumnStart', value:0});
globalThis.value.message.notify({name:'ColumnEnd', value:2});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd1');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd2');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd3');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd4');
let fifthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd5');
let sixthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd6');
let seventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd7');
let eighthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd8');
let ninthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd9');
let tenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd10');
let eleventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd11');
let twelfthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd12');
let thirteenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd13');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemColumnStartEnd_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemColumnStartEnd_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round((firstGridItem.right - firstGridItem.left)*10)/10).assertEqual(Math.round(vp2px(225)*10)/10);
expect(Math.round((firstGridItem.bottom - firstGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top); //firstGridItem
expect(secondGridItem.left).assertEqual(firstGridItem.right);
expect(secondGridItem.right).assertEqual(gridContainer.right);
expect(secondGridItem.top).assertEqual(gridContainer.top);
expect(secondGridItem.bottom).assertEqual(firstGridItem.bottom); //first Row
expect(Math.round((thirdGridItem.right - thirdGridItem.left )*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((thirdGridItem.bottom - thirdGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(Math.round((fourthGridItem.right - fourthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(fourthGridItem.bottom).assertEqual(thirdGridItem.bottom);
expect(Math.round((fifthGridItem.right - fifthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fifthGridItem.left).assertEqual(fourthGridItem.right);
expect(fifthGridItem.top).assertEqual(thirdGridItem.top);
expect(fifthGridItem.bottom).assertEqual(thirdGridItem.bottom);
expect(Math.round((sixthGridItem.right - sixthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(sixthGridItem.left).assertEqual(fifthGridItem.right);
expect(sixthGridItem.right).assertEqual(gridContainer.right);
expect(sixthGridItem.top).assertEqual(thirdGridItem.top);
expect(sixthGridItem.bottom).assertEqual(thirdGridItem.bottom); //second row
expect(Math.round((seventhGridItem.right - seventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((seventhGridItem.bottom - seventhGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(seventhGridItem.left).assertEqual(gridContainer.left);
expect(seventhGridItem.top).assertEqual(thirdGridItem.bottom);
expect(Math.round((eighthGridItem.right - eighthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eighthGridItem.left).assertEqual(seventhGridItem.right);
expect(eighthGridItem.top).assertEqual(seventhGridItem.top);
expect(eighthGridItem.bottom).assertEqual(seventhGridItem.bottom);
expect(Math.round((ninthGridItem.right - ninthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(ninthGridItem.left).assertEqual(eighthGridItem.right);
expect(ninthGridItem.top).assertEqual(seventhGridItem.top);
expect(ninthGridItem.bottom).assertEqual(seventhGridItem.bottom);
expect(Math.round((tenthGridItem.right - tenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(tenthGridItem.left).assertEqual(ninthGridItem.right);
expect(tenthGridItem.top).assertEqual(seventhGridItem.top);
expect(tenthGridItem.bottom).assertEqual(seventhGridItem.bottom); //third row
expect(Math.round((eleventhGridItem.right - eleventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((eleventhGridItem.bottom - eleventhGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eleventhGridItem.left).assertEqual(gridContainer.left);
expect(eleventhGridItem.top).assertEqual(seventhGridItem.bottom);
expect(Math.round((twelfthGridItem.right - twelfthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(twelfthGridItem.left).assertEqual(eleventhGridItem.right);
expect(twelfthGridItem.top).assertEqual(eleventhGridItem.top);
expect(twelfthGridItem.bottom).assertEqual(eleventhGridItem.bottom);
expect(Math.round((thirteenthGridItem.right - thirteenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirteenthGridItem.left).assertEqual(twelfthGridItem.right);
expect(thirteenthGridItem.top).assertEqual(eleventhGridItem.top);
expect(thirteenthGridItem.bottom).assertEqual(gridContainer.bottom); //fourth row
console.info('[testGridRowColItemColumnStartToZeroEndToTwo] END');
done();
});
})
}
/**
* 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemContentSizeTest() {
describe('Grid_RowCol_ItemContentSizeTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemContentSizeTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemContentSize',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemContentSize state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemContentSize" == pages.name)) {
console.info("get Grid_RowCol_ItemContentSize state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemContentSize page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemContentSize page error:" + err);
}
console.info("Grid_RowCol_ItemContentSizeTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemContentSizeTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0900
* @tc.name testGridRowColItemContentSize
* @tc.desc The second griditem set width to '50%',height to '50%'
*/
it('testGridRowColItemContentSize', 0, async function (done) {
console.info('[testGridRowColItemContentSize] START');
globalThis.value.message.notify({name:'secondGridItemContentHeight', value:'50%'});
globalThis.value.message.notify({name:'secondGridItemContentWidth', value:'50%'});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemContentSize01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemContentSize02');
let secondGridItemText = CommonFunc.getComponentRect('Grid_RowCol_ItemContentSize_Text02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemContentSize03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemContentSize04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemContentSize_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemContentSize_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round((secondGridItemText.right - secondGridItemText.left)*10)/10)
.assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((secondGridItemText.bottom - secondGridItemText.top)*10)/10)
.assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round(secondGridItemText.left - secondGridItem.left))
.assertEqual(Math.round(secondGridItem.right - secondGridItemText.right));
expect(Math.round(secondGridItemText.top - secondGridItem.top))
.assertEqual(Math.round(secondGridItem.bottom - secondGridItemText.bottom));
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(secondGridItem.left).assertEqual(firstGridItem.right);
expect(secondGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemContentSize] END');
done();
});
})
}
/**
* 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemOffsetTest() {
describe('Grid_RowCol_ItemOffsetTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemOffsetTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemOffset',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemOffset state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemOffset" == pages.name)) {
console.info("get Grid_RowCol_ItemOffset state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemOffset page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemOffset page error:" + err);
}
console.info("Grid_RowCol_ItemOffsetTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemOffsetTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0400
* @tc.name testGridRowColItemOffset
* @tc.desc The second griditem set offset to {x:20,y:20}
*/
it('testGridRowColItemOffset', 0, async function (done) {
console.info('[testGridRowColItemOffset] START');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemOffset02');
let secondGridItemTop = secondGridItem.top;
let secondGridItemLeft = secondGridItem.left;
globalThis.value.message.notify({name:'secondGridItemOffset', value:{x:20,y:20}});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemOffset01');
secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemOffset02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemOffset03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemOffset04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemOffset_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemOffset_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round(secondGridItem.left - secondGridItemLeft)).assertEqual(vp2px(20));
expect(Math.round(secondGridItem.top - secondGridItemTop)).assertEqual(vp2px(20)); //offset {x:20,y:20}
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemOffset] END');
done();
});
})
}
/**
* 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemPadMarTest() {
describe('Grid_RowCol_ItemPadMarTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemPadMarTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemPadMar',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemPadMar state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemPadMar" == pages.name)) {
console.info("get Grid_RowCol_ItemPadMar state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemPadMar page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemPadMar page error:" + err);
}
console.info("Grid_RowCol_ItemPadMarTest beforeEach end");
done();
});
afterEach(async function () {
globalThis.value.message.notify({name:'secondGridItemPadding', value:0});
globalThis.value.message.notify({name:'secondGridItemMargin', value:0});
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemPadMarTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0100
* @tc.name testGridRowColItemMargin
* @tc.desc The second griditem set margin to 10
*/
it('testGridRowColItemMargin', 0, async function (done) {
console.info('[testGridRowColItemMargin] START');
globalThis.value.message.notify({name:'secondGridItemMargin', value:10});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar02');
let secondText = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar_Text02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemPadMar_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round(secondGridItem.left - firstGridItem.right)).assertEqual(vp2px(10));
expect(Math.round(secondGridItem.top - gridContainer.top)).assertEqual(vp2px(10)); //margin = 10
expect(secondGridItem.left).assertEqual(secondText.left);
expect(secondGridItem.top).assertEqual(secondText.top);
expect(Math.round(secondGridItem.right - secondGridItem.left))
.assertEqual(Math.round(secondText.right - secondText.left));
expect(Math.round(secondGridItem.bottom - secondGridItem.top))
.assertEqual(Math.round(secondText.bottom - secondText.top));
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(130));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(130));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemMargin] END');
done();
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0200
* @tc.name testGridRowColItemPadding
* @tc.desc The second griditem set padding to 10
*/
it('testGridRowColItemPadding', 0, async function (done) {
console.info('[testGridRowColItemPadding] START');
globalThis.value.message.notify({name:'secondGridItemPadding', value:10});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar02');
let secondText = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar_Text02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemPadMar_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round(secondText.left - secondGridItem.left)).assertEqual(vp2px(10));
expect(Math.round(secondText.top - secondGridItem.top)).assertEqual(vp2px(10));
expect(Math.round(secondGridItem.right - secondText.right)).assertEqual(vp2px(10));
expect(Math.round(secondGridItem.bottom - secondText.bottom)).assertEqual(vp2px(10)); //padding = 10
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(secondGridItem.left).assertEqual(firstGridItem.right);
expect(secondGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemPadding] END');
done();
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0300
* @tc.name testGridRowColItemMarPad
* @tc.desc The second griditem set padding to 10,margin to 10
*/
it('testGridRowColItemMarPad', 0, async function (done) {
console.info('[testGridRowColItemMarPad] START');
globalThis.value.message.notify({name:'secondGridItemPadding', value:10});
globalThis.value.message.notify({name:'secondGridItemMargin', value:10});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar02');
let secondText = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar_Text02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemPadMar_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemPadMar_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round(secondGridItem.left - firstGridItem.right)).assertEqual(vp2px(10));
expect(Math.round(secondGridItem.top - gridContainer.top)).assertEqual(vp2px(10)); //margin = 10
expect(Math.round(secondText.left - secondGridItem.left)).assertEqual(vp2px(10));
expect(Math.round(secondText.top - secondGridItem.top)).assertEqual(vp2px(10));
expect(Math.round(secondGridItem.right - secondText.right)).assertEqual(vp2px(10));
expect(Math.round(secondGridItem.bottom - secondText.bottom)).assertEqual(vp2px(10)); //padding = 10
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(130));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(130));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemMarPad] END');
done();
});
})
}
/**
* 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemPositionTest() {
describe('Grid_RowCol_ItemPositionTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemPositionTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemPosition',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemPosition state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemPosition" == pages.name)) {
console.info("get Grid_RowCol_ItemPosition state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemPosition page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemPosition page error:" + err);
}
console.info("Grid_RowCol_ItemPositionTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemPositionTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0500
* @tc.name testGridRowColItemPosition
* @tc.desc The second griditem set position to {x:20,y:20}
*/
it('testGridRowColItemPosition', 0, async function (done) {
console.info('[testGridRowColItemPosition] START');
globalThis.value.message.notify({name:'secondGridItemPosition', value:{x:20,y:20}});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPosition01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPosition02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPosition03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemPosition04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemPosition_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemPosition_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round(secondGridItem.left - gridContainer.left)).assertEqual(vp2px(20));
expect(Math.round(secondGridItem.top - gridContainer.top)).assertEqual(vp2px(20)); //position {x:20,y:20}
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemPosition] END');
done();
});
})
}
/**
* 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemRowStartEndTest() {
describe('Grid_RowCol_ItemRowStartEndTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemRowStartEndTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemRowStartEnd',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemRowStartEnd state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemRowStartEnd" == pages.name)) {
console.info("get Grid_RowCol_ItemRowStartEnd state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemRowStartEnd page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemRowStartEnd page error:" + err);
}
console.info("Grid_RowCol_ItemRowStartEndTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemRowStartEndTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_1000
* @tc.name testGridRowColItemRowStartToZeroEndToThree
* @tc.desc The first griditem set rowStart to 0,rowEnd to 3
*/
it('testGridRowColItemRowStartToZeroEndToThree', 0, async function (done) {
console.info('[testGridRowColItemRowStartToZeroEndToThree] START');
globalThis.value.message.notify({name:'RowStart', value:0});
globalThis.value.message.notify({name:'RowEnd', value:3});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd1');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd2');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd3');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd4');
let fifthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd5');
let sixthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd6');
let seventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd7');
let eighthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd8');
let ninthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd9');
let tenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd10');
let eleventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd11');
let twelfthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd12');
let thirteenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd13');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemRowStartEnd_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round((firstGridItem.right - firstGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(300));
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(Math.round((secondGridItem.right- secondGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((secondGridItem.bottom - secondGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(secondGridItem.left).assertEqual(firstGridItem.right);
expect(secondGridItem.top).assertEqual(firstGridItem.top);
expect(Math.round((thirdGridItem.right - thirdGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirdGridItem.left).assertEqual(secondGridItem.right);
expect(thirdGridItem.top).assertEqual(firstGridItem.top);
expect(thirdGridItem.bottom).assertEqual(secondGridItem.bottom);
expect(Math.round((fourthGridItem.right - fourthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(firstGridItem.top);
expect(fourthGridItem.bottom).assertEqual(secondGridItem.bottom);
expect(fourthGridItem.right).assertEqual(gridContainer.right); // first row
expect(Math.round((fifthGridItem.right - fifthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((fifthGridItem.bottom - fifthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fifthGridItem.left).assertEqual(firstGridItem.right);
expect(fifthGridItem.top).assertEqual(secondGridItem.bottom);
expect(Math.round((sixthGridItem.right - sixthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(sixthGridItem.left).assertEqual(fifthGridItem.right);
expect(sixthGridItem.top).assertEqual(fifthGridItem.top);
expect(sixthGridItem.bottom).assertEqual(fifthGridItem.bottom);
expect(Math.round((seventhGridItem.right - seventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(seventhGridItem.left).assertEqual(sixthGridItem.right);
expect(seventhGridItem.top).assertEqual(fifthGridItem.top);
expect(seventhGridItem.right).assertEqual(gridContainer.right); // second row
expect(Math.round((eighthGridItem.right - eighthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((eighthGridItem.bottom - eighthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eighthGridItem.left).assertEqual(firstGridItem.right);
expect(eighthGridItem.top).assertEqual(fifthGridItem.bottom);
expect(Math.round((ninthGridItem.right - ninthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(ninthGridItem.left).assertEqual(eighthGridItem.right);
expect(ninthGridItem.top).assertEqual(eighthGridItem.top);
expect(ninthGridItem.bottom).assertEqual(eighthGridItem.bottom);
expect(Math.round((tenthGridItem.right - tenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(tenthGridItem.left).assertEqual(ninthGridItem.right);
expect(tenthGridItem.top).assertEqual(eighthGridItem.top);
expect(tenthGridItem.bottom).assertEqual(eighthGridItem.bottom);
expect(tenthGridItem.right).assertEqual(gridContainer.right); // third row
expect(Math.round((eleventhGridItem.right - eleventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((eleventhGridItem.bottom - eleventhGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eleventhGridItem.left).assertEqual(firstGridItem.right);
expect(eleventhGridItem.top).assertEqual(eighthGridItem.bottom);
expect(Math.round((eleventhGridItem.right - eleventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(twelfthGridItem.left).assertEqual(eleventhGridItem.right);
expect(twelfthGridItem.top).assertEqual(eleventhGridItem.top);
expect(twelfthGridItem.bottom).assertEqual(eleventhGridItem.bottom);
expect(thirteenthGridItem.left).assertEqual(twelfthGridItem.right);
expect(thirteenthGridItem.top).assertEqual(eleventhGridItem.top);
expect(thirteenthGridItem.right).assertEqual(gridContainer.right);
expect(thirteenthGridItem.bottom).assertEqual(gridContainer.bottom); // fourth row
console.info('[testGridRowColItemRowStartToZeroEndToThree] END');
done();
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_1100
* @tc.name testGridRowColItemRowStartToTwoEndToFour
* @tc.desc The first griditem set rowStart to 1,rowEnd to 3
*/
it('testGridRowColItemRowStartToOneEndToThree', 0, async function (done) {
console.info('[testGridRowColItemRowStartToOneEndToThree] START');
globalThis.value.message.notify({name:'RowStart', value:1});
globalThis.value.message.notify({name:'RowEnd', value:3});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd1');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd2');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd3');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd4');
let fifthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd5');
let sixthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd6');
let seventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd7');
let eighthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd8');
let ninthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd9');
let tenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd10');
let eleventhGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd11');
let twelfthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd12');
let thirteenthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd13');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemRowStartEnd_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemRowStartEnd_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
expect(Math.round((firstGridItem.right - firstGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((firstGridItem.bottom - firstGridItem.top)*10)/10).assertEqual(Math.round(vp2px(225)*10)/10);
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(Math.round((firstGridItem.top - gridContainer.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10); //firstGridItem
expect(Math.round((secondGridItem.right - secondGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((secondGridItem.bottom - secondGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(secondGridItem.left).assertEqual(gridContainer.left);
expect(secondGridItem.top).assertEqual(gridContainer.top);
expect(Math.round((thirdGridItem.right - thirdGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirdGridItem.left).assertEqual(secondGridItem.right);
expect(thirdGridItem.top).assertEqual(secondGridItem.top);
expect(thirdGridItem.bottom).assertEqual(secondGridItem.bottom);
expect(Math.round((fourthGridItem.right - fourthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(secondGridItem.top);
expect(fourthGridItem.bottom).assertEqual(secondGridItem.bottom);
expect(fifthGridItem.left).assertEqual(fourthGridItem.right);
expect(fifthGridItem.right).assertEqual(gridContainer.right);
expect(fifthGridItem.top).assertEqual(secondGridItem.top);
expect(fifthGridItem.bottom).assertEqual(secondGridItem.bottom); //first row
expect(Math.round((sixthGridItem.right - sixthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((sixthGridItem.bottom - sixthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(sixthGridItem.left).assertEqual(firstGridItem.right);
expect(sixthGridItem.top).assertEqual(thirdGridItem.bottom);
expect(Math.round((seventhGridItem.right - seventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(seventhGridItem.left).assertEqual(sixthGridItem.right);
expect(seventhGridItem.top).assertEqual(sixthGridItem.top);
expect(Math.round((eighthGridItem.right - eighthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eighthGridItem.left).assertEqual(seventhGridItem.right);
expect(eighthGridItem.top).assertEqual(sixthGridItem.top);
expect(eighthGridItem.bottom).assertEqual(sixthGridItem.bottom); //second row
expect(Math.round((ninthGridItem.right - ninthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((ninthGridItem.bottom - ninthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(ninthGridItem.left).assertEqual(firstGridItem.right);
expect(ninthGridItem.top).assertEqual(sixthGridItem.bottom);
expect(Math.round((tenthGridItem.right - tenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(tenthGridItem.left).assertEqual(ninthGridItem.right);
expect(tenthGridItem.top).assertEqual(ninthGridItem.top);
expect(tenthGridItem.bottom).assertEqual(ninthGridItem.bottom);
expect(Math.round((eleventhGridItem.right - eleventhGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(eleventhGridItem.left).assertEqual(tenthGridItem.right);
expect(eleventhGridItem.top).assertEqual(ninthGridItem.top);
expect(eleventhGridItem.bottom).assertEqual(ninthGridItem.bottom); //third row
expect(Math.round((twelfthGridItem.right - twelfthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(Math.round((twelfthGridItem.bottom - twelfthGridItem.top)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(twelfthGridItem.left).assertEqual(firstGridItem.right);
expect(twelfthGridItem.top).assertEqual(ninthGridItem.bottom);
expect(twelfthGridItem.bottom).assertEqual(gridContainer.bottom);
expect(thirteenthGridItem.left).assertEqual(twelfthGridItem.right);
expect(thirteenthGridItem.top).assertEqual(twelfthGridItem.top);
expect(Math.round((gridContainer.right - thirteenthGridItem.left)*10)/10).assertEqual(Math.round(vp2px(75)*10)/10);
expect(thirteenthGridItem.bottom).assertEqual(gridContainer.bottom); // fourth row
console.info('[testGridRowColItemRowStartToOneEndToThree] END');
done();
});
})
}
/**
* 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 '@ohos.router';
import CommonFunc from '../../../../MainAbility/common/Common';
export default function grid_RowCol_ItemVisibilityTest() {
describe('Grid_RowCol_ItemVisibilityTest', function () {
beforeEach(async function (done) {
console.info("Grid_RowCol_ItemVisibilityTest beforeEach start");
let options = {
url: 'MainAbility/pages/Grid/GridTemplatesAllSet/GridItemChange/Grid_RowCol_ItemVisibility',
}
try {
router.clear();
let pages = router.getState();
console.info("get Grid_RowCol_ItemVisibility state pages:" + JSON.stringify(pages));
if (!("Grid_RowCol_ItemVisibility" == pages.name)) {
console.info("get Grid_RowCol_ItemVisibility state pages.name:" + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push Grid_RowCol_ItemVisibility page result:" + JSON.stringify(result));
}
} catch (err) {
console.error("push Grid_RowCol_ItemVisibility page error:" + err);
}
console.info("Grid_RowCol_ItemVisibilityTest beforeEach end");
done();
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("Grid_RowCol_ItemVisibilityTest after each called");
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0600
* @tc.name testGridRowColItemVisibilityNone
* @tc.desc The second griditem set visibility to Visibility.None
*/
it('testGridRowColItemVisibilityNone', 0, async function (done) {
console.info('[testGridRowColItemVisibilityNone] START');
globalThis.value.message.notify({name:'secondGridItemVisibility', value:Visibility.None});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemVisibility_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
let secondGridItemStrJson = getInspectorByKey('Grid_RowCol_ItemVisibility02');
let secondGridItemObj = JSON.parse(secondGridItemStrJson);
expect(secondGridItemObj.$attrs.visibility).assertEqual("Visibility.None");
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(thirdGridItem.top);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemVisibilityNone] END');
done();
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0700
* @tc.name testGridRowColItemVisibilityHidden
* @tc.desc The second griditem set visibility to Visibility.Hidden
*/
it('testGridRowColItemVisibilityHidden', 0, async function (done) {
console.info('[testGridRowColItemVisibilityHidden] START');
globalThis.value.message.notify({name:'secondGridItemVisibility', value:Visibility.Hidden});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemVisibility_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
let secondGridItemStrJson = getInspectorByKey('Grid_RowCol_ItemVisibility02');
let secondGridItemObj = JSON.parse(secondGridItemStrJson);
expect(secondGridItemObj.$attrs.visibility).assertEqual("Visibility.Hidden");
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(firstGridItem.bottom);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemVisibilityHidden] END');
done();
});
/**
* @tc.number SUB_ACE_GRID_GRIDTEMPLATESALLSET_GRIDITEMCHANGE_0800
* @tc.name testGridRowColItemVisibilityVisible
* @tc.desc The second griditem set visibility to Visibility.Visible
*/
it('testGridRowColItemVisibilityVisible', 0, async function (done) {
console.info('[testGridRowColItemVisibilityVisible] START');
globalThis.value.message.notify({name:'secondGridItemVisibility', value:Visibility.Visible});
await CommonFunc.sleep(3000);
let firstGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility01');
let secondGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility02');
let thirdGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility03');
let fourthGridItem = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility04');
let gridContainer = CommonFunc.getComponentRect('Grid_RowCol_ItemVisibility_Container01');
let gridContainerStrJson = getInspectorByKey('Grid_RowCol_ItemVisibility_Container01');
let gridContainerObj = JSON.parse(gridContainerStrJson);
expect(gridContainerObj.$type).assertEqual('Grid');
let secondGridItemStrJson = getInspectorByKey('Grid_RowCol_ItemVisibility02');
let secondGridItemObj = JSON.parse(secondGridItemStrJson);
expect(secondGridItemObj.$attrs.visibility).assertEqual("Visibility.Visible");
expect(firstGridItem.left).assertEqual(gridContainer.left);
expect(firstGridItem.top).assertEqual(gridContainer.top);
expect(secondGridItem.left).assertEqual(firstGridItem.right);
expect(secondGridItem.top).assertEqual(gridContainer.top);
expect(thirdGridItem.left).assertEqual(gridContainer.left);
expect(thirdGridItem.top).assertEqual(firstGridItem.bottom);
expect(fourthGridItem.left).assertEqual(thirdGridItem.right);
expect(fourthGridItem.top).assertEqual(firstGridItem.bottom);
expect(Math.round(firstGridItem.right - firstGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(firstGridItem.bottom - firstGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.right - secondGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(secondGridItem.bottom - secondGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.right - thirdGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(thirdGridItem.bottom - thirdGridItem.top)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.right - fourthGridItem.left)).assertEqual(vp2px(150));
expect(Math.round(fourthGridItem.bottom - fourthGridItem.top)).assertEqual(vp2px(150));
console.info('[testGridRowColItemVisibilityVisible] END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册