react-native-navigation的迁移库

Orientations.test.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. });
  8. afterEach(async () => {
  9. await device.setOrientation('landscape');
  10. await device.setOrientation('portrait');
  11. });
  12. it('default allows all', async () => {
  13. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  14. await elementById(testIDs.DEFAULT_ORIENTATION_BUTTON).tap();
  15. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  16. await device.setOrientation('landscape');
  17. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  18. await device.setOrientation('portrait');
  19. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  20. await elementById(testIDs.DISMISS_BUTTON).tap();
  21. });
  22. it('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('currentOrientation'))).toHaveText('Portrait');
  26. await device.setOrientation('landscape');
  27. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  28. await device.setOrientation('portrait');
  29. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  30. await elementById(testIDs.DISMISS_BUTTON).tap();
  31. });
  32. it('portrait only', async () => {
  33. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  34. await elementById(testIDs.PORTRAIT_ORIENTATION_BUTTON).tap();
  35. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  36. await device.setOrientation('landscape');
  37. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  38. await device.setOrientation('portrait');
  39. await expect(element(by.id('currentOrientation'))).toHaveText('Portrait');
  40. await elementById(testIDs.DISMISS_BUTTON).tap();
  41. });
  42. it('landscape only', async () => {
  43. await elementById(testIDs.ORIENTATION_BUTTON).tap();
  44. await elementById(testIDs.LANDSCAPE_ORIENTATION_BUTTON).tap();
  45. await device.setOrientation('landscape');
  46. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  47. await device.setOrientation('portrait');
  48. await expect(element(by.id('currentOrientation'))).toHaveText('Landscape');
  49. await elementById(testIDs.DISMISS_BUTTON).tap();
  50. });
  51. });