8 #define BOOST_TEST_DYN_LINK
9 #define BOOST_TEST_MODULE "Test module for the ui TreeNode class"
24 BOOST_AUTO_TEST_SUITE( uiCoreNBrowserSuite )
46 boost::shared_ptr< NGeneric > node(
new NGeneric(
"MyNode",
"MyType"));
50 BOOST_CHECK_NO_THROW(
TreeNode(node->handle<
CNode>(),
nullptr, 0) );
57 boost::shared_ptr< NGeneric > node(
new NGeneric(
"MyNode",
"MyType"));
91 boost::shared_ptr< NRoot > node(
new NRoot(
"Root"));
92 boost::shared_ptr< NGeneric > node1(
new NGeneric(
"Node1",
"MyType"));
93 boost::shared_ptr< NGeneric > node11(
new NGeneric(
"Node11",
"MyType"));
94 boost::shared_ptr< NGeneric > node12(
new NGeneric(
"Node12",
"MyType"));
95 boost::shared_ptr< NGeneric > node2(
new NGeneric(
"Node2",
"MyType"));
96 boost::shared_ptr< NGeneric > node21(
new NGeneric(
"Node21",
"MyType"));
97 boost::shared_ptr< NGeneric > node22(
new NGeneric(
"Node22",
"MyType"));
98 boost::shared_ptr< NGeneric > node23(
new NGeneric(
"Node23",
"MyType"));
99 boost::shared_ptr< NGeneric > node3(
new NGeneric(
"Node3",
"MyType"));
111 node->add_node(node1);
112 node->add_node(node2);
113 node->add_node(node3);
115 node1->add_node(node11);
116 node1->add_node(node12);
118 node2->add_node(node21);
119 node2->add_node(node22);
120 node2->add_node(node23);
127 treeNode1 = treeNode->
child(0);
128 treeNode2 = treeNode->
child(1);
129 treeNode3 = treeNode->
child(2);
132 BOOST_CHECK( treeNode1 != (
TreeNode*)
nullptr );
133 BOOST_CHECK( treeNode2 != (
TreeNode*)
nullptr );
134 BOOST_CHECK( treeNode3 != (
TreeNode*)
nullptr );
137 BOOST_CHECK_EQUAL( treeNode1->
parent_node(), treeNode );
138 BOOST_CHECK_EQUAL( treeNode2->
parent_node(), treeNode );
139 BOOST_CHECK_EQUAL( treeNode3->
parent_node(), treeNode );
142 BOOST_CHECK_EQUAL( treeNode1->
node_name().toStdString(), std::string(
"Node1") );
143 BOOST_CHECK_EQUAL( treeNode2->
node_name().toStdString(), std::string(
"Node2") );
144 BOOST_CHECK_EQUAL( treeNode3->
node_name().toStdString(), std::string(
"Node3") );
149 treeNode11 = treeNode1->
child(0);
150 treeNode12 = treeNode1->
child(1);
153 BOOST_CHECK( treeNode11 != (
TreeNode*)
nullptr );
154 BOOST_CHECK( treeNode12 != (
TreeNode*)
nullptr );
157 BOOST_CHECK_EQUAL( treeNode11->parent_node(), treeNode1 );
158 BOOST_CHECK_EQUAL( treeNode12->
parent_node(), treeNode1 );
161 BOOST_CHECK_EQUAL( treeNode11->node_name().toStdString(), std::string(
"Node11") );
162 BOOST_CHECK_EQUAL( treeNode12->
node_name().toStdString(), std::string(
"Node12") );
167 treeNode21 = treeNode2->
child(0);
168 treeNode22 = treeNode2->
child(1);
169 treeNode23 = treeNode2->
child(2);
172 BOOST_CHECK( treeNode21 != (
TreeNode*)
nullptr );
173 BOOST_CHECK( treeNode22 != (
TreeNode*)
nullptr );
174 BOOST_CHECK( treeNode23 != (
TreeNode*)
nullptr );
177 BOOST_CHECK_EQUAL( treeNode21->parent_node(), treeNode2 );
178 BOOST_CHECK_EQUAL( treeNode22->
parent_node(), treeNode2 );
179 BOOST_CHECK_EQUAL( treeNode23->
parent_node(), treeNode2 );
182 BOOST_CHECK_EQUAL( treeNode21->node_name().toStdString(), std::string(
"Node21") );
183 BOOST_CHECK_EQUAL( treeNode22->
node_name().toStdString(), std::string(
"Node22") );
184 BOOST_CHECK_EQUAL( treeNode23->
node_name().toStdString(), std::string(
"Node23") );
189 BOOST_CHECK_EQUAL( treeNode3->
child(0), (
TreeNode*)
nullptr );
200 boost::shared_ptr< NRoot > node(
new NRoot(
"Root"));
201 boost::shared_ptr< NGeneric > node1(
new NGeneric(
"Node1",
"MyType"));
202 boost::shared_ptr< NGeneric > node11(
new NGeneric(
"Node11",
"MyType"));
203 boost::shared_ptr< NGeneric > node12(
new NGeneric(
"Node12",
"MyType"));
204 boost::shared_ptr< NGeneric > node2(
new NGeneric(
"Node2",
"MyType"));
205 boost::shared_ptr< NGeneric > node21(
new NGeneric(
"Node21",
"MyType"));
206 boost::shared_ptr< NGeneric > node22(
new NGeneric(
"Node22",
"MyType"));
207 boost::shared_ptr< NGeneric > node23(
new NGeneric(
"Node23",
"MyType"));
208 boost::shared_ptr< NGeneric > node3(
new NGeneric(
"Node3",
"MyType"));
220 node->add_node(node1);
221 node->add_node(node2);
222 node->add_node(node3);
224 node1->add_node(node11);
225 node1->add_node(node12);
227 node2->add_node(node21);
228 node2->add_node(node22);
229 node2->add_node(node23);
232 treeNode1 = treeNode->
child(0);
233 treeNode11 = treeNode1->
child(0);
234 treeNode12 = treeNode1->
child(1);
235 treeNode2 = treeNode->
child(1);
236 treeNode21 = treeNode2->
child(0);
237 treeNode22 = treeNode2->
child(1);
238 treeNode23 = treeNode2->
child(2);
239 treeNode3 = treeNode->
child(2);
249 BOOST_CHECK( treeNode1 != (
TreeNode*)
nullptr );
250 BOOST_CHECK( treeNode2 != (
TreeNode*)
nullptr );
251 BOOST_CHECK( treeNode3 != (
TreeNode*)
nullptr );
254 BOOST_CHECK_EQUAL( treeNode1->
parent_node(), treeNode );
255 BOOST_CHECK_EQUAL( treeNode2->
parent_node(), treeNode );
256 BOOST_CHECK_EQUAL( treeNode3->
parent_node(), treeNode );
259 BOOST_CHECK_EQUAL( treeNode1->
row_number(), 0 );
260 BOOST_CHECK_EQUAL( treeNode2->
row_number(), 1 );
261 BOOST_CHECK_EQUAL( treeNode3->
row_number(), 2 );
270 BOOST_CHECK( treeNode11 != (
TreeNode*)
nullptr );
271 BOOST_CHECK( treeNode12 != (
TreeNode*)
nullptr );
274 BOOST_CHECK_EQUAL( treeNode11->parent_node(), treeNode1 );
275 BOOST_CHECK_EQUAL( treeNode12->
parent_node(), treeNode1 );
278 BOOST_CHECK_EQUAL( treeNode11->row_number(), 0 );
279 BOOST_CHECK_EQUAL( treeNode12->
row_number(), 1 );
294 boost::shared_ptr< NRoot > node(
new NRoot(
"Root"));
295 boost::shared_ptr< NGeneric > node1(
new NGeneric(
"Node1",
"MyType"));
296 boost::shared_ptr< NGeneric > node2(
new NGeneric(
"Node2",
"MyType"));
300 node->add_node(node1);
306 node->add_node(node2);
310 child = treeNode->
child(1);
311 BOOST_CHECK( child !=
nullptr );
313 BOOST_CHECK_EQUAL( child->node_name().toStdString(), std::string(
"Node2"));
321 BOOST_AUTO_TEST_SUITE_END()
QApplication * application()
Safe pointer to an object. This is the supported method for referring to components.
bool AssertionThrows
assertions throw exceptions
bool ExceptionOutputs
if exception contructor should output
bool has_parent() const
Checks whether the node has a parent or not.
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
Handles a CNode component in the tree.
int child_count() const
Gives the child count.
int row_number() const
Gives the row number.
TreeNode * child_by_name(const QString &name)
Retrieves a child from its name.
Base component adapted to fit the client needs.
TreeNode * parent_node() const
Gives the parent.
Top-level namespace for coolfluid.
static ExceptionManager & instance()
Gets the instance of the manager.
TreeNode * child(int row_number)
Returns the ith child of this node.
Client root. This class is wrapper for cf3::common::Root class on the client side. A NRoot object may never have any child. Add them to the internal Root componenent instead. It can be obtained by calling root() method.
Client generic component.
BOOST_AUTO_TEST_CASE(init)
QString node_name() const
Gives the node name.
Most basic kernel library.