提交 ac8b3249 编写于 作者: Z zhangshuqi

fix the testcase

Signed-off-by: Nzhangshuqi <zhangshuqi7@huawei.com>
上级 6edaadd2
/*
* 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 SwiperItemSizeTest2 {
@State testHeight: number = 150
@State testWidth: number = 150
@State testIndex: number = 0
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('SwiperItemSize onPageShow');
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value);
if (message.name == 'height') {
this.testHeight = message.value;
}
if (message.name == 'width') {
this.testWidth = message.value;
}
if (message.name == 'index') {
this.testIndex = message.value;
}
}
this.messageManager.registerCallback(callback);
}
build() {
Column({ space: 5 }) {
Swiper() {
Column(){Text ('1')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xF5DEB3).key('itemSizekey2_01')
Column(){Text ('2')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xD2B48C).key('itemSizekey2_02')
Column(){Text ('3')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xF5DEB3).key('itemSizekey2_03')
Column(){Text ('4')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xD2B48C)
Column(){Text ('5')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xF5DEB3)
Column(){Text ('6')}.width(this.testWidth).height(this.testHeight).backgroundColor(0xD2B48C)
}
.key('itemSizekey2')
.height(300)
.width(300)
.index(this.testIndex)
.indicator(true)
.loop(true)
.displayCount(1)
}.margin({ top: 5 })
}
}
\ No newline at end of file
...@@ -75,10 +75,7 @@ import swiperIndex from './Swiper/Swiper_ParmsChange/swiperIndex.test.ets'; ...@@ -75,10 +75,7 @@ import swiperIndex from './Swiper/Swiper_ParmsChange/swiperIndex.test.ets';
import swiperVertical from './Swiper/Swiper_ParmsChange/swiperVertical.test.ets'; import swiperVertical from './Swiper/Swiper_ParmsChange/swiperVertical.test.ets';
import swiperLoopTrue from './Swiper/Swiper_ParmsChange/swiperLoopTrue.test.ets'; import swiperLoopTrue from './Swiper/Swiper_ParmsChange/swiperLoopTrue.test.ets';
import swiperLoopFalse from './Swiper/Swiper_ParmsChange/swiperLoopFalse.test.ets'; import swiperLoopFalse from './Swiper/Swiper_ParmsChange/swiperLoopFalse.test.ets';
import swiperAutoPlay_1 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_1.test.ets';
import swiperAutoPlay_2 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_2.test.ets';
import swiperAutoPlay_3 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_3.test.ets';
import swiperAutoPlay_4 from './Swiper/Swiper_ParmsChange/swiperAutoPlay_4.test.ets';
import swiperItemSpace from './Swiper/Swiper_ParmsChange/swiperItemSpace.test.ets'; import swiperItemSpace from './Swiper/Swiper_ParmsChange/swiperItemSpace.test.ets';
import swiperPadding from './Swiper/Swiper_ParmsChange/swiperPadding.test.ets'; import swiperPadding from './Swiper/Swiper_ParmsChange/swiperPadding.test.ets';
import swiperMargin from './Swiper/Swiper_ParmsChange/swiperMargin.test.ets'; import swiperMargin from './Swiper/Swiper_ParmsChange/swiperMargin.test.ets';
...@@ -86,6 +83,7 @@ import swiperMarPad from './Swiper/Swiper_ParmsChange/swiperMarPad.test.ets'; ...@@ -86,6 +83,7 @@ import swiperMarPad from './Swiper/Swiper_ParmsChange/swiperMarPad.test.ets';
import swiperDisableSwipeTrue from './Swiper/Swiper_ParmsChange/swiperDisableSwipeTrue.test.ets'; import swiperDisableSwipeTrue from './Swiper/Swiper_ParmsChange/swiperDisableSwipeTrue.test.ets';
import swiperDisableSwipeFalse from './Swiper/Swiper_ParmsChange/swiperDisableSwipeFalse.test.ets'; import swiperDisableSwipeFalse from './Swiper/Swiper_ParmsChange/swiperDisableSwipeFalse.test.ets';
import swiperItemSize from './Swiper/Swiper_ItemChange/swiperItemSize.test.ets'; import swiperItemSize from './Swiper/Swiper_ItemChange/swiperItemSize.test.ets';
import swiperItemSize2 from './Swiper/Swiper_ItemChange/swiperItemSize2.test.ets';
import swiperItemPadding from './Swiper/Swiper_ItemChange/swiperItemPadding.test.ets'; import swiperItemPadding from './Swiper/Swiper_ItemChange/swiperItemPadding.test.ets';
import swiperItemMargin from './Swiper/Swiper_ItemChange/swiperItemMargin.test.ets'; import swiperItemMargin from './Swiper/Swiper_ItemChange/swiperItemMargin.test.ets';
import swiperItemPadMar from './Swiper/Swiper_ItemChange/swiperItemPadMar.test.ets'; import swiperItemPadMar from './Swiper/Swiper_ItemChange/swiperItemPadMar.test.ets';
...@@ -469,10 +467,7 @@ swiperIndex() ...@@ -469,10 +467,7 @@ swiperIndex()
swiperVertical() swiperVertical()
swiperLoopTrue() swiperLoopTrue()
swiperLoopFalse() swiperLoopFalse()
swiperAutoPlay_1()
swiperAutoPlay_2()
swiperAutoPlay_3()
swiperAutoPlay_4()
swiperItemSpace() swiperItemSpace()
swiperPadding() swiperPadding()
swiperMargin() swiperMargin()
...@@ -480,6 +475,7 @@ swiperMarPad() ...@@ -480,6 +475,7 @@ swiperMarPad()
swiperDisableSwipeTrue() swiperDisableSwipeTrue()
swiperDisableSwipeFalse() swiperDisableSwipeFalse()
swiperItemSize() swiperItemSize()
swiperItemSize2()
swiperItemPadding() swiperItemPadding()
swiperItemMargin() swiperItemMargin()
swiperItemPadMar() swiperItemPadMar()
......
...@@ -60,8 +60,8 @@ export default function swiperItemSize() { ...@@ -60,8 +60,8 @@ export default function swiperItemSize() {
console.info("Before page turning , the itemSizekey01.left value is " + JSON.stringify(itemSizekey01.left)); console.info("Before page turning , the itemSizekey01.left value is " + JSON.stringify(itemSizekey01.left));
expect(itemSizekey.left).assertEqual(itemSizekey01.left); expect(itemSizekey.left).assertEqual(itemSizekey01.left);
expect(itemSizekey.top).assertEqual(itemSizekey01.top); expect(itemSizekey.top).assertEqual(itemSizekey01.top);
expect(Math.round(itemSizekey.right - itemSizekey01.right)).assertEqual(vp2px(150)); expect(itemSizekey.right).assertEqual(itemSizekey01.right);
expect(Math.round(itemSizekey.bottom - itemSizekey01.bottom)).assertEqual(vp2px(150));
// Flipping. // Flipping.
let driver = await Driver.create(); let driver = await Driver.create();
await driver.swipe(250, 230, 200, 230); await driver.swipe(250, 230, 200, 230);
...@@ -75,8 +75,8 @@ export default function swiperItemSize() { ...@@ -75,8 +75,8 @@ export default function swiperItemSize() {
console.info("After page turning , the itemSizekey02.left value is " + JSON.stringify(itemSizekey02.left)); console.info("After page turning , the itemSizekey02.left value is " + JSON.stringify(itemSizekey02.left));
expect(itemSizekey.left).assertEqual(itemSizekey02.left); expect(itemSizekey.left).assertEqual(itemSizekey02.left);
expect(itemSizekey.top).assertEqual(itemSizekey02.top); expect(itemSizekey.top).assertEqual(itemSizekey02.top);
expect(Math.round(itemSizekey.right - itemSizekey01.right)).assertEqual(vp2px(150)); expect(itemSizekey.right).assertEqual(itemSizekey02.right);
expect(Math.round(itemSizekey.bottom - itemSizekey01.bottom)).assertEqual(vp2px(150));
console.info("The type value is " + JSON.stringify(obj.$type)); console.info("The type value is " + JSON.stringify(obj.$type));
console.info("The loop value is " + JSON.stringify(obj.$attrs.loop)); console.info("The loop value is " + JSON.stringify(obj.$attrs.loop));
console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount)); console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount));
...@@ -87,53 +87,5 @@ export default function swiperItemSize() { ...@@ -87,53 +87,5 @@ export default function swiperItemSize() {
done(); done();
}); });
/**
* @tc.number SUB_ACE_SWIPER_ITEMCHANGED_0200
* @tc.name testSwiperItemSizeExceed.
* @tc.desc Set item's height and width values '350*350'.
*/
it('testSwiperItemSizeExceed', 0, async function (done) {
console.info('new testSwiperItemSizeExceed START');
globalThis.value.message.notify({name:'index', value: 0});
globalThis.value.message.notify({name:'height', value: 350});
globalThis.value.message.notify({name:'width', value: 350});
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('itemSizekey');
let obj = JSON.parse(strJson);
let itemSizekey = CommonFunc.getComponentRect('itemSizekey');
let itemSizekey01 = CommonFunc.getComponentRect('itemSizekey01');
let itemSizekey02 = CommonFunc.getComponentRect('itemSizekey02');
let itemSizekey03 = CommonFunc.getComponentRect('itemSizekey03');
// Before flipping the page.
console.info("Before page turning , the itemSizekey.left value is " + JSON.stringify(itemSizekey.left));
console.info("Before page turning , the itemSizekey01.left value is " + JSON.stringify(itemSizekey01.left));
expect(itemSizekey.left).assertEqual(itemSizekey01.left);
expect(itemSizekey.right).assertEqual(itemSizekey01.right);
expect(itemSizekey.top).assertEqual(itemSizekey01.top);
expect(itemSizekey.bottom).assertEqual(itemSizekey01.bottom);
// Flipping.
let driver = await Driver.create();
await driver.swipe(250, 230, 200, 230);
await CommonFunc.sleep(1000);
// After flipping the page.
itemSizekey = CommonFunc.getComponentRect('itemSizekey');
itemSizekey01 = CommonFunc.getComponentRect('itemSizekey01');
itemSizekey02 = CommonFunc.getComponentRect('itemSizekey02');
itemSizekey03 = CommonFunc.getComponentRect('itemSizekey03');
console.info("After page turning , the itemSizekey.left value is " + JSON.stringify(itemSizekey.left));
console.info("After page turning , the itemSizekey02.left value is " + JSON.stringify(itemSizekey02.left));
expect(itemSizekey.left).assertEqual(itemSizekey02.left);
expect(itemSizekey.right).assertEqual(itemSizekey02.right);
expect(itemSizekey.top).assertEqual(itemSizekey02.top);
expect(itemSizekey.bottom).assertEqual(itemSizekey02.bottom);
console.info("The type value is " + JSON.stringify(obj.$type));
console.info("The loop value is " + JSON.stringify(obj.$attrs.loop));
console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount));
expect(obj.$type).assertEqual('Swiper');
expect(obj.$attrs.loop).assertEqual('true');
expect(obj.$attrs.displayCount).assertEqual(1);
console.info('new testSwiperItemSizeExceed 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 { UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix, UiDirection, MouseButton } from '@ohos.UiTest';
export default function swiperItemSize2() {
describe('swiperItemSizeTest2', function () {
beforeEach(async function (done) {
let options = {
uri: 'MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2',
}
try {
router.clear();
await CommonFunc.sleep(1000);
let pages = router.getState();
console.info("get swiperItemSize2 state success " + JSON.stringify(pages));
if (!("swiperItemSize2" == pages.name)) {
console.info("get swiperItemSize2 state success " + JSON.stringify(pages.name));
let result = await router.push(options)
console.info("push swiperItemSize2 page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push swiperItemSize2 page error " + JSON.stringify(err));
}
});
afterEach(async function () {
await CommonFunc.sleep(1000);
console.info("swiperItemSize2 after each called");
});
/**
* @tc.number SUB_ACE_SWIPER_ITEMCHANGED_0100
* @tc.name testSwiperItemSizeExceed.
* @tc.desc Set item's height and width values '350*350'.
*/
it('testSwiperItemSizeExceed2', 0, async function (done) {
console.info('new testSwiperItemSizeExceed2 START');
globalThis.value.message.notify({name:'index', value: 0});
globalThis.value.message.notify({name:'height', value: 350});
globalThis.value.message.notify({name:'width', value: 350});
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('itemSizekey2');
let obj = JSON.parse(strJson);
let itemSizekey2 = CommonFunc.getComponentRect('itemSizekey2');
let itemSizekey2_01 = CommonFunc.getComponentRect('itemSizekey2_01');
let itemSizekey2_02 = CommonFunc.getComponentRect('itemSizekey2_02');
let itemSizekey2_03 = CommonFunc.getComponentRect('itemSizekey2_03');
// Before flipping the page.
console.info("Before page turning , the itemSizekey2.left value is " + JSON.stringify(itemSizekey2.left));
console.info("Before page turning , the itemSizekey2_01.left value is " + JSON.stringify(itemSizekey2_01.left));
expect(itemSizekey2.left).assertEqual(itemSizekey2_01.left);
expect(itemSizekey2.right).assertEqual(itemSizekey2_01.right);
expect(itemSizekey2.top).assertEqual(itemSizekey2_01.top);
expect(itemSizekey2.bottom).assertEqual(itemSizekey2_01.bottom);
// Flipping.
let driver = await Driver.create();
await driver.swipe(250, 230, 200, 230);
await CommonFunc.sleep(1000);
// After flipping the page.
itemSizekey2 = CommonFunc.getComponentRect('itemSizekey2');
itemSizekey2_01 = CommonFunc.getComponentRect('itemSizekey2_01');
itemSizekey2_02 = CommonFunc.getComponentRect('itemSizekey2_02');
itemSizekey2_03 = CommonFunc.getComponentRect('itemSizekey2_03');
console.info("After page turning , the itemSizekey2.left value is " + JSON.stringify(itemSizekey2.left));
console.info("After page turning , the itemSizekey2_02.left value is " + JSON.stringify(itemSizekey2_02.left));
expect(itemSizekey2.left).assertEqual(itemSizekey2_02.left);
expect(itemSizekey2.right).assertEqual(itemSizekey2_02.right);
expect(itemSizekey2.top).assertEqual(itemSizekey2_02.top);
expect(itemSizekey2.bottom).assertEqual(itemSizekey2_02.bottom);
console.info("The type value is " + JSON.stringify(obj.$type));
console.info("The loop value is " + JSON.stringify(obj.$attrs.loop));
console.info("The displayCount value is " + JSON.stringify(obj.$attrs.displayCount));
expect(obj.$type).assertEqual('Swiper');
expect(obj.$attrs.loop).assertEqual('true');
expect(obj.$attrs.displayCount).assertEqual(1);
console.info('new testSwiperItemSizeExceed2 END');
done();
});
})
}
\ No newline at end of file
...@@ -301,6 +301,7 @@ ...@@ -301,6 +301,7 @@
"MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemPadding", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemPadding",
"MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemPadMar", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemPadMar",
"MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize",
"MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemSize2",
"MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemVisibility", "MainAbility/pages/Swiper/Swiper_ItemChange/swiperItemVisibility",
"MainAbility/pages/Swiper/Swiper_ParmsChange/swiperAutoPlay_1", "MainAbility/pages/Swiper/Swiper_ParmsChange/swiperAutoPlay_1",
"MainAbility/pages/Swiper/Swiper_ParmsChange/swiperAutoPlay_2", "MainAbility/pages/Swiper/Swiper_ParmsChange/swiperAutoPlay_2",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册