8
unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
9
plan skip_all => 'Needs DISPLAY';
12
if ( $^O eq 'MSWin32' ) {
13
plan skip_all => 'Windows currently has problems with Unicode files';
18
plan( skip_all => 'Sometimes fails for unknown reasons, skipping for release till fixed' );
22
use File::Basename qw(basename);
23
use File::Copy qw(copy);
24
use File::Spec::Functions qw(catfile);
32
diag "PADRE_HOME: $ENV{PADRE_HOME}";
33
my $home = $ENV{PADRE_HOME};
34
copy catfile( 'eg', 'hello_world.pl' ), catfile( $home, 'hello_world.pl' );
35
copy catfile( 'eg', 'cyrillic_test.pl' ), catfile( $home, 'cyrillic_test.pl' );
36
copy catfile( 't', 'files', 'one_char.pl' ), catfile( $home, 'one_char.pl' );
38
my $padreInstance = Padre->new;
40
my $frame = $ide->wx->main;
42
diag "This test script is known to fail sometimes on some operating systems";
43
diag "If this happens to you, please report it to the Padre developers";
44
diag "and use the force to install Padre anyway.";
47
{ delay => 1000, # TODO: if we reduce this to 100 or even 500 the test crashes (segfault?) after 2 oks
48
# this seems to be an issue with Padre or wx beneath but for now we hide it with the larger
51
my $main = $ide->wx->main;
52
my $T = Test::Builder->new;
54
my @editors = $main->editors;
55
$T->is_num( scalar(@editors), 1, '1 editor' );
57
$main->setup_editors( catfile( $home, 'hello_world.pl' ) );
59
my @editors = $main->editors;
61
#$T->todo_skip('close the empty buffer');
62
$T->is_num( scalar(@editors), 1, '1 editor' );
68
my $main = $ide->wx->main;
69
my $doc = $main->current->document;
70
my $editor = $doc->editor;
71
$editor->SetSelection( 10, 15 );
72
my $T = Test::Builder->new;
73
$T->is_eq( $editor->GetSelectedText, '/perl', 'selection' );
74
$T->is_eq( $main->current->text, '/perl', 'selected_text' );
76
$editor->ReplaceSelection('/java');
77
$editor->SetSelection( 0, 0 );
78
$T->is_eq( $main->current->text, '', 'no selected_text' );
81
Padre::DB::History->create(
87
my ( $start, $end ) = $editor->GetSelection;
88
$T->is_num( $start, 11, 'start is 11' );
89
$T->is_num( $end, 15, 'end is 15' );
91
$T->is_eq( $main->current->text, 'java', 'java selected_text' );
96
# TODO: better report if file could not be opended
97
if ( open my $fh, '<', catfile( $home, 'hello_world.pl' ) ) {
101
$T->diag("Could not open hello_world.pl '$!'");
103
$T->is_eq( $line, "#!/usr/bin/java\n", 'file really changed' );
108
my $main = $ide->wx->main;
109
$main->setup_editors( catfile( $home, 'cyrillic_test.pl' ) );
111
my $T = Test::Builder->new;
112
my $doc = $main->current->document;
113
my $editor = $doc->editor;
115
Padre::DB::History->create(
121
my @editors = $main->editors;
122
$T->is_num( scalar(@editors), 2, '2 editors' );
126
$T->is_eq( $main->current->text, 'test', 'test selected_text' );
127
my ( $start, $end ) = $editor->GetSelection;
128
$T->is_num( $start, 56, 'start is 56' );
129
$T->is_num( $end, 60, 'end is 60' );
133
$T->is_eq( $main->current->text, 'test', 'selected_text' );
134
my ( $start, $end ) = $editor->GetSelection;
135
$T->is_num( $start, 211, 'start is 211' );
136
$T->is_num( $end, 215, 'end is 215' );
139
$main->close_all( $main->notebook->GetSelection );
141
my @editors = $main->editors;
142
$T->is_num( scalar(@editors), 1, '1 editor' );
143
my $doc = $main->current->document;
144
$T->is_eq( basename( $doc->filename ), 'cyrillic_test.pl', 'filename is cyrillic_test.pl' );
150
my $main = $ide->wx->main;
151
my $T = Test::Builder->new;
154
my @editors = $main->editors;
155
$T->is_num( scalar(@editors), 0, '0 editor' );
156
my $doc = $main->current->document;
157
$T->ok( not( defined $doc ), 'no document' );
163
my $T = Test::Builder->new;
164
$T->diag("changing locale");
165
my $main = $ide->wx->main;
166
$main->change_locale('en');
167
$main->change_locale('');
168
$main->change_locale('en');
173
my $T = Test::Builder->new;
174
$T->diag("setting syntax check");
175
my $main = $ide->wx->main;
176
$T->diag( "syntaxcheck_panel: " . $main->syntax );
177
$main->menu->view->{syntaxcheck}->Check(1);
178
$main->show_syntaxcheck(1);
179
$T->ok( $main->syntax->isa('Wx::ListView'), 'is a Wx::ListView' );
184
# for now, just check if there are no warnings generated
187
my $T = Test::Builder->new;
188
my $main = $ide->wx->main;
189
$T->diag("setup editor for one_char.pl");
190
$main->setup_editors( catfile( $home, 'one_char.pl' ) );
191
my @editors = $main->editors;
192
$T->is_num( scalar(@editors), 1, '1 editor' );
197
# for now, just check if there are no warnings generated
200
my $T = Test::Builder->new;
201
my $main = $ide->wx->main;
202
$T->diag("setup editor for cyrillic_test.pl");
203
$main->setup_editors( catfile( $home, 'cyrillic_test.pl' ) );
204
my @editors = $main->editors;
205
$T->is_num( scalar(@editors), 2, '2 editor' );
210
my $T = Test::Builder->new;
211
my $main = $ide->wx->main;
213
$T->diag("create a new editor");
215
my @editors = $main->pages;
216
$T->is_num( scalar(@editors), 1, 'one new editor' );
217
my $doc = $main->current->document;
218
my $editor = $doc->editor;
222
my $path = catfile( $home, 'cyrillic_test.pl' );
223
$doc->text_set($path);
224
$editor->SetSelection( 0, length($path) );
225
$main->on_open_selection;
226
$T->is_num( scalar( $main->pages ), 2, 'new and abs cyrillic_test open' );
230
$T->is_num( scalar( $main->pages ), 1, 'back to unsaved?' );
233
#put down one filename that is relative to the dir padre was started from
234
my $path = catfile( './eg/perl5/', 'cyrillic_test.pl' );
235
$doc->text_set($path);
236
$editor->SetSelection( 0, length($path) );
237
$main->on_open_selection;
238
$T->is_num( scalar( $main->pages ), 2, 'new and relative cyrillic_test open' );
241
$T->is_num( scalar( $main->pages ), 1, 'back to unsaved?' );
244
#put down one filename that is relative to the dir padre was started from
245
my $path = catfile( './eg/perl5/', 'cyrillic_test.pl' ) . "\n";
246
$doc->text_set($path);
247
$editor->SetSelection( 0, length($path) );
248
$main->on_open_selection;
249
$T->is_num( scalar( $main->pages ), 2, 'relative cyrillic_test open with additional \n' );
252
$T->is_num( scalar( $main->pages ), 1, 'back to unsaved?' );
255
#put down one filename that is relative to the dir padre was started from
256
my $path = "\n" . catfile( './eg/perl5/', 'cyrillic_test.pl' ) . "\n";
257
$doc->text_set($path);
258
$editor->SetSelection( 0, length($path) );
259
$main->on_open_selection;
260
$T->is_num( scalar( $main->pages ), 2, 'relative cyrillic_test open with additional \n' );
263
$T->is_num( scalar( $main->pages ), 1, 'back to unsaved?' );
266
#put down one filename that is relative to the dir padre was started from
267
#$T->diag(Cwd::cwd());
268
my $path = "\t " . catfile( './eg/perl5/', 'cyrillic_test.pl' ) . " \n\t ";
269
$doc->text_set($path);
270
$editor->SetSelection( 0, length($path) );
272
#$T->diag("selected : ".$main->current->text);
273
$main->on_open_selection;
274
$T->is_num( scalar( $main->pages ), 2, 'relative cyrillic_test open with additional \n' );
277
#redo above tests from an editor which _does_ have a filename (ie, has been opened or saved, not newly created
284
#multiple use/require lines
286
#no selection, fill in - not there, popup again with edit and possibly options to choose from
287
#selection isn't there, but found similar?
293
my $T = Test::Builder->new;
295
$ide->wx->ExitMainLoop;
296
$ide->wx->main->Destroy;
301
t::lib::Padre::setup_event( $frame, \@events, 0 );
309
return bless \%args, 'Wx::Event';