7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the ui PropertyModel class"
24 #include <boost/lexical_cast.hpp>
34 BOOST_AUTO_TEST_SUITE( uiCorePropertyModelSuite )
42 TreeThread& tree = ThreadManager::instance().tree();
49 boost::shared_ptr< MyNode > node(
new MyNode(
"MyAdditionalNode"));
59 opts.
add(
"AnUriOption",
URI(
"cpath:/"));
60 props.
add(
"Euler", Real(2.71));
61 opts.
add(
"MyString", std::string(
"Hello, World!"));
62 props.
add(
"Pi", Real(3.14159));
63 opts.
add(
"SomeBool",
true);
64 opts.
add(
"SomeInt",
int(-2168454));
65 props.
add(
"TheAnswer",
Uint(42));
67 BOOST_CHECK_EQUAL( props.
store.size(), size_t(3));
68 BOOST_CHECK_EQUAL( opts.
store.size(), size_t(4));
71 tree.
root()->add_node( node );
74 NTree::global()->set_current_index( NTree::global()->index_from_path( node->uri() ) );
82 int role = Qt::DisplayRole;
85 BOOST_CHECK( !model.
data(QModelIndex(), Qt::DisplayRole).isValid() );
88 BOOST_CHECK( !model.
data( model.
index(0, 0), Qt::DecorationRole).isValid() );
91 BOOST_CHECK_EQUAL( model.
data( model.
index(0, 0), role ).toString().toStdString(), std::string(
"AnUriOption") );
92 BOOST_CHECK_EQUAL( model.
data( model.
index(0, 1), role ).toString().toStdString(), std::string(
"cpath:/") );
94 BOOST_CHECK_EQUAL( model.
data( model.
index(1, 0), role ).toString().toStdString(), std::string(
"Euler") );
95 BOOST_CHECK_CLOSE( boost::lexical_cast<Real>(model.
data( model.
index(1, 1), role ).toString().toStdString()), 2.71, 1
e-10 );
97 BOOST_CHECK_EQUAL( model.
data( model.
index(2, 0), role ).toString().toStdString(), std::string(
"MyString") );
98 BOOST_CHECK_EQUAL( model.
data( model.
index(2, 1), role ).toString().toStdString(), std::string(
"Hello, World!") );
100 BOOST_CHECK_EQUAL( model.
data( model.
index(3, 0), role ).toString().toStdString(), std::string(
"Pi") );
101 BOOST_CHECK_CLOSE( boost::lexical_cast<Real>(model.
data( model.
index(3, 1), role ).toString().toStdString()), 3.14159, 1
e-10 );
103 BOOST_CHECK_EQUAL( model.
data( model.
index(4, 0), role ).toString().toStdString(), std::string(
"SomeBool") );
104 BOOST_CHECK_EQUAL( model.
data( model.
index(4, 1), role ).toString().toStdString(), std::string(
"true") );
106 BOOST_CHECK_EQUAL( model.
data( model.
index(5, 0), role ).toString().toStdString(), std::string(
"SomeInt") );
107 BOOST_CHECK_EQUAL( model.
data( model.
index(5, 1), role ).toString().toStdString(), std::string(
"-2168454") );
109 BOOST_CHECK_EQUAL( model.
data( model.
index(6, 0), role ).toString().toStdString(), std::string(
"TheAnswer") );
110 BOOST_CHECK_EQUAL( model.
data( model.
index(6, 1), role ).toString().toStdString(), std::string(
"42") );
123 BOOST_CHECK( model.
index(0, 0).isValid() );
124 BOOST_CHECK( model.
index(0, 1).isValid() );
126 BOOST_CHECK( model.
index(1, 0).isValid() );
127 BOOST_CHECK( model.
index(1, 1).isValid() );
129 BOOST_CHECK( model.
index(2, 0).isValid() );
130 BOOST_CHECK( model.
index(2, 1).isValid() );
132 BOOST_CHECK( model.
index(3, 0).isValid() );
133 BOOST_CHECK( model.
index(3, 1).isValid() );
135 BOOST_CHECK( model.
index(4, 0).isValid() );
136 BOOST_CHECK( model.
index(4, 1).isValid() );
138 BOOST_CHECK( model.
index(5, 0).isValid() );
139 BOOST_CHECK( model.
index(5, 1).isValid() );
141 BOOST_CHECK( model.
index(6, 0).isValid() );
142 BOOST_CHECK( model.
index(6, 1).isValid() );
145 BOOST_CHECK( !model.
index(7, 0).isValid() );
146 BOOST_CHECK( !model.
index(0, 2).isValid() );
149 BOOST_CHECK( !model.
index(0, 0, model.
index(0, 0) ).isValid() );
159 BOOST_CHECK_EQUAL( model.
rowCount( QModelIndex() ), 7);
171 BOOST_CHECK_EQUAL(model.
headerData(0, Qt::Horizontal).toString().toStdString(), std::string(
"Name"));
172 BOOST_CHECK_EQUAL(model.
headerData(1, Qt::Horizontal).toString().toStdString(), std::string(
"Value"));
174 BOOST_CHECK(!model.
headerData(0, Qt::Vertical).isValid());
175 BOOST_CHECK(!model.
headerData(0, Qt::Horizontal, Qt::DecorationRole).isValid());
181 BOOST_AUTO_TEST_SUITE_END()
QApplication * application()
bool AssertionThrows
assertions throw exceptions
bool ExceptionOutputs
if exception contructor should output
static AssertionManager & instance()
Gets the instance of the manager.
Basic Classes for client-core library used by coolfluid-client application.
bool AssertionDumps
assertions dump backtraces
bool ExceptionDumps
if exception contructor should dump backtrace
PropertyList & add(const std::string &name, const boost::any &value)
adds a property to the list
virtual int rowCount(const QModelIndex &parent=QModelIndex()) const
Implementation of QAbstractItemModel::rowCount().
Real e()
Definition of the Unit charge [C].
OptionStorage_t store
storage of options
Manages the client root node.
BOOST_AUTO_TEST_CASE(init)
tuple model
Global confifuration.
virtual QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Gives header titles.
Top-level namespace for coolfluid.
virtual QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Implementation of QAbstractItemModel::index().
static ExceptionManager & instance()
Gets the instance of the manager.
virtual QVariant data(const QModelIndex &index, int role) const
Destructor.
Handle< NRoot > root() const
unsigned int Uint
typedef for unsigned int
SelectOptionType< T >::type & add(const std::string &name, const T &default_value=T())
Most basic kernel library.
PropertyStorage_t store
storage of options
Model that maintains properties for the node pointed by the index returned by NTree::global()->curren...