diff _test/Test/Web/View.pm @ 289:85572f512abc

*TTView refactoring
author cin
date Wed, 20 Feb 2013 02:25:30 +0400
parents 3a9cfea098dd
children aeeb57a12046
line wrap: on
line diff
--- a/_test/Test/Web/View.pm	Tue Feb 19 19:58:27 2013 +0400
+++ b/_test/Test/Web/View.pm	Wed Feb 20 02:25:30 2013 +0400
@@ -87,7 +87,6 @@
     assert( $doc->context->stash->get('user') eq 'test_user');
     
     # document should not have 'this' template variable
-    assert( not $doc->templateVars('this') );
     
     assert( $doc->context != $loader->context); # document should have an own context
 };
@@ -108,14 +107,7 @@
     assert(not $doc->can('notexists')); # autoloaded property should be ignored
     assert(not defined $doc->notexists); # nonexisting property 
     assert($doc->template->version == 10); # static metadata
-    assert($doc->templateVars('notexists') eq ''); #nonexisting template variable
-    assert($doc->templateVars('user') eq 'test_user'); # global data
-    assert($doc->templateVars('templateVar') eq ''); # defined in CTOR block, should be local
-    assert($doc->templateVars('dynamic') eq 'this is a dynamic value');
     assert($doc->context->stash->get('user') eq 'test_user' ); # runtime context should be derived from documentContext
-    $doc->context->stash->set('user', 'nobody');
-    assert($doc->templateVars('user') eq 'test_user'); # isolated
-    $doc->context->stash->set('user', 'test_user');
     
     my $text = $doc->Render();
     my $expected = read_file($this->GetResourceFile('Resources','TTView.Output','simple.txt'), binmode => ':utf8');
@@ -124,55 +116,6 @@
     
 };
 
-test TTControlTests => sub {
-    my ($this) = @_;
-    
-    my $loader = $this->CreateLoader();
-    
-    my $doc = $loader->document('simple');
-    
-    assert(defined $doc);
-    
-    my $factory = $doc->RequireControl('My/Org/Panel');
-    
-    assert(defined $factory);
-    
-    # control factory shares document scope to perform an initialization on demand
-    assert($factory->context->stash == $doc->context->stash);
-    
-    assert($factory == $doc->RequireControl('My/Org/Panel'), "Control should be loaded only once");
-    
-    my $ctl = $factory->new('information', { visualClass => 'simple', data => ['one','two','hello world'] } );
-    
-    assert(defined $ctl);    
-    
-    assert($ctl->name eq 'information', "Created control should have a name", "Got: ".$ctl->name, "Expected: information");
-    
-    assert($ctl->GetAttribute('visualClass') eq 'simple');
-    
-    assert($factory->instances == 1);
-    
-    $doc->childNodes([$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');    
-    assert($text eq $expected, '$ctl->Render(): Bad output', "Got:      $text", "Expected: $expected");
-    
-    
-    my $doc2 = $loader->document('simple');
-    
-    assert( $doc2->documentContext->stash->get( ['require',['My/Org/Panel'] ] ) );
-    print Dumper($doc2->context->stash);
-    assert( $doc2->context->stash->get( ['require',['My/Org/Panel'] ] ) );
-    
-    
-};
-
 test TestDocumentLayout => sub {
     my ($this) = @_;
     
@@ -208,8 +151,6 @@
     assert(ref $loader->context->stash->get([ 'dojo', 0, 'require', 0]) eq 'ARRAY');
     assertarray($loader->context->stash->get([ 'dojo', 0, 'require', 0]),[]);
     assert($loader->context->stash != $doc->context->stash);
-    assert($loader->context->stash != $doc->documentContext->stash);
-    assert($doc->context->stash != $doc->documentContext->stash);
     
     assert(defined $doc);
     
@@ -251,21 +192,16 @@
     
     AssertMemoryLeak(sub {        
         my $doc = $loader->document('simple');
-    });
+    },'dump');
         
     AssertMemoryLeak(sub {
         my $doc = $loader->document('simple');
         $doc->Render( { self => $doc } );
-    });
+    },'dump');
     
     $loader->template('Layout/default');
     $loader->template('My/Org/Panel');
     $loader->template('My/Org/TextPreview');
-    AssertMemoryLeak(sub {
-        my $doc = $loader->document('simple');
-        my $factory = $doc->RequireControl('My/Org/Panel');
-        my $ctl = $doc->childNodes($factory->new('information', { visualClass => 'complex' }) );        
-    },'dump');
     
     $loader->template('complex');
     AssertMemoryLeak(sub {