#include #include #include #include "providers/provider.h" #include "providers/buffer_provider.h" #include "providers/null_provider.h" using namespace rcx; // -- Replicate the label-building logic from updateCommandRow so we can test it // without needing a full RcxController/RcxDocument/RcxEditor stack. static QString buildSourceLabel(const Provider& prov) { QString provName = prov.name(); if (provName.isEmpty()) return QStringLiteral("")); } void label_bufferNoName_showsSelectSource() { // BufferProvider with empty name also triggers ")); } void label_bufferWithName_showsFileAndName() { BufferProvider p(QByteArray(4, '\0'), "dump.bin"); QCOMPARE(buildSourceLabel(p), QStringLiteral("File 'dump.bin'")); } // --------------------------------------------------------------- // Full command row text // --------------------------------------------------------------- void row_nullProvider() { NullProvider p; QString row = buildCommandRow(p, 0); QCOMPARE(row, QStringLiteral(" ")); } void span_fileProvider() { BufferProvider p(QByteArray(4, '\0'), "dump.bin"); QString row = buildCommandRow(p, 0x140000000ULL); auto span = commandRowSrcSpan(row); QVERIFY(span.valid); QString extracted = row.mid(span.start, span.end - span.start); QCOMPARE(extracted, QStringLiteral("File 'dump.bin'")); } void span_processProvider_simulated() { // Simulate a process provider without needing Windows APIs // by building the string directly QString row = QStringLiteral(" Process 'notepad.exe' Address: 0x7FF600000000"); auto span = commandRowSrcSpan(row); QVERIFY(span.valid); QString extracted = row.mid(span.start, span.end - span.start); QCOMPARE(extracted, QStringLiteral("Process 'notepad.exe'")); } // --------------------------------------------------------------- // Provider switching simulation // --------------------------------------------------------------- void switching_nullToFileToProcess() { // Start with NullProvider std::unique_ptr prov = std::make_unique(); QCOMPARE(buildSourceLabel(*prov), QStringLiteral("