~ubuntu-branches/ubuntu/quantal/libcss-dom-perl/quantal

« back to all changes in this revision

Viewing changes to t/StyleSheet.t

  • Committer: Bazaar Package Importer
  • Author(s): Nicholas Bamber
  • Date: 2011-02-10 21:51:03 UTC
  • Revision ID: james.westby@ubuntu.com-20110210215103-vaalgfelzvw4bar4
Tags: upstream-0.14
ImportĀ upstreamĀ versionĀ 0.14

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl -T
 
2
 
 
3
use strict; use warnings;
 
4
our $tests;
 
5
BEGIN { ++$INC{'tests.pm'} }
 
6
sub tests'VERSION { $tests += pop };
 
7
use Test::More;
 
8
plan tests => $tests;
 
9
 
 
10
use tests 1; # use
 
11
use_ok 'CSS::DOM';
 
12
 
 
13
use tests 1; # constructor 
 
14
isa_ok my $ss = new CSS::DOM, 'CSS::DOM';
 
15
 
 
16
use tests 1; # type
 
17
is $ss->type, 'text/css', 'type';
 
18
 
 
19
use tests 3; # disabled
 
20
ok!$ss->disabled              ,     'get disabled';
 
21
ok!$ss->disabled(1),          , 'set/get disabled';
 
22
ok $ss->disabled              ,     'get disabled again';
 
23
$ss->disabled(0);
 
24
 
 
25
use tests 4; # (set_)ownerNode
 
26
{
 
27
        is +()=ownerNode $ss, 0, 'null ownerNode in list context';
 
28
 
 
29
        my $foo = [];
 
30
        $ss->set_ownerNode($foo);
 
31
        is $ss->ownerNode, $foo, 'ownerNode';
 
32
        undef $foo;
 
33
        is $ss->ownerNode, undef, 'ownerNode is a weak refeerenc';
 
34
 
 
35
        (my $ss = CSS::DOM::parse('@import "',url_fetcher=>sub{''}))
 
36
                ->set_ownerNode(my $thing = []);
 
37
        is +()=$ss->cssRules->[0]->styleSheet->ownerNode, 0,
 
38
                'ownerNode of @import\' style sheet';
 
39
}
 
40
 
 
41
use tests 2; # parentStyleSheet
 
42
{
 
43
        is +()=$ss->parentStyleSheet, 0, 'parentStyleSheet';
 
44
 
 
45
        my $ss = CSS::DOM::parse('@import "', url_fetcher=>sub{''});
 
46
        is $ss->cssRules->[0]->styleSheet->parentStyleSheet, $ss,
 
47
                'parentStyleSheet of @import rule\'s sheet';
 
48
}
 
49
 
 
50
use tests 1; # (set_)href
 
51
{
 
52
        $ss->set_href('eouvoenth');
 
53
        is $ss->href, 'eouvoenth', 'href';
 
54
}
 
55
 
 
56
use tests 1; # title
 
57
{
 
58
        sub foo'attr { return shift->{+shift} }
 
59
        $ss->set_ownerNode(my $foo = bless {title => 'tilde'}, 'foo');
 
60
        is $ss->title, 'tilde', 'title';
 
61
}
 
62
 
 
63
use tests 2; # media
 
64
{
 
65
        isa_ok $ss->media, 'CSS::DOM::MediaList';
 
66
        $ss->media->mediaText('screen, printer');
 
67
        is_deeply [$ss->media], [screen=>printer=>],
 
68
                'media in list context';
 
69
}