touch-events-bubbles.test.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isAndroid = platformInfo.startsWith('android')
  3. const isMP = platformInfo.startsWith('mp')
  4. const isWeb = platformInfo.startsWith('web')
  5. const isHarmony = platformInfo.startsWith('harmony')
  6. const PAGE_PATH = '/pages/component/global-events/touch-events-bubbles'
  7. describe('touch-events-test', () => {
  8. if (isAndroid || isWeb || isMP || process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
  9. it('other platform', () => {
  10. expect(1).toBe(1)
  11. })
  12. return
  13. }
  14. let page
  15. beforeAll(async () => {
  16. page = await program.reLaunch(PAGE_PATH)
  17. await page.waitFor(500);
  18. })
  19. it('touch-event-bubbles-test1', async () => {
  20. let iconRect = await page.data('iconRect')
  21. console.log('iconRect.x', iconRect.x)
  22. console.log('iconRect.y', iconRect.y)
  23. if (isHarmony && iconRect.x < 20) {
  24. iconRect.x = 144
  25. }
  26. let x = iconRect.x + iconRect.width / 2.0
  27. let y = iconRect.y + 25
  28. // 滑动事件
  29. await program.swipe({
  30. startPoint: {x: x, y: y},
  31. endPoint: {x: x,y: y+15},
  32. duration: 200
  33. })
  34. await page.waitFor(1500);
  35. await page.callMethod('isPassTest1')
  36. const ret = await page.data('ret1')
  37. expect(ret).toBe(true)
  38. })
  39. it('touch-event-bubbles-test2', async () => {
  40. let viewEleRect = await page.data('viewEleRect')
  41. let x = viewEleRect.x + viewEleRect.width / 2.0
  42. let y = viewEleRect.y + 25
  43. // 滑动事件
  44. await program.swipe({
  45. startPoint: {x: x, y: y},
  46. endPoint: {x: x,y: y+15},
  47. duration: 200
  48. })
  49. await page.waitFor(1500);
  50. await page.callMethod('isPassTest2')
  51. const ret = await page.data('ret2')
  52. expect(ret).toBe(true)
  53. })
  54. })