touch-events-bubbles.test.js 1.7 KB
Newer Older
1 2
const PAGE_PATH = '/pages/component/global-events/touch-events-bubbles'

3 4 5 6 7 8
describe('touch-events-test', () => {
  const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  const isAndroid = platformInfo.startsWith('android')
  const isIOS = platformInfo.startsWith('ios')
  const isMP = platformInfo.startsWith('mp')
  const isWeb = platformInfo.startsWith('web')
9

雪洛's avatar
雪洛 已提交
10
  if (
11 12 13
    isAndroid ||
    isWeb ||
    isMP
雪洛's avatar
雪洛 已提交
14
  ) {
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
    it('other platform', () => {
      expect(1).toBe(1)
    })
    return
  }

  if (process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
    it('跳过横屏模式', () => {
      expect(1).toBe(1)
    })
    return
  }

  let page
  beforeAll(async () => {
    page = await program.reLaunch(PAGE_PATH)
    await page.waitFor(500);
  })


  it('touch-event-bubbles-test1', async () => {

    let iconRect = await page.data('iconRect')
    let x = iconRect.x + iconRect.width / 2.0
39
    let y = iconRect.y + 25
40 41 42 43

    // 滑动事件
    await program.swipe({
      startPoint: {x: x, y: y},
44
      endPoint: {x: x,y: y+15},
45 46 47 48 49 50 51 52 53 54 55 56 57
      duration: 200
    })

    await page.waitFor(1500);
    await page.callMethod('isPassTest1')
    const ret = await page.data('ret1')
    expect(ret).toBe(true)
  })

  it('touch-event-bubbles-test2', async () => {

    let viewEleRect = await page.data('viewEleRect')
    let x = viewEleRect.x + viewEleRect.width / 2.0
58
    let y = viewEleRect.y + 25
59 60 61 62

    // 滑动事件
    await program.swipe({
      startPoint: {x: x, y: y},
63
      endPoint: {x: x,y: y+15},
64 65 66 67 68 69 70 71 72 73
      duration: 200
    })

    await page.waitFor(1500);
    await page.callMethod('isPassTest2')
    const ret = await page.data('ret2')
    expect(ret).toBe(true)
  })

})