OpenTTD Source: src/tests/mock_environment.h Source File

OpenTTD Source 14.0-beta3

mock_environment.h
Go to the documentation of this file.
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
10 #ifndef MOCK_ENVIRONMENT_H
11 #define MOCK_ENVIRONMENT_H
12
13 #include "mock_fontcache.h"
14 #include "mock_spritecache.h"
15
17 class MockEnvironment {
18 public:
19 static MockEnvironment &Instance()
20 {
21 static MockEnvironment instance;
22 return instance;
23 }
24
25 MockEnvironment(MockEnvironment const &) = delete;
26 void operator=(MockEnvironment const &) = delete;
27
28 private:
29 MockEnvironment()
30 {
31 /* Mock SpriteCache initialization is needed for some widget generators. */
32 MockGfxLoadSprites();
33
34 /* Mock FontCache initialization is needed for some NWidgetParts. */
35 MockFontCache::InitializeFontCaches();
36 }
37 };
38
39 #endif /* MOCK_ENVIRONMENT_H */
MockEnvironment
Singleton class to set up the mock environemnt once.
Definition: mock_environment.h:17
mock_fontcache.h
mock_spritecache.h