touch-events.test.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 PAGE_PATH = '/pages/component/global-events/touch-events'
  6. describe('touch-events-test', () => {
  7. if (isAndroid || isMP || isWeb || process.env.UNI_TEST_DEVICES_DIRECTION == 'landscape') {
  8. it('other platform', () => {
  9. expect(1).toBe(1)
  10. })
  11. return
  12. }
  13. let page
  14. beforeAll(async () => {
  15. page = await program.reLaunch(PAGE_PATH)
  16. await page.waitFor('view');
  17. await page.waitFor(1000);
  18. })
  19. it('touchStart-tagName-touchCount', async () => {
  20. let iconRect = await page.data('iconRect')
  21. let x = iconRect.x + iconRect.width / 2.0
  22. let y = iconRect.y + iconRect.height / 2.0
  23. // 点击图片
  24. await program.tap({
  25. x: x,
  26. y: y,
  27. duration: 100
  28. })
  29. await page.waitFor(1500);
  30. const touchTargets = await page.data('touchTargets')
  31. const touchTargetsCount = await page.data('touchTargetsCount')
  32. console.log('touchTargets', touchTargets)
  33. console.log('touchTargetsCount', touchTargetsCount)
  34. expect(touchTargets).toBe("IMAGEIMAGEIMAGEVIEW")
  35. expect(touchTargetsCount).toBe(2)
  36. })
  37. })