]> git.localhorst.tv Git - blobs.git/blob - tst/app/AssetTest.cpp
load universe from file
[blobs.git] / tst / app / AssetTest.cpp
1 #include "AssetTest.hpp"
2
3 #include "app/Assets.hpp"
4 #include "app/init.hpp"
5 #include "world/Simulation.hpp"
6
7 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(blobs::app::test::AssetTest, "headed");
8
9
10 namespace blobs {
11 namespace app {
12 namespace test {
13
14 void AssetTest::setUp() {
15 }
16
17 void AssetTest::tearDown() {
18 }
19
20
21 void AssetTest::testLoadBasic() {
22         Init init(false, 1);
23         Assets assets;
24
25         CPPUNIT_ASSERT_MESSAGE(
26                 "no resources loaded",
27                 assets.data.resources.Size() > 0
28         );
29         CPPUNIT_ASSERT_MESSAGE(
30                 "no tile types loaded",
31                 assets.data.resources.Size() > 0
32         );
33
34         CPPUNIT_ASSERT_MESSAGE(
35                 "tile texture has no width",
36                 assets.textures.tiles.Width() > 0
37         );
38         CPPUNIT_ASSERT_MESSAGE(
39                 "tile texture has no height",
40                 assets.textures.tiles.Height() > 0
41         );
42         CPPUNIT_ASSERT_MESSAGE(
43                 "tile texture has no depth",
44                 assets.textures.tiles.Depth() > 0
45         );
46
47         CPPUNIT_ASSERT_MESSAGE(
48                 "skin texture has no width",
49                 assets.textures.skins.Width() > 0
50         );
51         CPPUNIT_ASSERT_MESSAGE(
52                 "skin texture has no height",
53                 assets.textures.skins.Height() > 0
54         );
55         CPPUNIT_ASSERT_MESSAGE(
56                 "skin texture has no depth",
57                 assets.textures.skins.Depth() > 0
58         );
59
60         CPPUNIT_ASSERT_EQUAL_MESSAGE(
61                 "large font has wrong family",
62                 std::string("DejaVu Sans"), std::string(assets.fonts.large.FamilyName())
63         );
64         CPPUNIT_ASSERT_EQUAL_MESSAGE(
65                 "medium font has wrong family",
66                 std::string("DejaVu Sans"), std::string(assets.fonts.medium.FamilyName())
67         );
68         CPPUNIT_ASSERT_EQUAL_MESSAGE(
69                 "small font has wrong family",
70                 std::string("DejaVu Sans"), std::string(assets.fonts.small.FamilyName())
71         );
72 }
73
74 void AssetTest::testLoadUniverse() {
75         Init init(false, 1);
76         Assets assets;
77
78         world::Simulation sim(assets);
79         assets.LoadUniverse("universe", sim);
80
81         CPPUNIT_ASSERT_EQUAL_MESSAGE(
82                 "wrong number of suns in default universe",
83                 std::set<world::Sun *>::size_type(1), sim.Suns().size()
84         );
85         CPPUNIT_ASSERT_EQUAL_MESSAGE(
86                 "wrong number of planets in default universe",
87                 std::set<world::Planet *>::size_type(3), sim.Planets().size()
88         );
89         CPPUNIT_ASSERT_NO_THROW_MESSAGE(
90                 "spawn planet does not exist",
91                 sim.PlanetByName("Planet")
92         );
93 }
94
95 }
96 }
97 }