4 use Wx qw(wxTheClipboard);
7 use Tests_Helper qw(in_frame);
17 my $FORMAT = 'Wx::Perl::MyCustomFormat';
23 my $complex = { x => [ qw(a b c), { 'c' => 'd' } ] };
24 my $copied = MyDataObject->new( $complex );
27 wxTheClipboard->Clear;
29 ok( !wxTheClipboard->IsSupported( Wx::DataFormat->newUser( $FORMAT ) ),
34 ok( wxTheClipboard->SetData( $copied ), "copying succeeds" );
38 my $pasted = MyDataObject->new;
40 ok( wxTheClipboard->IsSupported( Wx::DataFormat->newUser( $FORMAT ) ),
42 ok( wxTheClipboard->GetData( $pasted ), "pasting succeeds" );
43 isnt( $pasted->GetPerlData, $complex, "Check that identity is not the same" );
45 is_deeply( $pasted->GetPerlData, $complex, "Correctly copied" );
47 wxTheClipboard->Close;
53 use base qw(Wx::PlDataObjectSimple);
58 my( $class, $data ) = @_;
59 my $self = $class->SUPER::new( Wx::DataFormat->newUser( $FORMAT ) );
61 $self->{data} = $data;
67 my( $self, $serialized ) = @_;
69 $self->{data} = Storable::thaw $serialized;
70 ok( 1, "SetData called" ) unless $silent;
78 ok( 1, "GetDataHere called" ) unless $silent;
80 return Storable::freeze $self->{data};
86 ok( 1, "GetDataSize called" ) unless $silent;
88 return length Storable::freeze $self->{data};
91 sub GetPerlData { $_[0]->{data} }