mirror of https://github.com/OpenMW/openmw.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
5.1 KiB
C++
137 lines
5.1 KiB
C++
3 years ago
|
#include <components/esm3/loadacti.hpp>
|
||
|
#include <components/esm3/loadcell.hpp>
|
||
|
#include <components/esm3/loadcont.hpp>
|
||
|
#include <components/esm3/loaddoor.hpp>
|
||
|
#include <components/esm3/loadgmst.hpp>
|
||
|
#include <components/esm3/loadland.hpp>
|
||
|
#include <components/esm3/loadstat.hpp>
|
||
2 years ago
|
#include <components/esm3/readerscache.hpp>
|
||
3 years ago
|
#include <components/esmloader/esmdata.hpp>
|
||
|
#include <components/esmloader/load.hpp>
|
||
3 years ago
|
#include <components/files/collections.hpp>
|
||
|
#include <components/files/multidircollection.hpp>
|
||
|
#include <components/to_utf8/to_utf8.hpp>
|
||
|
|
||
|
#include <gtest/gtest.h>
|
||
|
|
||
3 years ago
|
#ifndef OPENMW_DATA_DIR
|
||
|
#error "OPENMW_DATA_DIR is not defined"
|
||
|
#endif
|
||
|
|
||
3 years ago
|
namespace
|
||
|
{
|
||
|
using namespace testing;
|
||
|
using namespace EsmLoader;
|
||
|
|
||
|
struct EsmLoaderTest : Test
|
||
|
{
|
||
2 years ago
|
const Files::PathContainer mDataDirs{ { std::filesystem::path{ OPENMW_DATA_DIR } } };
|
||
2 years ago
|
const Files::Collections mFileCollections{ mDataDirs };
|
||
2 years ago
|
const std::vector<std::string> mContentFiles{ { "template.omwgame" } };
|
||
3 years ago
|
};
|
||
|
|
||
|
TEST_F(EsmLoaderTest, loadEsmDataShouldSupportOmwgame)
|
||
|
{
|
||
|
Query query;
|
||
|
query.mLoadActivators = true;
|
||
|
query.mLoadCells = true;
|
||
|
query.mLoadContainers = true;
|
||
|
query.mLoadDoors = true;
|
||
|
query.mLoadGameSettings = true;
|
||
|
query.mLoadLands = true;
|
||
|
query.mLoadStatics = true;
|
||
3 years ago
|
ESM::ReadersCache readers;
|
||
3 years ago
|
ToUTF8::Utf8Encoder* const encoder = nullptr;
|
||
|
const EsmData esmData = loadEsmData(query, mContentFiles, mFileCollections, readers, encoder);
|
||
|
EXPECT_EQ(esmData.mActivators.size(), 0);
|
||
|
EXPECT_EQ(esmData.mCells.size(), 1);
|
||
|
EXPECT_EQ(esmData.mContainers.size(), 0);
|
||
|
EXPECT_EQ(esmData.mDoors.size(), 0);
|
||
|
EXPECT_EQ(esmData.mGameSettings.size(), 1521);
|
||
|
EXPECT_EQ(esmData.mLands.size(), 1);
|
||
|
EXPECT_EQ(esmData.mStatics.size(), 2);
|
||
|
}
|
||
|
|
||
|
TEST_F(EsmLoaderTest, shouldIgnoreCellsWhenQueryLoadCellsIsFalse)
|
||
|
{
|
||
|
Query query;
|
||
|
query.mLoadActivators = true;
|
||
|
query.mLoadCells = false;
|
||
|
query.mLoadContainers = true;
|
||
|
query.mLoadDoors = true;
|
||
|
query.mLoadGameSettings = true;
|
||
|
query.mLoadLands = true;
|
||
|
query.mLoadStatics = true;
|
||
3 years ago
|
ESM::ReadersCache readers;
|
||
3 years ago
|
ToUTF8::Utf8Encoder* const encoder = nullptr;
|
||
|
const EsmData esmData = loadEsmData(query, mContentFiles, mFileCollections, readers, encoder);
|
||
|
EXPECT_EQ(esmData.mActivators.size(), 0);
|
||
|
EXPECT_EQ(esmData.mCells.size(), 0);
|
||
|
EXPECT_EQ(esmData.mContainers.size(), 0);
|
||
|
EXPECT_EQ(esmData.mDoors.size(), 0);
|
||
|
EXPECT_EQ(esmData.mGameSettings.size(), 1521);
|
||
|
EXPECT_EQ(esmData.mLands.size(), 1);
|
||
|
EXPECT_EQ(esmData.mStatics.size(), 2);
|
||
|
}
|
||
|
|
||
|
TEST_F(EsmLoaderTest, shouldIgnoreCellsGameSettingsWhenQueryLoadGameSettingsIsFalse)
|
||
|
{
|
||
|
Query query;
|
||
|
query.mLoadActivators = true;
|
||
|
query.mLoadCells = true;
|
||
|
query.mLoadContainers = true;
|
||
|
query.mLoadDoors = true;
|
||
|
query.mLoadGameSettings = false;
|
||
|
query.mLoadLands = true;
|
||
|
query.mLoadStatics = true;
|
||
3 years ago
|
ESM::ReadersCache readers;
|
||
3 years ago
|
ToUTF8::Utf8Encoder* const encoder = nullptr;
|
||
|
const EsmData esmData = loadEsmData(query, mContentFiles, mFileCollections, readers, encoder);
|
||
|
EXPECT_EQ(esmData.mActivators.size(), 0);
|
||
|
EXPECT_EQ(esmData.mCells.size(), 1);
|
||
|
EXPECT_EQ(esmData.mContainers.size(), 0);
|
||
|
EXPECT_EQ(esmData.mDoors.size(), 0);
|
||
|
EXPECT_EQ(esmData.mGameSettings.size(), 0);
|
||
|
EXPECT_EQ(esmData.mLands.size(), 1);
|
||
|
EXPECT_EQ(esmData.mStatics.size(), 2);
|
||
|
}
|
||
|
|
||
|
TEST_F(EsmLoaderTest, shouldIgnoreAllWithDefaultQuery)
|
||
|
{
|
||
|
const Query query;
|
||
3 years ago
|
ESM::ReadersCache readers;
|
||
3 years ago
|
ToUTF8::Utf8Encoder* const encoder = nullptr;
|
||
|
const EsmData esmData = loadEsmData(query, mContentFiles, mFileCollections, readers, encoder);
|
||
|
EXPECT_EQ(esmData.mActivators.size(), 0);
|
||
|
EXPECT_EQ(esmData.mCells.size(), 0);
|
||
|
EXPECT_EQ(esmData.mContainers.size(), 0);
|
||
|
EXPECT_EQ(esmData.mDoors.size(), 0);
|
||
|
EXPECT_EQ(esmData.mGameSettings.size(), 0);
|
||
|
EXPECT_EQ(esmData.mLands.size(), 0);
|
||
|
EXPECT_EQ(esmData.mStatics.size(), 0);
|
||
|
}
|
||
3 years ago
|
|
||
|
TEST_F(EsmLoaderTest, loadEsmDataShouldSkipUnsupportedFormats)
|
||
|
{
|
||
|
Query query;
|
||
|
query.mLoadActivators = true;
|
||
|
query.mLoadCells = true;
|
||
|
query.mLoadContainers = true;
|
||
|
query.mLoadDoors = true;
|
||
|
query.mLoadGameSettings = true;
|
||
|
query.mLoadLands = true;
|
||
|
query.mLoadStatics = true;
|
||
2 years ago
|
const std::vector<std::string> contentFiles{ { "script.omwscripts" } };
|
||
3 years ago
|
ESM::ReadersCache readers;
|
||
3 years ago
|
ToUTF8::Utf8Encoder* const encoder = nullptr;
|
||
|
const EsmData esmData = loadEsmData(query, contentFiles, mFileCollections, readers, encoder);
|
||
|
EXPECT_EQ(esmData.mActivators.size(), 0);
|
||
|
EXPECT_EQ(esmData.mCells.size(), 0);
|
||
|
EXPECT_EQ(esmData.mContainers.size(), 0);
|
||
|
EXPECT_EQ(esmData.mDoors.size(), 0);
|
||
|
EXPECT_EQ(esmData.mGameSettings.size(), 0);
|
||
|
EXPECT_EQ(esmData.mLands.size(), 0);
|
||
|
EXPECT_EQ(esmData.mStatics.size(), 0);
|
||
|
}
|
||
3 years ago
|
}
|