summaryrefslogtreecommitdiff
path: root/indra/newview/tests
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/tests')
-rw-r--r--indra/newview/tests/lldir_stub.cpp30
-rw-r--r--indra/newview/tests/llviewercontrollistener_test.cpp173
-rw-r--r--indra/newview/tests/llvieweroctree_stub.cpp86
-rw-r--r--indra/newview/tests/llvocache_test.cpp147
4 files changed, 425 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/llviewercontrollistener_test.cpp b/indra/newview/tests/llviewercontrollistener_test.cpp
new file mode 100644
index 0000000000..8aed2a8043
--- /dev/null
+++ b/indra/newview/tests/llviewercontrollistener_test.cpp
@@ -0,0 +1,173 @@
+/**
+ * @file llviewercontrollistener_test.cpp
+ * @author Nat Goodspeed
+ * @date 2022-06-09
+ * @brief Test for llviewercontrollistener.
+ *
+ * $LicenseInfo:firstyear=2022&license=viewerlgpl$
+ * Copyright (c) 2022, Linden Research, Inc.
+ * $/LicenseInfo$
+ */
+
+// Precompiled header
+#include "../llviewerprecompiledheaders.h"
+// associated header
+#include "../llviewercontrollistener.h"
+// STL headers
+// std headers
+// external library headers
+// other Linden headers
+#include "../test/lltut.h"
+#include "../test/catch_and_store_what_in.h" // catch_what()
+#include "commoncontrol.h"
+#include "llcontrol.h" // LLControlGroup
+
+/*****************************************************************************
+* TUT
+*****************************************************************************/
+namespace tut
+{
+ void ensure_contains(const std::string& msg, const std::string& substr)
+ {
+ ensure_contains("Exception does not contain " + substr, msg, substr);
+ }
+
+ struct llviewercontrollistener_data
+ {
+ LLControlGroup Global{"FakeGlobal"};
+
+ llviewercontrollistener_data()
+ {
+ Global.declareString("strvar", "woof", "string variable");
+ // together we will stroll the boolvar, ma cherie
+ Global.declareBOOL("boolvar", TRUE, "bool variable");
+ }
+ };
+ typedef test_group<llviewercontrollistener_data> llviewercontrollistener_group;
+ typedef llviewercontrollistener_group::object object;
+ llviewercontrollistener_group llviewercontrollistenergrp("llviewercontrollistener");
+
+ template<> template<>
+ void object::test<1>()
+ {
+ set_test_name("CommonControl no listener");
+ // Not implemented: the linker drags in LLViewerControlListener when
+ // we bring in LLViewerControl.
+ }
+
+ template<> template<>
+ void object::test<2>()
+ {
+ set_test_name("CommonControl bad group");
+ std::string threw{ catch_what<LL::CommonControl::ParamError>(
+ [](){ LL::CommonControl::get("Nonexistent", "Variable"); }) };
+ ensure_contains(threw, "group");
+ ensure_contains(threw, "Nonexistent");
+ }
+
+ template<> template<>
+ void object::test<3>()
+ {
+ set_test_name("CommonControl bad variable");
+ std::string threw{ catch_what<LL::CommonControl::ParamError>(
+ [](){ LL::CommonControl::get("FakeGlobal", "Nonexistent"); }) };
+ ensure_contains(threw, "key");
+ ensure_contains(threw, "Nonexistent");
+ }
+
+ template<> template<>
+ void object::test<4>()
+ {
+ set_test_name("CommonControl toggle string");
+ std::string threw{ catch_what<LL::CommonControl::ParamError>(
+ [](){ LL::CommonControl::toggle("FakeGlobal", "strvar"); }) };
+ ensure_contains(threw, "non-boolean");
+ ensure_contains(threw, "strvar");
+ }
+
+ template<> template<>
+ void object::test<5>()
+ {
+ set_test_name("CommonControl list bad group");
+ std::string threw{ catch_what<LL::CommonControl::ParamError>(
+ [](){ LL::CommonControl::get_vars("Nonexistent"); }) };
+ ensure_contains(threw, "group");
+ ensure_contains(threw, "Nonexistent");
+ }
+
+ template<> template<>
+ void object::test<6>()
+ {
+ set_test_name("CommonControl get");
+ auto strvar{ LL::CommonControl::get("FakeGlobal", "strvar") };
+ ensure_equals(strvar, "woof");
+ auto boolvar{ LL::CommonControl::get("FakeGlobal", "boolvar") };
+ ensure(boolvar);
+ }
+
+ template<> template<>
+ void object::test<7>()
+ {
+ set_test_name("CommonControl set, set_default, toggle");
+
+ std::string newstr{ LL::CommonControl::set("FakeGlobal", "strvar", "mouse").asString() };
+ ensure_equals(newstr, "mouse");
+ ensure_equals(LL::CommonControl::get("FakeGlobal", "strvar").asString(), "mouse");
+ ensure_equals(LL::CommonControl::set_default("FakeGlobal", "strvar").asString(), "woof");
+
+ bool newbool{ LL::CommonControl::set("FakeGlobal", "boolvar", false) };
+ ensure(! newbool);
+ ensure(! LL::CommonControl::get("FakeGlobal", "boolvar").asBoolean());
+ ensure(LL::CommonControl::set_default("FakeGlobal", "boolvar").asBoolean());
+ ensure(! LL::CommonControl::toggle("FakeGlobal", "boolvar").asBoolean());
+ }
+
+ template<> template<>
+ void object::test<8>()
+ {
+ set_test_name("CommonControl get_def");
+ LLSD def{ LL::CommonControl::get_def("FakeGlobal", "strvar") };
+ ensure_equals(
+ def,
+ llsd::map("name", "strvar",
+ "type", "String",
+ "value", "woof",
+ "comment", "string variable"));
+ }
+
+ template<> template<>
+ void object::test<9>()
+ {
+ set_test_name("CommonControl get_groups");
+ std::vector<std::string> groups{ LL::CommonControl::get_groups() };
+ ensure_equals(groups.size(), 1);
+ ensure_equals(groups[0], "FakeGlobal");
+ }
+
+ template<> template<>
+ void object::test<10>()
+ {
+ set_test_name("CommonControl get_vars");
+ LLSD vars{ LL::CommonControl::get_vars("FakeGlobal") };
+ // convert from array (unpredictable order) to map
+ LLSD varsmap{ LLSD::emptyMap() };
+ for (auto& var : llsd::inArray(vars))
+ {
+ varsmap[var["name"].asString()] = var;
+ }
+ // comparing maps is order-insensitive
+ ensure_equals(
+ varsmap,
+ llsd::map(
+ "strvar",
+ llsd::map("name", "strvar",
+ "type", "String",
+ "value", "woof",
+ "comment", "string variable"),
+ "boolvar",
+ llsd::map("name", "boolvar",
+ "type", "Boolean",
+ "value", TRUE,
+ "comment", "bool variable")));
+ }
+} // namespace tut
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..c27730eb58
--- /dev/null
+++ b/indra/newview/tests/llvocache_test.cpp
@@ -0,0 +1,147 @@
+/**
+ * @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);
+ }
+}