react-native-navigation的迁移库

Orientations.test.js 2.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. });
  9. test('default allows all', async () => {
  10. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  11. await elementById(testIDs.DEFAULT_ORIENTATION_BUTTON).tap();
  12. waitForDeviceToSettleAfterOrientationChangeAndroid();
  13. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  14. await device.setOrientation('landscape');
  15. waitForDeviceToSettleAfterOrientationChangeAndroid();
  16. await expect(elementById(testIDs.LANDSCAPE_ELEMENT)).toBeVisible();
  17. await device.setOrientation('portrait');
  18. waitForDeviceToSettleAfterOrientationChangeAndroid();
  19. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  20. await elementById(testIDs.DISMISS_BUTTON).tap();
  21. });
  22. test('landscape and portrait array', async () => {
  23. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  24. await elementById(testIDs.LANDSCAPE_PORTRAIT_ORIENTATION_BUTTON).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_BUTTON).tap();
  33. });
  34. test(':ios: portrait only', async () => {
  35. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  36. await elementById(testIDs.PORTRAIT_ORIENTATION_BUTTON).tap();
  37. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  38. await device.setOrientation('landscape');
  39. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  40. await device.setOrientation('portrait');
  41. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  42. await elementById(testIDs.DISMISS_BUTTON).tap();
  43. });
  44. test(':ios: landscape only', async () => {
  45. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  46. await elementById(testIDs.LANDSCAPE_ORIENTATION_BUTTON).tap();
  47. await device.setOrientation('landscape');
  48. await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  49. await device.setOrientation('portrait');
  50. await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  51. await elementById(testIDs.DISMISS_BUTTON).tap();
  52. });
  53. });