提交 9f8eb0e4 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

合并 swiper2.test.js 解决冲突

上级 5b6f9356
...@@ -9,9 +9,9 @@ ...@@ -9,9 +9,9 @@
:rebound="reboundSelect" :interval="intervalSelect" :circular="circularSelect" :rebound="reboundSelect" :interval="intervalSelect" :circular="circularSelect"
:indicator-color="indicatorColor" :indicator-active-color="indicatorColorActive" :indicator-color="indicatorColor" :indicator-active-color="indicatorColorActive"
:disable-touch="disableTouchSelect" :current="currentVal" :current-item-id="currentItemIdVal" :disable-touch="disableTouchSelect" :current="currentVal" :current-item-id="currentItemIdVal"
@change="swiperChange" @transition="swiperTransition" @animationfinish="swiperAnimationfinish"> @change="swiperChange" @transition="swiperTransition" @animationfinish="swiperAnimationfinish" @touchstart="swipertouchStart">
<swiper-item item-id="A"> <swiper-item item-id="A">
<view class="swiper-item uni-bg-red"><text class="swiper-item-Text">A</text></view> <view class="swiper-item uni-bg-red"><text class="swiper-item-Text" >A</text></view>
</swiper-item> </swiper-item>
<swiper-item item-id="B"> <swiper-item item-id="B">
<view class="swiper-item uni-bg-green"><text class="swiper-item-Text">B</text></view> <view class="swiper-item uni-bg-green"><text class="swiper-item-Text">B</text></view>
...@@ -73,13 +73,13 @@ ...@@ -73,13 +73,13 @@
<view class="uni-list-cell uni-list-cell-padding"> <view class="uni-list-cell uni-list-cell-padding">
<view class="uni-list-cell-db">swiperChange 是否打印</view> <view class="uni-list-cell-db">swiperChange 是否打印</view>
<switch :checked="swiperChangeSelect" @change="swiperChangeChange" /> <switch :checked="swiperChangeSelect" @change="swiperChangeChange" />
</view> </view>
<navigator url="/pages/component/swiper/swiper-list-view"> <navigator url="/pages/component/swiper/swiper-list-view">
<button type="primary"> <button type="primary">
swiper 嵌套 list-view 测试 swiper 嵌套 list-view 测试
</button> </button>
</navigator> </navigator>
</view> </view>
</view> </view>
...@@ -88,11 +88,11 @@ ...@@ -88,11 +88,11 @@
<!-- #endif --> <!-- #endif -->
</template> </template>
<script> <script>
type SwiperEventTest = { type SwiperEventTest = {
type: string; type : string;
target: UniElement | null; target : UniElement | null;
currentTarget: UniElement | null; currentTarget : UniElement | null;
} }
export default { export default {
data() { data() {
...@@ -115,24 +115,30 @@ ...@@ -115,24 +115,30 @@
swiperTransitionSelect: false, swiperTransitionSelect: false,
swiperAnimationfinishSelect: false, swiperAnimationfinishSelect: false,
swiperChangeSelect: false, swiperChangeSelect: false,
currentValChange: 0, currentValChange: 0,
// 自动化测试 // 自动化测试
changeDetailTest:null as UniSwiperChangeEventDetail | null, changeDetailTest: null as UniSwiperChangeEventDetail | null,
transitionDetailTest:null as UniSwiperTransitionEventDetail | null, transitionDetailTest: null as UniSwiperTransitionEventDetail | null,
animationfinishDetailTest:null as UniSwiperAnimationFinishEventDetail | null, animationfinishDetailTest: null as UniSwiperAnimationFinishEventDetail | null,
isChangeTest:'', isChangeTest: '',
isTransitionTest:'', isTransitionTest: '',
isAnimationfinishTest:'' isAnimationfinishTest: ''
} }
}, },
methods: { methods: {
swiperChange: function (e : UniSwiperChangeEvent) { swipertouchStart(e: UniTouchEvent) {
this.changeDetailTest = e.detail console.log("swiper touchstart")
this.checkEventTest({ },
type:e.type, viewtouchStart(e: UniTouchEvent) {
target:e.target, console.log("view touchstart:")
currentTarget:e.currentTarget },
} as SwiperEventTest,'change') swiperChange: function (e : UniSwiperChangeEvent) {
this.changeDetailTest = e.detail
this.checkEventTest({
type: e.type,
target: e.target,
currentTarget: e.currentTarget
} as SwiperEventTest, 'change')
this.currentValChange = e.detail.current this.currentValChange = e.detail.current
console.log(this.currentValChange) console.log(this.currentValChange)
if (this.swiperChangeSelect) { if (this.swiperChangeSelect) {
...@@ -140,47 +146,47 @@ ...@@ -140,47 +146,47 @@
console.log(e) console.log(e)
} }
}, },
swiperTransition: function (e : UniSwiperTransitionEvent) { swiperTransition: function (e : UniSwiperTransitionEvent) {
this.transitionDetailTest = e.detail this.transitionDetailTest = e.detail
this.checkEventTest({ this.checkEventTest({
type:e.type, type: e.type,
target:e.target, target: e.target,
currentTarget:e.currentTarget currentTarget: e.currentTarget
} as SwiperEventTest,'transition') } as SwiperEventTest, 'transition')
if (this.swiperTransitionSelect) { if (this.swiperTransitionSelect) {
console.log("swiperTransition") console.log("swiperTransition")
console.log(e) console.log(e)
} }
}, },
swiperAnimationfinish: function (e : UniSwiperAnimationFinishEvent) { swiperAnimationfinish: function (e : UniSwiperAnimationFinishEvent) {
this.animationfinishDetailTest = e.detail this.animationfinishDetailTest = e.detail
this.checkEventTest({ this.checkEventTest({
type:e.type, type: e.type,
target:e.target, target: e.target,
currentTarget:e.currentTarget currentTarget: e.currentTarget
} as SwiperEventTest,'animationfinish') } as SwiperEventTest, 'animationfinish')
if (this.swiperAnimationfinishSelect) { if (this.swiperAnimationfinishSelect) {
console.log("swiperAnimationfinish") console.log("swiperAnimationfinish")
console.log(e) console.log(e)
} }
}, },
// 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取) // 自动化测试专用(由于事件event参数对象中存在循环引用,在ios端JSON.stringify报错,自动化测试无法page.data获取)
checkEventTest(e:SwiperEventTest, eventName:String){ checkEventTest(e : SwiperEventTest, eventName : String) {
const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement; const isPass = e.type === eventName && e.target instanceof UniElement && e.currentTarget instanceof UniElement;
const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`; const result = isPass ? `${eventName}:Success` : `${eventName}:Fail`;
switch (eventName){ switch (eventName) {
case 'change': case 'change':
this.isChangeTest = result this.isChangeTest = result
break; break;
case 'transition': case 'transition':
this.isTransitionTest = result this.isTransitionTest = result
break; break;
case 'animationfinish': case 'animationfinish':
this.isAnimationfinishTest = result this.isAnimationfinishTest = result
break; break;
default: default:
break; break;
} }
}, },
dotsChange: function (e : UniSwitchChangeEvent) { dotsChange: function (e : UniSwitchChangeEvent) {
this.dotsSelect = e.detail.value this.dotsSelect = e.detail.value
...@@ -194,7 +200,7 @@ ...@@ -194,7 +200,7 @@
swiperAnimationfinishChange: function (e : UniSwitchChangeEvent) { swiperAnimationfinishChange: function (e : UniSwitchChangeEvent) {
this.swiperAnimationfinishSelect = e.detail.value this.swiperAnimationfinishSelect = e.detail.value
}, },
autoplayChange: function (e : UniSwitchChangeEvent) { autoplayChange: function (e : UniSwitchChangeEvent) {
this.autoplaySelect = e.detail.value this.autoplaySelect = e.detail.value
}, },
verticalChange: function (e : UniSwitchChangeEvent) { verticalChange: function (e : UniSwitchChangeEvent) {
......
const PAGE_PATH = '/pages/component/swiper/swiper'
describe('swiper-touch-test', () => {
// 屏蔽 web 平台
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('other platform', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1500);
})
it('swiper-touch-test', async () => {
await program.swipe({
startPoint: {x: 246,y: 193},
endPoint: {x: 1,y: 193},
duration: 200
})
await page.waitFor(1000)
let val = await page.data('currentValChange')
console.log(val)
expect(val).toEqual(1)
})
})
...@@ -6,6 +6,7 @@ const sortTestFilePaths = [ ...@@ -6,6 +6,7 @@ const sortTestFilePaths = [
"pages/component/list-view/list-view-refresh.test.js", "pages/component/list-view/list-view-refresh.test.js",
"pages/component/scroll-view/scroll-view-refresher.test.js", "pages/component/scroll-view/scroll-view-refresher.test.js",
"pages/component/global-events/touch-events.test.js", "pages/component/global-events/touch-events.test.js",
"pages/component/swiper/swiper2.test.js",
"pages/component/rich-text/rich-text-complex.test.js" "pages/component/rich-text/rich-text-complex.test.js"
] ]
class CustomSequencer extends Sequencer { class CustomSequencer extends Sequencer {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册