mail[Wesnoth-commits] r28320 - in /trunk/src: tests/data/ tests/data/macros/ tests/data/scenarios/ tests/gui/ widgets/


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by paniemin on August 04, 2008 - 12:15:
Author: suokko
Date: Mon Aug  4 12:15:25 2008
New Revision: 28320

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28320&view=rev
Log:
* Fixes  gcc 4.3 warning in drop_target.hpp
* Added som test data configs
* Cleaned test_drop_target not to require anything special from drop_target 
class

Added:
    trunk/src/tests/data/
    trunk/src/tests/data/_main.cfg   (with props)
    trunk/src/tests/data/macros/
    trunk/src/tests/data/scenarios/
Modified:
    trunk/src/tests/gui/test_drop_target.cpp
    trunk/src/widgets/drop_target.cpp
    trunk/src/widgets/drop_target.hpp

Added: trunk/src/tests/data/_main.cfg
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/data/_main.cfg?rev=28320&view=auto
==============================================================================
--- trunk/src/tests/data/_main.cfg (added)
+++ trunk/src/tests/data/_main.cfg Mon Aug  4 12:15:25 2008
@@ -1,0 +1,15 @@
+#textdomain wesnoth
+[textdomain]
+       name="wesnoth"
+[/textdomain]
+
+#ifdef TEST
+# Load core wml for tests including macros and units
+{@core/}
+
+#Load test macros
+{macros/}
+
+#Load test scenarios
+{scenarios/}
+#endif

Propchange: trunk/src/tests/data/_main.cfg
------------------------------------------------------------------------------
    svn:eol-style = native

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=28320&r1=28319&r2=28320&view=diff
==============================================================================
--- trunk/src/tests/gui/test_drop_target.cpp (original)
+++ trunk/src/tests/gui/test_drop_target.cpp Mon Aug  4 12:15:25 2008
@@ -23,6 +23,24 @@
 
 BOOST_AUTO_TEST_SUITE( test_drop_target )
 
+       /**
+        * Specialized testing class so unit test
+        * can call protected member functions to
+        * simulate drop operation
+        **/
+       class test_drop_target : public gui::drop_target {
+               public:
+               test_drop_target(gui::drop_group_manager_ptr group, const 
SDL_Rect& loc) : gui::drop_target(group, loc)
+               {}
+
+               int handle_drop() {
+                       return gui::drop_target::handle_drop();
+               }
+               static bool empty() {
+                       return gui::drop_target::empty();
+               };
+       };
+
 BOOST_AUTO_TEST_CASE( test_create_group )
 {
 
@@ -44,11 +62,11 @@
 
 void create_drop_targets(const SDL_Rect& loc, gui::drop_group_manager_ptr 
group, target_store& targets, int& id_counter)
 {
-       gui::drop_target_ptr new_target(new gui::drop_target(group, loc));
+       gui::drop_target_ptr new_target(new test_drop_target(group, loc));
        BOOST_CHECK_EQUAL(id_counter++, new_target->get_id());
        // Test that drop gives -1 correctly for non overlapping
        // targets
-       BOOST_CHECK_EQUAL(new_target->handle_drop(), -1);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(new_target.get())->handle_drop(),
 -1);
        targets.push_back(new_target);
 }
 
@@ -81,15 +99,15 @@
        locations[2].y = 190;
 
        // Check for correct drop results
-       BOOST_CHECK_EQUAL(targets[2]->handle_drop(), 3);
-       BOOST_CHECK_EQUAL(targets[3]->handle_drop(), 2);
-       BOOST_CHECK_EQUAL(targets[1]->handle_drop(), -1);
-       BOOST_CHECK_EQUAL(targets[4]->handle_drop(), -1);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[2].get())->handle_drop(),
 3);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[3].get())->handle_drop(),
 2);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[1].get())->handle_drop(),
 -1);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[4].get())->handle_drop(),
 -1);
 }
 
 BOOST_AUTO_TEST_CASE( check_memory_leaks )
 {
-       BOOST_CHECK(gui::drop_target::empty());
+       BOOST_CHECK(test_drop_target::empty());
 }
 
 BOOST_AUTO_TEST_CASE( test_multiple_drop_groups )
@@ -137,15 +155,15 @@
        locations[2].y = 190;
 
        // Check for correct drop results
-       BOOST_CHECK_EQUAL(targets[2]->handle_drop(), 3);
-       BOOST_CHECK_EQUAL(targets[3]->handle_drop(), 2);
-       BOOST_CHECK_EQUAL(targets[1]->handle_drop(), -1);
-       BOOST_CHECK_EQUAL(targets[4]->handle_drop(), -1);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[2].get())->handle_drop(),
 3);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[3].get())->handle_drop(),
 2);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[1].get())->handle_drop(),
 -1);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets[4].get())->handle_drop(),
 -1);
 
        locations2[2].y = 180;
        locations2[2].x = 50;
 
-       BOOST_CHECK_EQUAL(targets2[2]->handle_drop(), -1);
+       
BOOST_CHECK_EQUAL(static_cast<test_drop_target*>(targets2[2].get())->handle_drop(),
 -1);
 
 }
 

Modified: trunk/src/widgets/drop_target.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/widgets/drop_target.cpp?rev=28320&r1=28319&r2=28320&view=diff
==============================================================================
--- trunk/src/widgets/drop_target.cpp (original)
+++ trunk/src/widgets/drop_target.cpp Mon Aug  4 12:15:25 2008
@@ -112,7 +112,7 @@
                drop_target::delete_group(group_id_);
        }
 
-       const drop_target_group drop_group_manager::get_group_id() const
+       drop_target_group drop_group_manager::get_group_id() const
        {
                return group_id_;
        }

Modified: trunk/src/widgets/drop_target.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/widgets/drop_target.hpp?rev=28320&r1=28319&r2=28320&view=diff
==============================================================================
--- trunk/src/widgets/drop_target.hpp (original)
+++ trunk/src/widgets/drop_target.hpp Mon Aug  4 12:15:25 2008
@@ -53,16 +53,12 @@
                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: 
-               static bool empty()
-               {
-                       return groups_.empty() && next_id_.empty();
-               }
-#else
                protected:
-#endif
+               /**
+                * Used to check if static storages are empty.
+                * Only for testing.
+                **/
+               static bool empty()     { return groups_.empty() && 
next_id_.empty(); }
                /**
                 * Called by widget object when droping happens.
                 *
@@ -102,7 +98,7 @@
                drop_group_manager();
                ~drop_group_manager();
 
-               const drop_target_group get_group_id() const;
+               drop_target_group get_group_id() const;
        };
 
 }




Related Messages


Powered by MHonArc, Updated Mon Aug 04 13:02:18 2008