in reply to Including a Gtk2 app in a Test

I would start by using some the test machinery in the Gtk2 module itself. For instance Gtk2::Test::Helper sets up a nice test environment for Gtk2 method calls. Also look at the tests used in proofing the Gtk2 module. They will give you hints regarding the exercising of your GUI.

-Mark

Replies are listed 'Best First'.
Re: Re: Including a Gtk2 app in a Test
by mutated (Monk) on Apr 26, 2004 at 18:46 UTC
    The actual Gtk2 code to load the window and run the main loop is in the body of my foo.pl ie not encapsulated in a function..All the examples I have seen show windows and what not being created in function calls in libraries so you can use the library and call the methode to build the window. Since I can't use a non-library ie my main perl program, and even if I could can't execute the body of said program which draws the interface, I can't figure out how to use any of the Gtk2::Test::Helper stuff to help me..


    daN.
      You can probably rewrite foo.pl like this:

      sub foo { # original foo.pl code here return "all right"; } foo() unless defined caller(); # call foo() unless require'd

      And then in your tests do something like

      # Test::More style used.... use Test::More tests => 1; require "foo.pl"; is(foo(),"all right","Foo() executed normally")
      Update: You'll probably not want everything in the foo() function, just the stuff that's needed to set up the gui.

      For instance, the run loop will probably be set up by the test module (but I'm only guessing, I've never used the Gtk test modules).

      Update 2:: Actually, most of the above is wrong. It will give you some hints on how to solve your problem, though. I'm going to eat something now.

      Joost.

        Actually it was helpful! thanks Joost, it's got me on the road to being able to use Gtk2::Test::Helper as kvale suggested which is what I was looking for.


        daN.