refactor: split core/ui/apps targets and add unit tests
Move all business logic into liblivecaption_core (no Qt dependency) and the widgets into liblivecaption_ui, leaving two executables: the caption window and the CLI, which no longer links Qt Widgets. Abstract the ASR backend behind IAsr so the streaming policy and the live pipeline can be tested with a scripted fake backend instead of a real model. 把全部业务逻辑下沉到不依赖 Qt 的 liblivecaption_core,界面独立成 liblivecaption_ui,拆出悬浮窗与命令行两个可执行程序(CLI 不再链接 Qt Widgets);并用 IAsr 抽象推理后端,使流式策略与实时管线可脱离真模型 用假实现做单元测试。测试还抓到一个真 bug:段恰好结束在 chunk 边界时 只提交了稳定部分,最后几个词被丢掉,已修。
This commit is contained in:
1 parent
4ed4e23282
commit
736ec14d5b
32 files changed
+1502
-655
No files matched your search
@@ -0,0 +1,48 @@
|
||||
#include <QtTest>
|
||||
|
||||
#include "transcript.h"
|
||||
|
||||
// 输出解析:Qwen3-ASR 的原始输出形如 "language English<asr_text>正文"
|
||||
class TstTranscript : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
private slots:
|
||||
void splitsLanguageAndText()
|
||||
{
|
||||
const auto r = lc::parseAsrOutput("language English<asr_text>He hoped there would be stew.");
|
||||
QCOMPARE(QString::fromStdString(r.language), QString("English"));
|
||||
QCOMPARE(QString::fromStdString(r.text), QString("He hoped there would be stew."));
|
||||
}
|
||||
|
||||
void handlesChinese()
|
||||
{
|
||||
const auto r = lc::parseAsrOutput("language Chinese<asr_text>不排除购房者可以在互联网上下单。");
|
||||
QCOMPARE(QString::fromStdString(r.language), QString("Chinese"));
|
||||
QCOMPARE(QString::fromStdString(r.text), QString("不排除购房者可以在互联网上下单。"));
|
||||
}
|
||||
|
||||
void withoutMarkerKeepsWholeText()
|
||||
{
|
||||
const auto r = lc::parseAsrOutput(" just text ");
|
||||
QVERIFY(r.language.empty());
|
||||
QCOMPARE(QString::fromStdString(r.text), QString("just text"));
|
||||
}
|
||||
|
||||
void trimsSurroundingWhitespaceOfBody()
|
||||
{
|
||||
const auto r = lc::parseAsrOutput("language English<asr_text> hi there ");
|
||||
QCOMPARE(QString::fromStdString(r.text), QString("hi there"));
|
||||
}
|
||||
|
||||
void displayNameMapping()
|
||||
{
|
||||
QCOMPARE(QString::fromStdString(lc::languageDisplayName("English")), QString("英语"));
|
||||
QCOMPARE(QString::fromStdString(lc::languageDisplayName("Chinese")), QString("中文"));
|
||||
// 未收录的语言原样返回
|
||||
QCOMPARE(QString::fromStdString(lc::languageDisplayName("Klingon")), QString("Klingon"));
|
||||
QVERIFY(lc::languageDisplayName("").empty());
|
||||
}
|
||||
};
|
||||
|
||||
QTEST_MAIN(TstTranscript)
|
||||
#include "tst_transcript.moc"
|
||||
Reference in new issue
Block a user