15 #define GETTEXT_DOMAIN "wesnoth-test"
17 #include <boost/test/unit_test.hpp>
59 BOOST_CHECK_EQUAL(group2->get_group_id(), 2);
67 BOOST_CHECK_EQUAL(id_counter++, new_target->get_id());
70 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(new_target.get())->handle_drop(), -1);
71 targets.push_back(new_target);
77 BOOST_CHECK(group->get_group_id() > 0);
79 typedef std::vector<SDL_Rect> location_store;
94 std::for_each(locations.begin(), locations.end(),
97 BOOST_CHECK_EQUAL(targets.size(), locations.size());
100 locations[2].y = 190;
103 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[2].
get())->handle_drop(), 3);
104 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[3].
get())->handle_drop(), 2);
105 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[1].
get())->handle_drop(), -1);
106 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[4].
get())->handle_drop(), -1);
118 BOOST_CHECK(group->get_group_id() > 0);
119 BOOST_CHECK(group2->get_group_id() > 0);
121 typedef std::vector<SDL_Rect> location_store;
123 location_store locations2;
146 std::for_each(locations.begin(), locations.end(),
149 std::for_each(locations2.begin(), locations2.end(),
152 BOOST_CHECK_EQUAL(targets.size(), locations.size());
153 BOOST_CHECK_EQUAL(targets2.size(), locations2.size());
156 locations[2].y = 190;
159 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[2].
get())->handle_drop(), 3);
160 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[3].
get())->handle_drop(), 2);
161 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[1].
get())->handle_drop(), -1);
162 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[4].
get())->handle_drop(), -1);
164 locations2[2].y = 180;
165 locations2[2].x = 50;
167 BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets2[2].
get())->handle_drop(), -1);
172 BOOST_AUTO_TEST_SUITE_END()
drop_target_group get_group_id() const
static void create_drop_targets(const SDL_Rect &loc, gui::drop_group_manager_ptr group, target_store &targets, int &id_counter)
BOOST_AUTO_TEST_SUITE(test_map_location)
test_drop_target(gui::drop_group_manager_ptr group, const SDL_Rect &loc)
int handle_drop()
Called by widget object when droping happens.
std::vector< gui::drop_target_ptr > target_store
BOOST_AUTO_TEST_CASE(test_create_group)
GLsizei const GLint * locations
static bool empty()
Used to check if static storages are empty.
Used to create and destroy drop groups.
SDL_Rect create_rect(const int x, const int y, const int w, const int h)
Creates an empty SDL_Rect.
Contains the SDL_Rect helper code.
Specialized testing class so unit test can call protected member functions to simulate drop operation...