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