react-native-navigation的迁移库

Orientations.test.js 2.5KB

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