Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 55... Línea 55...
55
    }
55
    }
Línea 56... Línea 56...
56
 
56
 
57
    /**
57
    /**
58
     * Test that plugin is returned as enabled media plugin.
58
     * Test that plugin is returned as enabled media plugin.
59
     */
59
     */
60
    public function test_is_installed() {
60
    public function test_is_installed(): void {
61
        $sortorder = \core\plugininfo\media::get_enabled_plugins();
61
        $sortorder = \core\plugininfo\media::get_enabled_plugins();
62
        $this->assertEquals(['videojs' => 'videojs'], $sortorder);
62
        $this->assertEquals(['videojs' => 'videojs'], $sortorder);
Línea 63... Línea 63...
63
    }
63
    }
64
 
64
 
65
    /**
65
    /**
66
     * Test method get_supported_extensions()
66
     * Test method get_supported_extensions()
67
     */
67
     */
68
    public function test_supported_extensions() {
68
    public function test_supported_extensions(): void {
Línea 69... Línea 69...
69
        $supportedextensions = array_merge(file_get_typegroup('extension', 'html_video'),
69
        $supportedextensions = array_merge(file_get_typegroup('extension', 'html_video'),
70
            file_get_typegroup('extension', 'html_audio'), file_get_typegroup('extension', 'media_source'));
70
            file_get_typegroup('extension', 'html_audio'), file_get_typegroup('extension', 'media_source'));
Línea 90... Línea 90...
90
    }
90
    }
Línea 91... Línea 91...
91
 
91
 
92
    /**
92
    /**
93
     * Test embedding without media filter (for example for displaying file resorce).
93
     * Test embedding without media filter (for example for displaying file resorce).
94
     */
94
     */
95
    public function test_embed_url() {
95
    public function test_embed_url(): void {
Línea 96... Línea 96...
96
        global $CFG;
96
        global $CFG;
Línea 97... Línea 97...
97
 
97
 
Línea 126... Línea 126...
126
    /**
126
    /**
127
     * Test that mediaplugin filter replaces a link to the supported file with media tag.
127
     * Test that mediaplugin filter replaces a link to the supported file with media tag.
128
     *
128
     *
129
     * filter_mediaplugin is enabled by default.
129
     * filter_mediaplugin is enabled by default.
130
     */
130
     */
131
    public function test_embed_link() {
131
    public function test_embed_link(): void {
132
        global $CFG;
132
        global $CFG;
133
        $url = new moodle_url('http://example.org/some_filename.mp4');
133
        $url = new moodle_url('http://example.org/some_filename.mp4');
134
        $text = html_writer::link($url, 'Watch this one');
134
        $text = html_writer::link($url, 'Watch this one');
135
        $content = format_text($text, FORMAT_HTML);
135
        $content = format_text($text, FORMAT_HTML);
Línea 142... Línea 142...
142
    }
142
    }
Línea 143... Línea 143...
143
 
143
 
144
    /**
144
    /**
145
     * Test that only supported URLs are listed as sources but all URLs are present in links fallbacks.
145
     * Test that only supported URLs are listed as sources but all URLs are present in links fallbacks.
146
     */
146
     */
Línea 147... Línea 147...
147
    public function test_fallback() {
147
    public function test_fallback(): void {
148
 
148
 
149
        $urls = [
149
        $urls = [
150
            new moodle_url('http://example.org/1.rv'), // Not supported.
150
            new moodle_url('http://example.org/1.rv'), // Not supported.
Línea 173... Línea 173...
173
    }
173
    }
Línea 174... Línea 174...
174
 
174
 
175
    /**
175
    /**
176
     * Assert other players do not apply after videojs was applied.
176
     * Assert other players do not apply after videojs was applied.
177
     */
177
     */
178
    public function test_prevent_other_players() {
178
    public function test_prevent_other_players(): void {
179
        \core\plugininfo\media::set_enabled_plugins('videojs,html5video');
179
        \core\plugininfo\media::set_enabled_plugins('videojs,html5video');
180
        $url = new moodle_url('http://example.org/some_filename.webm');
180
        $url = new moodle_url('http://example.org/some_filename.webm');
181
        $text = html_writer::link($url, 'Apply one player only');
181
        $text = html_writer::link($url, 'Apply one player only');
Línea 191... Línea 191...
191
    /**
191
    /**
192
     * Test that mediaplugin filter adds player code on top of <video> tags.
192
     * Test that mediaplugin filter adds player code on top of <video> tags.
193
     *
193
     *
194
     * filter_mediaplugin is enabled by default.
194
     * filter_mediaplugin is enabled by default.
195
     */
195
     */
196
    public function test_embed_media() {
196
    public function test_embed_media(): void {
197
        global $CFG;
197
        global $CFG;
198
        $url = new moodle_url('http://example.org/some_filename.mp4');
198
        $url = new moodle_url('http://example.org/some_filename.mp4');
199
        $trackurl = new moodle_url('http://example.org/some_filename.vtt');
199
        $trackurl = new moodle_url('http://example.org/some_filename.vtt');
200
        $text = '<video controls="true"><source src="'.$url.'"/><source src="somethinginvalid"/>' .
200
        $text = '<video controls="true"><source src="'.$url.'"/><source src="somethinginvalid"/>' .
201
            '<track src="'.$trackurl.'">Unsupported text</video>';
201
            '<track src="'.$trackurl.'">Unsupported text</video>';
Línea 251... Línea 251...
251
    }
251
    }
Línea 252... Línea 252...
252
 
252
 
253
    /**
253
    /**
254
     * Test that VideoJS can embed youtube videos.
254
     * Test that VideoJS can embed youtube videos.
255
     */
255
     */
256
    public function test_youtube() {
256
    public function test_youtube(): void {
Línea 257... Línea 257...
257
        set_config('youtube', 1, 'media_videojs');
257
        set_config('youtube', 1, 'media_videojs');
Línea 258... Línea 258...
258
 
258
 
Línea 307... Línea 307...
307
     * @param string $url
307
     * @param string $url
308
     * @param int $expectedstart
308
     * @param int $expectedstart
309
     *
309
     *
310
     * @dataProvider youtube_start_time_provider
310
     * @dataProvider youtube_start_time_provider
311
     */
311
     */
312
    public function test_youtube_start_time(string $url, int $expectedstart) {
312
    public function test_youtube_start_time(string $url, int $expectedstart): void {
313
        set_config('youtube', 1, 'media_videojs');
313
        set_config('youtube', 1, 'media_videojs');
Línea 314... Línea 314...
314
 
314
 
Línea 315... Línea 315...
315
        $embedcode = core_media_manager::instance()->embed_url(new moodle_url($url));
315
        $embedcode = core_media_manager::instance()->embed_url(new moodle_url($url));
Línea 329... Línea 329...
329
    }
329
    }
Línea 330... Línea 330...
330
 
330
 
331
    /**
331
    /**
332
     * Test that VideoJS can not embed flash videos.
332
     * Test that VideoJS can not embed flash videos.
333
     */
333
     */
334
    public function test_flash_behaviour() {
334
    public function test_flash_behaviour(): void {
Línea 335... Línea 335...
335
        $manager = core_media_manager::instance();
335
        $manager = core_media_manager::instance();
336
 
336
 
337
        $url = new moodle_url('http://example.org/some_filename.flv');
337
        $url = new moodle_url('http://example.org/some_filename.flv');
Línea 342... Línea 342...
342
    }
342
    }
Línea 343... Línea 343...
343
 
343
 
344
    /**
344
    /**
345
     * Test that VideoJS can not embed RTMP streams.
345
     * Test that VideoJS can not embed RTMP streams.
346
     */
346
     */
347
    public function test_rtmp_behaviour() {
347
    public function test_rtmp_behaviour(): void {
Línea 348... Línea 348...
348
        $manager = core_media_manager::instance();
348
        $manager = core_media_manager::instance();
349
 
349
 
350
        $url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
350
        $url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');