Skip to content

Commit

Permalink
#5108: More test cases checking OpenMap command behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Nov 21, 2020
1 parent f5b63f2 commit b51b6b7
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/MapSavingLoading.cpp
Expand Up @@ -7,6 +7,7 @@
#include "icommandsystem.h"
#include "messages/FileSelectionRequest.h"
#include "algorithm/Scene.h"
#include "os/file.h"

namespace test
{
Expand Down Expand Up @@ -125,4 +126,44 @@ TEST_F(MapLoadingTest, openMapFromAbsolutePath)
checkAltarScene();
}

TEST_F(MapLoadingTest, openMapFromModRelativePath)
{
std::string modRelativePath = "maps/altar.map";

// The map is located in maps/altar.map folder, check that it physically exists
fs::path mapPath = _context.getTestResourcePath();
mapPath /= modRelativePath;
EXPECT_TRUE(os::fileOrDirExists(mapPath));

GlobalCommandSystem().executeCommand("OpenMap", modRelativePath);

// Check if the scene contains what we expect
checkAltarScene();
}

TEST_F(MapLoadingTest, openMapFromMapsFolder)
{
std::string mapName = "altar.map";

// The map is located in maps/altar.map folder, check that it physically exists
fs::path mapPath = _context.getTestResourcePath();
mapPath /= "maps";
mapPath /= mapName;
EXPECT_TRUE(os::fileOrDirExists(mapPath));

GlobalCommandSystem().executeCommand("OpenMap", mapName);

// Check if the scene contains what we expect
checkAltarScene();
}

TEST_F(MapLoadingTest, openNonExistentMap)
{
std::string mapName = "idontexist.map";
GlobalCommandSystem().executeCommand("OpenMap", mapName);

// No worldspawn in this map, it should be empty
EXPECT_FALSE(algorithm::getEntityByName(GlobalMapModule().getRoot(), "world"));
}

}

0 comments on commit b51b6b7

Please sign in to comment.