File: StyleSheet.t

package info (click to toggle)
libcss-dom-perl 0.15-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 716 kB
  • ctags: 249
  • sloc: perl: 7,310; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,681 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/perl -T

use strict; use warnings;
our $tests;
BEGIN { ++$INC{'tests.pm'} }
sub tests'VERSION { $tests += pop };
use Test::More;
plan tests => $tests;

use tests 1; # use
use_ok 'CSS::DOM';

use tests 1; # constructor 
isa_ok my $ss = new CSS::DOM, 'CSS::DOM';

use tests 1; # type
is $ss->type, 'text/css', 'type';

use tests 3; # disabled
ok!$ss->disabled              ,     'get disabled';
ok!$ss->disabled(1),          , 'set/get disabled';
ok $ss->disabled              ,     'get disabled again';
$ss->disabled(0);

use tests 4; # (set_)ownerNode
{
	is +()=ownerNode $ss, 0, 'null ownerNode in list context';

	my $foo = [];
	$ss->set_ownerNode($foo);
	is $ss->ownerNode, $foo, 'ownerNode';
	undef $foo;
	is $ss->ownerNode, undef, 'ownerNode is a weak refeerenc';

	(my $ss = CSS::DOM::parse('@import "',url_fetcher=>sub{''}))
		->set_ownerNode(my $thing = []);
	is +()=$ss->cssRules->[0]->styleSheet->ownerNode, 0,
		'ownerNode of @import\' style sheet';
}

use tests 2; # parentStyleSheet
{
	is +()=$ss->parentStyleSheet, 0, 'parentStyleSheet';

	my $ss = CSS::DOM::parse('@import "', url_fetcher=>sub{''});
	is $ss->cssRules->[0]->styleSheet->parentStyleSheet, $ss,
		'parentStyleSheet of @import rule\'s sheet';
}

use tests 1; # (set_)href
{
	$ss->set_href('eouvoenth');
	is $ss->href, 'eouvoenth', 'href';
}

use tests 1; # title
{
	sub foo'attr { return shift->{+shift} }
	$ss->set_ownerNode(my $foo = bless {title => 'tilde'}, 'foo');
	is $ss->title, 'tilde', 'title';
}

use tests 2; # media
{
	isa_ok $ss->media, 'CSS::DOM::MediaList';
	$ss->media->mediaText('screen, printer');
	is_deeply [$ss->media], [screen=>printer=>],
		'media in list context';
}