react-native-navigation的迁移库

Orientations.test.js 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 : 10));
  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. await expect(element(by.id(testIDs.PORTRAIT_ELEMENT))).toBeVisible();
  28. await elementById(testIDs.DISMISS_BUTTON).tap();
  29. });
  30. it(':ios: portrait only', async () => {
  31. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  32. await elementById(testIDs.PORTRAIT_ORIENTATION_BUTTON).tap();
  33. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  34. await device.setOrientation('landscape');
  35. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  36. await device.setOrientation('portrait');
  37. await expect(elementById(testIDs.PORTRAIT_ELEMENT)).toBeVisible();
  38. await elementById(testIDs.DISMISS_BUTTON).tap();
  39. });
  40. it(':ios: landscape only', async () => {
  41. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  42. await elementById(testIDs.LANDSCAPE_ORIENTATION_BUTTON).tap();
  43. await device.setOrientation('landscape');
  44. await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  45. await device.setOrientation('portrait');
  46. await expect(element(by.id(testIDs.LANDSCAPE_ELEMENT))).toBeVisible();
  47. await elementById(testIDs.DISMISS_BUTTON).tap();
  48. });
  49. });