7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the GUI GraphicalInt class with int values"
10 #include <QDoubleSpinBox>
11 #include <QHBoxLayout>
36 QHBoxLayout * layout =
dynamic_cast<QHBoxLayout*
>(value->layout());
37 QDoubleSpinBox * spin_box =
nullptr;
41 spin_box =
dynamic_cast<QDoubleSpinBox*
>(layout->itemAt(0)->widget());
44 std::cerr <<
"Failed to find the spin box." << std::endl;
47 std::cerr <<
"Failed to find the layout or cast it to QHBoxLayout." << std::endl;
54 BOOST_AUTO_TEST_SUITE( uiGraphicsGraphicalBoolSuite )
87 BOOST_CHECK_EQUAL(
int(spin_box->value()), 0 );
95 BOOST_CHECK_EQUAL(
int(spin_box->value()), 1456 );
113 BOOST_CHECK_EQUAL(
int(spin_box->value()), -1456 );
115 BOOST_CHECK( value->
set_value(215468548) );
116 BOOST_CHECK_EQUAL(
int(spin_box->value()), 215468548 );
121 BOOST_CHECK( !value->
set_value(3.141592) );
122 BOOST_CHECK_EQUAL(
int(spin_box->value()), 215468548 );
125 BOOST_CHECK_EQUAL(
int(spin_box->value()), 215468548 );
127 BOOST_CHECK( !value->
set_value(
"789654123") );
128 BOOST_CHECK_EQUAL(
int(spin_box->value()), 215468548 );
142 theValue = value->
value();
143 BOOST_CHECK( theValue.type() == QVariant::Int );
144 BOOST_CHECK_EQUAL( theValue.toInt(), 0 );
147 spin_box->setValue(488654);
148 theValue = value->
value();
149 BOOST_CHECK( theValue.type() == QVariant::Int );
150 BOOST_CHECK_EQUAL( theValue.toInt(), 488654 );
161 QSignalSpy spy(value, SIGNAL(value_changed()));
170 BOOST_CHECK_EQUAL( spy.count(), 2 );
179 QTest::keyClicks(spin_box,
"-2014" );
180 QTest::keyClicks(spin_box,
"357" );
181 QTest::keyClicks(spin_box,
"aq45s2" );
185 BOOST_CHECK_EQUAL( spy.count(), 10 );
194 BOOST_CHECK_EQUAL( spy.count(), 1 );
206 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"78646") );
209 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"165464") );
225 spin_box->setValue(123464);
229 spin_box->setValue(65454354);
235 spin_box->setValue(65454354);
243 BOOST_AUTO_TEST_SUITE_END()
QApplication * application()
bool is_null(T ptr)
predicate for comparison to nullptr
bool AssertionThrows
assertions throw exceptions
bool ExceptionOutputs
if exception contructor should output
static AssertionManager & instance()
Gets the instance of the manager.
Basic Classes for Mathematical applications used by COOLFluiD.
bool AssertionDumps
assertions dump backtraces
bool ExceptionDumps
if exception contructor should dump backtrace
virtual QVariant value() const
Real int_min()
Definition of the minimum number representable with the chosen precision.
virtual bool set_value(const QVariant &value)
QDoubleSpinBox * find_spin_box(const GraphicalInt *value)
Real int_max()
Returns the maximum number representable with the chosen precision.
BOOST_AUTO_TEST_CASE(init)
Top-level namespace for coolfluid.
static ExceptionManager & instance()
Gets the instance of the manager.
Basic Classes for Graphics applications used by CF.
QString value_string() const
Most basic kernel library.
bool is_not_null(T ptr)
predicate for comparison to nullptr