Пример #1
0
void GraphicalBoolTest::initTestCase()
{
  GraphicalBool * value = new GraphicalBool();

  QVERIFY( is_not_null(  findCheckBox(value) ) );

  delete value;
}
Пример #2
0
void StylePainterMobile::drawCheckBox(const QRect& rect, bool checked, bool enabled)
{
    const QRect square = shrinkRectToSquare(rect);
    QPixmap checkBox = findCheckBox(sizeForPainterScale(square), checked, enabled);
    if (checkBox.isNull())
        return;
    painter->drawPixmap(square, checkBox);
}
Пример #3
0
void GraphicalBoolTest::test_setValue()
{
  GraphicalBool * value = new GraphicalBool(false);
  QCheckBox * checkbox = findCheckBox(value);

  QVERIFY( is_not_null(checkbox) );

  //
  // 1. check with bool values
  //
  QVERIFY( value->setValue(true) );
  QVERIFY( checkbox->isChecked() );
  QVERIFY( value->originalValue().toBool() );

  QVERIFY( value->setValue(false) );
  QVERIFY( !checkbox->isChecked() );
  QVERIFY( !value->originalValue().toBool() );

  //
  // 2. check with strings (those supported by CF::Common::from_str<bool>())
  //
  QVERIFY( value->setValue("true") );
  QVERIFY( checkbox->isChecked() );

  QVERIFY( value->setValue("false") );
  QVERIFY( !checkbox->isChecked() );

  QVERIFY( value->setValue("on") );
  QVERIFY( checkbox->isChecked() );

  QVERIFY( value->setValue("off") );
  QVERIFY( !checkbox->isChecked() );

  QVERIFY( value->setValue("1") );
  QVERIFY( checkbox->isChecked() );

  QVERIFY( value->setValue("0") );
  QVERIFY( !checkbox->isChecked() );

  GUI_CHECK_THROW( value->setValue("ThisIsNotABoolValue"), ParsingFailed );
  QVERIFY( !checkbox->isChecked() ); // state should not have changed

  //
  // 3. check with other types
  //
  QVERIFY( !value->setValue(12) );
  QVERIFY( !checkbox->isChecked() );

  QVERIFY( !value->setValue(3.141592) );
  QVERIFY( !checkbox->isChecked() );

  QVERIFY( !value->setValue(-456) );
  QVERIFY( !checkbox->isChecked() );

  delete value;
}
Пример #4
0
void GraphicalBoolTest::test_constructor()
{
  GraphicalBool * value = new GraphicalBool(false);
  QCheckBox * checkbox = findCheckBox(value);

  // 1. value is false, the checkbox should be unchecked
  QVERIFY( is_not_null(checkbox) );
  QVERIFY( !checkbox->isChecked() );

  delete value;
  value = new GraphicalBool(true);
  checkbox = findCheckBox(value);

  // 2. value is true, the checkbox should be checked
  QVERIFY( is_not_null(checkbox) );
  QVERIFY( checkbox->isChecked() );

  delete value;
}
Пример #5
0
void GraphicalBoolTest::test_value()
{
  GraphicalBool * value = new GraphicalBool(false);
  QCheckBox * checkbox = findCheckBox(value);
  QVariant isChecked;

  // get value when the check box is checked
  checkbox->setChecked(true);
  isChecked = value->value();
  QVERIFY( isChecked.type() == QVariant::Bool );
  QVERIFY( isChecked.toBool() );

  // get value when the check box is not checked
  checkbox->setChecked(false);
  isChecked = value->value();
  QVERIFY( isChecked.type() == QVariant::Bool );
  QVERIFY( !isChecked.toBool() );

  delete value;
}
Пример #6
0
void GraphicalBoolTest::test_signalEmmitting()
{
  GraphicalBool * value = new GraphicalBool(false);
  QCheckBox * checkbox = findCheckBox(value);
  QSignalSpy spy(value, SIGNAL(valueChanged()));

  //
  // 1. check/uncheck through setValue()
  //
  value->setValue(true);
  value->setValue(false);

  // 2 signal should have been emitted
  QCOMPARE( spy.count(), 2 );

  spy.clear();

  //
  // 2. check/uncheck by simulating a mouse click
  //
  value->show(); // make the value visible (it ignores mouse events if not)
  QTest::mouseClick(checkbox, Qt::LeftButton);
  QTest::mouseClick(checkbox, Qt::LeftButton);

  // 2 signal should have been emitted as well
  QCOMPARE( spy.count(), 2 );

  spy.clear();
  //
  // 3. when committing
  //
  value->commit();

  // 1 signal should have been emitted
  QCOMPARE( spy.count(), 1 );

  delete value;
}
Пример #7
0
void GraphicalBoolTest::test_isModified()
{
  GraphicalBool * value = new GraphicalBool(false);
  QCheckBox * checkbox = findCheckBox(value);

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

  // 2. change the value
  checkbox->setChecked(true);
  QVERIFY( value->isModified() );

  // 3. set the same value again
  value->setValue(true);
  QVERIFY( !value->isModified() );

  // 4. change the value and commit
  checkbox->setChecked(false);
  QVERIFY( value->isModified() );
  value->commit();
  QVERIFY( !value->isModified() );

  delete value;
}