void GraphicalIntTest::test_signalEmmitting() { GraphicalInt * value = new GraphicalInt(false); QDoubleSpinBox * spinBox = findSpinBox(value); QSignalSpy spy(value, SIGNAL(valueChanged())); // // 1. through setValue() // value->setValue(125464); value->setValue(-876541); // 2 signals should have been emitted QCOMPARE( spy.count(), 2 ); spy.clear(); // // 2. by simulating keyboard events // spinBox->clear(); value->show(); // make the value visible (it ignores keyboard events if not) QTest::keyClicks(spinBox, "-2014" ); QTest::keyClicks(spinBox, "357" ); QTest::keyClicks(spinBox, "aq45s2" ); // 10 signals should have been emitted (one per character) // (13 chars entered but 'a', 'q' and 's' were ignored) QCOMPARE( spy.count(), 10 ); spy.clear(); // // 3. when committing // value->commit(); // 1 signal should have been emitted QCOMPARE( spy.count(), 1 ); delete value; }