~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to t/75-autocomplete.t

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl
2
 
 
3
 
use strict;
4
 
use warnings;
5
 
use Test::More;
6
 
 
7
 
BEGIN {
8
 
        unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
9
 
                plan skip_all => 'Needs DISPLAY';
10
 
                exit 0;
11
 
        }
12
 
        plan tests => 12;
13
 
}
14
 
 
15
 
use Test::NoWarnings;
16
 
use t::lib::Padre;
17
 
use Test::MockObject;
18
 
 
19
 
# Setup
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');
24
 
 
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 );
28
 
 
29
 
my $mock_config = Test::MockObject->new();
30
 
 
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 );
36
 
 
37
 
 
38
 
$mock_main->fake_module(
39
 
        'Wx::Event',
40
 
        EVT_KILL_FOCUS => sub { }
41
 
);
42
 
 
43
 
use_ok('Padre::Wx::Main');
44
 
 
45
 
SCOPE: {
46
 
 
47
 
        # Test 'Set Single' turned on for autocomplete
48
 
 
49
 
        # GIVEN
50
 
        $mock_config->set_always( 'autocomplete_always', 0 );
51
 
 
52
 
        # WHEN
53
 
        Padre::Wx::Main::on_autocompletion($mock_main);
54
 
 
55
 
        # THEN
56
 
        my ( $name, $args );
57
 
 
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" );
62
 
 
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" );
68
 
}
69
 
 
70
 
SCOPE: {
71
 
 
72
 
        # Test 'Set Single' turned kept off when autocomplete_always is on
73
 
 
74
 
        # GIVEN
75
 
        $mock_config->set_always( 'autocomplete_always', 1 );
76
 
 
77
 
        # WHEN
78
 
        Padre::Wx::Main::on_autocompletion($mock_main);
79
 
 
80
 
        # THEN
81
 
        my ( $name, $args );
82
 
 
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" );
87
 
 
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" );
93
 
}