The Battle for Wesnoth  1.15.2+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_display.hpp"
21 #include "terrain/type_data.hpp"
22 #include "reports.hpp"
23 
24 namespace wb {
25  class manager;
26 }
27 
28 namespace test_utils {
29 
32 
39 
40 
42 
43  public:
44  static fake_display_manager* get_manager();
45  game_display& get_display();
46 
48 // ~fake_display_manager();
49  };
50 
51  fake_display_manager* fake_display_manager::manager_ = 0;
52 
53  fake_display_manager* fake_display_manager::get_manager()
54  {
55  if (!manager_)
56  {
57  manager_ = new fake_display_manager();
58  }
59  return manager_;
60  }
61 
62  fake_display_manager::fake_display_manager() :
63  video_(CVideo::FAKE_TEST),
64  dummy_cfg_(),
65  dummy_cfg2_(),
66  dummy_board_(std::make_shared<terrain_type_data>(dummy_cfg_), dummy_cfg2_),
67  main_event_context_(),
68  disp_(dummy_board_, std::shared_ptr<wb::manager> (), dummy_reports, dummy_cfg_, dummy_cfg_)
69  {
70  }
71 
73  {
74  return disp_;
75  }
76 
77  game_display& get_fake_display(const int width, const int height)
78  {
81 
82  if(width >= 0 && height >= 0) {
83  display.video().make_test_fake(width, height);
84  }
85 
86  return display;
87  }
88 
89 
90 }
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.
Contains the database of all known terrain types, both those defined explicitly by WML [terrain_type]...
Definition: type_data.hpp:37
void make_test_fake(const unsigned width=1024, const unsigned height=768)
Creates a fake frame buffer for the unit tests.
Definition: video.cpp:184
static fake_display_manager * manager_
CVideo & video()
Gets the underlying screen object.
Definition: display.hpp:196
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:68
Definition: display.hpp:48