get-recorder-manager.test.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  2. const isAndroid = platformInfo.startsWith('android')
  3. const args = platformInfo.split(' ')
  4. const version = parseFloat(args[args.length - 1])
  5. describe('recorder', () => {
  6. if (!isAndroid || (isAndroid && version < 9)) {
  7. it('app', () => {
  8. expect(1).toBe(1)
  9. })
  10. return
  11. }
  12. beforeAll(async () => {
  13. page = await program.reLaunch('/pages/API/get-recorder-manager/get-recorder-manager')
  14. await page.waitFor(600);
  15. });
  16. it('onError', async () => {
  17. await page.waitFor(100)
  18. const btnError = await page.$('#btn-error')
  19. await btnError.tap()
  20. await page.waitFor(200)
  21. expect(await page.data('registerError')).toBeTruthy()
  22. });
  23. it('start and onStart', async () => {
  24. await page.waitFor(1000)
  25. const btnStart = await page.$('#btn-startRecord')
  26. await btnStart.tap()
  27. await page.waitFor(200)
  28. expect(await page.data('recording')).toBeTruthy()
  29. })
  30. it('onStop', async () => {
  31. await page.waitFor(1000)
  32. const btnStop = await page.$('#btn-stopRecord')
  33. await btnStop.tap()
  34. await page.waitFor(200)
  35. expect(await page.data('recording')).toBeFalsy()
  36. });
  37. it('startPlay', async () => {
  38. await page.waitFor(100)
  39. const startPlay = await page.$('#btn-startPlay')
  40. await startPlay.tap()
  41. await page.waitFor(200)
  42. expect(await page.data('playing')).toBeTruthy()
  43. });
  44. it('stopPlay', async () => {
  45. await page.waitFor(100)
  46. const stopPlay = await page.$('#btn-stopPlay')
  47. await stopPlay.tap()
  48. await page.waitFor(200)
  49. expect(await page.data('playing')).toBeFalsy()
  50. });
  51. });