view.test.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. const PAGE_PATH = '/pages/component/view/view'
  2. // 此用例仅用于模拟点击关闭iOS弹窗逻辑,无实际意义
  3. describe('view-test', () => {
  4. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  5. const isAndroid = platformInfo.startsWith('android')
  6. const isMP = platformInfo.startsWith('mp')
  7. const isWeb = platformInfo.startsWith('web')
  8. const isHarmony = platformInfo.startsWith('harmony')
  9. if (isAndroid || isWeb || isMP) {
  10. it('other platform', () => {
  11. expect(1).toBe(1)
  12. })
  13. return
  14. }
  15. let page
  16. beforeAll(async () => {
  17. page = await program.reLaunch(PAGE_PATH)
  18. await page.waitFor(1000);
  19. })
  20. it('itemclick-event', async () => {
  21. // 关闭弹窗 iPhone Pro 机型
  22. await program.tap({
  23. x: 220,
  24. y: 516,
  25. duration: 100
  26. })
  27. // 关闭弹窗 iPhone ProMax 机型
  28. await program.tap({
  29. x: 220,
  30. y: 546,
  31. duration: 100
  32. })
  33. // 关闭弹窗 iPhone mini 机型
  34. await program.tap({
  35. x: 186,
  36. y: 463,
  37. duration: 100
  38. })
  39. expect(1).toBe(1)
  40. })
  41. if (isHarmony) {
  42. it('hover-class', async () => {
  43. await page.setData({
  44. hover_class: true,
  45. stay_time: 1000 * 10
  46. })
  47. await page.waitFor(100)
  48. await program.tap({ x: 150, y: 325, duration: 2000 })
  49. // const systemInfo = await program.systemInfo()
  50. // const devicePixelRatio = systemInfo.devicePixelRatio
  51. // const positionX = systemInfo.screenWidth / 2
  52. // const positionY = systemInfo.screenWidth
  53. // await program.tap({
  54. // x: positionX,
  55. // y: positionY,
  56. // duration: 5000
  57. // })
  58. // 通过检查样式来判断 hover-class 是否生效
  59. const viewChild1 = await page.$('#view-child1')
  60. expect(await viewChild1.style('background-color')).toBe('#179b16')
  61. })
  62. }
  63. })