Author: suokko
Date: Sun Aug 3 22:13:25 2008
New Revision: 28313
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28313&view=rev
Log:
* Improved unit test log level selection
* Added comments to drag&drop code
Modified:
trunk/src/multiplayer_connect.cpp
trunk/src/tests/gui/test_drop_target.cpp
trunk/src/tests/gui/test_save_dialog.cpp
trunk/src/tests/main.cpp
trunk/src/tests/test_network_worker.cpp
trunk/src/tests/test_team.cpp
trunk/src/tests/test_util.cpp
trunk/src/widgets/combo_drag.cpp
trunk/src/widgets/combo_drag.hpp
trunk/src/widgets/drop_target.hpp
Modified: trunk/src/multiplayer_connect.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/multiplayer_connect.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/multiplayer_connect.cpp (original)
+++ trunk/src/multiplayer_connect.cpp Sun Aug 3 22:13:25 2008
@@ -379,7 +379,7 @@
void connect::side::process_event()
{
int drop_target;
- if ( ( drop_target = combo_controller_->get_drag_target() )> -1)
+ if ( ( drop_target = combo_controller_->get_drop_target() )> -1)
{
const std::string target_id =
parent_->sides_[drop_target].get_id();
const mp::controller target_controller =
parent_->sides_[drop_target].get_controller();
Modified: trunk/src/tests/gui/test_drop_target.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_drop_target.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/tests/gui/test_drop_target.cpp (original)
+++ trunk/src/tests/gui/test_drop_target.cpp Sun Aug 3 22:13:25 2008
@@ -25,7 +25,6 @@
BOOST_AUTO_TEST_CASE( test_create_group )
{
- BOOST_MESSAGE( "Starting drop target test!" );
gui::drop_group_manager group0;
gui::drop_group_manager* group1 = new gui::drop_group_manager();
Modified: trunk/src/tests/gui/test_save_dialog.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/gui/test_save_dialog.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/tests/gui/test_save_dialog.cpp (original)
+++ trunk/src/tests/gui/test_save_dialog.cpp Sun Aug 3 22:13:25 2008
@@ -37,19 +37,10 @@
struct save_dialog_fixture {
save_dialog_fixture()
{
- if (!started_)
- {
- BOOST_MESSAGE("Starting save dialog test!");
- started_ = true;
- }
}
test_utils::fake_event_source source;
-
- private:
- static bool started_;
};
- bool save_dialog_fixture::started_ = false;
BOOST_FIXTURE_TEST_SUITE( save_dialog , save_dialog_fixture)
Modified: trunk/src/tests/main.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/main.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/tests/main.cpp (original)
+++ trunk/src/tests/main.cpp Sun Aug 3 22:13:25 2008
@@ -45,14 +45,15 @@
struct wesnoth_global_fixture {
wesnoth_global_fixture()
{
+
+ // Initialize unit tests
SDL_Init(SDL_INIT_TIMER);
test_utils::get_fake_display();
// lg::set_log_domain_severity("all",3);
- if (boost::unit_test::runtime_config::log_level() <
boost::unit_test::log_messages)
+ if (boost::unit_test::runtime_config::log_level() ==
boost::unit_test::invalid_log_level)
boost::unit_test::unit_test_log.set_threshold_level(
boost::unit_test::log_messages );
- BOOST_MESSAGE("Initializing test!");
boost::unit_test::unit_test_monitor.register_exception_translator<game::error>(&exception_translator_game);
boost::unit_test::unit_test_monitor.register_exception_translator<network::error>(&exception_translator_network);
boost::unit_test::unit_test_monitor.register_exception_translator<config::error>(&exception_translator_config);
Modified: trunk/src/tests/test_network_worker.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_network_worker.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/tests/test_network_worker.cpp (original)
+++ trunk/src/tests/test_network_worker.cpp Sun Aug 3 22:13:25 2008
@@ -47,7 +47,6 @@
BOOST_AUTO_TEST_CASE( test_connect )
{
- BOOST_MESSAGE( "Starting network test!" );
int connections = network::nconnections();
BOOST_WARN_MESSAGE(connections == 0, "There is open "<< connections <<"
connections before test!");
Modified: trunk/src/tests/test_team.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_team.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/tests/test_team.cpp (original)
+++ trunk/src/tests/test_team.cpp Sun Aug 3 22:13:25 2008
@@ -18,7 +18,6 @@
BOOST_AUTO_TEST_CASE( test_user_team_name )
{
- BOOST_MESSAGE( "Starting team test!" );
}
/* vim: set ts=4 sw=4: */
Modified: trunk/src/tests/test_util.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/test_util.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/tests/test_util.cpp (original)
+++ trunk/src/tests/test_util.cpp Sun Aug 3 22:13:25 2008
@@ -19,7 +19,6 @@
BOOST_AUTO_TEST_CASE( test_lexical_cast )
{
- BOOST_MESSAGE( "Starting utils test!" );
/* First check if lexical_cast returns correct results for correct args
*/
int result = lexical_cast<int, const std::string&>(std::string("1"));
BOOST_CHECK( result == 1 );
Modified: trunk/src/widgets/combo_drag.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/widgets/combo_drag.cpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/widgets/combo_drag.cpp (original)
+++ trunk/src/widgets/combo_drag.cpp Sun Aug 3 22:13:25 2008
@@ -24,7 +24,7 @@
namespace gui {
- const int combo_drag::MIN_DRAG_DISTANCE = 30;
+ const float combo_drag::MIN_DRAG_DISTANCE = 10.0;
const float combo_drag::RETURN_SPEED = 25.0;
combo_drag::combo_drag(display& disp, const std::vector<std::string>&
items, const drop_group_manager_ptr group)
@@ -34,7 +34,7 @@
{
}
- int combo_drag::get_drag_target()
+ int combo_drag::get_drop_target()
{
old_drag_target_ = drag_target_;
drag_target_ = -1;
Modified: trunk/src/widgets/combo_drag.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/widgets/combo_drag.hpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/widgets/combo_drag.hpp (original)
+++ trunk/src/widgets/combo_drag.hpp Sun Aug 3 22:13:25 2008
@@ -34,7 +34,14 @@
public:
combo_drag(display& disp, const
std::vector<std::string>& items, const drop_group_manager_ptr group);
- int get_drag_target();
+ /**
+ * used to query if this object was droped to a target
+ * @return: -1 if not droped and other the id of target
object
+ **/
+ int get_drop_target();
+ /**
+ * Implements return after drop
+ **/
virtual void process(events::pump_info& /*info*/);
protected:
virtual void process_event();
@@ -42,6 +49,7 @@
virtual void mouse_down(const SDL_MouseButtonEvent&
event);
virtual void mouse_up(const SDL_MouseButtonEvent&
event);
private:
+
void handle_move(const SDL_MouseMotionEvent& event);
void handle_drop();
int drag_target_, old_drag_target_;
Modified: trunk/src/widgets/drop_target.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/widgets/drop_target.hpp?rev=28313&r1=28312&r2=28313&view=diff
==============================================================================
--- trunk/src/widgets/drop_target.hpp (original)
+++ trunk/src/widgets/drop_target.hpp Sun Aug 3 22:13:25 2008
@@ -29,6 +29,12 @@
typedef int drop_target_group;
class drop_group_manager;
typedef boost::shared_ptr<drop_group_manager> drop_group_manager_ptr;
+
+ /**
+ * Handles droping for drag able ui items.
+ * Widget class just has to inherit from drop_target,
+ * call constructor and handle_drop.
+ **/
class drop_target : public boost::noncopyable {
typedef std::multimap<drop_target_group, drop_target*>
drop_groups;
typedef std::map<drop_target_group, int> target_id;
@@ -43,6 +49,10 @@
const SDL_Rect& loc_;
const int id_;
drop_group_manager_ptr group_;
+
+ static drop_target_group create_group();
+ static void delete_group(const drop_target_group id);
+
// We allow access for unit test to call handle_drop
#ifdef BOOST_TEST_DYN_LINK
public:
@@ -53,17 +63,39 @@
#else
protected:
#endif
+ /**
+ * Called by widget object when droping happens.
+ *
+ * Droping over multiple widget objects in same group
+ * is undefined.
+ *
+ * @return: id which widget was hit when droping
+ **/
int handle_drop();
public:
+ /**
+ * Registers drop target and saves reference to location.
+ **/
drop_target(const drop_group_manager_ptr group, const SDL_Rect&
loc);
~drop_target();
+
int get_id() const;
+ /**
+ * Checks if id matches id for this object.
+ * Used by for_each/boost:bind
+ **/
bool is_this_id(const int id) const;
- static drop_target_group create_group();
- static void delete_group(const drop_target_group id);
+
+ friend class drop_group_manager;
+
};
+ /**
+ * Used to create and destroy drop groups.
+ * To create drop_target widgets one has to have
+ * drop_group_manager stored in drop_group_manager_ptr.
+ **/
class drop_group_manager : public boost::noncopyable {
const drop_target_group group_id_;
public:
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits