重构:完善串流就绪检测并补充 GPU 联调记录
变更详情:kiosk 会话就绪检测重构(Moonlight 输出解析器/事件化回调/单元测试);GPU 直通实操记录(vfio Subsystem 注入、sysfs vBIOS、7zr+pnputil 安装、566.36 驱动、Sunshine 配对断链修复)
This commit is contained in:
1 parent
b08486046b
commit
13f645a503
14 files changed
+743
-225
No files matched your search
@@ -0,0 +1,53 @@
|
||||
#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"
|
||||
@@ -0,0 +1,94 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include "moonlight_session.h"
|
||||
|
||||
using namespace vdi;
|
||||
|
||||
class MoonlightSessionTest : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void parsesSplitReadyMarkers();
|
||||
void requiresBothReadyMarkers();
|
||||
void rejectsSecondStart();
|
||||
};
|
||||
|
||||
void MoonlightSessionTest::parsesSplitReadyMarkers() {
|
||||
MoonlightOutputParser parser;
|
||||
parser.append("Test decode succ");
|
||||
QVERIFY(!parser.isReady());
|
||||
parser.append("essful\nRenderer 'SDL' with 'DRM' backend ");
|
||||
QVERIFY(parser.hasTestDecode());
|
||||
QVERIFY(!parser.hasRenderer());
|
||||
parser.append("chosen\n");
|
||||
QVERIFY(parser.isReady());
|
||||
}
|
||||
|
||||
void MoonlightSessionTest::requiresBothReadyMarkers() {
|
||||
MoonlightOutputParser parser;
|
||||
parser.append("Test decode successful\n");
|
||||
QVERIFY(!parser.isReady());
|
||||
|
||||
parser.reset();
|
||||
parser.append("Renderer 'SDL' chosen\n");
|
||||
QVERIFY(!parser.isReady());
|
||||
|
||||
parser.append("Connection terminated: -1\n");
|
||||
QVERIFY(parser.hasTerminalError());
|
||||
QVERIFY(!parser.isReady());
|
||||
}
|
||||
|
||||
void MoonlightSessionTest::rejectsSecondStart() {
|
||||
QTemporaryDir tempDir;
|
||||
QVERIFY(tempDir.isValid());
|
||||
|
||||
const QString executable = tempDir.filePath(QStringLiteral("moonlight-qt"));
|
||||
QFile script(executable);
|
||||
QVERIFY(script.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||
script.write("#!/bin/sh\n"
|
||||
"printf 'Test decode successful\\n'\n"
|
||||
"printf \"Renderer 'SDL' with 'DRM' backend chosen\\n\"\n"
|
||||
"sleep 5\n");
|
||||
script.close();
|
||||
QVERIFY(script.setPermissions(QFileDevice::ReadOwner | QFileDevice::WriteOwner |
|
||||
QFileDevice::ExeOwner | QFileDevice::ReadGroup |
|
||||
QFileDevice::ExeGroup | QFileDevice::ReadOther |
|
||||
QFileDevice::ExeOther));
|
||||
|
||||
const QByteArray oldPath = qgetenv("PATH");
|
||||
qputenv("PATH", tempDir.path().toUtf8() + ':' + oldPath);
|
||||
|
||||
ConnectionTicket ticket;
|
||||
ticket.endpoint = QStringLiteral("127.0.0.1");
|
||||
ticket.app = QStringLiteral("Desktop");
|
||||
|
||||
MoonlightSession session;
|
||||
int started = 0;
|
||||
int ready = 0;
|
||||
int terminal = 0;
|
||||
const auto callback = [&](const MoonlightSession::Event& event) {
|
||||
if (event.type == MoonlightSession::EventType::kStarted) {
|
||||
++started;
|
||||
} else if (event.type == MoonlightSession::EventType::kStreamReady) {
|
||||
++ready;
|
||||
} else if (event.type == MoonlightSession::EventType::kFailed ||
|
||||
event.type == MoonlightSession::EventType::kFinished) {
|
||||
++terminal;
|
||||
}
|
||||
};
|
||||
|
||||
QVERIFY(session.start(ticket, callback));
|
||||
QTRY_COMPARE_WITH_TIMEOUT(started, 1, 2000);
|
||||
QVERIFY(!session.start(ticket, callback));
|
||||
QTRY_COMPARE_WITH_TIMEOUT(ready, 1, 3000);
|
||||
|
||||
session.stop();
|
||||
QTRY_COMPARE_WITH_TIMEOUT(terminal, 1, 4000);
|
||||
QCOMPARE(ready, 1);
|
||||
QCOMPARE(terminal, 1);
|
||||
|
||||
qputenv("PATH", oldPath);
|
||||
}
|
||||
|
||||
QTEST_GUILESS_MAIN(MoonlightSessionTest)
|
||||
#include "test_moonlight_session.moc"
|
||||
Reference in new issue
Block a user