Alex 'AdUser' Z
9 years ago
1 changed files with 75 additions and 0 deletions
@ -0,0 +1,75 @@ |
|||||||
|
use strict; |
||||||
|
use warnings; |
||||||
|
|
||||||
|
use Test::More tests => 47; |
||||||
|
|
||||||
|
use Subtitle::SSA::Style; |
||||||
|
|
||||||
|
my ($fields, @fields, $format, $sample, $style); |
||||||
|
|
||||||
|
# SSA format line |
||||||
|
$format = 'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding'; |
||||||
|
@fields = qw(name fontname fontsize primarycolour secondarycolour tertiarycolour backcolour bold italic borderstyle outline shadow alignment marginl marginr marginv alphalevel encoding); |
||||||
|
$style = Subtitle::SSA::Style->new(version => 'ssa'); |
||||||
|
$fields = $style->parse_format_line($format); |
||||||
|
is(ref $fields, 'ARRAY'); |
||||||
|
is_deeply($fields, \@fields); |
||||||
|
|
||||||
|
# ASS format line |
||||||
|
$format = 'Format:Name,Fontname,Fontsize,PrimaryColour,SecondaryColour,OutlineColour,BackColour,Bold,Italic,Underline,StrikeOut,ScaleX,ScaleY,Spacing,Angle,BorderStyle,Outline,Shadow,Alignment,MarginL,MarginR,MarginV,Encoding'; |
||||||
|
@fields = qw(name fontname fontsize primarycolour secondarycolour outlinecolour backcolour bold italic underline strikeout scalex scaley spacing angle borderstyle outline shadow alignment marginl marginr marginv encoding); |
||||||
|
$style = Subtitle::SSA::Style->new(version => 'ass'); |
||||||
|
$fields = $style->parse_format_line($format); |
||||||
|
is(ref $fields, 'ARRAY'); |
||||||
|
is_deeply($fields, \@fields); |
||||||
|
|
||||||
|
$sample = 'Style: Default,Arial,20,11259130,33023,12582847,32,-1,0,1,2,1,2,10,10,2,0,204'; |
||||||
|
$style = Subtitle::SSA::Style->new(version => 'ssa'); |
||||||
|
ok($style->parse($sample), "SSA style parsing test"); |
||||||
|
is($style->{name} => 'Default'); |
||||||
|
is($style->{fontname} => 'Arial'); |
||||||
|
is($style->{fontsize} => 20); |
||||||
|
is($style->{primarycolour} => 11259130); |
||||||
|
is($style->{secondarycolour} => 33023); |
||||||
|
is($style->{tertiarycolour} => 12582847); |
||||||
|
is($style->{backcolour} => 32); |
||||||
|
is($style->{bold} => -1); |
||||||
|
is($style->{italic} => 0); |
||||||
|
is($style->{borderstyle} => 1); |
||||||
|
is($style->{outline} => 2); |
||||||
|
is($style->{shadow} => 1); |
||||||
|
is($style->{alignment} => 2); |
||||||
|
is($style->{marginl} => 10); |
||||||
|
is($style->{marginr} => 10); |
||||||
|
is($style->{marginv} => 2); |
||||||
|
is($style->{alphalevel} => 0); |
||||||
|
is($style->{encoding} => 204); |
||||||
|
|
||||||
|
$sample = 'Style: Default,Georgia,50,&H00F0F4F6,&H008D7127,&H00414B4C,&H00000000,0,0,0,0,100,95,0,0,1,3.5,0,2,11,11,13,204'; |
||||||
|
$style = Subtitle::SSA::Style->new(version => 'ass'); |
||||||
|
ok($style->parse($sample), "ASS style parsing test"); |
||||||
|
is($style->{name} => 'Default'); |
||||||
|
is($style->{fontname} => 'Georgia'); |
||||||
|
is($style->{fontsize} => 50); |
||||||
|
is($style->{primarycolour} => 0x00F0F4F6); |
||||||
|
is($style->{secondarycolour} => 0x008D7127); |
||||||
|
is($style->{outlinecolour} => 0x00414B4C); |
||||||
|
is($style->{backcolour} => 0); |
||||||
|
is($style->{bold} => 0); |
||||||
|
is($style->{italic} => 0); |
||||||
|
is($style->{underline} => 0); |
||||||
|
is($style->{strikeout} => 0); |
||||||
|
is($style->{scalex} => 100); |
||||||
|
is($style->{scaley} => 95); |
||||||
|
is($style->{spacing} => 0); |
||||||
|
is($style->{angle} => 0); |
||||||
|
is($style->{borderstyle} => 1); |
||||||
|
is($style->{outline} => 3.5); |
||||||
|
is($style->{shadow} => 0); |
||||||
|
is($style->{alignment} => 2); |
||||||
|
is($style->{marginl} => 11); |
||||||
|
is($style->{marginr} => 11); |
||||||
|
is($style->{marginv} => 13); |
||||||
|
is($style->{encoding} => 204); |
||||||
|
|
||||||
|
exit 0; |
Loading…
Reference in new issue