2017-03-04 58 views
2

我很喜欢特拉维斯CI进行持续集成测试。我测试了大部分C++控制台,桌面(Qt,SFML)和Web(使用Wt)应用程序。它非常适合测试基于浏览器的应用程序and has documented this nicely特拉维斯CI的C++桌面GUI测试

我不能做的一件事是在Travis CI上测试桌面应用程序的GUI。我需要一些基本的东西,例如'获得一个具有特定标题的窗口/命名它的大小','在窗口的中心'点击鼠标左键'和'发送一个空间到窗口'。

我已经可以在本地做到这一点,但只能在本地使用xdotools,LDTP2和Sikuli。然而,在Travis CI上,我无法让这些工具成功运行。我一直试图写一个关于它的tutorialthese are my scripts),我有contacted the folks at Travis甚至set a bounty here,都没有成功。因为这是一个复杂的过程(在Travis上设置一个Windows管理器,编写桌面应用程序进行测试,编写脚本以便在bash中测试这些脚本)我认为在这里发布这些小个体错误是没有用的(大多数答案这里已经)。

我的问题是:任何人都不会有的

  • 非网C++图形用户界面应用程序
  • 有它的GUI在本地和特拉维斯
  • 这些测试包括了测试工作示例发送按键和鼠标点击

我不关心确切的工具(xdotools或其他窗口管理器工具,Qt左右我其他C++ GUI库,bash或任何其他脚本语言)。我想要的是让Travis CI在git push上检查我的GUI。

回答

0

不知道这是否回答你的问题,但你尝试过的东西的语法可能是它为什么会破坏你的原因。

upstream issue,反复以下时:

var=value; program 

你能尝试使用下面的语法来代替:

var=value program 

export var=value; program 

说明:;是表达式的终止符,并且有变量t已设置不适用于子PID。要么导出变量,要么使用特殊语法(没有;作为分隔符)将使变量刚好可用于子PID。

+0

这很有帮助。我现在会试试这个。谢谢! – richelbilderbeek

+0

我试过使用它,但是https://travis-ci.org/richelbilderbeek/testing_cpp_gui_applications_tutorial#L948显示这不是问题。感谢您的帮助,但:-) – richelbilderbeek

0

好了,我这里有:

Nana C++ GUI test in Travis

Other click,特拉维斯:

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 ... 

编程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(); 

     }); 
} 

这远远没有准备好,只是我最初的想法。我最大的问题是,我没有在Linux的GUI经验。我实施了一些测试和几个例子,目前这些例子足以让我们发现大问题。我在Windows中测试localy(当然,当我有时间的时候......)但我个人无法在Linux中测试,所以,Travis对我来说非常有用。 我发明了几个函数来在GUI库自己写测试。不是(非常)优雅。我希望我会有时间让它变得更好。我很乐意看到您的解决方案。

+0

我很高兴听到你享受体面的单元测试。太糟糕了,它不能回答我的问题,例如'有一个特定的标题窗口/名称的大小'。我也能够从应用程序内操纵我的窗口。我想从程序外部发送按键和鼠标点击。 – richelbilderbeek