1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
/************************************************************************
*
* Copyright (C) 2022-2023 IRCAD France
*
* This file is part of Sight.
*
* Sight is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Sight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Sight. If not, see <https://www.gnu.org/licenses/>.
*
***********************************************************************/
#include "select_object_test.hpp"
#include <core/com/slot_base.hxx>
#include <data/string.hpp>
#include <service/op.hpp>
CPPUNIT_TEST_SUITE_REGISTRATION(sight::module::data::ut::select_object_test);
namespace sight::module::data::ut
{
//------------------------------------------------------------------------------
void select_object_test::setUp()
{
m_select_object = service::add("sight::module::data::select_object");
}
//------------------------------------------------------------------------------
void select_object_test::tearDown()
{
CPPUNIT_ASSERT_NO_THROW(m_select_object->stop().get());
service::remove(m_select_object);
}
//------------------------------------------------------------------------------
void select_object_test::basic_test()
{
auto object1 = std::make_shared<sight::data::string>("Hello");
auto object2 = std::make_shared<sight::data::string>("world");
CPPUNIT_ASSERT_NO_THROW(m_select_object->start().get());
m_select_object->slot("add")->run(std::dynamic_pointer_cast<sight::data::object>(object1));
CPPUNIT_ASSERT(m_select_object->output<sight::data::string>("object").lock() == object1);
m_select_object->slot("remove")->run();
CPPUNIT_ASSERT(m_select_object->output<sight::data::string>("object").lock() == nullptr);
m_select_object->slot("add")->run(std::dynamic_pointer_cast<sight::data::object>(object2));
CPPUNIT_ASSERT(m_select_object->output<sight::data::string>("object").lock() == object2);
}
} // namespace sight::module::data::ut
|