tests/utils/play_scenario.hpp

Go to the documentation of this file.
00001 /* $Id: play_scenario.hpp 52533 2012-01-07 02:35:17Z shadowmaster $ */
00002 /*
00003    Copyright (C) 2008 - 2012 by Pauli Nieminen <paniemin@cc.hut.fi>
00004    Part of thie Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 
00016 #ifndef TESTS_UTILS_PLAY_SCENARIO_HPP_INCLUDED
00017 #define TESTS_UTILS_PLAY_SCENARIO_HPP_INCLUDED
00018 
00019 #include "tests/utils/fake_event_source.hpp"
00020 
00021 #include "map_location.hpp"
00022 
00023 #include <boost/scoped_ptr.hpp>
00024 
00025 class config;
00026 
00027 
00028 namespace test_utils {
00029 
00030     class end_position_collector;
00031 
00032     class timing {
00033         static const size_t step_size = 2;
00034         size_t time_;
00035         public:
00036         timing() : time_(0) {}
00037         timing(const size_t& t) : time_(t) {}
00038 
00039         timing operator++()
00040         {
00041             return time_ += step_size;
00042         }
00043 
00044         timing operator++(int)
00045         {
00046             timing ret(*this);
00047             operator++();
00048             return ret;
00049         }
00050 
00051         operator size_t&()
00052         { return time_;}
00053 
00054         timing operator+(const size_t& t) const
00055         { return timing(time_ + t*step_size);}
00056 
00057         timing operator+(const int& t) const
00058         { return *this + size_t(t);}
00059 
00060         timing& operator+=(const size_t& t)
00061         { time_ += t*step_size;
00062         return *this;}
00063 
00064         timing& operator+=(const int& t)
00065         { return *this+= size_t(t);}
00066     };
00067 
00068     /**
00069      * simple abstaction to settup scenario playing test case
00070      **/
00071     class play_scenario {
00072         const std::string id_;
00073         fake_event_source source_;
00074         const config& game_config_;
00075         timing current_time_;
00076         event_node_ptr end_pos_;
00077 
00078         /**
00079          * We have to add automatically one enter press
00080          * for objectives view
00081          **/
00082         void add_initial_signals();
00083         public:
00084             play_scenario(const std::string& id);
00085 
00086             void play();
00087 
00088             void add_formula_command(const std::string& command);
00089 
00090             std::string get_unit_id(const map_location &loc);
00091     };
00092 }
00093 
00094 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:12 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs