54 lines
1.4 KiB
C++
54 lines
1.4 KiB
C++
|
|
#include <QPushButton>
|
||
|
|
#include <QSignalSpy>
|
||
|
|
#include <QtTest>
|
||
|
|
|
||
|
|
#include "desktop_list_page.h"
|
||
|
|
|
||
|
|
using namespace vdi;
|
||
|
|
|
||
|
|
class DesktopListPageTest : public QObject {
|
||
|
|
Q_OBJECT
|
||
|
|
|
||
|
|
private slots:
|
||
|
|
void firstClickDisablesActionsAndBlocksDuplicate();
|
||
|
|
};
|
||
|
|
|
||
|
|
void DesktopListPageTest::firstClickDisablesActionsAndBlocksDuplicate() {
|
||
|
|
DesktopListPage page;
|
||
|
|
DesktopInfo desktop;
|
||
|
|
desktop.id = QStringLiteral("desktop-1");
|
||
|
|
desktop.name = QStringLiteral("Windows 10");
|
||
|
|
desktop.os = QStringLiteral("Windows");
|
||
|
|
desktop.state = DesktopState::kAvailable;
|
||
|
|
page.setDesktops({desktop});
|
||
|
|
|
||
|
|
QPushButton* connectButton = nullptr;
|
||
|
|
QPushButton* editButton = nullptr;
|
||
|
|
const auto buttons = page.findChildren<QPushButton*>();
|
||
|
|
for (QPushButton* button : buttons) {
|
||
|
|
if (button->text() == QStringLiteral("连接")) {
|
||
|
|
connectButton = button;
|
||
|
|
} else if (button->text() == QStringLiteral("设置")) {
|
||
|
|
editButton = button;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
QVERIFY(connectButton);
|
||
|
|
QVERIFY(editButton);
|
||
|
|
|
||
|
|
QSignalSpy spy(&page, &DesktopListPage::desktopSelected);
|
||
|
|
connectButton->click();
|
||
|
|
QCOMPARE(spy.count(), 1);
|
||
|
|
QVERIFY(!connectButton->isEnabled());
|
||
|
|
QVERIFY(!editButton->isEnabled());
|
||
|
|
|
||
|
|
connectButton->click();
|
||
|
|
QCOMPARE(spy.count(), 1);
|
||
|
|
|
||
|
|
page.setBusy(false);
|
||
|
|
QVERIFY(connectButton->isEnabled());
|
||
|
|
QVERIFY(editButton->isEnabled());
|
||
|
|
}
|
||
|
|
|
||
|
|
QTEST_MAIN(DesktopListPageTest)
|
||
|
|
#include "test_desktop_list_page.moc"
|