8
unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
9
plan skip_all => 'Needs DISPLAY';
20
my $mock_editor = Test::MockObject->new();
21
$mock_editor->set_true('AutoCompSetChooseSingle');
22
$mock_editor->set_true('AutoCompSetSeparator');
23
$mock_editor->set_true('AutoCompShow');
25
my $mock_document = Test::MockObject->new();
26
$mock_document->mock( 'autocomplete', sub { return ( 1, 'abc', 'def' ) } );
27
$mock_document->set_always( 'editor', $mock_editor );
29
my $mock_config = Test::MockObject->new();
31
my $mock_main = Test::MockObject->new();
32
$mock_main->set_always( 'current', $mock_main );
33
$mock_main->set_always( 'document', $mock_document );
34
$mock_main->set_always( 'ide', $mock_main );
35
$mock_main->set_always( 'config', $mock_config );
38
$mock_main->fake_module(
40
EVT_KILL_FOCUS => sub { }
43
use_ok('Padre::Wx::Main');
47
# Test 'Set Single' turned on for autocomplete
50
$mock_config->set_always( 'autocomplete_always', 0 );
53
Padre::Wx::Main::on_autocompletion($mock_main);
58
# Check AutoCompSetChooseSingle set
59
( $name, $args ) = $mock_editor->next_call();
60
is( $name, 'AutoCompSetChooseSingle', "AutoCompSetChooseSingle called" );
61
is( $args->[1], 1, "AutoCompSetChooseSingle set to true" );
63
# Check correct params passed to AutoCompShow
64
( $name, $args ) = $mock_editor->next_call(2);
65
is( $name, 'AutoCompShow', "AutoCompShow called" );
66
is( $args->[1], 1, "Length passed to AutoCompShow" );
67
is( $args->[2], 'abc def', "World list passed to AutoCompShow" );
72
# Test 'Set Single' turned kept off when autocomplete_always is on
75
$mock_config->set_always( 'autocomplete_always', 1 );
78
Padre::Wx::Main::on_autocompletion($mock_main);
83
# Check AutoCompSetChooseSingle set
84
( $name, $args ) = $mock_editor->next_call();
85
is( $name, 'AutoCompSetChooseSingle', "AutoCompSetChooseSingle called" );
86
is( $args->[1], 0, "AutoCompSetChooseSingle set to false" );
88
# Check correct params passed to AutoCompShow
89
( $name, $args ) = $mock_editor->next_call(2);
90
is( $name, 'AutoCompShow', "AutoCompShow called" );
91
is( $args->[1], 1, "Length passed to AutoCompShow" );
92
is( $args->[2], 'abc def', "World list passed to AutoCompShow" );