File: video_controls.cpp

package info (click to toggle)
sight 25.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 42,180 kB
  • sloc: cpp: 289,476; xml: 17,257; ansic: 9,878; python: 1,379; sh: 144; makefile: 33
file content (110 lines) | stat: -rw-r--r-- 4,136 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/************************************************************************
 *
 * Copyright (C) 2023 IRCAD France
 *
 * This file is part of Sight.
 *
 * Sight is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Sight is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with Sight. If not, see <https://www.gnu.org/licenses/>.
 *
 ***********************************************************************/

#include "video_controls.hpp"

#include "button.hpp"
#include "combo_box.hpp"
#include "dialog.hpp"
#include "file_dialog.hpp"
#include "selector_dialog.hpp"

namespace sight::ui::test::helper
{

//------------------------------------------------------------------------------

void video_controls::load(tester& _tester, const std::string& _controls_name, const std::filesystem::path& _path)
{
    // Some activity takes time to load and the control is not always there
    QTest::qWait(1000);

    _tester.take("controls", _controls_name);
    helper::combo_box::select(_tester, selector::from_parent(_controls_name, "videoSelectorSrv"), "File...");
    helper::file_dialog::fill(_tester, _path);

    // If RealSense is activated, another dialog appears
    helper::dialog::maybe_take(_tester, "choose video grabber implementation dialog");
    if(_tester.exists())
    {
        helper::selector_dialog::select(_tester, "OpenCV player");
    }
}

//------------------------------------------------------------------------------

void video_controls::start(tester& _tester, const std::string& _controls_name)
{
    auto bt = _tester.add_in_backtrace("Start the video controlled by " + _controls_name);
    helper::button::push(_tester, _controls_name + "/Start");
    _tester.should_be_hidden(
        "start button",
        [&_tester, &_controls_name]
        {
            return _tester.get_main_window()->findChild<QWidget*>(QString::fromStdString(_controls_name + "/Start"));
        });
}

//------------------------------------------------------------------------------

void video_controls::pause(tester& _tester, const std::string& _controls_name)
{
    auto bt = _tester.add_in_backtrace("Pause the video controlled by " + _controls_name);
    helper::button::push(_tester, _controls_name + "/Pause");
    _tester.should_be_hidden(
        "pause button",
        [&_tester, &_controls_name]
        {
            return _tester.get_main_window()->findChild<QWidget*>(QString::fromStdString(_controls_name + "/Pause"));
        });
}

//------------------------------------------------------------------------------

void video_controls::play(tester& _tester, const std::string& _controls_name)
{
    auto bt = _tester.add_in_backtrace("Play the video controlled by " + _controls_name);
    helper::button::push(_tester, _controls_name + "/Play");
    _tester.should_be_hidden(
        "play button",
        [&_tester, &_controls_name]
        {
            return _tester.get_main_window()->findChild<QWidget*>(QString::fromStdString(_controls_name + "/Play"));
        });
}

//------------------------------------------------------------------------------

void video_controls::stop(tester& _tester, const std::string& _controls_name)
{
    auto bt = _tester.add_in_backtrace("Stop the video controlled by " + _controls_name);
    helper::button::push(_tester, _controls_name + "/Stop");
}

//------------------------------------------------------------------------------

void video_controls::loop(tester& _tester, const std::string& _controls_name)
{
    auto bt = _tester.add_in_backtrace("Loop the video controlled by " + _controls_name);
    helper::button::push(_tester, _controls_name + "/Loop");
}

} // namespace sight::ui::test::helper