The Battle for Wesnoth  1.17.0-dev
fake_display.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 - 2021
3  by Pauli Nieminen <paniemin@cc.hut.fi>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-test"
17 
19 
20 #include "game_board.hpp"
21 #include "game_config_view.hpp"
22 #include "game_display.hpp"
23 #include "reports.hpp"
24 
25 namespace wb
26 {
27 class manager;
28 }
29 
30 namespace test_utils
31 {
33 {
35 
42 
44 
45 public:
46  static fake_display_manager* get_manager();
47  game_display& get_display();
48 
50  // ~fake_display_manager();
51 };
52 
53 fake_display_manager* fake_display_manager::manager_ = 0;
54 
55 fake_display_manager* fake_display_manager::get_manager()
56 {
57  if(!manager_) {
58  manager_ = new fake_display_manager();
59  }
60 
61  return manager_;
62 }
63 
64 fake_display_manager::fake_display_manager()
65  : video_(CVideo::FAKE_TEST)
66  , dummy_cfg_()
67  , dummy_cfg2_()
68  , dummy_board_(dummy_cfg2_)
69  , main_event_context_()
70  , disp_(dummy_board_, std::shared_ptr<wb::manager>(), dummy_reports, dummy_cfg_, dummy_cfg_)
71 {
72 }
73 
75 {
76  return disp_;
77 }
78 
79 game_display& get_fake_display(const int width, const int height)
80 {
82 
83  if(width >= 0 && height >= 0) {
84  display.video().make_test_fake(width, height);
85  }
86 
87  return display;
88 }
89 
90 } // namespace test_utils
Game board class.
Definition: game_board.hpp:51
Definition: video.hpp:32
game_display & get_fake_display(const int width, const int height)
Gets a fake test display.
static fake_display_manager * get_manager()
STL namespace.
Unit and team statistics.
void make_test_fake(const unsigned width=1024, const unsigned height=768)
Creates a fake frame buffer for the unit tests.
Definition: video.cpp:180
static fake_display_manager * manager_
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:201
const events::event_context main_event_context_
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:61
Definition: display.hpp:49