| 342 | } |
| 343 | |
| 344 | class TestEditor : public QObject { |
| 345 | Q_OBJECT |
| 346 | private: |
| 347 | RcxEditor* m_editor = nullptr; |
| 348 | ComposeResult m_result; |
| 349 | |
| 350 | private slots: |
| 351 | void initTestCase() { |
| 352 | m_editor = new RcxEditor(); |
| 353 | m_editor->resize(800, 600); |
| 354 | m_editor->show(); |
| 355 | QVERIFY(QTest::qWaitForWindowExposed(m_editor)); |
| 356 | |
| 357 | NodeTree tree = makeTestTree(); |
| 358 | BufferProvider prov = makeTestProvider(); |
| 359 | m_result = compose(tree, prov); |
| 360 | m_editor->applyDocument(m_result); |
| 361 | } |
| 362 | |
| 363 | void cleanupTestCase() { |
| 364 | delete m_editor; |
| 365 | } |
| 366 | |
| 367 | // ── Test: CommandRow at line 0 rejects non-ADDR edits ── |
| 368 | void testCommandRowLineRejectsEdits() { |
| 369 | m_editor->applyDocument(m_result); |
| 370 | |
| 371 | // Line 0 should be the CommandRow |
| 372 | const LineMeta* lm = m_editor->metaForLine(0); |
| 373 | QVERIFY(lm); |
| 374 | QCOMPARE(lm->lineKind, LineKind::CommandRow); |
| 375 | QCOMPARE(lm->nodeId, kCommandRowId); |
| 376 | QCOMPARE(lm->nodeIdx, -1); |
| 377 | |
| 378 | // Type/Name/Value should be rejected on CommandRow |
| 379 | QVERIFY(!m_editor->beginInlineEdit(EditTarget::Type, 0)); |
| 380 | QVERIFY(!m_editor->beginInlineEdit(EditTarget::Name, 0)); |
| 381 | QVERIFY(!m_editor->beginInlineEdit(EditTarget::Value, 0)); |
| 382 | QVERIFY(!m_editor->isEditing()); |
| 383 | |
| 384 | // Set CommandRow text with an ADDR value (simulates controller.updateCommandRow) |
| 385 | m_editor->setCommandRowText( |
| 386 | QStringLiteral("source\u25BE \u00B7 0xD87B5E5000")); |
| 387 | |
| 388 | // BaseAddress should be ALLOWED on CommandRow (ADDR field) |
| 389 | bool ok = m_editor->beginInlineEdit(EditTarget::BaseAddress, 0); |
| 390 | QVERIFY2(ok, "BaseAddress edit should be allowed on CommandRow"); |
| 391 | QVERIFY(m_editor->isEditing()); |
| 392 | m_editor->cancelInlineEdit(); |
| 393 | |
| 394 | // Source should be ALLOWED on CommandRow (SRC field) |
| 395 | ok = m_editor->beginInlineEdit(EditTarget::Source, 0); |
| 396 | QVERIFY2(ok, "Source edit should be allowed on CommandRow"); |
| 397 | QVERIFY(m_editor->isEditing()); |
| 398 | m_editor->cancelInlineEdit(); |
| 399 | QApplication::processEvents(); // flush deferred showSourcePicker timer |
| 400 | } |
| 401 |
nothing calls this directly
no outgoing calls
no test coverage detected