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 => 14;
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(), '', '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');

my $size = Kephra::App::Focus::stack_size();
Kephra::App::Focus::set($label);
is(Kephra::App::Focus::stack_size(), $size, 'don\'t store widget twice in a row');

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( Wx::Button->new( undef, -1, '') ) 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');

$size = Kephra::App::Focus::stack_size();
Kephra::App::Focus::max_stack_size($size);
is(Kephra::App::Focus::max_stack_size(), $size, 'max_stack_size() works');

Kephra::App::Focus::set( Wx::Button->new( undef, -1, '') );
is(Kephra::App::Focus::max_stack_size(), $size, 'set() keeps intended stack size');

my $btn   = Wx::Button->new( undef, -1, '');


exit(0);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.