2

我非常喜欢 Travis CI 的持续集成测试。我用它测试了我的大部分 C++ 控制台、桌面(Qt、SFML)和 Web(使用 Wt)应用程序。它非常适合测试基于浏览器的应用程序,并且已经很好地记录了这一点

我不能做的一件事是在 Travis CI 上测试桌面应用程序的 GUI。

我需要一些基本的东西,比如“获得一个具有特定标题/名称的窗口”、“在窗口中心单击鼠标左键”和“向窗口发送一个空格”。

我已经可以使用 xdotools、LDTP2 和 Sikuli 在本地执行此操作,但只能在本地执行。然而,在 Travis CI 上,我无法让这些工具成功运行。我一直在尝试写一个关于它的教程这些是我的脚本),我已经联系了 Travis 的人,甚至在这里设置了赏金,但都没有成功。

因为这是一个复杂的过程(在 Travis 上设置 Windows 管理器,编写桌面应用程序进行测试,编写脚本以在 bash 中测试这些)我认为在这里发布那些小错误没有用(大多数人已经在这里有了答案)。

我的问题是:有没有人有一个工作的例子

  • 非 Web C++ GUI 应用程序
  • 它的 GUI 在本地和 Travis 上都经过测试
  • 这些测试包括发送按键和鼠标点击

我不关心确切的工具(xdotools 或其他一些窗口管理器工具、Qt 或其他一些 C++ GUI 库、bash 或任何其他脚本语言)。我只想让 Travis CI 在git push.

4

2 回答 2

0

好吧,我在这里:

Travis 中的 Nana C++ GUI 测试

其他点击,在 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 ...

在这里编程。

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 中测试本地化(好吧,当我有时间时......)但我个人无法在 linux 中进行测试,所以,Travis 对我来说非常有用。我发明了一些函数来在 GUI 库 self 中编写测试。(还)不是很优雅。我希望我有时间让它变得更好。我很乐意看到您的解决方案。

于 2017-04-03T21:31:06.083 回答
0

不确定这是否回答了您的问题,但您尝试过的东西的语法可能是它一直为您破坏的原因。

上游问题中,反复使用以下内容:

var=value; program

您能否尝试使用以下语法:

var=value program

或者

export var=value; program

解释:;是表达式的终止符,刚刚设置的变量不可用于子 PID。导出变量或使用特殊语法(不;作为分隔符)将使刚刚设置的变量可用于子 PID。

于 2017-03-05T22:40:57.707 回答