diff _test/Test/Web/View.pm @ 191:78a18a2b6266

IMPL::Web::View improvements (unstable)
author cin
date Thu, 05 Apr 2012 17:51:51 +0400
parents cd1ff7029a63
children 4d0e1962161c
line wrap: on
line diff
--- a/_test/Test/Web/View.pm	Wed Apr 04 17:51:27 2012 +0400
+++ b/_test/Test/Web/View.pm	Thu Apr 05 17:51:51 2012 +0400
@@ -108,7 +108,6 @@
 	my $loader = $this->CreateLoader();
 	
 	my $doc = $loader->document('simple');
-	$doc->templateVars(data => ['one','two','hello world']);
 	
 	assert(defined $doc);
 	
@@ -121,7 +120,7 @@
 	
 	assert($factory == $doc->require('My/Org/Panel'), "Control should be loaded only once");
 	
-	my $ctl = $factory->new('information', { visualClass => 'simple' } );
+	my $ctl = $factory->new('information', { visualClass => 'simple', data => ['one','two','hello world'] } );
 	
 	assert(defined $ctl);	
 	
@@ -133,13 +132,34 @@
 	
 	$doc->appendChild($ctl);
 	
-	
+	assert($doc->templateVars('dojo.require'));
+	assert(ref $doc->templateVars('dojo.require') eq 'ARRAY');
+	assert($doc->templateVars('dojo.require')->[0] eq 'dijit.form.Input' );
 	
 	my $text = $ctl->Render();
-	my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8');
 	
+	my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'Panel.txt'), binmode => ':utf8');	
 	assert($text eq $expected, '$ctl->Render(): Bad output', "Got:      $text", "Expected: $expected");
 	
+	
+	
+};
+
+test TestDocumentLayout => sub {
+	my ($this) = @_;
+	
+	my $loader = $this->CreateLoader();
+	
+	my $doc = $loader->document('complex');
+	assert($doc->layout eq 'Layout/default');
+	
+	my $expected = read_file($this->GetResourceFile('Resources', 'TTView.Output', 'complex.default.txt'), binmode => ':utf8' );
+	
+	assert($doc->templateVars('dojo.require')->[0]);
+	
+	my $text = $doc->Render({ data => [qw(one two three)] });
+	
+	assert($text eq $expected, '$doc->Render(): Bad output', "Got:      $text", "Expected: $expected"); 
 };
 
 test TestMemoryLeaks => sub {
@@ -157,6 +177,7 @@
 		$doc->Render( { self => $doc } );
 	});
 	
+	$loader->template('Layout/default');
 	$loader->template('My/Org/Panel');
 	$loader->template('My/Org/TextPreview');
 	AssertMemoryLeak(sub {