comparison _test/Test/DOM/Navigator.pm @ 13:bb8d67f811ea

merge heads
author Sergey
date Wed, 02 Sep 2009 23:11:14 +0400
parents 75980091813b
children 7f00786f8210
comparison
equal deleted inserted replaced
12:955b2324c1bf 13:bb8d67f811ea
1 package Test::DOM::Navigator;
2 use base qw(IMPL::Test::Unit);
3
4 __PACKAGE__->PassThroughArgs;
5
6 use IMPL::Test qw(test failed);
7 use IMPL::DOM::Navigator;
8 use IMPL::DOM::Node;
9
10 test Creation => sub {
11 my ($this) = @_;
12
13 my $doc = new IMPL::DOM::Node(nodeName => 'root');
14
15 my $obj = new IMPL::DOM::Navigator($doc) or failed "Failed to create instance" ;
16 };
17
18 test Navigate => sub {
19 my $doc = new IMPL::DOM::Node(nodeName => 'root');
20 my $child = $doc->insertNode(
21 new IMPL::DOM::Node(
22 nodeName => 'Child'
23 )
24 );
25
26 my $navi = new IMPL::DOM::Navigator($doc);
27 my $navresult = $navi->Navigate("Child");
28
29 failed ("Navigate retuned unexpected result", "Recieved: $navresult", "Expected: $child") if $child != $navresult;
30 my $curr = $navi->Current;
31 failed ("Current node has a wrong value","Current: $curr","Expected: $child") if $child != $curr;
32 };
33
34 test PathToString => sub {
35 my $doc = new IMPL::DOM::Node(nodeName => 'root');
36 my $child = $doc->insertNode(
37 new IMPL::DOM::Node(
38 nodeName => 'Child'
39 )
40 );
41
42 my $navi = new IMPL::DOM::Navigator($doc);
43 $navi->Navigate("Child");
44
45 my $expected = "root/Child";
46 my $res = $navi->PathToString;
47 failed("Unexpected PathToString result","Recieved: $res","Expected: $expected") if $res ne $expected;
48 };
49
50 test Back => sub {
51 my $doc = new IMPL::DOM::Node(nodeName => 'root');
52 my $child = $doc->insertNode(
53 new IMPL::DOM::Node(
54 nodeName => 'Child'
55 )
56 );
57
58 my $navi = new IMPL::DOM::Navigator($doc);
59 $navi->Navigate("Child");
60 my $navresult = $navi->Back;
61
62 failed ("Back() retuned unexpected result", "Recieved: $navresult", "Expected: $doc") if $doc != $navresult;
63 my $curr = $navi->Current;
64 failed ("Current node has a wrong value","Current: $curr","Expected: $doc") if $doc != $curr;
65 };
66
67
68
69
70
71 1;