react-native-navigation的迁移库

Orientation.test.js 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. const Utils = require('./Utils');
  2. const TestIDs = require('../playground/src/testIDs');
  3. const { elementById } = Utils;
  4. describe(':ios: orientation', () => {
  5. beforeEach(async () => {
  6. await device.relaunchApp();
  7. waitForDeviceToSettleAfterOrientationChangeAndroid = ms => new Promise(res => setTimeout(res, device.getPlatform() === 'ios' ? 0 : 400));
  8. await elementById(TestIDs.NAVIGATION_TAB).tap();
  9. await elementById(TestIDs.SHOW_ORIENTATION_SCREEN).tap();
  10. });
  11. it('default allows all', async () => {
  12. await elementById(TestIDs.DEFAULT_ORIENTATION_BTN).tap();
  13. waitForDeviceToSettleAfterOrientationChangeAndroid();
  14. await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
  15. await device.setOrientation('landscape');
  16. waitForDeviceToSettleAfterOrientationChangeAndroid();
  17. await expect(elementById(TestIDs.LANDSCAPE_ELEMENT)).toBeVisible();
  18. await device.setOrientation('portrait');
  19. waitForDeviceToSettleAfterOrientationChangeAndroid();
  20. await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
  21. await elementById(TestIDs.DISMISS_BTN).tap();
  22. });
  23. it('landscape and portrait array', async () => {
  24. await elementById(TestIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BTN).tap();
  25. await expect(element(by.id(TestIDs.PORTRAIT_ELEMENT))).toBeVisible();
  26. await device.setOrientation('landscape');
  27. waitForDeviceToSettleAfterOrientationChangeAndroid();
  28. await expect(element(by.id(TestIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  29. await device.setOrientation('portrait');
  30. waitForDeviceToSettleAfterOrientationChangeAndroid();
  31. await expect(element(by.id(TestIDs.PORTRAIT_ELEMENT))).toBeVisible();
  32. await elementById(TestIDs.DISMISS_BTN).tap();
  33. });
  34. it(':ios: portrait only', async () => {
  35. await elementById(TestIDs.PORTRAIT_ORIENTATION_BTN).tap();
  36. await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
  37. await device.setOrientation('landscape');
  38. await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
  39. await device.setOrientation('portrait');
  40. await expect(elementById(TestIDs.PORTRAIT_ELEMENT)).toBeVisible();
  41. await elementById(TestIDs.DISMISS_BTN).tap();
  42. });
  43. it(':ios: landscape only', async () => {
  44. await elementById(TestIDs.LANDSCAPE_ORIENTATION_BTN).tap();
  45. await device.setOrientation('landscape');
  46. await expect(element(by.id(TestIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  47. await device.setOrientation('portrait');
  48. await expect(element(by.id(TestIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  49. await elementById(TestIDs.DISMISS_BTN).tap();
  50. });
  51. });