save-video-to-photos-album.test.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isIOS = platformInfo.startsWith('ios')
  3. const isMP = platformInfo.startsWith('mp')
  4. const isWeb = platformInfo.startsWith('web')
  5. const isAndroid = platformInfo.startsWith('android')
  6. const isHarmony = platformInfo.startsWith('harmony')
  7. describe('API-saveVideoToPhotosAlbum', () => {
  8. if (isIOS || isWeb || isMP) {
  9. it('pass', async () => {
  10. expect(1).toBe(1);
  11. });
  12. return;
  13. }
  14. let page;
  15. beforeAll(async () => {
  16. page = await program.reLaunch('/pages/API/save-video-to-photos-album/save-video-to-photos-album');
  17. await page.waitFor('view');
  18. });
  19. it('test saveVideoToPhotosAlbum', async () => {
  20. if (isAndroid) {
  21. const infos = platformInfo.split(' ');
  22. const version = parseInt(infos[infos.length - 1]);
  23. if (version < 7) {
  24. console.log("安卓版本小于7设备 不进行saveVideo测试,模拟器会出现闪退影响后续测试")
  25. expect(1).toBe(1)
  26. return
  27. }
  28. await program.adbCommand(
  29. 'pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE');
  30. }
  31. await page.callMethod('saveVideo');
  32. if (isHarmony) {
  33. await page.waitFor(2000);
  34. await program.tap({x: 305, y: 567})
  35. }
  36. await page.waitFor(1000);
  37. const windowInfo = await program.callUniMethod('getWindowInfo');
  38. const image = await program.screenshot({
  39. deviceShot: true,
  40. area: {
  41. x: 0,
  42. y: windowInfo.safeAreaInsets.top + 44
  43. }
  44. });
  45. expect(image).toSaveImageSnapshot();
  46. expect(await page.data('success')).toBe(true);
  47. await page.waitFor(2000);
  48. });
  49. });