# vi:filetype= use strict; use warnings; use File::Slurp qw( write_file ); use Test::Base; use Cwd 'cwd'; use IPC::Run (); my $tmp_file = cwd() . '/t/vdom.html'; plan tests => 2 * blocks(); run { my $block = shift; my $name = $block->name; my $html = $block->html; my $expected_vdom = $block->vdom; my $expected_core_vdom = $block->core_vdom; write_file $tmp_file, $html; #warn "Tmpfile: $tmp_file\n"; my @cmd = ("./start.sh", "vdom"); my $stdin = "file://$tmp_file"; IPC::Run::run(\@cmd, \$stdin, \(my $vdom), \(my $err)); is $?, 0, "$name - qt-webkit exited with 0 status code"; if (defined $expected_vdom) { $expected_vdom =~ s/^ +//gm; $vdom =~ s{(location="file:///).*?/(t/vdom.html")}{$1$2}; is $vdom, $expected_vdom, "$name - vdom ok"; } elsif (defined $expected_core_vdom) { $expected_core_vdom =~ s/^ +//gm; (my $core_vdom = $vdom) =~ s/^(?:[^\n]*\n){3}//s; #warn "Count: $count\n"; $core_vdom =~ s/(?:\n}$){3}$//sm; is $core_vdom, $expected_core_vdom, "$name - core vdom ok"; } else { die "$name - neither --- vdom nor --- core_vdom are specified.\n"; } } __DATA__ === TEST 1: empty html --- html
--- vdom window location="file:///t/vdom.html" innerHeight=768 innerWidth=1024 outerHeight=0 outerWidth=0 { document width=1024 height=768 { BODY offsetX=0 offsetY=0 offsetWidth=1008 offsetHeight=752 fontFamily="Arial" fontSize="14px" fontStyle="normal" fontWeight="normal" color="rgb(0, 0, 0)" backgroundColor="rgba(0, 0, 0, 0)" { "\n " "\n" "\n" } } } === TEST 2: A tags --- html foo bar --- core_vdom "\n" A id="b" name="hello" offsetX=8 offsetY=8 offsetWidth=17 offsetHeight=15 { "foo" } "\n" A href="file:///abc.html" target="_blank" offsetX=29 offsetY=8 offsetWidth=18 offsetHeight=15 color="rgb(0, 0, 238)" { "bar" } "\n" "\n" === TEST 3: attribute inheritance (first child) --- html