Source

Kephra / t / 605-app-focus.t

#!usr/bin/perl

# making local lib favoured
BEGIN { unshift @INC, -d 't' ? 'lib' : '../lib' }

package probe;
use Test::More tests => 11;
use Test::NoWarnings;

use Wx;
use Kephra;

Kephra::load_libs();
$Kephra::Log::test_mode = 1;

my $frame = Wx::Frame->new( undef, -1, '');
my $label = Wx::StaticText->new( undef, -1, '');


is(Kephra::App::Focus::get(), undef, 'stack starts empty');

Kephra::App::Focus::set($frame);
is(Kephra::App::Focus::get(), $frame, 'first widget was stored with set and retrieved with get');

Kephra::App::Focus::set($label);
is(Kephra::App::Focus::get(), $label, 'second widget was stored');

Kephra::App::Focus::set(4);
is(Kephra::App::Focus::get(), $label, 'set doesnt take number');

Kephra::App::Focus::set([]);
is(Kephra::App::Focus::get(), $label, 'set doesnt take references');

Kephra::App::Focus::set_back();
is(Kephra::App::Focus::get(), $frame, 'set_back() works');

Kephra::App::Focus::set($label) for 1..7;
Kephra::App::Focus::set_back(7);
is(Kephra::App::Focus::get(), $frame, 'set_back() works with parameter');

Kephra::App::Focus::set_back();
is(Kephra::App::Focus::get(), $frame, 'set_back() leaves one widget');

Kephra::App::Focus::set($label);
Kephra::App::Focus::set_back(0);
is(Kephra::App::Focus::get(), $label, 'set_back(0) is handeled right');

Kephra::App::Focus::stay();
is(Kephra::App::Focus::get(), $label, 'stay does no harm');


exit(0);