summaryrefslogtreecommitdiffstats
path: root/PerlTQt/t
diff options
context:
space:
mode:
authorTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-01-01 18:29:30 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2012-01-01 18:29:30 -0600
commitb2af005db21bd8fd068cb79b2ae700953128af2c (patch)
treeabd0ed633726bf0bbecb57d30e92836c31e02695 /PerlTQt/t
parentc1b9383f2032d82db5eb8918dca885e37a901dde (diff)
downloadlibtqt-perl-b2af005db21bd8fd068cb79b2ae700953128af2c.tar.gz
libtqt-perl-b2af005db21bd8fd068cb79b2ae700953128af2c.zip
Move PerlQt
Diffstat (limited to 'PerlTQt/t')
-rw-r--r--PerlTQt/t/Foo/SubCodec.pm14
-rw-r--r--PerlTQt/t/My/Codec.pm10
-rw-r--r--PerlTQt/t/My/SubCodec.pm15
-rw-r--r--PerlTQt/t/a_loading.t6
-rw-r--r--PerlTQt/t/b_nogui.t48
-rw-r--r--PerlTQt/t/c_qapp.t23
-rw-r--r--PerlTQt/t/ca_i18n.t23
-rw-r--r--PerlTQt/t/d_sigslot.t49
-rw-r--r--PerlTQt/t/e_sigslot_inherit.t72
-rw-r--r--PerlTQt/t/f_import.t19
-rw-r--r--PerlTQt/t/g_gui.t127
11 files changed, 406 insertions, 0 deletions
diff --git a/PerlTQt/t/Foo/SubCodec.pm b/PerlTQt/t/Foo/SubCodec.pm
new file mode 100644
index 0000000..9d79fba
--- /dev/null
+++ b/PerlTQt/t/Foo/SubCodec.pm
@@ -0,0 +1,14 @@
+package Foo::SubCodec;
+use TQt;
+use My::Codec;
+use TQt::isa qw( My::Codec );
+
+
+sub NEW
+{
+ shift->SUPER::NEW(@_);
+}
+
+sub foo {}
+
+1;
diff --git a/PerlTQt/t/My/Codec.pm b/PerlTQt/t/My/Codec.pm
new file mode 100644
index 0000000..f853f5d
--- /dev/null
+++ b/PerlTQt/t/My/Codec.pm
@@ -0,0 +1,10 @@
+package My::Codec;
+use TQt;
+use TQt::isa qw( TQt::TextCodec );
+
+sub NEW
+{
+ shift->SUPER::NEW(@_);
+}
+
+1; \ No newline at end of file
diff --git a/PerlTQt/t/My/SubCodec.pm b/PerlTQt/t/My/SubCodec.pm
new file mode 100644
index 0000000..35e2b0c
--- /dev/null
+++ b/PerlTQt/t/My/SubCodec.pm
@@ -0,0 +1,15 @@
+
+package My::SubCodec;
+use TQt;
+use My::Codec;
+use TQt::isa qw( My::Codec );
+
+
+sub NEW
+{
+ shift->SUPER::NEW(@_);
+}
+
+sub bar {}
+
+1; \ No newline at end of file
diff --git a/PerlTQt/t/a_loading.t b/PerlTQt/t/a_loading.t
new file mode 100644
index 0000000..1cffc31
--- /dev/null
+++ b/PerlTQt/t/a_loading.t
@@ -0,0 +1,6 @@
+
+BEGIN { print "1..1\n" }
+
+use TQt;
+
+print "ok 1\n"
diff --git a/PerlTQt/t/b_nogui.t b/PerlTQt/t/b_nogui.t
new file mode 100644
index 0000000..cd28260
--- /dev/null
+++ b/PerlTQt/t/b_nogui.t
@@ -0,0 +1,48 @@
+
+BEGIN { print "1..6\n" }
+
+use TQt;
+use TQt::constants;
+
+eval {my $c = TQt::TextCodec::codecForLocale()};
+
+print +$@ ? "not ok\n" : "ok 1\n";
+
+eval {my $s = TQt::Variant( TQt::DateTime::currentDateTime() ) };
+
+print +$@ ? "not ok\n" : "ok 2\n";
+
+my $ret;
+eval {$ret = TQt::Point(20,20); $ret += TQt::Point(10,10); $ret *= 2 ; $ret /= 3 };
+
+print +$@ ? "not ok\n" : "ok 3\n";
+
+eval { $ret = ($ret->x != 20 or $ret->y != 20) ? 1 : 0 };
+
+print +($@ || $ret) ? "not ok\n" : "ok 4\n";
+
+eval { my $z = TQt::GlobalSpace::qVersion() };
+
+if( $@ )
+{
+ print "ok 5 # skip Smoke version too old\n";
+ print "ok 6 # skip Smoke version too old\n";
+}
+else
+{
+ eval{ my $p = TQt::Point( 20, 20 );
+ my $p2 = TQt::Point( 30, 30 );
+ $p = $p + $p2 + $p;
+ $p2 = $p * 2;
+ $p2 = -$p2;
+ $ret = ($p2->x != -140 or $p2->y != -140) ? 1 : 0
+ };
+ print +($@ || $ret) ? "not ok\n" : "ok 5\n";
+
+ eval {
+ $str = "Fooooooooooo";
+ $ts = TQt::TextStream( $str, IO_WriteOnly );
+ $ts << "pi = " << 3.14;
+ };
+ print +($str eq "pi = 3.14ooo") ? "ok 6\n":"not ok\n";
+}
diff --git a/PerlTQt/t/c_qapp.t b/PerlTQt/t/c_qapp.t
new file mode 100644
index 0000000..01d6b39
--- /dev/null
+++ b/PerlTQt/t/c_qapp.t
@@ -0,0 +1,23 @@
+BEGIN { print "1..3\n" }
+
+use TQt;
+
+$a=0;
+
+# testing if the TQt::Application ctor works
+
+eval { $a=TQt::Application(\@ARGV) };
+
+print +$@ ? "not ok\n" : "ok 1\n";
+
+# testing wether the global object is properly setup
+
+eval { TQt::app()->libraryPaths() };
+
+print +$@ ? "not ok\n" : "ok 2\n";
+
+# one second test of the event loop
+
+TQt::Timer::singleShot( 300, TQt::app(), TQT_SLOT "quit()" );
+
+print TQt::app()->exec ? "not ok\n" : "ok 3\n";
diff --git a/PerlTQt/t/ca_i18n.t b/PerlTQt/t/ca_i18n.t
new file mode 100644
index 0000000..1e71c29
--- /dev/null
+++ b/PerlTQt/t/ca_i18n.t
@@ -0,0 +1,23 @@
+BEGIN { print "1..1\n" }
+
+use TQt;
+
+$a = TQt::Application();
+$pb=TQt::PushButton("Foooo", undef);
+
+{
+ use bytes;
+ $pb->setText( "élégant" );
+
+ $b = $pb->text();
+ $b2 = TQt::Widget::tr("élégant");
+}
+
+
+$c = $pb->text();
+$c2= TQt::Widget::tr("élégant");
+
+{
+ use bytes;
+ print +($b ne $c and $b2 ne $c2) ? "ok 1\n":"not ok\n";
+}
diff --git a/PerlTQt/t/d_sigslot.t b/PerlTQt/t/d_sigslot.t
new file mode 100644
index 0000000..acd3c4a
--- /dev/null
+++ b/PerlTQt/t/d_sigslot.t
@@ -0,0 +1,49 @@
+BEGIN { print "1..3\n" }
+
+package MyApp;
+use TQt;
+use TQt::isa qw(TQt::Application);
+use TQt::slots
+ foo => ['int'],
+ baz => [];
+use TQt::signals
+ bar => ['int'];
+
+sub NEW {
+ shift->SUPER::NEW(@_);
+
+ # 1) testing correct subclassing of TQt::Application and this pointer
+ print +(ref(this) eq " MyApp")? "ok 1\n" : "not ok\n";
+
+ this->connect(this, TQT_SIGNAL 'bar(int)', TQT_SLOT 'foo(int)');
+
+ # 3) automatic quitting will test TQt sig to custom slot
+ this->connect(this, TQT_SIGNAL 'aboutToQuit()', TQT_SLOT 'baz()');
+
+ # 2) testing custom sig to custom slot
+ emit bar(3);
+}
+
+sub foo
+{
+ print +($_[0] == 3) ? "ok 2\n" : "not ok\n";
+}
+
+sub baz
+{
+ print "ok 3\n";
+}
+
+1;
+
+package main;
+
+use TQt;
+use MyApp;
+
+$a = 0;
+$a = MyApp(\@ARGV);
+
+TQt::Timer::singleShot( 300, TQt::app(), TQT_SLOT "quit()" );
+
+exit TQt::app()->exec;
diff --git a/PerlTQt/t/e_sigslot_inherit.t b/PerlTQt/t/e_sigslot_inherit.t
new file mode 100644
index 0000000..338a405
--- /dev/null
+++ b/PerlTQt/t/e_sigslot_inherit.t
@@ -0,0 +1,72 @@
+BEGIN { print "1..6\n" }
+
+package MyApp;
+use TQt;
+use TQt::isa('TQt::Application');
+use TQt::slots
+ foo => ['int'],
+ baz => [];
+use TQt::signals
+ bar => ['int'];
+
+sub NEW
+{
+ shift->SUPER::NEW(@_);
+ this->connect(this, TQT_SIGNAL 'bar(int)', TQT_SLOT 'foo(int)');
+ this->connect(this, TQT_SIGNAL 'aboutToQuit()', TQT_SLOT 'baz()');
+}
+
+sub foo
+{
+ # 1) testing correct inheritance of sig/slots
+ print +($_[0] == 3) ? "ok 1\n" : "not ok\n";
+}
+
+sub baz
+{
+ print "ok 3\n";
+}
+
+sub coincoin
+{
+ print +(@_ == 2) ? "ok 5\n":"not ok\n";
+ print +(ref(this) eq " MySubApp") ? "ok 6\n":"not ok\n";
+}
+
+1;
+
+package MySubApp;
+use TQt;
+use TQt::isa('MyApp');
+
+
+sub NEW
+{
+ shift->SUPER::NEW(@_);
+ emit foo(3);
+}
+
+sub baz
+{
+ # 2) testing further inheritance of sig/slots
+ print "ok 2\n";
+ # 3) testing Perl to Perl SUPER
+ SUPER->baz();
+ # 4) 5) 6) testing non-qualified enum calls vs. Perl method/static calls
+ eval { &blue }; print !$@ ? "ok 4\n":"not ok\n";
+ coincoin("a","b");
+}
+
+1;
+
+package main;
+
+use TQt;
+use MySubApp;
+
+$a = 0;
+$a = MySubApp(\@ARGV);
+
+TQt::Timer::singleShot( 300, TQt::app(), TQT_SLOT "quit()" );
+
+exit TQt::app()->exec;
diff --git a/PerlTQt/t/f_import.t b/PerlTQt/t/f_import.t
new file mode 100644
index 0000000..9f8977c
--- /dev/null
+++ b/PerlTQt/t/f_import.t
@@ -0,0 +1,19 @@
+BEGIN { push @INC, "./t" ; print "1..1\n" }
+
+package main;
+
+use TQt;
+use My::SubCodec;
+use Foo::SubCodec;
+
+$tc1 = My::SubCodec();
+$tc2 = Foo::SubCodec();
+
+$tc1->bar();
+$tc2->foo();
+
+$tc2->deleteAllCodecs;
+
+# all imports OK
+
+print "ok 1\n";
diff --git a/PerlTQt/t/g_gui.t b/PerlTQt/t/g_gui.t
new file mode 100644
index 0000000..f3a7d05
--- /dev/null
+++ b/PerlTQt/t/g_gui.t
@@ -0,0 +1,127 @@
+
+BEGIN { print "1..1\n" }
+
+package ButtonsGroups;
+use strict;
+use TQt;
+use TQt::isa qw(TQt::Widget);
+use TQt::slots
+ slotChangeGrp3State => [];
+use TQt::attributes qw(
+ state
+ rb21
+ rb22
+ rb23
+);
+
+#
+# Constructor
+#
+# Creates all child widgets of the ButtonGroups window
+#
+
+sub NEW {
+ shift->SUPER::NEW(@_);
+
+ # Create Widgets which allow easy layouting
+ my $vbox = TQt::VBoxLayout(this);
+ my $box1 = TQt::HBoxLayout($vbox);
+ my $box2 = TQt::HBoxLayout($vbox);
+
+ # ------- first group
+
+ # Create an exclusive button group
+ my $bgrp1 = TQt::ButtonGroup(1, &Horizontal, "Button Group &1 (exclusive)", this);
+ $box1->addWidget($bgrp1);
+ $bgrp1->setExclusive(1);
+
+ # insert 3 radiobuttons
+ TQt::RadioButton("R&adiobutton 2", $bgrp1);
+ TQt::RadioButton("Ra&diobutton 3", $bgrp1);
+
+ # ------- second group
+
+ # Create a non-exclusive buttongroup
+ my $bgrp2 = TQt::ButtonGroup(1, &Horizontal, "Button Group &2 (non-exclusive)", this);
+ $box1->addWidget($bgrp2);
+ $bgrp2->setExclusive(0);
+
+ # insert 3 checkboxes
+ TQt::CheckBox("&Checkbox 1", $bgrp2);
+ my $cb12 = TQt::CheckBox("C&heckbox 2", $bgrp2);
+ $cb12->setChecked(1);
+ my $cb13 = TQt::CheckBox("Triple &State Button", $bgrp2);
+ $cb13->setTristate(1);
+ $cb13->setChecked(1);
+
+ # ----------- third group
+
+ # create a buttongroup which is exclusive for radiobuttons and non-exclusive for all other buttons
+ my $bgrp3 = TQt::ButtonGroup(1, &Horizontal, "Button Group &3 (Radiobutton-exclusive)", this);
+ $box2->addWidget($bgrp3);
+ $bgrp3->setRadioButtonExclusive(1);
+
+ # insert three radiobuttons
+ rb21 = TQt::RadioButton("Rad&iobutton 1", $bgrp3);
+ rb22 = TQt::RadioButton("Radi&obutton 2", $bgrp3);
+ rb23 = TQt::RadioButton("Radio&button 3", $bgrp3);
+ rb23->setChecked(1);
+
+ # insert a checkbox
+ state = TQt::CheckBox("E&nable Radiobuttons", $bgrp3);
+ state->setChecked(1);
+ # ...and connect its TQT_SIGNAL clicked() with the TQT_SLOT slotChangeGrp3State()
+ this->connect(state, TQT_SIGNAL('clicked()'), TQT_SLOT('slotChangeGrp3State()'));
+
+ # ----------- fourth group
+
+ # create a groupbox which layouts its childs in a columns
+ my $bgrp4 = TQt::ButtonGroup(1, &Horizontal, "Groupbox with &normal buttons", this);
+ $box2->addWidget($bgrp4);
+
+ # insert three pushbuttons...
+ TQt::PushButton("&Push Button", $bgrp4);
+ my $tb2 = TQt::PushButton("&Toggle Button", $bgrp4);
+ my $tb3 = TQt::PushButton("&Flat Button", $bgrp4);
+
+ # ... and make the second one a toggle button
+ $tb2->setToggleButton(1);
+ $tb2->setOn(1);
+
+ # ... and make the third one a flat button
+ $tb3->setFlat(1);
+}
+
+#
+# TQT_SLOT slotChangeGrp3State()
+#
+# enables/disables the radiobuttons of the third buttongroup
+#
+
+sub slotChangeGrp3State {
+ rb21->setEnabled(state->isChecked);
+ rb22->setEnabled(state->isChecked);
+ rb23->setEnabled(state->isChecked);
+}
+
+1;
+
+package main;
+
+use TQt;
+use ButtonsGroups;
+
+TQt::StyleFactory::keys(); # disable style plugins (hacky)
+
+my $a = TQt::Application(\@ARGV);
+
+my $buttonsgroups = ButtonsGroups;
+$buttonsgroups->resize(500, 250);
+$buttonsgroups->setCaption("PerlTQt Test - Please wait");
+$a->setMainWidget($buttonsgroups);
+$buttonsgroups->show;
+
+TQt::Timer::singleShot( 2000, TQt::app(), TQT_SLOT "quit()" );
+my $r = $a->exec;
+print +$r?"not ok\n" : "ok 1\n";
+exit $r;