Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 80 lines (59 sloc) 2.474 kB
fc5d3d9 @LiNiO Formatter/YouTube.pm: Allow to embed youtube video player
LiNiO authored
1 #!/usr/bin/perl -w
2 package Dummy;
3 sub new {
4 my $class = shift;
5 bless {}, $class;
6 }
7
8 sub loc {
9 return $_[1];
10 }
11
12 sub action {
13 return $_[0];
14 }
15
16 sub reverse {
17 return $reverse;
18 }
19
20 sub set_reverse {
21 $reverse=$_[1];
22 }
23
24 sub cache {
25 my ($self,$c)=@_;
26 return undef;
27 }
28
29 sub session {
30 my ($self,$c)=@_;
31 return "";
32 }
33
34 sub pref {
35 my ($self,$c)=@_;
36 return "";
37 }
38
39
40
41 package main;
42
43 use MojoMojo::Formatter::YouTube;
44 use Test::More;
45
46 plan tests => 5;
47
48 my ($content,$exist,$new);
49
50 my $fake_c=Dummy->new;
51
52 $content = " youtube http://www.youtube.com/abc";
53 MojoMojo::Formatter::YouTube->format_content(\$content, $fake_c, undef);
54 #warn("Content is $content");
55 is($content, " youtube http://www.youtube.com/abc\n","no youtube formatter line");
56
57 $fake_c->set_reverse('pageadmin/edit');
58 $content = "{{youtube http://www.youtube.com/v=abcABC0}}\n";
59 MojoMojo::Formatter::YouTube->format_content(\$content, $fake_c, undef);
60 #warn("Content is $content");
61 is($content, qq(<div style='width: 425px;height: 344px; border: 1px black dotted;'>YouTube Video<br /><a href="http://www.youtube.com/v=abcABC0">http://www.youtube.com/v=abcABC0</a></div>\n));
62
63 $fake_c->set_reverse('jsrpc/render');
64 $content = "{{youtube http://www.youtube.com/v=abcABC0}} xx\n";
65 MojoMojo::Formatter::YouTube->format_content(\$content, $fake_c, undef);
66 #warn("Content is $content");
67 is($content, qq(<div style='width: 425px;height: 344px; border: 1px black dotted;'>YouTube Video<br /><a href="http://www.youtube.com/v=abcABC0">http://www.youtube.com/v=abcABC0</a></div> xx\n));
68
69 $content = "{{youtube http://wwwwwwww.youtube.com/abc}}";
70 MojoMojo::Formatter::YouTube->format_content(\$content, $fake_c, undef);
71 #warn("Content is $content");
72 is($content, "YouTube Video: http://wwwwwwww.youtube.com/abc is not a valid link to youtube video\n","no youtube link");
73
74 $fake_c->set_reverse('');
75
76 $content = "{{youtube http://www.youtube.com/watch?v=ABC_abc_09}}";
77 MojoMojo::Formatter::YouTube->format_content(\$content, $fake_c, undef);
78 #warn("Content is $content");
79 is($content, qq(<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/ABC_abc_09&hl=en"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ABC_abc_09&hl=en" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>\n));
Something went wrong with that request. Please try again.