content-editing-movie-player 0.38.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. data/.gitmodules +3 -0
  2. data/.rvmrc +1 -0
  3. data/LICENSE.TXT +20 -0
  4. data/README.TXT +225 -0
  5. data/Rakefile +206 -0
  6. data/TODO +740 -0
  7. data/VERSION +1 -0
  8. data/_DO_NOT_RUN_IT_FROM_HERE_DOWNLOAD_THE_RELEASE_ZIP_FROM_SOURCEFORGE_INSTEAD +0 -0
  9. data/bin/sensible-cinema +60 -0
  10. data/bin/sensible-cinema-cli +161 -0
  11. data/business_ideas.txt +21 -0
  12. data/change_log_with_feature_list.txt +952 -0
  13. data/documentation/DOCUMENTATION_README.TXT +44 -0
  14. data/documentation/how_to_get_files_from_dvd.txt +30 -0
  15. data/documentation/is_it_legal_to_copy_dvds.txt +97 -0
  16. data/documentation/troubleshooting.txt +30 -0
  17. data/documentation/upconversion.txt +4 -0
  18. data/experimental_online_player_ocr_readme.txt +45 -0
  19. data/go +1 -0
  20. data/go.bat +2 -0
  21. data/go.sh +1 -0
  22. data/go_ocr_tracker.bat +1 -0
  23. data/goc +1 -0
  24. data/goc.bat +1 -0
  25. data/goc.sh +1 -0
  26. data/gpl-2.0.txt +339 -0
  27. data/gplv3.txt +219 -0
  28. data/history_and_related_works_list.txt +108 -0
  29. data/inventionzy_files/cone.png +0 -0
  30. data/inventionzy_files/md5s.txt +53 -0
  31. data/inventionzy_files/play_with_inserted_scene.bat +8 -0
  32. data/inventionzy_files/play_with_overlay.bat +24 -0
  33. data/inventionzy_files/transcript_mute_vlc.txt +117 -0
  34. data/legal_draft +23 -0
  35. data/lib/add_any_bundled_gems_to_load_path.rb +32 -0
  36. data/lib/auto_window_finder.rb +41 -0
  37. data/lib/blanker.rb +104 -0
  38. data/lib/check_installed_mac.rb +34 -0
  39. data/lib/convert_thirty_fps.rb +20 -0
  40. data/lib/edl_parser.rb +387 -0
  41. data/lib/eight_three.rb +28 -0
  42. data/lib/extract/dumpstream.bat +1 -0
  43. data/lib/extract/get_init.bat +3 -0
  44. data/lib/extract/pause_early.rb +13 -0
  45. data/lib/fake_blanker.rb +35 -0
  46. data/lib/frame_accurate.rb +3 -0
  47. data/lib/gui/base.rb +748 -0
  48. data/lib/gui/create-file.rb +24 -0
  49. data/lib/gui/create.rb +581 -0
  50. data/lib/gui/dependencies.rb +219 -0
  51. data/lib/gui/normal.rb +123 -0
  52. data/lib/gui/upconvert.rb +284 -0
  53. data/lib/keyboard_input.rb +60 -0
  54. data/lib/media_info_parser.rb +27 -0
  55. data/lib/mouse_forever.rb +19 -0
  56. data/lib/movie_hasher.rb +27 -0
  57. data/lib/mplayer_edl.rb +42 -0
  58. data/lib/muter.rb +87 -0
  59. data/lib/ocr.rb +125 -0
  60. data/lib/ocr_seed/netflix_b9.bmp +0 -0
  61. data/lib/overlayer.rb +373 -0
  62. data/lib/screen_tracker.rb +269 -0
  63. data/lib/subtitle_profanity_finder.rb +294 -0
  64. data/lib/vlc_programmer.rb +112 -0
  65. data/lib/zoom_player_max_edl.rb +50 -0
  66. data/never_do +40 -0
  67. data/notes_for_potential_developers.txt +46 -0
  68. data/preamble +17 -0
  69. data/roadmap_possibilities +12 -0
  70. data/spec/arse.srt +41 -0
  71. data/spec/auto_window_finder.spec.rb +65 -0
  72. data/spec/bad_beginning.srt +3778 -0
  73. data/spec/blanker.spec.rb +60 -0
  74. data/spec/common.rb +81 -0
  75. data/spec/convert_image.rb +25 -0
  76. data/spec/deity_end.srt +11 -0
  77. data/spec/dragon.srt +34 -0
  78. data/spec/edl_parser.spec.rb +270 -0
  79. data/spec/frame_accurate.spec.rb +71 -0
  80. data/spec/keyboard_input.spec.rb +73 -0
  81. data/spec/media_info_parser.spec.rb +29 -0
  82. data/spec/mplayer_edl.spec.rb +100 -0
  83. data/spec/muter.spec.rb +50 -0
  84. data/spec/notes +4996 -0
  85. data/spec/ocr.spec.rb +119 -0
  86. data/spec/overlayer.spec.rb +440 -0
  87. data/spec/screen_tracker.spec.rb +318 -0
  88. data/spec/sensible_cinema_gui.spec.rb +452 -0
  89. data/spec/subtitle_profanity_finder.spec.rb +224 -0
  90. data/spec/test_yaml.yml +4 -0
  91. data/spec/tsmuxer.output +33 -0
  92. data/spec/vlc_programmer.spec.rb +124 -0
  93. data/spec/youtube_edl.spec.rb +28 -0
  94. data/spec/zoom_player_max_edl.spec.rb +29 -0
  95. data/template_bats/README_DISTRO.TXT +8 -0
  96. data/template_bats/RUN SENSIBLE CINEMA CLICK HERE WINDOWS.bat +25 -0
  97. data/template_bats/_DO_NOT_RUN_IT_FROM_HERE_DOWNLOAD_THE_RELEASE_ZIP_FROM_SOURCEFORGE_INSTEAD +0 -0
  98. data/template_bats/mac/RUN SENSIBLE CINEMA CLICK HERE.command +5 -0
  99. data/template_bats/mac/advanced--create or edit sensible cinema edit list files.command +3 -0
  100. data/template_bats/mac/advanced--run-upconverting-video-player.command +3 -0
  101. data/template_bats/pc/advanced--create or edit sensible cinema edit list files.bat +2 -0
  102. data/template_bats/pc/advanced--run-upconverting-video-player.bat +2 -0
  103. data/todo.build_library.txt +11 -0
  104. data/todo.inventionzy.txt +162 -0
  105. data/todo.open_edl_list_org.txt +169 -0
  106. data/todo.propaganda +107 -0
  107. data/todo.subtitle +17 -0
  108. data/todo.upconvert +53 -0
  109. data/upconvert.bat +1 -0
  110. data/upconvert_from_screen/go_upscaling.bat +12 -0
  111. data/upconvert_from_screen/go_upscaling_works +0 -0
  112. data/upconvert_from_screen/old/latest2/combine_video.avs +23 -0
  113. data/upconvert_from_screen/old/latest2/go_no_upscaling.bat +1 -0
  114. data/upconvert_from_screen/old/latest2/go_upscaling.bat +12 -0
  115. data/upconvert_from_screen/old/latest2/push2.GRF +0 -0
  116. data/upconvert_from_screen/old/latest2/push3.grf +0 -0
  117. data/upconvert_from_screen/old/latest2/setup_capture_coords.rb +27 -0
  118. data/upconvert_from_screen/old/latest2/setup_directshow_filter_params.rb +29 -0
  119. data/upconvert_from_screen/old/latest2/upconvert_from_screen_me2.avs +19 -0
  120. data/upconvert_from_screen/old/latest_now_possibly_oudated/push2.GRF +0 -0
  121. data/upconvert_from_screen/old/latest_now_possibly_oudated/upconvert_from_screen_me2.avs +18 -0
  122. data/upconvert_from_screen/old/position_window.png +0 -0
  123. data/upconvert_from_screen/old/push_source_desktop.GRF +0 -0
  124. data/upconvert_from_screen/old/record_screen/record.bat +2 -0
  125. data/upconvert_from_screen/old/upconvert_from_screen.avs +21 -0
  126. data/upconvert_from_screen/old/upconvert_from_screen_me.avs +21 -0
  127. data/upconvert_from_screen/old/upconvert_from_screen_me2.avs +3 -0
  128. data/upconvert_from_screen/old/upconvert_from_screen_me_push_source.avs +3 -0
  129. data/upconvert_from_screen/old/uscreen.GRF +0 -0
  130. data/upconvert_from_screen/old/uscreen_me.GRF +0 -0
  131. data/upconvert_from_screen/push3.grf +0 -0
  132. data/upconvert_from_screen/upconvert_from_screen_me2.avs +19 -0
  133. data/vendor/movie-content-editor-read-only/.metadata/.lock +0 -0
  134. data/vendor/movie-content-editor-read-only/.metadata/.mylyn/.tasks.xml.zip +0 -0
  135. data/vendor/movie-content-editor-read-only/.metadata/.mylyn/repositories.xml.zip +0 -0
  136. data/vendor/movie-content-editor-read-only/.metadata/.mylyn/tasks.xml.zip +0 -0
  137. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/history.version +1 -0
  138. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.index +0 -0
  139. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/.indexes/properties.version +1 -0
  140. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.root/2.tree +0 -0
  141. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.resources/.safetable/org.eclipse.core.resources +0 -0
  142. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.core.resources.prefs +3 -0
  143. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.jdt.ui.prefs +14 -0
  144. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.mylyn.context.core.prefs +3 -0
  145. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.ide.prefs +5 -0
  146. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.ui.prefs +3 -0
  147. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.core/nonChainingJarsCache +0 -0
  148. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.core/variablesAndContainers.dat +0 -0
  149. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.ui/OpenTypeHistory.xml +2 -0
  150. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.ui/QualifiedTypeNameHistory.xml +2 -0
  151. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.jdt.ui/dialog_settings.xml +10 -0
  152. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.ide/dialog_settings.xml +11 -0
  153. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.intro/dialog_settings.xml +4 -0
  154. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.workbench/dialog_settings.xml +10 -0
  155. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.workbench/workbench.xml +232 -0
  156. data/vendor/movie-content-editor-read-only/.metadata/.plugins/org.eclipse.ui.workbench/workingsets.xml +4 -0
  157. data/vendor/movie-content-editor-read-only/.metadata/version.ini +1 -0
  158. data/vendor/movie-content-editor-read-only/.project +17 -0
  159. data/vendor/movie-content-editor-read-only/.pydevproject +11 -0
  160. data/vendor/movie-content-editor-read-only/.settings/org.eclipse.core.resources.prefs +6 -0
  161. data/vendor/movie-content-editor-read-only/SubIt.py +171 -0
  162. data/vendor/movie-content-editor-read-only/VLCMacVideo.py +257 -0
  163. data/vendor/movie-content-editor-read-only/VideoMac.ui +102 -0
  164. data/vendor/movie-content-editor-read-only/badwords.txt +4 -0
  165. data/vendor/movie-content-editor-read-only/blank.srt +4 -0
  166. data/vendor/movie-content-editor-read-only/edit.py +197 -0
  167. data/vendor/movie-content-editor-read-only/mergeCommands.py +73 -0
  168. data/vendor/movie-content-editor-read-only/mute.txt +5 -0
  169. data/vendor/movie-content-editor-read-only/panda.srt +4235 -0
  170. data/vendor/movie-content-editor-read-only/panda_custom.txt +3 -0
  171. data/vendor/movie-content-editor-read-only/panda_edit.srt +4235 -0
  172. data/vendor/movie-content-editor-read-only/subtitle.py +90 -0
  173. data/vendor/movie-content-editor-read-only/vlc.py +5579 -0
  174. data/vendor/movie-content-editor-read-only/vlcwidget.py +154 -0
  175. data/vendor/mplayer_patches/how_to_doze.bat +6 -0
  176. data/vendor/mplayer_patches/port_dir/PortIndex.quick +2 -0
  177. data/vendor/mplayer_patches/port_dir/how_to +20 -0
  178. data/vendor/mplayer_patches/port_dir/multimedia/mplayer-edl/Portfile +285 -0
  179. data/vendor/mplayer_patches/port_dir/multimedia/mplayer-edl/files/configure.x11.patch +20 -0
  180. data/vendor/mplayer_patches/port_dir/multimedia/mplayer-edl/files/llvm-gcc-workaround.patch +11 -0
  181. data/vendor/mplayer_patches/port_dir/multimedia/rdp-projects/Portfile +43 -0
  182. data/vendor/mplayer_patches/port_dir_is_for_mac +0 -0
  183. data/www/content_editor.html +92 -0
  184. data/www/index.html +47 -0
  185. data/www/upconverting_movie_player.html +62 -0
  186. data/www/video reel.jpg +0 -0
  187. data/www/youtube_edl/.htaccess +44 -0
  188. data/www/youtube_edl/control_youtube.rhtml +141 -0
  189. data/www/youtube_edl/dispatch.fcgi +25 -0
  190. data/www/youtube_edl/render_edited.rb +25 -0
  191. data/www/youtube_edl/server_this_dir.rb +6 -0
  192. data/www/youtube_edl/todo +23 -0
  193. data/www/zoomplayer_max.png +0 -0
  194. data/zamples/edit_decision_lists/dvds/Harry Potter 2 chamber of secrets.txt +22 -0
  195. data/zamples/edit_decision_lists/dvds/aa_example_delete_list_that_has_no_cuts_in_it.txt +10 -0
  196. data/zamples/edit_decision_lists/dvds/aladdin.txt +30 -0
  197. data/zamples/edit_decision_lists/dvds/bambi.txt +17 -0
  198. data/zamples/edit_decision_lists/dvds/big_buck_bunny_dvd.txt +23 -0
  199. data/zamples/edit_decision_lists/dvds/bob the builder pets in a pickle.txt +10 -0
  200. data/zamples/edit_decision_lists/dvds/bobs_big_plan.txt +10 -0
  201. data/zamples/edit_decision_lists/dvds/cars_2.txt +26 -0
  202. data/zamples/edit_decision_lists/dvds/cars_disney.txt +40 -0
  203. data/zamples/edit_decision_lists/dvds/condor_man_widescreen.txt +22 -0
  204. data/zamples/edit_decision_lists/dvds/cool runnings.txt +53 -0
  205. data/zamples/edit_decision_lists/dvds/court_jester.txt +24 -0
  206. data/zamples/edit_decision_lists/dvds/edls_being_edited/amazing_grace.txt +49 -0
  207. data/zamples/edit_decision_lists/dvds/edls_being_edited/father_goose.txt +41 -0
  208. data/zamples/edit_decision_lists/dvds/edls_being_edited/harry_potter_and_the_goblet_of_fire.txt +45 -0
  209. data/zamples/edit_decision_lists/dvds/edls_being_edited/hugo.txt +31 -0
  210. data/zamples/edit_decision_lists/dvds/edls_being_edited/making_marriage_work.txt +15 -0
  211. data/zamples/edit_decision_lists/dvds/edls_being_edited/national_treasure.txt +26 -0
  212. data/zamples/edit_decision_lists/dvds/edls_being_edited/percy_jackson_lightening_thief.txt +40 -0
  213. data/zamples/edit_decision_lists/dvds/edls_being_edited/percy_jackson_lightening_thief_mute_scary.txt +23 -0
  214. data/zamples/edit_decision_lists/dvds/edls_being_edited/prince_of_egypt.txt +28 -0
  215. data/zamples/edit_decision_lists/dvds/edls_being_edited/puss_in_boots.txt +33 -0
  216. data/zamples/edit_decision_lists/dvds/edls_being_edited/ratatouille.txt +35 -0
  217. data/zamples/edit_decision_lists/dvds/edls_being_edited/rio.txt +24 -0
  218. data/zamples/edit_decision_lists/dvds/edls_being_edited/test_delete_list_for_experimenting_with.txt +10 -0
  219. data/zamples/edit_decision_lists/dvds/edls_being_edited/the_explorers.txt +49 -0
  220. data/zamples/edit_decision_lists/dvds/finding_neverland.txt +32 -0
  221. data/zamples/edit_decision_lists/dvds/flight_of_the_navigator.txt +40 -0
  222. data/zamples/edit_decision_lists/dvds/happiest baby on the block.txt +9 -0
  223. data/zamples/edit_decision_lists/dvds/harry_potter_3_prisoner_of_azkaban.txt +37 -0
  224. data/zamples/edit_decision_lists/dvds/hitchhiker's_guide_to_the_galaxy.txt +32 -0
  225. data/zamples/edit_decision_lists/dvds/how_to_train_your_dragon.txt +25 -0
  226. data/zamples/edit_decision_lists/dvds/if_a_man_answers.txt +43 -0
  227. data/zamples/edit_decision_lists/dvds/innerspace.txt +77 -0
  228. data/zamples/edit_decision_lists/dvds/iq.txt +32 -0
  229. data/zamples/edit_decision_lists/dvds/king_of_kings.txt +28 -0
  230. data/zamples/edit_decision_lists/dvds/kung_fu_panda_1.txt +17 -0
  231. data/zamples/edit_decision_lists/dvds/legend_of_the_guardians_the_owls_of_gahoole.txt +18 -0
  232. data/zamples/edit_decision_lists/dvds/monsters_vs_aliens.txt +41 -0
  233. data/zamples/edit_decision_lists/dvds/muppet_treasure_island.txt +21 -0
  234. data/zamples/edit_decision_lists/dvds/nanny_mcphee.txt +31 -0
  235. data/zamples/edit_decision_lists/dvds/narnia_voyage_of_the_dawn_treader.txt +16 -0
  236. data/zamples/edit_decision_lists/dvds/pack_jackson_wedding_2007-03-03.txt +31 -0
  237. data/zamples/edit_decision_lists/dvds/peter_pan.txt +29 -0
  238. data/zamples/edit_decision_lists/dvds/remember_the_titans.txt +35 -0
  239. data/zamples/edit_decision_lists/dvds/sintel_open_source_blender_ntsc_dvd.txt +22 -0
  240. data/zamples/edit_decision_lists/dvds/snow_white_and_the_7_dwarfs_1937.txt +19 -0
  241. data/zamples/edit_decision_lists/dvds/speed_racer.txt +47 -0
  242. data/zamples/edit_decision_lists/dvds/tangled.txt +21 -0
  243. data/zamples/edit_decision_lists/dvds/tron_legacy.txt +29 -0
  244. data/zamples/edit_decision_lists/dvds/turn_around_alma_younger.txt +17 -0
  245. data/zamples/edit_decision_lists/files/conference_music_video.txt +10 -0
  246. data/zamples/edit_decision_lists/netflix_instant/avatar-last-air-bender-movie.txt +13 -0
  247. data/zamples/edit_decision_lists/netflix_instant/avatar-last-airbender-series.txt +1 -0
  248. data/zamples/edit_decision_lists/netflix_instant/greatest_story_ever_told_netflix.txt +10 -0
  249. data/zamples/edit_decision_lists/netflix_instant/wrinkle-in-time.txt +23 -0
  250. data/zamples/edit_decision_lists/notes_on_movies_without_edls_yet/tron.txt +10 -0
  251. data/zamples/edit_decision_lists/old_not_yet_updated/dvds/White Christmas.txt +15 -0
  252. data/zamples/edit_decision_lists/old_not_yet_updated/dvds/all_dogs_go_to_heaven.txt +9 -0
  253. data/zamples/edit_decision_lists/old_not_yet_updated/dvds/cars_disney.txt +24 -0
  254. data/zamples/edit_decision_lists/old_not_yet_updated/dvds/happy_feet.txt +12 -0
  255. data/zamples/edit_decision_lists/old_not_yet_updated/dvds/labyrinth.txt +17 -0
  256. data/zamples/edit_decision_lists/old_not_yet_updated/dvds/star_trek_generations_hulu.txt +8 -0
  257. data/zamples/edit_decision_lists/old_not_yet_updated/example_edit_decision_list.txt +14 -0
  258. data/zamples/edit_decision_lists/old_not_yet_updated/youtube/gummy_bear_song_youtube.txt +9 -0
  259. data/zamples/edit_decision_lists/youtube/demo_mutes.txt +12 -0
  260. data/zamples/edit_decision_lists/youtube/nuki_song_youtube.txt +14 -0
  261. data/zamples/edit_decision_lists/youtube/nuki_song_youtube_pointer.txt +3 -0
  262. data/zamples/players/how_to_create_more_players.txt +24 -0
  263. data/zamples/players/hulu/total_length_over_an_hour.txt +25 -0
  264. data/zamples/players/netflix/netflix_firefox_non_maximized.txt +25 -0
  265. data/zamples/players/vlc/full_screened_total_length_over_an_hour.txt +27 -0
  266. data/zamples/players/vlc/windowed_total_length_over_an_hour.txt +26 -0
  267. data/zamples/players/vlc/windowed_total_length_under_an_hour.txt +22 -0
  268. data/zamples/players/youtube/full_screened_1024x768.txt +20 -0
  269. data/zamples/players/youtube/full_screened_1152x864.txt +20 -0
  270. data/zamples/players/youtube/full_screened_1680x1050.txt +20 -0
  271. data/zamples/players/youtube/normal_in_youtube.com.chrome.txt +23 -0
  272. data/zamples/players/youtube/note_these_assume_less_than_10_minutes_length.txt +2 -0
  273. metadata +483 -0
@@ -0,0 +1,318 @@
1
+ =begin
2
+ Copyright 2010, Roger Pack
3
+ This file is part of Sensible Cinema.
4
+
5
+ Sensible Cinema is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ Sensible Cinema is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+ require File.expand_path(File.dirname(__FILE__) + '/common')
19
+ require_relative '../lib/overlayer'
20
+ require_relative '../lib/screen_tracker'
21
+
22
+ describe ScreenTracker do
23
+
24
+ SILENCE = /silence.*VLC/
25
+
26
+ def start_vlc_windowed_doze
27
+ unless $pid1
28
+ assert !$pid1
29
+ # enforce that we only have at most one running...
30
+ begin
31
+ Win32::Screenshot.window(SILENCE, 0) {}
32
+ raise Exception.new('must close existing vlcs first') # isn't caught
33
+ rescue
34
+ silence = File.expand_path("../lib/silence.wav").gsub("/", "\\")
35
+ vlc = Dir['/program files*/videolan/VLC/vlc.exe'][0]
36
+ # /Applications/VLC.app/Contents/MacOS/VLC lib/silence.wav -f
37
+ Dir.chdir(File.dirname(vlc)) do; IO.popen("vlc.exe #{silence}").pid; end # includes a work around for JRUBY-4959 /4958
38
+
39
+ # now also work around JRUBY-5756
40
+ until $pid1
41
+ $pid1 = GetPid.get_process_id_from_window(Win32::Screenshot::Util.window_hwnd(SILENCE)) rescue nil
42
+ sleep 0.01
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ def start_vlc_full_screen_mac
49
+ a = IO.popen "/Applications/VLC.app/Contents/MacOS/VLC --fullscreen --play-and-exit ../lib/silence.wav"
50
+ $pid1 = a.pid
51
+ end
52
+
53
+ before(:all) do
54
+ if OS.doze?
55
+ start_vlc_windowed_doze
56
+ elsif OS.mac?
57
+ start_vlc_full_screen_mac
58
+ else
59
+ raise 'unsupported'
60
+ end
61
+ end
62
+
63
+ before do
64
+ @a = ScreenTracker.new(SILENCE,10,10,20,20)
65
+ end
66
+
67
+ it "can take a regex or string" do
68
+ ScreenTracker.new(SILENCE,10,10,20,20)
69
+ ScreenTracker.new("silence",10,10,20,20)
70
+ end
71
+
72
+ it "should be able to grab a picture from screen coords...probably from the current active window" do
73
+ @a.get_bmp.should_not be_nil
74
+ end
75
+
76
+ it "should loop if unable to find the right window" do
77
+ proc {
78
+ Timeout::timeout(1) do
79
+ ScreenTracker.new("this is supposed to be not running",10,10,20,20)
80
+ end
81
+ }.should raise_error(Timeout::Error)
82
+ end
83
+
84
+ it "should be at least somewhat fast" do
85
+ Benchmark.realtime { @a.get_bmp }.should be < 0.3
86
+ end
87
+
88
+ it "should not allow for negative widths" do
89
+ proc {ScreenTracker.new("VLC",10,10,-20,20)}.should raise_error
90
+ end
91
+
92
+ it "should disallow size 0 widths" do
93
+ proc {ScreenTracker.new("VLC",10,10,0,0)}.should raise_error
94
+ end
95
+
96
+ it "should have different bmp if sizes different" do
97
+ a = ScreenTracker.new("VLC",10,10,5,5)
98
+ assert a.get_relative_coords_of_timestamp_window == [10,10,15,15]
99
+ b = ScreenTracker.new("VLC",10,10,50,50)
100
+ assert a.get_bmp != b.get_bmp
101
+ end
102
+
103
+ it "should allow for straight desktop if they specify Desktop or desktop" do
104
+ a = ScreenTracker.new("desktop",0,0,100,100)
105
+ end
106
+
107
+ context "negative numbers should be interpreted as an offset" do
108
+
109
+ it "should allow for negative size parameter" do
110
+ a = ScreenTracker.new("VLC",-10,10,5,5)
111
+ a.get_bmp
112
+ a = ScreenTracker.new("VLC",-10,-10,10,10) # right to the edge
113
+ a.get_bmp
114
+ a = ScreenTracker.new("VLC",10,-10,5,5)
115
+ a.get_bmp
116
+ end
117
+
118
+ it "should assign right offsets" do
119
+ a = ScreenTracker.new("VLC",-10,-10,5,5)
120
+ a.get_bmp
121
+ x,y,x2,y2=a.get_relative_coords_of_timestamp_window
122
+ hwnd = Win32::Screenshot::BitmapMaker.hwnd("VLC")
123
+ max_x, max_y = Win32::Screenshot::Util.dimensions_for(hwnd)
124
+ x.should == max_x-10
125
+ y.should == max_y-10
126
+ x2.should == x+5
127
+ y2.should == y+5
128
+ end
129
+
130
+ it "should take negative coords and appear to use them" do
131
+ a = ScreenTracker.new("VLC",10,10,50,50)
132
+ b = ScreenTracker.new("VLC",10,10,50,50)
133
+ c = ScreenTracker.new("VLC",-99,-99,50,50)
134
+ assert a.get_bmp == b.get_bmp
135
+ assert c.get_relative_coords_of_timestamp_window != b.get_relative_coords_of_timestamp_window
136
+ cb = c.get_bmp
137
+ bb = b.get_bmp
138
+ c.get_bmp.length == b.get_bmp.length
139
+ assert c.get_bmp != b.get_bmp
140
+ end
141
+
142
+ it "should fail with out of bounds or zero sizes" do
143
+ proc { a = ScreenTracker.new(SILENCE,-10,10,20,20) }.should raise_error
144
+ proc { a = ScreenTracker.new(SILENCE,10,-10,20,20) }.should raise_error
145
+ proc { a = ScreenTracker.new(SILENCE,-10,10,0,2) }.should raise_error
146
+ proc { a = ScreenTracker.new(SILENCE,10,10,2,0) }.should raise_error
147
+ end
148
+
149
+ end
150
+
151
+ # lodo: this 7 looks rather redundant...
152
+ it "should parse yaml appropro" do
153
+ yaml = <<-YAML
154
+ name: VLC
155
+ x: 32
156
+ y: 34
157
+ width: 100
158
+ height: 20
159
+ digits:
160
+ :hours:
161
+ :minute_tens:
162
+ - -90
163
+ - 7
164
+ :minute_ones:
165
+ - -82
166
+ - 7
167
+ :second_tens:
168
+ - -72
169
+ - 7
170
+ :second_ones:
171
+ - -66
172
+ - 7
173
+ YAML
174
+ a = ScreenTracker.new_from_yaml(yaml,nil)
175
+ a.get_relative_coords_of_timestamp_window.should == [32,34,132,54]
176
+ end
177
+
178
+ it "should be able to dump images it uses" do
179
+ @a.dump_bmp
180
+ assert File.exist?('dump.bmp') && File.exist?('all.dump.bmp')
181
+ end
182
+
183
+ context "tracking a real player that is moving" do
184
+
185
+ before do
186
+ @a = ScreenTracker.new(SILENCE, -111, -16, 86, 13)
187
+ end
188
+
189
+ it "should be able to poll the screen to know when something changes" do
190
+ @a.wait_till_next_change
191
+ # it updates every 1 second...
192
+ Benchmark.realtime { @a.wait_till_next_change }.should be > 0.2
193
+ @a.dump_bmp # for debugging...
194
+ end
195
+
196
+ it "should be able to track via class_name" do
197
+ a = ScreenTracker.new(SILENCE,10,10,20,20)
198
+ b = ScreenTracker.new(/qwidget/i,10,10,20,20, true, {:second_ones => [-66, 7]})
199
+ a.hwnd.should == b.hwnd
200
+ end
201
+
202
+ end
203
+
204
+ context "using hulu" do
205
+ it "should be able to parse all digits" do
206
+ pending "completion"
207
+ a = ScreenTracker.new_from_yaml File.read("../zamples/players/hulu/total_length_over_an_hour.txt"), nil
208
+ end
209
+
210
+ end
211
+
212
+ context "using youtube" do
213
+ it "should be able to parse"
214
+ end
215
+
216
+ context "using a digit capable setting" do
217
+
218
+ before do
219
+ @a = ScreenTracker.new_from_yaml File.read("../zamples/players/vlc/windowed_total_length_under_an_hour.txt"), nil
220
+ end
221
+
222
+ it "should use OCR against the changes appropriately" do
223
+ sleep 1.1 # sleep until it should show something for sure
224
+ output = @a.wait_till_next_change # grab a real change
225
+ output[0].should be_a(String)
226
+ output[0].should include("00:") # like 00:09 or what not...
227
+ output[0].should match(/[1-9]/)
228
+ output[1].should be_a(Float)
229
+ end
230
+
231
+ it "should be able to scan for/identify new windows, since VLC creates entirely new windows when it transition
232
+ from menu -> player" do
233
+
234
+ output = @a.wait_till_next_change
235
+ output[0].should_not be_nil
236
+ old_handle = @a.hwnd
237
+ kill_vlc
238
+ start_vlc
239
+ output = @a.wait_till_next_change
240
+ output[0].should_not be_nil
241
+ old_handle.should_not == @a.hwnd
242
+ end
243
+
244
+ it "should be able to disk dump its digit images" do
245
+ @a.dump_bmp
246
+ # what is the right number here?
247
+ Pathname.new('minute_tens.1.bmp').should exist
248
+ Pathname.new('minute_tens.1.bmp').size.should be > 0
249
+ # doesn't have hours
250
+ Pathname.new('hours.1.bmp').should_not exist
251
+ end
252
+
253
+ it "should be ok with a non-existent (non-returned) hours image" do
254
+ @a.stub!(:get_digits_as_bitmaps) do
255
+ four = File.binread('images/vlc_4.bmp')
256
+ black = File.binread('images/black.bmp')
257
+ {:minute_tens=>four,:second_tens => four, :second_ones => four, :minute_ones => four,
258
+ :hours => black}
259
+ end
260
+ @a.attempt_to_get_time_from_screen(Time.now)[0].should == "0:44:44" # hour is zero
261
+ end
262
+
263
+ it "should track the screen until it stabilizes, as VLC has a slight lag when seconds turn but minutes don't for a tidge" do
264
+ time_through = 0
265
+ four = File.binread('images/vlc_4.bmp')
266
+ black = File.binread('images/black.bmp')
267
+ times_read=0
268
+ @a.stub!(:get_digits_as_bitmaps) do
269
+ time_through += 1
270
+ if time_through == 1
271
+ {:minute_tens=>four}
272
+ elsif time_through == 2
273
+ {:minute_tens=>black}
274
+ else
275
+ # just return the same thing
276
+ times_read += 1
277
+ {:minute_tens=>four,:second_tens => four, :second_ones => four, :minute_ones => four,
278
+ :hours => four}
279
+ end
280
+ end
281
+
282
+ got = @a.attempt_to_get_time_from_screen(Time.now)
283
+ time_through.should == 4
284
+ times_read.should == 2
285
+ got[0].should == "4:44:44"
286
+ end
287
+
288
+ context "with an OCR that can change from hour to minutes during ads" do
289
+ it "should detect this change and act appropriately"
290
+ end
291
+
292
+ it "should be able to pass through the option to invert images" do
293
+ @a = ScreenTracker.new(SILENCE, 100, 100, 10, 10, false,
294
+ {:should_invert => true, :second_ones => [-66, 7]} ) # VLC descriptor is messed currently...
295
+ got_it = nil
296
+ OCR.stub!(:identify_digit) {|*args|
297
+ got_it = args
298
+ }
299
+ @a.identify_digit('some binary bitmap data')
300
+ got_it[1][:should_invert].should be_true
301
+ end
302
+ end
303
+
304
+
305
+ def kill_vlc
306
+ assert $pid1
307
+ # jruby...<sigh>
308
+ system("taskkill /pid #{$pid1}")
309
+ Process.kill 9, $pid1 # MRI...sigh.
310
+ FileUtils.rm_rf Dir['*.bmp']
311
+ $pid1 = nil
312
+ sleep 1
313
+ end
314
+
315
+ after(:all) do
316
+ kill_vlc
317
+ end
318
+ end
@@ -0,0 +1,452 @@
1
+ =begin
2
+ Copyright 2010, Roger Pack
3
+ This file is part of Sensible Cinema.
4
+
5
+ Sensible Cinema is free software: you can redistribute it and/or modify
6
+ it under the terms of the GNU General Public License as published by
7
+ the Free Software Foundation, either version 3 of the License, or
8
+ (at your option) any later version.
9
+
10
+ Sensible Cinema is distributed in the hope that it will be useful,
11
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License
16
+ along with Sensible Cinema. If not, see <http://www.gnu.org/licenses/>.
17
+ =end
18
+ require 'ostruct'
19
+ require File.expand_path(File.dirname(__FILE__) + '/common')
20
+
21
+ Dir.chdir '..' # need to run in the main folder, common moves us to spec...
22
+ load 'bin/sensible-cinema'
23
+ #require_relative 'lib/edl_parser' # to avoid having require_relative collide with autoload <sigh>
24
+
25
+ module SensibleSwing
26
+ describe MainWindow do
27
+ it "should be able to start up" do
28
+ MainWindow.new.dispose# doesn't crash :)
29
+ end
30
+
31
+ it "should have working is_dvd method for mac"
32
+
33
+ Test_DVD_ID = 'deadbeef|8b27d001'
34
+
35
+ it "should die if you file select a poorly formed edl" do
36
+ time_through = 0
37
+ EdlParser.stub!(:single_edit_list_matches_dvd) { |dir, md5|
38
+ 'fake filename doesnt matter what we return here because we fake its parsing later anyway'
39
+ }
40
+
41
+ @subject.stub!(:parse_edl) {
42
+ time_through += 1
43
+ eval("a-----") # force it to throw a Syntax Error first time
44
+ }
45
+ proc { @subject.choose_dvd_or_file_and_edl_for_it}.should raise_exception(SyntaxError)
46
+ @show_blocking_message_dialog_last_arg.should be nil
47
+ time_through.should == 1
48
+ end
49
+
50
+ def with_clean_edl_dir_as this
51
+ FileUtils.rm_rf 'temp'
52
+ Dir.mkdir 'temp'
53
+ old_edl = EdlParser::EDL_DIR.dup
54
+ EdlParser::EDL_DIR.sub!(/.*/, 'temp')
55
+ begin
56
+ yield
57
+ ensure
58
+ EdlParser::EDL_DIR.sub!(/.*/, old_edl)
59
+ end
60
+ end
61
+
62
+ it "should not modify path to have mplayer available" do
63
+ ENV['PATH'].should_not include("mplayer")
64
+ end
65
+
66
+ before do
67
+ File.write('selected_file', '"name" => "a dvd name to satisfy internal assertion", "dvd_title_track" => "2", "mutes" => ["06:10", "06:15"]')
68
+ end
69
+
70
+ before do
71
+ @subject = MainWindow.new false # false to speedup tests
72
+ # want lots of buttons :)
73
+ @subject.setup_advanced_buttons
74
+ @subject.setup_normal_buttons
75
+ @subject.add_options_that_use_local_files
76
+ FileUtils.touch "selected_file.fulli_unedited.tmp.mpg.done" # a few of them need this...
77
+ FileUtils.touch 'selected_file.avi'
78
+ @subject.stub!(:choose_dvd_drive_or_file) {
79
+ ["mock_dvd_drive", "Volume", Test_DVD_ID] # happiest baby on the block
80
+ }
81
+ @subject.stub!(:get_mencoder_commands) { |*args|
82
+ args[-5].should == 'selected_file'
83
+ @get_mencoder_commands_args = args
84
+ 'fake get_mencoder_commands'
85
+ }
86
+ @subject.stub!(:new_existing_file_selector_and_select_file) {
87
+ 'selected_file'
88
+ }
89
+ @subject.stub!(:new_nonexisting_filechooser_and_go) {
90
+ 'selected_file' # TODO do we need FakefileChooser anymore?
91
+ }
92
+ @subject.stub!(:get_drive_with_most_space_with_slash) {
93
+ "e:\\"
94
+ }
95
+ @subject.stub!(:show_blocking_message_dialog) { |*args|
96
+ @show_blocking_message_dialog_last_arg = args[0]
97
+ }
98
+
99
+ @subject.stub!(:get_user_input) {'01:00'}
100
+ @subject.stub!(:system_blocking) { |*command|
101
+ @system_blocking_command = command[0]
102
+ }
103
+
104
+ @subject.stub!(:system_non_blocking) { |command|
105
+ @system_non_blocking_command = command
106
+ Thread.new {} # fake out the return...
107
+ }
108
+ @subject.stub!(:open_file_to_edit_it) {}
109
+
110
+ PlayAudio.stub!(:play) {
111
+ # don't play anything, by default :)
112
+ }
113
+
114
+ @subject.stub!(:show_in_explorer) {|filename|}
115
+ unless $VERBOSE
116
+ # less chatty...
117
+ @subject.stub!(:print) {}
118
+ @subject.stub!(:p) {}
119
+ @subject.stub!(:puts) {}
120
+ EdlParser.stub!(:p) {}
121
+ end
122
+
123
+ @subject.stub(:show_non_blocking_message_dialog) {
124
+ # don't display the popup message...
125
+ fake_window = OpenStruct.new
126
+ fake_window.dispose = :ok
127
+ fake_window
128
+ }
129
+ end
130
+
131
+ before do
132
+ EdlParser::EDL_DIR.gsub!(/^.*$/, 'spec/files/edls')
133
+ end
134
+
135
+ after do
136
+ # too dangerous...if it ever joins on a swing thread lights out!
137
+ #Thread.join_all_others
138
+ FileUtils.rm_rf EdlParser::EDL_DIR
139
+ Dir.mkdir EdlParser::EDL_DIR
140
+ end
141
+
142
+ class FakeFileChooser
143
+ def set_title x; end
144
+ def set_file y; end
145
+ def set_current_directory x; end
146
+ def get_current_directory ; 'a great dir!'; end
147
+ def go
148
+ 'selected_file'
149
+ end
150
+ end
151
+
152
+ # name like :@rerun_previous
153
+ def click_button(name)
154
+ button = @subject.instance_variable_get(name)
155
+ raise 'button not found: ' + name.to_s unless button
156
+ button.simulate_click
157
+ end
158
+
159
+ it "should be able to run system" do
160
+ @subject.system_non_blocking "ls"
161
+ end
162
+
163
+ it "should have a good default title of 1" do
164
+ @subject.get_title_track({}).should == "1"
165
+ descriptors = {"dvd_title_track" => "3"}
166
+ @subject.get_title_track(descriptors).should == "3"
167
+ end
168
+
169
+ def assert_played_mplayer # used?
170
+ Thread.join_all_others
171
+ if OS.doze?
172
+ @system_blocking_command.should =~ /smplayer/
173
+ else
174
+ @system_blocking_command.should =~ /mplayer/
175
+ end
176
+ end
177
+
178
+ def run_preview_section_button_successfully
179
+ click_button(:@preview_section)
180
+ join_background_thread
181
+ @get_mencoder_commands_args[-2].should == "2"
182
+ @get_mencoder_commands_args[-3].should == "01:00"
183
+ assert_played_mplayer
184
+ end
185
+
186
+ it "should prompt for start and end times" do
187
+ run_preview_section_button_successfully
188
+ end
189
+
190
+ temp_dir = Dir.tmpdir
191
+
192
+ def join_background_thread
193
+ @subject.background_thread.join # force it to have been started at least
194
+ Thread.join_all_others # just in case...
195
+ end
196
+
197
+ it "should warn if you give it an mkv file, just in case" do
198
+ @subject.stub!(:run_smplayer_blocking) {} # avoid check for file existence
199
+ @subject.unstub!(:get_mencoder_commands) # this time through, let it really check for existence of edits...
200
+ @subject.stub!(:get_user_input).and_return('06:00', '07:00')
201
+ click_button(:@preview_section)
202
+ @show_blocking_message_dialog_last_arg.should =~ /is not a/
203
+ join_background_thread
204
+ end
205
+
206
+ it "should not warn if a ts file, and has appropriate entries within timeframe" do
207
+ @subject.stub!(:get_user_input).and_return('06:00', '07:00')
208
+ @subject.stub!(:new_existing_file_selector_and_select_file).and_return('selected_file', 'selected_file.mpg')
209
+ click_button(:@preview_section)
210
+
211
+ @show_blocking_message_dialog_last_arg.should =~ /preview just a portion/
212
+ join_background_thread # weird...rspec you should do my after blocks before you'n... LODO
213
+ end
214
+
215
+ it "should create a new file based on stats of current disc" do
216
+ out = EdlParser::EDL_DIR + "/edls_being_edited/sweetest_disc_ever.txt"
217
+ FileUtils.mkdir_p File.dirname(out)
218
+ File.exist?( out ).should be_false
219
+ @subject.stub!(:get_user_input) {'sweetest disc ever'}
220
+ @subject.instance_variable_get(:@create_new_edl_for_current_dvd).simulate_click
221
+ begin
222
+ File.exist?( out ).should be_true
223
+ content = File.read(out)
224
+ content.should_not include("\"title\"")
225
+ content.should include("disk_unique_id")
226
+ content.should include("dvd_title_track")
227
+ content.should include("mplayer_dvd_splits")
228
+ ensure
229
+ FileUtils.rm_rf out
230
+ end
231
+ end
232
+
233
+ it "should display unique disc in an input box" do
234
+ click_button(:@display_dvd_info).should =~ /deadbeef/
235
+ end
236
+
237
+ it "should create an edl and pass it through to mplayer" do
238
+ smplayer_opts = nil
239
+ @subject.stub(:set_smplayer_opts) { |to_this, show_subs|
240
+ smplayer_opts = to_this
241
+ }
242
+ click_button(:@mplayer_edl).join
243
+ smplayer_opts.should match(/-edl /)
244
+ @system_blocking_command.should match(/mock_dvd_drive/) #
245
+ @system_blocking_command.should_not =~ /dvdnav/ # file based, so no dvdvnav
246
+ @system_blocking_command.should_not =~ /-nocache/ # file based, so no -nocache
247
+ end
248
+
249
+ it "should handle dvd drive -> dvdnav" do
250
+ for drive in ['d:', 'e:', 'f:', 'g:']
251
+ if File.exist?(drive + '/VIDEO_TS')
252
+ @subject.run_smplayer_blocking drive, nil, '', true, true, true
253
+ @system_blocking_command.should =~ /dvdnav/
254
+ @system_blocking_command.should =~ /-dvd-device/
255
+ end
256
+ end
257
+ end
258
+
259
+ it 'should handle a/b/VIDEO_TS/yo.vob' do
260
+ FileUtils.mkdir_p f = 'a/b/VIDEO_TS/yo.vob'
261
+ @subject.run_smplayer_blocking f, 3, '', true, false, true
262
+ @system_blocking_command.should =~ /dvdnav:\/\/3/
263
+ @system_blocking_command.should =~ /VIDEO_TS\/\.\./
264
+ @system_blocking_command.should =~ / -alang/ # preceding space :)
265
+
266
+ # exercise the yes subtitle options...
267
+ @subject.run_smplayer_blocking f, 3, '', true, true, true
268
+ @system_blocking_command.should_not =~ /-nosub/
269
+
270
+ end
271
+
272
+ it "should play edl with extra time for the mutes because of the EDL aspect" do
273
+ click_button(:@mplayer_edl).join
274
+ wrote = File.read(MainWindow::EdlTempFile)
275
+ wrote.should include("369.0 375.0 1") # right numbers, except first -= 1
276
+ end
277
+
278
+ def should_allow_for_changing_file corrupt_the_file = false
279
+ with_clean_edl_dir_as 'temp' do
280
+ File.binwrite('temp/a.txt', "\"disk_unique_id\" => \"abcdef1234\"")
281
+ @subject.stub!(:choose_dvd_drive_or_file) {
282
+ FileUtils.touch 'mock_dvd_drive'
283
+ ["mock_dvd_drive", "Volume", "abcdef1234"]
284
+ }
285
+ @subject.choose_dvd_or_file_and_edl_for_it[4]['mutes'].should == []
286
+ new_file_contents = '"disk_unique_id" => "abcdef1234","mutes"=>["0:33", "0:34"]'
287
+ new_file_contents = '"a syntax error' if corrupt_the_file
288
+ File.binwrite('temp/a.txt', new_file_contents)
289
+ # file has been modified!
290
+ @subject.choose_dvd_or_file_and_edl_for_it[4]['mutes'].should_not == []
291
+ end
292
+ end
293
+
294
+ it "should allow for file to change contents while editing it" do
295
+ should_allow_for_changing_file
296
+ end
297
+
298
+ it "should prompt you if you re-choose, and your file now has a failure in it" do
299
+ @subject.stub(:show_blocking_message_dialog) {
300
+ @got_here = true
301
+ @subject.stub(:parse_edl) { 'pass the second time through' }
302
+ }
303
+ should_allow_for_changing_file true
304
+ @got_here.should == true
305
+ end
306
+
307
+ describe 'with unstubbed choose_dvd_drive_or_file' do
308
+ before do
309
+ DriveInfo.stub!(:get_dvd_drives_as_openstruct) {
310
+ a = OpenStruct.new
311
+ a.VolumeName = 'a dvd name'
312
+ a.Name = 'a path location'
313
+ [a]
314
+ }
315
+ @subject.unstub!(:choose_dvd_drive_or_file)
316
+ end
317
+
318
+ def yo select_a_dvd
319
+ count = 0
320
+ DriveInfo.stub!(:md5sum_disk) {
321
+ count += 1
322
+ Test_DVD_ID
323
+ }
324
+ if !select_a_dvd
325
+ DriveInfo.stub!(:get_dvd_drives_as_openstruct) { [] } # no DVD disks inserted...
326
+ end
327
+ @subject.stub(:get_disk_chooser_window) {|names|
328
+ a = OpenStruct.new
329
+ def a.setSize x,y; end
330
+ a.stub(:selected_idx) { 0 } # first entry is either DVD name *or* file, and is apparently "0" weird weird weird
331
+ # ruby bug [?] always return nil
332
+ # def a.selected_idx; p 'returning', select_this_idx; select_this_idx; end
333
+ a
334
+ }
335
+ @subject.stub(:new_nonexisting_filechooser_and_go) {|a, b|
336
+ 'selected_filename'
337
+ }
338
+ @subject.stub(:new_existing_file_selector_and_select_file) {
339
+ 'selected_edl'
340
+ }
341
+ FileUtils.touch 'selected_edl' # blank file is ok :P
342
+ @subject.choose_dvd_or_file_and_edl_for_it
343
+ @subject.choose_dvd_or_file_and_edl_for_it
344
+ count
345
+ end
346
+
347
+ it "should only prompt for disk selection once" do
348
+ yo( true ).should == 1 # choose the 'a dvd name' DVD
349
+ end
350
+
351
+ it "should only prompt for file selection once" do
352
+ prompted = false
353
+ @subject.stub(:assert_ownership_dialog) {
354
+ prompted = true
355
+ }
356
+ yo( false ).should == 0 # choose a file, so never dvdid any dvd...
357
+ assert prompted
358
+ end
359
+
360
+ it "should prompt you if you need to insert a dvd" do
361
+ DriveInfo.stub!(:get_dvd_drives_as_openstruct) {
362
+ a = OpenStruct.new
363
+ #a.VolumeName = 'a dvd name' # we "don't have a disk in" for this test...
364
+ a.Name = 'a path location'
365
+ [a]
366
+ }
367
+ proc {@subject.choose_dvd_drive_or_file true}.should raise_error(/no dvd found/)
368
+ @show_blocking_message_dialog_last_arg.should_not be nil
369
+ end
370
+ end
371
+
372
+ it "should show additional buttons in create mode" do
373
+ MainWindow.new(false).setup_default_buttons.buttons.length.should be > 3
374
+ MainWindow.new(false).setup_default_buttons.buttons.length.should be < 10
375
+ old_length = MainWindow.new(false).setup_default_buttons.buttons.length
376
+ ARGV << "--create-mode"
377
+ MainWindow.new(false).setup_default_buttons.buttons.length.should be > (old_length + 5)
378
+ ARGV.pop # post-test cleanup--why not :)
379
+ end
380
+
381
+ it "should show upconvert buttons" do
382
+ ARGV << "--upconvert-mode"
383
+ MainWindow.new(false).setup_default_buttons.buttons.length.should be > 3
384
+ ARGV.pop
385
+ end
386
+
387
+ it "should be able to parse an srt for ya" do
388
+ @subject.stub!(:new_existing_file_selector_and_select_file) {
389
+ 'spec/dragon.srt'
390
+ }
391
+ file = SensibleSwing::MainWindow::EdlTempFile
392
+ FileUtils.rm_rf file
393
+ click_button(:@parse_srt)
394
+ assert File.read(file).contain? "deitys"
395
+ end
396
+
397
+ it "should have a created play unedited smplayer button" do
398
+ click_button(:@play_smplayer)
399
+ end
400
+
401
+ it "should create an sxs file" do
402
+ FileUtils.rm_rf 'yo.edl' # nothing up my sleeve.
403
+ prompted = false
404
+ @subject.stub(:assert_ownership_dialog) {
405
+ prompted = true
406
+ }
407
+ @subject.stub(:new_existing_file_selector_and_select_file).and_return("yo.mpg", "selected_file")
408
+ click_button(:@create_dot_edl)
409
+ assert File.exist? 'yo.edl'
410
+ assert prompted
411
+ end
412
+
413
+ it "should be able to upconvert at all" do
414
+ MainWindow.any_instance.stub(:display_current_upconvert_setting_and_close_window) {} # TRY it out
415
+ @subject = MainWindow.new(false)
416
+ MainWindow::LocalStorage['screen_multiples'] = 2.0 # default so it won't fail us...
417
+ @subject.add_change_upconvert_buttons
418
+ @subject.stub(:show_mplayer_instructions_once) {}
419
+ click_button(:@medium_dvd)
420
+ storage = MainWindow::LocalStorage
421
+ key = MainWindow::UpConvertKey
422
+ storage[key].should =~ /hqdn3d/
423
+ click_button(:@none)
424
+ storage[key].should be_nil
425
+ click_button(:@medium_dvd)
426
+
427
+ # now it should use them on mplayer
428
+ got = nil
429
+ @subject.stub(:system_blocking) { |c|
430
+ got = c
431
+ }
432
+ @subject.run_smplayer_blocking 'selected_file.avi', nil, "", true, true, false
433
+ assert got =~ /hqdn3d/
434
+
435
+ # and on smplayer
436
+ MainWindow::SMPlayerIniFile.gsub!(/^.*$/, File.expand_path('./smplayer_ini_file')) # don't overwrite the real one...
437
+ @subject.run_smplayer_blocking 'selected_file.avi', nil, "", false, true, false
438
+ assert got =~ /mplayer/
439
+ assert File.read(MainWindow::SMPlayerIniFile) =~ /hqdn3d/
440
+ end
441
+
442
+ it "should be able to play upconverted stuff" do
443
+ @subject.add_play_upconvert_buttons
444
+ click_button(:@watch_file_upconvert)
445
+ assert_played_mplayer
446
+ click_button(:@watch_dvd_upconvert)
447
+ assert_played_mplayer
448
+ end
449
+
450
+ end # describe MainWindow
451
+
452
+ end