Exemplo n.º 1
0
void GraphicalIntTest::test_valueString()
{
  GraphicalInt * value = new GraphicalInt(false);

  value->setValue(78646);
  QCOMPARE( value->valueString(), QString("78646") );

  value->setValue(165464);
  QCOMPARE( value->valueString(), QString("165464") );

  delete value;
}
Exemplo n.º 2
0
void GraphicalUintTest::test_value()
{
  GraphicalInt * value = new GraphicalInt(true);
  QDoubleSpinBox * spinBox = findSpinBox(value);
  QVariant theValue;

  theValue = value->value();
  QVERIFY( theValue.type() == QVariant::UInt );
  QCOMPARE( theValue.toInt(), 0 );

  spinBox->setValue(412654);
  theValue = value->value();
  QVERIFY( theValue.type() == QVariant::UInt );
  QCOMPARE( theValue.toInt(), 412654 );

  delete value;
}
Exemplo n.º 3
0
void GraphicalUintTest::test_setValue()
{
  GraphicalInt * value = new GraphicalInt(true);
  QDoubleSpinBox * spinBox = findSpinBox(value);

  QVERIFY( is_not_null(spinBox) );

  //
  // 1. check with Uints
  //
  QVERIFY( value->setValue(Uint(1456)) );
  QCOMPARE( Uint(spinBox->value()), Uint(1456) );

  QVERIFY( value->setValue(Uint(215468)) );
  QCOMPARE( Uint(spinBox->value()), Uint(215468) );

  //
  // 2. check with other types
  //
  QVERIFY( !value->setValue(-3592) );
  QCOMPARE( Uint(spinBox->value()), Uint(215468) );

  QVERIFY( !value->setValue(3.141592) );
  QCOMPARE( Uint(spinBox->value()), Uint(215468) );

  QVERIFY( !value->setValue(true) );
  QCOMPARE( Uint(spinBox->value()), Uint(215468) );

  QVERIFY( !value->setValue("789654123") );
  QCOMPARE( Uint(spinBox->value()), Uint(215468) );

  delete value;
}
Exemplo n.º 4
0
void GraphicalIntTest::test_value()
{
  GraphicalInt * value = new GraphicalInt(false);
  QDoubleSpinBox * spinBox = findSpinBox(value);
  QVariant theValue;

  // get value when the line edit is empty
  theValue = value->value();
  QVERIFY( theValue.type() == QVariant::Int );
  QCOMPARE( theValue.toInt(), 0 );

  // get value when the line edit has a string
  spinBox->setValue(488654);
  theValue = value->value();
  QVERIFY( theValue.type() == QVariant::Int );
  QCOMPARE( theValue.toInt(), 488654 );

  delete value;
}
Exemplo n.º 5
0
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;
}
Exemplo n.º 6
0
void GraphicalIntTest::test_isModified()
{
  GraphicalInt * value = new GraphicalInt(false);
  QDoubleSpinBox* spinBox = findSpinBox(value);

  // 1. initially, it's not modified
  QVERIFY( !value->isModified() );

  // 2. change the value
  spinBox->setValue(123464);
  QVERIFY( value->isModified() );

  // 3. change the value and commit
  spinBox->setValue(65454354);
  QVERIFY( value->isModified() );
  value->commit();
  QVERIFY( !value->isModified() );

  // 4. put the same value
  spinBox->setValue(65454354);
  QVERIFY( !value->isModified() );

  delete value;
}