7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the GUI GraphicalRestrictedList class"
11 #include <QHBoxLayout>
37 QHBoxLayout * layout =
dynamic_cast<QHBoxLayout*
>(value->layout());
38 QComboBox * comboBox =
nullptr;
42 comboBox =
dynamic_cast<QComboBox*
>(layout->itemAt(0)->widget());
45 std::cerr <<
"Failed to find the line edit." << std::endl;
48 std::cerr <<
"Failed to find the layout or cast it to QHBoxLayout." << std::endl;
55 BOOST_AUTO_TEST_SUITE( uiGraphicsGraphicalRestrictedListSuite )
84 BOOST_CHECK_EQUAL( combo_box->count(), 0 );
92 BOOST_CHECK_EQUAL( combo_box->count(), 0 );
97 opt->restricted_list().push_back( std::string(
"World") );
98 opt->restricted_list().push_back( std::string(
"Third restricted value") );
103 BOOST_CHECK_EQUAL( combo_box->count(), 2 );
113 opt->restricted_list().push_back( std::string(
"World") );
114 opt->restricted_list().push_back( std::string(
"Hello") );
115 opt->restricted_list().push_back( std::string(
"Third restricted value") );
125 BOOST_CHECK( value->
set_value(
"Hello") );
126 BOOST_CHECK_EQUAL( comboBox->currentText().toStdString(), std::string(
"Hello") );
128 BOOST_CHECK( value->
set_value(
"World") );
129 BOOST_CHECK_EQUAL( comboBox->currentText().toStdString(), std::string(
"World") );
131 BOOST_CHECK( !value->
set_value(
"something") );
132 BOOST_CHECK_EQUAL( comboBox->currentText().toStdString(), std::string(
"World") );
138 BOOST_CHECK_EQUAL( comboBox->currentText().toStdString(), std::string(
"World") );
140 BOOST_CHECK( !value->
set_value(3.141592) );
141 BOOST_CHECK_EQUAL( comboBox->currentText().toStdString(), std::string(
"World") );
144 BOOST_CHECK_EQUAL( comboBox->currentText().toStdString(), std::string(
"World") );
154 opt->restricted_list().push_back( std::string(
"Hello") );
155 opt->restricted_list().push_back( std::string(
"World") );
156 opt->restricted_list().push_back( std::string(
"Third restricted value") );
163 theValue = value->
value();
164 BOOST_CHECK( theValue.type() == QVariant::String );
165 BOOST_CHECK_EQUAL( theValue.toString().toStdString(), std::string(
"Hello") );
169 comboBox->setCurrentIndex(2);
170 theValue = value->
value();
171 BOOST_CHECK( theValue.type() == QVariant::String );
172 BOOST_CHECK_EQUAL( theValue.toString().toStdString(), std::string(
"Third restricted value") );
182 opt->restricted_list().push_back( std::string(
"Hello") );
183 opt->restricted_list().push_back( std::string(
"World") );
184 opt->restricted_list().push_back( std::string(
"Third restricted value") );
188 QSignalSpy spy(value, SIGNAL(value_changed()));
197 BOOST_CHECK_EQUAL( spy.count(), 2 );
205 comboBox->setCurrentIndex(2);
206 comboBox->setCurrentIndex(0);
207 comboBox->setCurrentIndex(1);
210 BOOST_CHECK_EQUAL( spy.count(), 3 );
219 BOOST_CHECK_EQUAL( spy.count(), 1 );
229 opt->restricted_list().push_back( std::string(
"Hello") );
230 opt->restricted_list().push_back( std::string(
"World") );
231 opt->restricted_list().push_back( std::string(
"Third restricted value") );
236 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"Hello") );
239 BOOST_CHECK_EQUAL( value->
value_string().toStdString(), std::string(
"World") );
249 opt->restricted_list().push_back( std::string(
"World") );
250 opt->restricted_list().push_back( std::string(
"Third restricted value") );
259 comboBox->setCurrentIndex(2);
263 comboBox->setCurrentIndex(1);
276 opt->restricted_list().push_back( std::string(
"World") );
277 opt->restricted_list().push_back( std::string(
"Third restricted value") );
283 newList <<
"Here" <<
"is" <<
"a new" <<
"list";
285 comboBox->setCurrentIndex(2);
289 BOOST_CHECK_EQUAL( comboBox->count(), newList.count() );
290 BOOST_CHECK_EQUAL( comboBox->itemText(0).toStdString(), newList.at(0).toStdString() );
291 BOOST_CHECK_EQUAL( comboBox->itemText(1).toStdString(), newList.at(1).toStdString() );
292 BOOST_CHECK_EQUAL( comboBox->itemText(2).toStdString(), newList.at(2).toStdString() );
293 BOOST_CHECK_EQUAL( comboBox->itemText(3).toStdString(), newList.at(3).toStdString() );
295 BOOST_CHECK_EQUAL( comboBox->currentIndex(), 0 );
300 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.
bool AssertionDumps
assertions dump backtraces
QComboBox * find_combo_box(const GraphicalRestrictedList *value)
bool ExceptionDumps
if exception contructor should dump backtrace
Conversions from and to std::string.
void set_restricted_list(const QStringList &list)
Uniform Resource Identifier (see http://en.wikipedia.org/wiki/Uniform_Resource_Identifier) ...
Top-level namespace for coolfluid.
static ExceptionManager & instance()
Gets the instance of the manager.
BOOST_AUTO_TEST_CASE(init)
Basic Classes for Graphics applications used by CF.
virtual QVariant value() const
virtual bool set_value(const QVariant &value)
QString value_string() const
Most basic kernel library.
bool is_not_null(T ptr)
predicate for comparison to nullptr