get-video-info.test.js 1.4 KB
Newer Older
1 2
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('API-getVideoInfo', () => {
3 4 5 6 7
  if (
    process.env.uniTestPlatformInfo.startsWith('web') ||
    process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios') ||
    process.env.uniTestPlatformInfo.toLowerCase().startsWith('mp')
  ) {
8
    // web平台在自动化测试场景下API调用失败
9 10 11 12 13 14
    it('pass', async () => {
      expect(1).toBe(1);
    });
    return;
  }

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
  let page;
  beforeAll(async () => {
    page = await program.reLaunch('/pages/API/get-video-info/get-video-info');
    await page.waitFor(500);
  });

  it('test getVideoInfo', async () => {
    await page.callMethod('testGetVideoInfo');
    await page.waitFor(1000);
    if (process.env.uniTestPlatformInfo.startsWith('web')) {
      expect(await page.data('videoInfoForTest')).toEqual({
        duration: 10,
        size: 211,
        width: 1280,
        height: 720
      });
      return;
    }
33 34 35 36 37 38 39 40 41 42 43 44 45 46
    const infos = process.env.uniTestPlatformInfo.split(' ');
    const version = parseInt(infos[infos.length - 1]);
    if (process.env.uniTestPlatformInfo.startsWith('android') && version > 5) {
      expect(await page.data('videoInfoForTest')).toEqual({
        orientation: 'up',
        type: 'video/mp4',
        duration: 10,
        size: 211,
        width: 1280,
        height: 720,
        fps: 30,
        bitrate: 172
      });
    }
47 48
  });
});