diff options
Diffstat (limited to 'indra/newview/tests')
-rw-r--r-- | indra/newview/tests/lldir_stub.cpp | 30 | ||||
-rw-r--r-- | indra/newview/tests/llvieweroctree_stub.cpp | 86 | ||||
-rw-r--r-- | indra/newview/tests/llvocache_test.cpp | 146 |
3 files changed, 251 insertions, 11 deletions
diff --git a/indra/newview/tests/lldir_stub.cpp b/indra/newview/tests/lldir_stub.cpp index 2bc6772d86..911e9334dd 100644 --- a/indra/newview/tests/lldir_stub.cpp +++ b/indra/newview/tests/lldir_stub.cpp @@ -30,25 +30,29 @@ LLDir::LLDir() {} LLDir::~LLDir() {} BOOL LLDir::deleteFilesInDir(const std::string &dirname, const std::string &mask) { return true; } void LLDir::setChatLogsDir(const std::string &path) {} -void LLDir::setPerAccountChatLogsDir(const std::string &first, const std::string &last) {} -void LLDir::setLindenUserDir(const std::string &first, const std::string &last) {} +void LLDir::setPerAccountChatLogsDir(const std::string &) {} +void LLDir::updatePerAccountChatLogsDir() {} +void LLDir::setLindenUserDir(const std::string &) {} void LLDir::setSkinFolder(const std::string &skin_folder, const std::string& language) {} bool LLDir::setCacheDir(const std::string &path) { return true; } -void LLDir::dumpCurrentDirectories() {} +void LLDir::dumpCurrentDirectories(LLError::ELevel) {} +std::string LLDir::getSkinFolder() const { return ""; } +std::string LLDir::getLanguage() const { return ""; } + class LLDir_stub : public LLDir { public: - LLDir_stub() {} - ~LLDir_stub() {} + LLDir_stub() = default; + ~LLDir_stub() = default; + + void initAppDirs(const std::string &app_name, const std::string &) override {} - /*virtual*/ void initAppDirs(const std::string &app_name) {} + std::string getCurPath() override { return "CUR_PATH_FROM_LLDIR"; } + bool fileExists(const std::string &filename) const override { return false; } - /*virtual*/ std::string getCurPath() { return "CUR_PATH_FROM_LLDIR"; } - /*virtual*/ U32 countFilesInDir(const std::string &dirname, const std::string &mask) { return 42; } - /*virtual*/ BOOL getNextFileInDir(const std::string &dirname, const std::string &mask, std::string &fname, BOOL wrap) { fname = fname + "_NEXT"; return false; } - /*virtual*/ void getRandomFileInDir(const std::string &dirname, const std::string &mask, std::string &fname) { fname = "RANDOM_FILE"; } - /*virtual*/ bool fileExists(const std::string &filename) const { return false; } + std::string getLLPluginLauncher() override { return ""; } + std::string getLLPluginFilename(std::string base_name) override { return ""; } }; LLDir_stub gDirUtil; @@ -60,3 +64,7 @@ std::string LLDir::getExpandedFilename(ELLPath loc, const std::string& subdir, c return subdir + " --- " + filename + " --- expanded!"; } +std::string LLDir::getExpandedFilename(ELLPath location, const std::string &filename) const +{ + return filename + " --- expanded!"; +} diff --git a/indra/newview/tests/llvieweroctree_stub.cpp b/indra/newview/tests/llvieweroctree_stub.cpp new file mode 100644 index 0000000000..ab180c49a3 --- /dev/null +++ b/indra/newview/tests/llvieweroctree_stub.cpp @@ -0,0 +1,86 @@ +/** + * @file llvieweroctree_stub.cpp + * @brief stub implementations to allow unit testing + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +S32 AABBSphereIntersect(const LLVector4a& min, const LLVector4a& max, const LLVector3 &origin, const F32 &rad) { return 0; } + +void LLViewerOctreeCull::traverse(const LLOctreeNode<LLViewerOctreeEntry, LLPointer<LLViewerOctreeEntry> >* node) { } +void LLViewerOctreeCull::visit(const LLOctreeNode<LLViewerOctreeEntry, LLPointer<LLViewerOctreeEntry> >* node) { } +void LLViewerOctreeCull::preprocess(LLViewerOctreeGroup* group) {} +bool LLViewerOctreeCull::earlyFail(LLViewerOctreeGroup* group) { return false; } +bool LLViewerOctreeCull::checkProjectionArea(const LLVector4a& center, const LLVector4a& size, const LLVector3& shift, F32 pixel_threshold, F32 near_radius) { return false; } +bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLViewerOctreeGroup* group) { return false; } +void LLViewerOctreeCull::processGroup(LLViewerOctreeGroup* group) {} + + +bool LLViewerOctreeGroup::boundObjects(BOOL empty, LLVector4a& minOut, LLVector4a& maxOut) { return false; } +void LLViewerOctreeGroup::unbound() {} +void LLViewerOctreeGroup::rebound() {} +void LLViewerOctreeGroup::handleInsertion(const TreeNode* node, LLViewerOctreeEntry* obj) {} +void LLViewerOctreeGroup::handleRemoval(const TreeNode* node, LLViewerOctreeEntry* obj) {} +void LLViewerOctreeGroup::handleDestruction(const TreeNode* node) {} +void LLViewerOctreeGroup::handleStateChange(const TreeNode* node) {} +void LLViewerOctreeGroup::handleChildAddition(const OctreeNode* parent, OctreeNode* child) {} +void LLViewerOctreeGroup::handleChildRemoval(const OctreeNode* parent, const OctreeNode* child) {} + +LLOcclusionCullingGroup::LLOcclusionCullingGroup(OctreeNode* node, LLViewerOctreePartition* part) : + LLViewerOctreeGroup(node), + mSpatialPartition(part) +{ +} +LLOcclusionCullingGroup::~LLOcclusionCullingGroup() = default; +void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* shift) {} +void LLOcclusionCullingGroup::setOcclusionState(U32 state, S32 mode) {} +void LLOcclusionCullingGroup::clearOcclusionState(U32 state, S32 mode) {} +void LLOcclusionCullingGroup::handleChildAddition(const OctreeNode *parent, OctreeNode *child) {} +BOOL LLOcclusionCullingGroup::isRecentlyVisible() const { return FALSE; } +BOOL LLOcclusionCullingGroup::isAnyRecentlyVisible() const { return FALSE; } + + +LLViewerOctreeGroup::LLViewerOctreeGroup(OctreeNode* node) : mOctreeNode(node) {} +LLViewerOctreeGroup::~LLViewerOctreeGroup() = default; + +LLViewerOctreeEntryData::LLViewerOctreeEntryData(LLViewerOctreeEntry::eEntryDataType_t) {} +LLViewerOctreeEntryData::~LLViewerOctreeEntryData() = default; +bool LLViewerOctreeEntryData::isVisible() const { return false; } +bool LLViewerOctreeEntryData::isRecentlyVisible() const { return false; } +void LLViewerOctreeEntryData::setVisible() const {} +void LLViewerOctreeEntryData::resetVisible() const {} +const LLVector4a& LLViewerOctreeEntryData::getPositionGroup() const { return LLVector4a::getZero(); } +const LLVector4a* LLViewerOctreeEntryData::getSpatialExtents() const { return nullptr; } +LLViewerOctreeGroup* LLViewerOctreeEntryData::getGroup() const { return nullptr; } +void LLViewerOctreeEntryData::setSpatialExtents(const LLVector4a& min, const LLVector4a& max) {} +void LLViewerOctreeEntryData::setPositionGroup(const LLVector4a& pos) {} +void LLViewerOctreeEntryData::setGroup(LLViewerOctreeGroup* group) {} +void LLViewerOctreeEntryData::setOctreeEntry(LLViewerOctreeEntry* entry) {} +U32 LLViewerOctreeEntryData::sCurVisible{}; + +LLViewerOctreePartition::LLViewerOctreePartition() = default; +LLViewerOctreePartition::~LLViewerOctreePartition() = default; +void LLViewerOctreePartition::cleanup() {} + +BOOL LLViewerOctreeGroup::isRecentlyVisible() const { return FALSE; } + + diff --git a/indra/newview/tests/llvocache_test.cpp b/indra/newview/tests/llvocache_test.cpp new file mode 100644 index 0000000000..ea6abe254e --- /dev/null +++ b/indra/newview/tests/llvocache_test.cpp @@ -0,0 +1,146 @@ +/** + * @file llvocache_.cpp + * @author Brad + * @date 2023-03-01 + * @brief Test Viewer Object Cache functionality + * + * $LicenseInfo:firstyear=2023&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2014, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library 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. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +#include "../llviewerprecompiledheaders.h" +#include "../test/lltut.h" + +#include "llvocache.h" + +#include "lldir.h" +#include "llhudobject.h" +#include "llregionhandle.h" +#include "llsdutil.h" +#include "llsdserialize.h" +#include "llviewerobjectlist.h" +#include "llviewerregion.h" + +#include "lldir_stub.cpp" +#include "llvieweroctree_stub.cpp" + +namespace +{ + +} + + +//---------------------------------------------------------------------------- +// Mock objects for the dependencies of the code we're testing +S32 LLVOCachePartition::cull(LLCamera &camera, bool do_occlusion) { return 0; } + +LLViewerObjectList::LLViewerObjectList() = default; +LLViewerObjectList::~LLViewerObjectList() = default; +LLDebugBeacon::~LLDebugBeacon() = default; +LLViewerObjectList gObjectList{}; +LLViewerCamera::eCameraID LLViewerCamera::sCurCameraID{}; +void LLViewerObject::unpackUUID(LLDataPackerBinaryBuffer *dp, LLUUID &value, std::string name) {} + +bool LLViewerRegion::addVisibleGroup(LLViewerOctreeGroup*) { return false; } +U32 LLViewerRegion::getNumOfVisibleGroups() const { return 0; } +LLVector3 LLViewerRegion::getOriginAgent() const { return LLVector3::zero; } +S32 LLViewerRegion::sLastCameraUpdated{}; + +// ------------------------------------------------------------------------------------------- +// TUT +// ------------------------------------------------------------------------------------------- +namespace tut +{ + // Test wrapper declaration + struct vocacheTest + { + vocacheTest() = default; + ~vocacheTest() = default; + + static const std::string override_llsd_text[]; + }; + + const std::string vocacheTest::override_llsd_text[]{ + // sample override contents captured from traffic + R"(<? llsd/notation ?> + {'gltf_json':['{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n','{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n','{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n','{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n','{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n','{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n','{"asset":{"version":"2.0"},"images":[{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"},{"uri":"00000000-0000-0000-0000-000000000000"}],"materials":[{"emissiveTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":3},"normalTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":1},"occlusionTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":4},"pbrMetallicRoughness":{"baseColorTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":0},"metallicRoughnessTexture":{"extensions":{"KHR_texture_transform":{"offset":[0.0,0.0],"rotation":0.0,"scale":[2.0,2.0]}},"index":2}}}],"textures":[{"source":0},{"source":1},{"source":2},{"source":3},{"source":4}]}\n'],'object_id':u8b357110-4845-1d40-1cf0-cc4a2c22a4f1,'sides':[i0,i1,i2,i3,i4,i5,i6]})" + }; + + // Tut templating thingamagic: test group, object and test instance + struct vocacheTestFactory : public test_group<vocacheTest> + { + vocacheTestFactory() + : test_group<vocacheTest>("LLVOCache") + { + ll_init_apr(); + + const bool READ_ONLY = false; + const U32 INDRA_OBJECT_CACHE_VERSION = 15; // see LLAppViewer::getObjectCacheVersion() + const U32 CACHE_NUMBER_OF_REGIONS = 128; // see setting CacheNumberOfRegionsForObjects + + LLVOCache &instance = LLVOCache::initParamSingleton(READ_ONLY); + instance.initCache(LL_PATH_CACHE, CACHE_NUMBER_OF_REGIONS, INDRA_OBJECT_CACHE_VERSION); + } + + ~vocacheTestFactory() + { + LLVOCache::deleteSingleton(); + ll_cleanup_apr(); + } + + }; + + typedef vocacheTestFactory::object vocacheTestObject; + tut::vocacheTestFactory tut_test; + + // --------------------------------------------------------------------------------------- + // Test functions + // --------------------------------------------------------------------------------------- + + template<> template<> + void vocacheTestObject::test<1>() + { + LLGLTFOverrideCacheEntry entry{}; + LLSD entry_llsd; + + std::istringstream in_llsd(override_llsd_text[0]); + bool success = LLSDSerialize::deserialize(entry_llsd, in_llsd, override_llsd_text[0].length()); + + ensure("llsd deserialize succeeds", success); + + entry.fromLLSD(entry_llsd); + ensure_equals("entry object_id match", entry.mObjectId, LLUUID("8b357110-4845-1d40-1cf0-cc4a2c22a4f1")); + ensure_equals("sides count", entry.mSides.size(), 7); + + //std::cout << other << std::endl; + ensure_equals("toLLSD() match", entry.toLLSD(), entry_llsd); + } + + template<> template<> + void vocacheTestObject::test<2>() + { + LLVOCacheEntry::vocache_gltf_overrides_map_t extras; + + U64 region_handle = to_region_handle(140, 81); + LLUUID region_id = LLUUID::generateNewID(); + + LLVOCache::instance().readGenericExtrasFromCache(region_handle, region_id, extras); + } +} |