Ei kuvausta

test-stream.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import RNTest from './react-native-testkit/'
  2. import React from 'react'
  3. import RNFetchBlob from 'react-native-fetch-blob'
  4. import {
  5. StyleSheet,
  6. Text,
  7. View,
  8. ScrollView,
  9. Platform,
  10. Dimensions,
  11. Image,
  12. TouchableOpacity,
  13. } from 'react-native';
  14. window.XMLHttpRequest = RNFetchBlob.polyfill.XMLHttpRequest
  15. window.Blob = RNFetchBlob.polyfill.Blob
  16. const fs = RNFetchBlob.fs
  17. const { Assert, Comparer, Info, prop } = RNTest
  18. const describe = RNTest.config({
  19. group : 'streaming',
  20. run : true,
  21. expand : true,
  22. timeout : 20000,
  23. })
  24. const { TEST_SERVER_URL, TEST_SERVER_URL_SSL, FILENAME, DROPBOX_TOKEN, styles } = prop()
  25. const dirs = RNFetchBlob.fs.dirs
  26. let prefix = ((Platform.OS === 'android') ? 'file://' : '')
  27. describe('#143 streaming', (report, done) => {
  28. let count = 0
  29. let last = null
  30. RNFetchBlob.fetch('GET', `${TEST_SERVER_URL}/video/150`, {
  31. 'Cache-Control' : 'no-store'
  32. })
  33. .part((chunk) => {
  34. console.log('part', ++count, chunk.length)
  35. last = chunk
  36. report(<Info key="stream viewr" uid="100">
  37. <Image key="frame" style={{ height : 256, width : 256 }} source={{uri :'data:image/jpeg;base64,' + chunk}}/>
  38. </Info>)
  39. })
  40. .then((res) => {
  41. done()
  42. })
  43. })