2

I enjoy Travis CI a lot for continuous integration testing. I test most of my C++ console, desktop (Qt, SFML) and web (using Wt) applications with it. It is great for testing browser-based applications and has documented this nicely.

One thing I cannot do is test the GUI of a desktop application on Travis CI.

I need basic things like 'get a window with a certain title/name its size', 'click left mouse button in the center' of the window' and 'send a space to the window'.

I can already do this locally, but only locally, with xdotools, LDTP2 and Sikuli. On Travis CI, however, I cannot get those tools to run successfully. I have been trying to write a tutorial about it (these are my scripts), I have contacted the folks at Travis and even set a bounty here, all without success.

Because this is a complex process (setting up a windows manager on Travis, writing desktop applications to test, writing scripts to test these in bash) I think it is not useful to post those little individuals errors here (most have answers here already).

My question is: does anyone have a working example of

  • a non-web C++ GUI application
  • that has its GUI tested both locally and on Travis
  • these tests consist out of sending key presses and mouse clicks

I do not care about the exact tools (xdotools or some other window manager tool, Qt or some other C++ GUI library, bash or any other scripting language). All I want is to have Travis CI check my GUI upon a git push.

richelbilderbeek
  • 349
  • 3
  • 10

2 Answers2

0

Not sure if this answers your question, but the syntax of the stuff you have attempted might be the cause of why it has been breaking for you.

In the upstream issue, repeatedly the following is used:

var=value; program

Could you try and use the following syntax instead:

var=value program

or

export var=value; program

Explanation: The ; is a terminator of the expression, and the variable that has just been set is not available for child PIDs. Either exporting the variable, or using the special syntax (without ; as a separator) will make the variable just set available for the child PID.

joepd
  • 4,681
  • 2
  • 26
  • 27
0

Well, I have here:

Nana C++ GUI test in Travis

Other click, in travis:

3.04s$ ./clicked
Will wait 2 sec...
waiting 2 sec...
running... 
3 times automatic click. 
Automatically clicking widget :
When the window  fm  is clicked, this function is called. 
Automatically clicking widget :
When the window  fm  is clicked, this function is called. 
Automatically clicking widget :
When the window  fm  is clicked, this function is called. 
Now with then mouse. 
Congratulations, this was not trivial !
Done... 
Now again waiting 1 sec...
Done... Now API::exit all ...

programmed here.

void clicked(const nana::arg_click & eventinfo)
{
     std::cout<<  "When the window  fm  is clicked, this function is called. \n";
}



int main()
{
    using namespace nana;
    form fm;
    fm.events().click(clicked);
    fm.show();
    exec( 2, 1, [&fm]()
        {
            std::cout << "3 times automatic click. \n";
            click(fm);
            click(fm);
            click(fm);

            nana::arg_mouse m;
            m.window_handle=fm;
            m.alt=m.ctrl=m.mid_button=m.shift=false;
            m.left_button=true;
            m.pos.x=m.pos.y=1;
            m.button=::nana::mouse::left_button;

            std::cout << "Now with then mouse. \n";
            //fm.events().mouse_down.emit(m);
            //fm.events().mouse_up.emit(m);

            // char c;
            // std::cin >> c;

            //fm.close();

         });
}

This is far from ready, is only my initial idea. My biggest problem is that I have no experience with GUI in linux. I implemented just a few test, a few examples, which for now is enough for us to detect big problems. I test localy in Windows (well, when I have the time...) but no way I personally can test in linux, so, Travis is for me very useful. I invented a few functions to write the test inside the GUI library self. Is not (yet) very elegant. I hope I will have the time to make it better. I will love to see your solutions.

qPCR4vir
  • 3,521
  • 1
  • 22
  • 32
  • I am happy to hear you to enjoy decent unit testing. Too bad it does not answer my question, e.g. 'get a window with a certain title/name its size'. I too am able to manipulate my windows from within an application. I want to send key presses and mouseclicks from outside of the program. – richelbilderbeek Apr 05 '17 at 10:52