COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
utest-ui-core-nroot.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 von Karman Institute for Fluid Dynamics, Belgium
2 //
3 // This software is distributed under the terms of the
4 // GNU Lesser General Public License version 3 (LGPLv3).
5 // See doc/lgpl.txt and doc/gpl.txt for the license text.
6 
7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for the ui NRoot class"
9 
10 #include "ui/core/NGeneric.hpp"
11 #include "ui/core/NRoot.hpp"
12 
14 
15 using namespace cf3;
16 using namespace cf3::common;
17 using namespace cf3::ui::core;
18 
21 
22 BOOST_AUTO_TEST_SUITE( uiCoreNBrowserSuite )
23 
24 
27 {
28  application();
29 
34 }
35 
37 
38 BOOST_AUTO_TEST_CASE( child_from_root )
39 {
40  boost::shared_ptr< NRoot > root( new NRoot("Root") );
41  boost::shared_ptr< NGeneric > node1(new NGeneric("Node1", "MyFirstType"));
42  boost::shared_ptr< NGeneric > node2(new NGeneric("Node2", "MySecondType"));
43  Handle< CNode > node;
44 
45  // 1. root has no child
46  BOOST_CHECK_THROW( root->child_from_root(0), FailedAssertion );
47  BOOST_CHECK_THROW( root->child_from_root(1), FailedAssertion );
48 
49  root->add_node(node1);
50  root->add_node(node2);
51 
52  // 2. get the first child (node1)
53  BOOST_REQUIRE_NO_THROW( node = root->child_from_root(0) );
54  BOOST_CHECK_EQUAL( node->name(), std::string("Node1") );
55  BOOST_CHECK_EQUAL( node->component_type().toStdString(), std::string("MyFirstType") );
56 
57  // 3. get the second child (node2)
58  BOOST_REQUIRE_NO_THROW( node = root->child_from_root(1) );
59  BOOST_CHECK_EQUAL( node->name(), std::string("Node2") );
60  BOOST_CHECK_EQUAL( node->component_type().toStdString(), std::string("MySecondType") );
61 }
62 
65 
66 BOOST_AUTO_TEST_SUITE_END()
67 
QApplication * application()
Definition: Application.hpp:11
Safe pointer to an object. This is the supported method for referring to components.
Definition: Handle.hpp:39
bool AssertionThrows
assertions throw exceptions
Definition: Assertions.hpp:67
bool ExceptionOutputs
if exception contructor should output
Definition: Exception.hpp:32
static AssertionManager & instance()
Gets the instance of the manager.
Definition: Assertions.cpp:33
Basic Classes for client-core library used by coolfluid-client application.
Definition: CNode.cpp:57
bool AssertionDumps
assertions dump backtraces
Definition: Assertions.hpp:65
bool ExceptionDumps
if exception contructor should dump backtrace
Definition: Exception.hpp:34
QString component_type() const
Definition: CNode.cpp:120
const std::string & name() const
Access the name of the component.
Definition: Component.hpp:146
tuple root
Definition: coolfluid.py:24
Top-level namespace for coolfluid.
Definition: Action.cpp:18
BOOST_AUTO_TEST_CASE(init)
static ExceptionManager & instance()
Gets the instance of the manager.
Definition: Exception.cpp:34
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.
Definition: NRoot.hpp:34
Client generic component.
Definition: NGeneric.hpp:29
Most basic kernel library.
Definition: Action.cpp:19
Send comments to:
COOLFluiD Web Admin