video.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * Created with JetBrains PhpStorm.
  3. * User: Administrator
  4. * Date: 13-5-15
  5. * Time: 下午7:15
  6. * To change this template use File | Settings | File Templates.
  7. */
  8. module( 'plugins.video' );
  9. test( '插入优酷视频', function () {
  10. var editor = te.obj[0];
  11. var range = te.obj[1];
  12. editor.setContent( '<p>hello</p>' );
  13. range.setStart(editor.body.firstChild,0).collapse(true).select();
  14. var videoObject ={url: "http://player.youku.com/player.php/Type/Folder/Fid/19275705/Ob/1/sid/XNTU3Mjk4NzQ4/v.swf", width: "500", height: "400", align: "center"}
  15. editor.execCommand( 'insertvideo',videoObject);
  16. stop();
  17. setTimeout(function(){
  18. var img = editor.body.getElementsByTagName('img');
  19. equal(img.length,1,'插入img');
  20. equal(img[0].width,"500");
  21. equal(img[0].height,"400");
  22. equal(img[0].src,editor.options.UEDITOR_HOME_URL+'themes/default/images/spacer.gif');
  23. if(ua.browser.gecko||ua.browser.ie>8){
  24. ok(img[0].style.background.indexOf('url(\"'+editor.options.UEDITOR_HOME_URL+'themes/default/images/videologo.gif\")') > -1, '占位符背景图是否正常');
  25. }
  26. else
  27. {
  28. ok(img[0].style.background.indexOf("url("+editor.options.UEDITOR_HOME_URL+"themes/default/images/videologo.gif)") > -1, '占位符背景图是否正常');
  29. }
  30. var html = editor.getContent();
  31. ok(html.toLowerCase().indexOf('<embed') != -1, '转换为embed标签');
  32. start();
  33. },100);
  34. } );
  35. test( '插入上传视频', function () {
  36. var editor = te.obj[0];
  37. var range = te.obj[1];
  38. editor.setContent( '<p>hello</p>' );
  39. range.setStart(editor.body.firstChild,0).collapse(true).select();
  40. var videoObject ={url: "http://video-js.zencoder.com/oceans-clip.mp4", width: "500", height: "400", align: "center"}
  41. editor.execCommand( 'insertvideo',videoObject,'upload');
  42. stop();
  43. setTimeout(function(){
  44. var img = editor.body.getElementsByTagName('img');
  45. equal(img.length,1,'插入img');
  46. equal(img[0].width,"500");
  47. equal(img[0].height,"400");
  48. ok(img[0].className && img[0].className.indexOf('edui-upload-video') != -1, 'okey:有edui-upload-video的class标记');
  49. equal(img[0].src,editor.options.UEDITOR_HOME_URL+'themes/default/images/spacer.gif');
  50. if(ua.browser.gecko||ua.browser.ie>8){
  51. ok(img[0].style.background.indexOf('url(\"'+editor.options.UEDITOR_HOME_URL+'themes/default/images/videologo.gif\")') > -1, '占位符背景图是否正常');
  52. }
  53. else
  54. {
  55. ok(img[0].style.background.indexOf("url("+editor.options.UEDITOR_HOME_URL+"themes/default/images/videologo.gif)") > -1, '占位符背景图是否正常');
  56. }
  57. var html = editor.getContent();
  58. ok(html.toLowerCase().indexOf('<video') != -1, '转换为video标签');
  59. start();
  60. },100);
  61. } );