File: 10_oor.t

package info (click to toggle)
libwx-perl 1%3A0.9932-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,300 kB
  • sloc: cpp: 11,064; perl: 8,603; ansic: 711; makefile: 53
file content (109 lines) | stat: -rwxr-xr-x 3,017 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/perl -w

# tests that Original Object Return works
# only tests a few classes

use strict;
use Wx;
use lib './t';
use Tests_Helper 'test_frame';

package MyListBox;

use base 'Wx::ListBox';

package MyFrame;

use base 'Wx::Frame';
use Test::More 'tests' => 58;

sub new {
my $this = shift->SUPER::new( undef, -1, 'a' );

# class, params
my @data = ( [ 'Wx::Button', [ 'a' ] ],
             [ 'Wx::BitmapButton', [ Wx::Bitmap->new( 10, 10 ) ] ],
             [ 'Wx::CheckBox', [ 'foo' ] ],
             [ 'Wx::CheckListBox', [ [-1, -1], [-1, -1], [1] ] ],
             [ 'Wx::Choice', [] ],
             [ 'Wx::ComboBox', [ 'a' ] ],
             [ 'Wx::Gauge', [ 1 ] ],
             [ 'Wx::ListBox', [] ],
             [ 'Wx::ListCtrl', [] ],
             [ 'Wx::ListView', [] ],
             [ 'Wx::MiniFrame', [ 'a' ], 'SKIP' ],
             [ 'Wx::Notebook', [] ],
             [ 'Wx::RadioBox', [ 'a', [-1, -1], [-1, -1], [ 'a' ] ] ],
             [ 'Wx::RadioButton', [ 'a' ] ],
             [ 'Wx::SashWindow', [] ],
             [ 'Wx::ScrollBar', [] ],
             [ 'Wx::SpinButton', [] ],
             [ 'Wx::SpinCtrl', [ 'aaa' ] ],
             [ 'Wx::SplitterWindow', [] ],
             [ 'Wx::Slider', [ 3, 2, 4 ] ],
             [ 'Wx::StaticBitmap', [ Wx::Bitmap->new( 10, 10 ) ], 'SKIP' ],
             [ 'Wx::StaticBox', [ 'a' ], 'SKIP' ],
             [ 'Wx::StaticLine', [], 'SKIP' ],
             [ 'Wx::StaticText', [ 'a' ], 'SKIP' ],
             [ 'Wx::StatusBar', [], 'SKIP' ],
             [ 'Wx::TextCtrl', [ 'a' ] ],
             [ 'Wx::TreeCtrl', [] ],
             [ 'Wx::Window', [] ],
           );

foreach my $d ( @data ) {
    my( $class, $args, $skip_phase ) = @$d;

  SKIP: {
      # simple creation
      skip "Some controls are weird", 2
        if Wx::wxMOTIF() && $class eq 'Wx::StaticLine'
        or Wx::wxMOTIF() && $class eq 'Wx::SpinCtrl'
        or Wx::wxGTK() && $class =~ m/^Wx::(MiniFrame|StatusBar)/
        or Wx::wxMAC() && $class eq 'Wx::SpinCtrl';
      skip "Segfaults under wxMotif 2.6.x", 2
        if Wx::wxMOTIF() && $class eq 'Wx::StaticBitmap'
           && Wx::wxVERSION < 2.008;

      my $lb = $class->new( $this, -1, @$args );
      my $lb2 = ($this->GetChildren)[-1];

      is( $lb2, $lb, "objects reference the same hash ($class)" );

      $lb->Destroy;

      skip "Skipping two-phase creation for $class", 1
        if $skip_phase;

      # test double-phase creation
      $lb = $class->new;
      $lb->Create( $this, -1, @$args );
      $lb2 = ($this->GetChildren)[-1];

      is( $lb2, $lb, "objects reference the same hash ($class) (2 phase) " );

      $lb->Destroy;
  }
}

my $lb = MyListBox->new( $this, -1 );
$lb->{MYDATA} = 'some data';

my $lb2 = ($this->GetChildren)[-1];

is( $lb2, $lb, "objects reference the same hash" );
is( $lb2->{MYDATA}, $lb->{MYDATA}, "sanity check" );

$lb->Destroy;

return $this;
};

package main;

test_frame( 'MyFrame', 1 );
Wx::wxTheApp()->MainLoop();

# local variables:
# mode: cperl
# end: