Mercurial > pub > Impl
annotate _test/Test/Web/View.pm @ 367:608e74bc309f
form metadata, mostly done
author | cin |
---|---|
date | Tue, 03 Dec 2013 17:55:36 +0400 |
parents | aeeb57a12046 |
children | 010ceafd0c5a |
rev | line source |
---|---|
183 | 1 package Test::Web::View; |
188 | 2 use IMPL::Profiler::Memory; |
183 | 3 use strict; |
4 use warnings; | |
185 | 5 use utf8; |
183 | 6 |
185 | 7 use File::Slurp; |
188 | 8 use Scalar::Util qw(weaken); |
288
3a9cfea098dd
*TTView refactoring: removed RequireControl method, etc.
sergey
parents:
287
diff
changeset
|
9 use Data::Dumper; |
280 | 10 use IMPL::lang; |
286 | 11 use IMPL::Test qw(assert assertarray test GetCallerSourceLine); |
183 | 12 |
367 | 13 use IMPL::declare { |
14 require => { | |
15 FormMeta => 'IMPL::Web::View::Metadata::FormMeta', | |
16 Schema => 'IMPL::DOM::Schema', | |
17 Builder => 'IMPL::DOM::Navigator::Builder', | |
18 Document => 'IMPL::DOM::Document', | |
19 XMLReader => 'IMPL::DOM::XMLReader' | |
20 }, | |
21 base => [ | |
22 'IMPL::Test::Unit' => '@_' | |
23 ] | |
183 | 24 }; |
25 | |
367 | 26 |
188 | 27 sub AssertMemoryLeak { |
194 | 28 my $code = shift; |
29 my $dump = shift; | |
30 | |
31 my $data = MProfiler->Monitor($code); | |
32 | |
33 if ($data->isLeak and $dump) { | |
34 write_file("dump.out", { binmode => ':utf8' }, $data->Dump() ); | |
35 } | |
36 | |
37 assert( not($data->isLeak), "Memory leak detected", GetCallerSourceLine() , @{$data->{objects}} ); | |
188 | 38 } |
39 | |
185 | 40 sub templatesDir { |
367 | 41 shift->GetResourceDir('Resources','TTView'); |
188 | 42 } |
43 | |
367 | 44 test TestFormMetadata => sub { |
45 my ($this) = @_; | |
46 | |
47 my $schema = Schema->LoadSchema($this->GetResourceFile('Resources','person.schema.xml')); | |
48 my $builder = Builder->new(Document, $schema); | |
49 | |
50 my $reader = XMLReader->new( Navigator => $builder ); | |
51 | |
52 $reader->ParseFile("Resources/person_info.xml"); | |
53 | |
54 my $doc = $builder->document; | |
55 my @errors = $builder->buildErrors; | |
56 | |
57 push @errors, $schema->Validate($doc); | |
58 | |
59 my $meta = FormMeta->new( | |
60 $doc, | |
61 $doc->schemaSource->type, | |
62 { | |
63 decl => $doc->schemaSource, | |
64 schema => $doc->schema, | |
65 errors => \@errors | |
66 } | |
67 ); | |
183 | 68 |
367 | 69 my $props = $meta->GetProperties; |
70 | |
71 my $prop = $meta->GetProperty('address'); | |
72 | |
73 join ',', map $_->GetProperty('line')->name, @{$prop->GetItems}; | |
185 | 74 }; |
75 | |
188 | 76 |
183 | 77 1; |