7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the GUI GraphicalString class"
12 #include <QHBoxLayout>
37 QHBoxLayout * layout =
dynamic_cast<QHBoxLayout*
>(value->layout());
38 QWidget * widget =
nullptr;
41 widget = layout->itemAt(index)->widget();
43 std::cerr <<
"Failed to find the layout or cast it to QHBoxLayout." << std::endl;
56 QLineEdit * lineEdit =
dynamic_cast<QLineEdit*
>(
find_widget(value, 1));
59 std::cerr <<
"Failed to find the line edit." << std::endl;
72 QComboBox * comboBox =
dynamic_cast<QComboBox*
>(
find_widget(value, 0));
75 std::cerr <<
"Failed to find the combo box." << std::endl;
82 BOOST_AUTO_TEST_SUITE( uiGraphicsGraphicalBoolSuite )
111 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string() );
114 boost::shared_ptr<OptionURI> option(
new OptionURI(
"Option",
URI(
"cpath:/")));
120 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:/") );
129 boost::shared_ptr<OptionURI> option(
new OptionURI(
"Option",
URI(
"cpath:/")));
132 std::vector<URI::Scheme::Type> schemes;
137 BOOST_CHECK_EQUAL( comboBox->count(), 3);
138 BOOST_CHECK_EQUAL( comboBox->itemText(0).toStdString(), std::string(
"cpath") );
139 BOOST_CHECK_EQUAL( comboBox->itemText(1).toStdString(), std::string(
"file") );
140 BOOST_CHECK_EQUAL( comboBox->itemText(2).toStdString(), std::string(
"http") );
147 BOOST_CHECK_EQUAL( comboBox->count(), 2);
148 BOOST_CHECK_EQUAL( comboBox->itemText(0).toStdString(), std::string(
"cpath") );
149 BOOST_CHECK_EQUAL( comboBox->itemText(1).toStdString(), std::string(
"file") );
158 BOOST_CHECK_EQUAL( comboBox->count(), 2);
159 BOOST_CHECK_EQUAL( comboBox->itemText(0).toStdString(), std::string(
"cpath") );
160 BOOST_CHECK_EQUAL( comboBox->itemText(1).toStdString(), std::string(
"file") );
166 BOOST_CHECK_EQUAL( comboBox->count(), 3);
167 BOOST_CHECK_EQUAL( comboBox->itemText(0).toStdString(), std::string(
"cpath") );
168 BOOST_CHECK_EQUAL( comboBox->itemText(1).toStdString(), std::string(
"file") );
169 BOOST_CHECK_EQUAL( comboBox->itemText(2).toStdString(), std::string(
"http") );
178 boost::shared_ptr<OptionURI> option(
new OptionURI(
"Option",
URI(
"cpath:/")));
187 BOOST_CHECK( value->
set_value(
"cpath:/Component") );
188 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:/Component") );
190 BOOST_CHECK( value->
set_value(
"coolfluidsrv.vki.ac.be") );
191 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:coolfluidsrv.vki.ac.be") );
197 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:coolfluidsrv.vki.ac.be") );
200 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:coolfluidsrv.vki.ac.be") );
202 BOOST_CHECK( !value->
set_value(3.141592) );
203 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:coolfluidsrv.vki.ac.be") );
206 BOOST_CHECK_EQUAL( lineEdit->text().toStdString(), std::string(
"cpath:coolfluidsrv.vki.ac.be") );
215 boost::shared_ptr<OptionURI> option(
new OptionURI(
"Option",
URI(
"cpath:/")));
224 comboBox->setCurrentIndex( comboBox->findText(
"file") );
227 theValue = value->
value();
228 BOOST_CHECK( theValue.type() == QVariant::String );
229 BOOST_CHECK_EQUAL( theValue.toString().toStdString(), std::string(
"cpath:/") );
232 lineEdit->setText(
"/etc/fstab");
233 theValue = value->
value();
234 BOOST_CHECK( theValue.type() == QVariant::String );
235 BOOST_CHECK_EQUAL( theValue.toString().toStdString(), std::string(
"file:/etc/fstab") );
238 comboBox->setCurrentIndex( comboBox->findText(
"http") );
240 lineEdit->setText(
"coolfluidsrv.vki.ac.be");
241 theValue = value->
value();
242 BOOST_CHECK( theValue.type() == QVariant::String );
243 BOOST_CHECK_EQUAL( theValue.toString().toStdString(), std::string(
"http:coolfluidsrv.vki.ac.be") );
246 lineEdit->setText(
"");
247 theValue = value->
value();
248 BOOST_CHECK( theValue.type() == QVariant::String );
249 BOOST_CHECK_EQUAL( theValue.toString().toStdString(), std::string() );
260 QSignalSpy spy(value, SIGNAL(value_changed()));
270 BOOST_CHECK_EQUAL( spy.count(), 2 );
279 QTest::keyClicks(lineEdit,
"cpath:" );
280 QTest::keyClicks(lineEdit,
"//Path" );
281 QTest::keyClicks(lineEdit,
"/To/A/Component" );
284 BOOST_CHECK_EQUAL( spy.count(), 28 );
293 BOOST_CHECK_EQUAL( spy.count(), 1 );
305 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"cpath:/") );
307 value->
set_value(
"http://coolfluidsrv.vki.ac.be");
308 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"http://coolfluidsrv.vki.ac.be") );
324 lineEdit->setText(
"cpath:/");
328 lineEdit->setText(
"cpath:/Component");
334 lineEdit->setText(
"cpath:/Component");
342 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
BOOST_AUTO_TEST_CASE(init)
QWidget * find_widget(const GraphicalUri *value, int index)
Top-level namespace for coolfluid.
static ExceptionManager & instance()
Gets the instance of the manager.
virtual bool set_value(const QVariant &path)
Basic Classes for Graphics applications used by CF.
QComboBox * find_combo_box(const GraphicalUri *value)
void set_schemes(const std::vector< common::URI::Scheme::Type > &list)
QString value_string() const
virtual QVariant value() const
Most basic kernel library.
bool is_not_null(T ptr)
predicate for comparison to nullptr
QLineEdit * find_line_edit(const GraphicalUri *value)