── Test: value edit commit fires signal with typed text ──
| 817 | |
| 818 | // ── Test: value edit commit fires signal with typed text ── |
| 819 | void testValueEditCommitUpdatesSignal() { |
| 820 | m_editor->applyDocument(m_result); |
| 821 | |
| 822 | // kFirstDataLine = first UInt8 field (InheritedAddressSpace, root header suppressed) |
| 823 | const LineMeta* lm = m_editor->metaForLine(kFirstDataLine); |
| 824 | QVERIFY(lm); |
| 825 | QCOMPARE(lm->lineKind, LineKind::Field); |
| 826 | QVERIFY(lm->nodeKind != NodeKind::Padding); |
| 827 | |
| 828 | // Begin value edit |
| 829 | bool ok = m_editor->beginInlineEdit(EditTarget::Value, kFirstDataLine); |
| 830 | QVERIFY(ok); |
| 831 | QVERIFY(m_editor->isEditing()); |
| 832 | |
| 833 | // Select all text in the edit span and type replacement |
| 834 | QKeyEvent home(QEvent::KeyPress, Qt::Key_Home, Qt::NoModifier); |
| 835 | QApplication::sendEvent(m_editor->scintilla(), &home); |
| 836 | QKeyEvent end(QEvent::KeyPress, Qt::Key_End, Qt::ShiftModifier); |
| 837 | QApplication::sendEvent(m_editor->scintilla(), &end); |
| 838 | |
| 839 | // Type "42" to replace selected text |
| 840 | for (QChar c : QString("42")) { |
| 841 | QKeyEvent key(QEvent::KeyPress, 0, Qt::NoModifier, QString(c)); |
| 842 | QApplication::sendEvent(m_editor->scintilla(), &key); |
| 843 | } |
| 844 | QApplication::processEvents(); |
| 845 | |
| 846 | // Commit with Enter |
| 847 | QSignalSpy spy(m_editor, &RcxEditor::inlineEditCommitted); |
| 848 | QKeyEvent enter(QEvent::KeyPress, Qt::Key_Return, Qt::NoModifier); |
| 849 | QApplication::sendEvent(m_editor->scintilla(), &enter); |
| 850 | |
| 851 | QCOMPARE(spy.count(), 1); |
| 852 | QVERIFY(!m_editor->isEditing()); |
| 853 | |
| 854 | // Verify the committed text contains what was typed. |
| 855 | // UInt8 values display as hex (e.g., "0x042"), so the typed "42" gets |
| 856 | // concatenated with the existing "0x0" prefix → "0x042". |
| 857 | // The important check: the signal fired with non-empty text. |
| 858 | QList<QVariant> args = spy.first(); |
| 859 | QString committedText = args.at(3).toString().trimmed(); |
| 860 | QVERIFY2(!committedText.isEmpty(), |
| 861 | "Committed text should not be empty"); |
| 862 | |
| 863 | m_editor->applyDocument(m_result); |
| 864 | } |
| 865 | |
| 866 | // ── Test: base address edit begins on CommandRow (line 0) ── |
| 867 | void testBaseAddressEditBegins() { |
nothing calls this directly
no test coverage detected