summaryrefslogtreecommitdiff
path: root/indra/llinventory/tests
diff options
context:
space:
mode:
authorRye <rye@alchemyviewer.org>2025-12-09 19:27:14 -0500
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2025-12-11 21:37:03 +0200
commit3b88739957d8b0d5072646e571d27b743e68fe2e (patch)
treee9cdd325e282735c1f3e7021bef7e8d0e983083b /indra/llinventory/tests
parent0e70989f6804f71a5efb2ff7e1352fb556321446 (diff)
Rework legacy lltest executable into individual integration tests and restore some disabled tests
Removes dead llprimlinkinfo and related test Remove dead llassetuploadqueue llhttpclient lltimestampcache lltranscode tests Remove dead mock_http_client Remove duplicate hex_dump.h Fix crash in LLDataPacker test
Diffstat (limited to 'indra/llinventory/tests')
-rw-r--r--indra/llinventory/tests/llpermissions_test.cpp491
-rw-r--r--indra/llinventory/tests/llsaleinfo_test.cpp194
-rw-r--r--indra/llinventory/tests/lluserrelations_test.cpp156
3 files changed, 841 insertions, 0 deletions
diff --git a/indra/llinventory/tests/llpermissions_test.cpp b/indra/llinventory/tests/llpermissions_test.cpp
new file mode 100644
index 0000000000..1328939004
--- /dev/null
+++ b/indra/llinventory/tests/llpermissions_test.cpp
@@ -0,0 +1,491 @@
+/**
+ * @file llpermissions_tut.cpp
+ * @author Adroit
+ * @date March 2007
+ * @brief llpermissions test cases.
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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 <tut/tut.hpp>
+#include "linden_common.h"
+
+#include "lltut.h"
+
+#include "message.h"
+#include "llpermissions.h"
+
+
+namespace tut
+{
+ struct permission
+ {
+ };
+ typedef test_group<permission> permission_t;
+ typedef permission_t::object permission_object_t;
+ tut::permission_t tut_permission("permission");
+
+ template<> template<>
+ void permission_object_t::test<1>()
+ {
+ LLPermissions permissions;
+ LLUUID uuid = permissions.getCreator();
+ LLUUID uuid1 = permissions.getOwner();
+ LLUUID uuid2 = permissions.getGroup();
+ LLUUID uuid3 = permissions.getLastOwner();
+
+ ensure("LLPermission Get Functions failed", (uuid == LLUUID::null && uuid1 == LLUUID::null &&
+ uuid2 == LLUUID::null && uuid3 == LLUUID::null));
+ ensure("LLPermission Get Functions failed", (permissions.getMaskBase() == PERM_ALL && permissions.getMaskOwner() == PERM_ALL &&
+ permissions.getMaskGroup() == PERM_ALL && permissions.getMaskEveryone() == PERM_ALL && permissions.getMaskNextOwner() == PERM_ALL));
+ ensure("Ownership functions failed", ((! permissions.isGroupOwned()) && (! permissions.isOwned())));
+ }
+
+ template<> template<>
+ void permission_object_t::test<2>()
+ {
+ LLPermissions permissions;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ permissions.init(creator, owner, lastOwner, group);
+
+ ensure_equals("init/getCreator():failed to return the creator ", creator, permissions.getCreator());
+ ensure_equals("init/getOwner():failed to return the owner ", owner, permissions.getOwner());
+ ensure_equals("init/getLastOwner():failed to return the group ", lastOwner, permissions.getLastOwner());
+ ensure_equals("init/getGroup():failed to return the group ", group, permissions.getGroup());
+ }
+
+ template<> template<>
+ void permission_object_t::test<3>()
+ {
+ LLPermissions permissions;
+ U32 base = PERM_ALL;
+ U32 owner = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
+ U32 group = PERM_TRANSFER | PERM_MOVE | PERM_COPY|PERM_MODIFY;
+ U32 everyone = PERM_TRANSFER | PERM_MOVE | PERM_MODIFY;
+ U32 next = PERM_NONE;
+
+ U32 fixedbase = base;
+ U32 fixedowner = PERM_ITEM_UNRESTRICTED; //owner & fixedbase
+ U32 fixedgroup = PERM_ITEM_UNRESTRICTED; // no PERM_MOVE as owner does not have that perm either
+ U32 fixedeveryone = PERM_TRANSFER; // no PERM_MOVE. Everyone can never modify.
+ U32 fixednext = PERM_NONE;
+
+ permissions.initMasks(base, owner, everyone, group, next); // will fix perms if not allowed.
+ ensure_equals("initMasks/getMaskBase():failed to return the MaskBase ", fixedbase, permissions.getMaskBase());
+ ensure_equals("initMasks/getMaskOwner():failed to return the MaskOwner ", fixedowner, permissions.getMaskOwner());
+ ensure_equals("initMasks/getMaskEveryone():failed to return the MaskGroup ", fixedgroup, permissions.getMaskGroup());
+ ensure_equals("initMasks/getMaskEveryone():failed to return the MaskEveryone ", fixedeveryone, permissions.getMaskEveryone());
+ ensure_equals("initMasks/getMaskNextOwner():failed to return the MaskNext ", fixednext, permissions.getMaskNextOwner());
+
+ // explictly set should maintain the values
+ permissions.setMaskBase(base); //no fixing
+ ensure_equals("setMaskBase/getMaskBase():failed to return the MaskBase ", base, permissions.getMaskBase());
+
+ permissions.setMaskOwner(owner);
+ ensure_equals("setMaskOwner/getMaskOwner():failed to return the MaskOwner ", owner, permissions.getMaskOwner());
+
+ permissions.setMaskEveryone(everyone);
+ ensure_equals("setMaskEveryone/getMaskEveryone():failed to return the MaskEveryone ", everyone, permissions.getMaskEveryone());
+
+ permissions.setMaskGroup(group);
+ ensure_equals("setMaskGroup/getMaskEveryone():failed to return the MaskGroup ", group, permissions.getMaskGroup());
+
+ permissions.setMaskNext(next);
+ ensure_equals("setMaskNext/getMaskNextOwner():failed to return the MaskNext ", next, permissions.getMaskNextOwner());
+
+ // further tests can be added to ensure perms for owner/group/everyone etc. get properly fixed.
+ // code however suggests that there is no explict check if the perms are correct and the user of this
+ // class is expected to know how to use them correctly. skipping further test cases for now for various
+ // perm combinations.
+ }
+
+ template<> template<>
+ void permission_object_t::test<4>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm1.init(creator,owner,lastOwner,group);
+ perm.set(perm1);
+ ensure("set():failed to set ", (creator == perm.getCreator()) && (owner == perm.getOwner())&&
+ (lastOwner == perm.getLastOwner())&& (group == perm.getGroup()));
+ }
+
+ template<> template<>
+ void permission_object_t::test<5>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm1.init(creator,owner,lastOwner,group);
+
+ U32 base = PERM_TRANSFER;
+ U32 ownerp = PERM_TRANSFER;
+ U32 groupp = PERM_TRANSFER;
+ U32 everyone = PERM_TRANSFER;
+ U32 next = PERM_NONE;
+
+ perm1.initMasks(base, ownerp, everyone, groupp, next);
+
+ base = PERM_ALL;
+ ownerp = PERM_ITEM_UNRESTRICTED; //PERM_ITEM_UNRESTRICTED = PERM_MODIFY | PERM_COPY | PERM_TRANSFER;
+ groupp = PERM_TRANSFER | PERM_COPY|PERM_MODIFY;
+ everyone = PERM_TRANSFER;
+ next = PERM_NONE;
+
+ perm.init(creator,owner,lastOwner,group);
+ perm.initMasks(base, ownerp, everyone, groupp, next);
+
+ // restrict permissions by accumulation
+ perm.accumulate(perm1);
+
+ U32 fixedbase = PERM_TRANSFER | PERM_MOVE;
+ U32 fixedowner = PERM_TRANSFER;
+ U32 fixedgroup = PERM_TRANSFER;
+ U32 fixedeveryone = PERM_TRANSFER;
+ U32 fixednext = PERM_NONE;
+
+ ensure_equals("accumulate failed ", fixedbase, perm.getMaskBase());
+ ensure_equals("accumulate failed ", fixedowner, perm.getMaskOwner());
+ ensure_equals("accumulate failed ", fixedgroup, perm.getMaskGroup());
+ ensure_equals("accumulate failed ", fixedeveryone, perm.getMaskEveryone());
+ ensure_equals("accumulate failed ", fixednext, perm.getMaskNextOwner());
+ }
+
+ template<> template<>
+ void permission_object_t::test<6>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ ensure_equals("getSafeOwner:failed ", owner,perm.getSafeOwner());
+
+ ///NULL Owner
+ perm.init(creator,LLUUID::null,lastOwner,group);
+ ensure_equals("getSafeOwner:failed ", group, perm.getSafeOwner());
+ }
+
+ template<> template<>
+ void permission_object_t::test<7>()
+ {
+ LLPermissions perm1;
+ LLUUID uuid;
+ bool is_group_owned = false;
+ ensure("1:getOwnership:failed ", ! perm1.getOwnership(uuid,is_group_owned));
+
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ perm.getOwnership(uuid,is_group_owned);
+ ensure("2:getOwnership:failed ", ((uuid == owner) && (! is_group_owned)));
+
+ perm.init(creator,LLUUID::null,lastOwner,group);
+ perm.getOwnership(uuid,is_group_owned);
+ ensure("3:getOwnership:failed ", ((uuid == group) && is_group_owned));
+ }
+
+ template<> template<>
+ void permission_object_t::test<8>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ perm1.init(creator,owner,lastOwner,group);
+ ensure_equals("getCRC32:failed ", perm.getCRC32(),perm1.getCRC32());
+ }
+
+ template<> template<>
+ void permission_object_t::test<9>()
+ {
+ LLPermissions perm;
+ LLUUID agent("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ bool is_atomic = true;
+ ensure("setOwnerAndGroup():failed ", perm.setOwnerAndGroup(agent,owner,group,is_atomic));
+
+ LLUUID owner2("68edcf47-ccd7-45b8-9f90-1649d7f12807");
+ LLUUID group2("9c8eca51-53d5-42a7-bb58-cef070395db9");
+
+ // cant change - agent need to be current owner
+ ensure("setOwnerAndGroup():failed ", ! perm.setOwnerAndGroup(agent,owner2,group2,is_atomic));
+
+ // should be able to change - agent and owner same as current owner
+ ensure("setOwnerAndGroup():failed ", perm.setOwnerAndGroup(owner,owner,group2,is_atomic));
+ }
+
+ template<> template<>
+ void permission_object_t::test<10>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("deedToGroup():failed ", perm.deedToGroup(agent,group));
+ }
+ template<> template<>
+ void permission_object_t::test<11>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ bool set = true;
+ U32 bits = PERM_TRANSFER | PERM_MODIFY;
+ ensure("setBaseBits():failed ", perm.setBaseBits(agent, set, bits));
+ ensure("setOwnerBits():failed ", perm.setOwnerBits(agent, set, bits));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("setBaseBits():failed ", ! perm.setBaseBits(agent1, set, bits));
+ ensure("setOwnerBits():failed ", ! perm.setOwnerBits(agent1, set, bits));
+ }
+
+ template<> template<>
+ void permission_object_t::test<12>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ bool set = true;
+ U32 bits = 10;
+ ensure("setGroupBits():failed ", perm.setGroupBits(agent,group, set, bits));
+ ensure("setEveryoneBits():failed ", perm.setEveryoneBits(agent,group, set, bits));
+ ensure("setNextOwnerBits():failed ", perm.setNextOwnerBits(agent,group, set, bits));
+
+ LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ ensure("setGroupBits():failed ", ! perm.setGroupBits(agent1,group, set, bits));
+ ensure("setEveryoneBits():failed ", ! perm.setEveryoneBits(agent1,group, set, bits));
+ ensure("setNextOwnerBits():failed ", ! perm.setNextOwnerBits(agent1,group, set, bits));
+ }
+
+ template<> template<>
+ void permission_object_t::test<13>()
+ {
+ LLPermissions perm;
+ LLUUID agent;
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ U32 bits = 10;
+ ensure("allowOperationBy():failed ", perm.allowOperationBy(bits,agent,group));
+
+ LLUUID agent1("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ perm.init(creator,owner,lastOwner,group);
+ ensure("allowOperationBy():failed ", perm.allowOperationBy(bits,agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<14>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ LLUUID agent;
+ ensure("1:allowModifyBy():failed ", perm.allowModifyBy(agent));
+ ensure("2:allowModifyBy():failed ", perm.allowModifyBy(agent,group));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("3:allowModifyBy():failed ", perm.allowModifyBy(agent1));
+ ensure("4:allowModifyBy():failed ", perm.allowModifyBy(agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<15>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ LLUUID agent;
+ ensure("1:allowCopyBy():failed ", perm.allowModifyBy(agent));
+ ensure("2:allowCopyBy():failed ", perm.allowModifyBy(agent,group));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("3:allowCopyBy():failed ", perm.allowCopyBy(agent1));
+ ensure("4:allowCopyBy():failed ", perm.allowCopyBy(agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<16>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ LLUUID agent;
+ ensure("1:allowMoveBy():failed ", perm.allowMoveBy(agent));
+ ensure("2:allowMoveBy():failed ", perm.allowMoveBy(agent,group));
+
+ LLUUID agent1("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ ensure("3:allowMoveBy():failed ", perm.allowMoveBy(agent1));
+ ensure("4:allowMoveBy():failed ", perm.allowMoveBy(agent1,group));
+ }
+
+ template<> template<>
+ void permission_object_t::test<17>()
+ {
+ LLPermissions perm;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner;
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ LLUUID agent;
+ ensure("1:allowMoveBy():failed ", perm.allowTransferTo(agent));
+
+ perm.init(creator,owner,lastOwner,group);
+ ensure("2:allowMoveBy():failed ", perm.allowTransferTo(agent));
+ }
+
+ template<> template<>
+ void permission_object_t::test<18>()
+ {
+ LLPermissions perm,perm1;
+ ensure_equals("1:Operator==:failed ", perm, perm1);
+
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ perm = perm1;
+ ensure_equals("2:Operator==:failed ", perm, perm1);
+ }
+
+ template<> template<>
+ void permission_object_t::test<19>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ ensure_not_equals("2:Operator==:failed ", perm, perm1);
+ }
+
+ template<> template<>
+ void permission_object_t::test<20>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+
+ U32 base = PERM_TRANSFER | PERM_COPY;
+ U32 ownerp = PERM_TRANSFER;
+ U32 groupp = PERM_TRANSFER;
+ U32 everyone = PERM_TRANSFER;
+ U32 next = PERM_NONE;
+
+ perm.initMasks(base, ownerp, everyone, groupp, next);
+
+ std::ostringstream ostream;
+ perm.exportLegacyStream(ostream);
+ std::istringstream istream(ostream.str());
+ perm1.importLegacyStream(istream);
+
+ ensure_equals("exportStream()/importStream():failed to export and import the data ", perm1, perm);
+ }
+
+ template<> template<>
+ void permission_object_t::test<21>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+ std::ostringstream stream1, stream2;
+ stream1 << perm;
+ perm1.init(creator,owner,lastOwner,group);
+ stream2 << perm1;
+ ensure_equals("1:operator << failed", stream1.str(), stream2.str());
+ }
+
+ template<> template<>
+ void permission_object_t::test<22>()
+ {
+ LLPermissions perm,perm1;
+ LLUUID creator("abf0d56b-82e5-47a2-a8ad-74741bb2c29e");
+ LLUUID owner("68edcf47-ccd7-45b8-9f90-1649d7f12806");
+ LLUUID lastOwner("5e47a0dc-97bf-44e0-8b40-de06718cee9d");
+ LLUUID group("9c8eca51-53d5-42a7-bb58-cef070395db8");
+ perm.init(creator,owner,lastOwner,group);
+
+ U32 base = PERM_TRANSFER | PERM_COPY;
+ U32 ownerp = PERM_TRANSFER;
+ U32 groupp = PERM_TRANSFER;
+ U32 everyone = PERM_TRANSFER;
+ U32 next = PERM_NONE;
+
+ perm.initMasks(base, ownerp, everyone, groupp, next);
+
+ LLSD sd = ll_create_sd_from_permissions(perm);
+ perm1 = ll_permissions_from_sd(sd);
+ ensure_equals("ll_permissions_from_sd() and ll_create_sd_from_permissions()functions failed", perm, perm1);
+ }
+
+ template<> template<>
+ void permission_object_t::test<23>()
+ {
+ LLAggregatePermissions AggrPermission;
+ LLAggregatePermissions AggrPermission1;
+ ensure_equals("getU8() function failed", AggrPermission.getU8(), 0);
+ ensure("isEmpty() function failed", AggrPermission.isEmpty());
+ AggrPermission.getValue(PERM_TRANSFER);
+ ensure_equals("getValue() function failed", AggrPermission.getValue(PERM_TRANSFER), 0x00);
+
+ AggrPermission.aggregate(PERM_ITEM_UNRESTRICTED);
+ ensure("aggregate() function failed", ! AggrPermission.isEmpty());
+
+ AggrPermission1.aggregate(AggrPermission);
+ ensure("aggregate() function failed", ! AggrPermission1.isEmpty());
+
+ std::ostringstream stream1;
+ stream1 << AggrPermission;
+ ensure_equals("operator<< failed", stream1.str(), "{PI_COPY=All, PI_MODIFY=All, PI_TRANSFER=All}");
+ }
+}
diff --git a/indra/llinventory/tests/llsaleinfo_test.cpp b/indra/llinventory/tests/llsaleinfo_test.cpp
new file mode 100644
index 0000000000..1da7101aa3
--- /dev/null
+++ b/indra/llinventory/tests/llsaleinfo_test.cpp
@@ -0,0 +1,194 @@
+/**
+ * @file LLSaleInfo_tut.cpp
+ * @author Adroit
+ * @date 2007-03
+ * @brief Test cases of llsaleinfo.h
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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 <tut/tut.hpp>
+#include "linden_common.h"
+#include "lltut.h"
+#include "llsaleinfo.h"
+
+namespace tut
+{
+ struct llsaleinfo_tut
+ {
+ };
+ typedef test_group<llsaleinfo_tut> llsaleinfo_tut_t;
+ typedef llsaleinfo_tut_t::object llsaleinfo_test_t;
+ tut::llsaleinfo_tut_t tut_llsaleinfo_test("llsaleinfo");
+
+ template<> template<>
+ void llsaleinfo_test_t::test<1>()
+ {
+ //test case for getSaleType(), getSalePrice(), getCRC32() fn.
+ //test case for setSaleType(), setSalePrice() fn.
+
+ S32 sale_price = 10000;
+ LLSaleInfo llsaleinfo(LLSaleInfo::FS_COPY, sale_price);
+ const char* sale= "copy";
+
+ LLSD llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ LLSaleInfo saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("1. The getSaleType() fn failed", LLSaleInfo::FS_COPY == llsaleinfo.getSaleType());
+ ensure("2. LLSaleInfo::isForSale() fn failed", true == llsaleinfo.isForSale());
+ ensure("3. The getSalePrice() fn failed", sale_price == llsaleinfo.getSalePrice());
+ ensure("4. The getCRC32() fn failed", 235833404 == llsaleinfo.getCRC32());
+ ensure("5. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_COPY == llsaleinfo.lookup(sale));
+ ensure_equals("6. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("7. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+
+ llsaleinfo.setSalePrice(10000000);
+ llsaleinfo.setSaleType(LLSaleInfo::FS_ORIGINAL);
+ sale = "cntn";
+ llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("8. The getSaleType() and setSaleType() fn failed", LLSaleInfo::FS_ORIGINAL == llsaleinfo.getSaleType());
+ ensure("9. LLSaleInfo::isForSale() fn failed", true == llsaleinfo.isForSale());
+ ensure("10. The getSalePrice() fn failed", 10000000 == llsaleinfo.getSalePrice());
+ ensure("11. The getCRC32() fn failed", 127911702 == llsaleinfo.getCRC32());
+ ensure("12. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_CONTENTS == llsaleinfo.lookup(sale));
+ ensure_equals("13. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("14. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+
+ llsaleinfo.setSalePrice(55000550);
+ llsaleinfo.setSaleType(LLSaleInfo::FS_CONTENTS);
+ sale = "orig";
+ llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("15. The getSaleType() and setSaleType() fn failed", LLSaleInfo::FS_CONTENTS == llsaleinfo.getSaleType());
+ ensure("16. LLSaleInfo::isForSale() fn failed", true == llsaleinfo.isForSale());
+ ensure("17. The getSalePrice() fn failed", 55000550 == llsaleinfo.getSalePrice());
+ ensure("18. The getCRC32() fn failed", 408735656 == llsaleinfo.getCRC32());
+ ensure("19. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_ORIGINAL == llsaleinfo.lookup(sale));
+ ensure_equals("20. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("21. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+
+ llsaleinfo.setSalePrice(-6432);
+ llsaleinfo.setSaleType(LLSaleInfo::FS_NOT);
+ sale = "not";
+ llsd_obj1 = ll_create_sd_from_sale_info(llsaleinfo);
+ saleinfo1 = ll_sale_info_from_sd(llsd_obj1);
+
+ ensure("22. The getSaleType() and setSaleType() fn failed", LLSaleInfo::FS_NOT == llsaleinfo.getSaleType());
+ ensure("23. LLSaleInfo::isForSale() fn failed", false == llsaleinfo.isForSale());
+ ensure("24. The getSalePrice() fn failed", 0 == llsaleinfo.getSalePrice());
+ ensure("25. The getCRC32() fn failed", 0 == llsaleinfo.getCRC32());
+ ensure("26. LLSaleInfo::lookup(const char* name) fn failed", LLSaleInfo::FS_NOT == llsaleinfo.lookup(sale));
+ ensure_equals("27. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("28. ll_create_sd_from_sale_info() fn failed", llsaleinfo.getSaleType(), saleinfo1.getSaleType());
+ }
+
+ template<> template<>
+ void llsaleinfo_test_t::test<2>()
+ {
+ S32 sale_price = 525452;
+ LLSaleInfo llsaleinfo(LLSaleInfo::FS_ORIGINAL, sale_price);
+
+ std::ostringstream ostream;
+ llsaleinfo.exportLegacyStream(ostream);
+
+ std::istringstream istream(ostream.str());
+ LLSaleInfo llsaleinfo1;
+ U32 perm_mask = 0;
+ bool has_perm_mask = false;
+ llsaleinfo1.importLegacyStream(istream, has_perm_mask, perm_mask);
+
+ ensure("importStream() fn failed ",
+ llsaleinfo.getSalePrice() == llsaleinfo1.getSalePrice() &&
+ llsaleinfo.getSaleType() == llsaleinfo1.getSaleType());
+ }
+
+ template<> template<>
+ void llsaleinfo_test_t::test<3>()
+ {
+ S32 sale_price = 99000;
+ LLSaleInfo saleinfo(LLSaleInfo::FS_ORIGINAL, sale_price);
+
+ LLSD sd_result = saleinfo.asLLSD();
+
+ U32 perm_mask = 0 ;
+ bool has_perm_mask = false;
+
+ LLSaleInfo saleinfo1;
+ saleinfo1.fromLLSD( sd_result, has_perm_mask, perm_mask);
+
+ ensure_equals("asLLSD and fromLLSD failed", saleinfo.getSalePrice(), saleinfo1.getSalePrice());
+ ensure_equals("asLLSD and fromLLSD failed", saleinfo.getSaleType(), saleinfo1.getSaleType());
+ }
+
+ //static EForSale lookup(const char* name) fn test
+ template<> template<>
+ void llsaleinfo_test_t::test<4>()
+ {
+ S32 sale_price = 233223;
+ LLSaleInfo::EForSale ret_type = LLSaleInfo::lookup("orig");
+
+ ensure_equals("lookup(const char* name) fn failed", ret_type, LLSaleInfo::FS_ORIGINAL);
+
+ LLSaleInfo saleinfo(LLSaleInfo::FS_COPY, sale_price);
+ const char* result = LLSaleInfo::lookup(LLSaleInfo::FS_COPY);
+ ensure("char* lookup(EForSale type) fn failed", 0 == strcmp("copy", result));
+ }
+
+ //void LLSaleInfo::accumulate(const LLSaleInfo& sale_info) fn test
+ template<> template<>
+ void llsaleinfo_test_t::test<5>()
+ {
+ S32 sale_price = 20;
+ LLSaleInfo saleinfo(LLSaleInfo::FS_COPY, sale_price);
+ LLSaleInfo saleinfo1(LLSaleInfo::FS_COPY, sale_price);
+ saleinfo1.accumulate(saleinfo);
+ ensure_equals("LLSaleInfo::accumulate(const LLSaleInfo& sale_info) fn failed", saleinfo1.getSalePrice(), 40);
+
+ }
+
+ // test cases of bool operator==(const LLSaleInfo &rhs) fn
+ // test case of bool operator!=(const LLSaleInfo &rhs) fn
+ template<> template<>
+ void llsaleinfo_test_t::test<6>()
+ {
+ S32 sale_price = 55000;
+ LLSaleInfo saleinfo(LLSaleInfo::FS_ORIGINAL, sale_price);
+ LLSaleInfo saleinfoequal(LLSaleInfo::FS_ORIGINAL, sale_price);
+ LLSaleInfo saleinfonotequal(LLSaleInfo::FS_ORIGINAL, sale_price*2);
+
+ ensure("operator == fn. failed", true == (saleinfo == saleinfoequal));
+ ensure("operator != fn. failed", true == (saleinfo != saleinfonotequal));
+ }
+
+ template<> template<>
+ void llsaleinfo_test_t::test<7>()
+ {
+
+ //TBD: void LLSaleInfo::packMessage(LLMessageSystem* msg) const
+ //TBD: void LLSaleInfo::unpackMessage(LLMessageSystem* msg, const char* block)
+ //TBD: void LLSaleInfo::unpackMultiMessage(LLMessageSystem* msg, const char* block, S32 block_num)
+ }
+
+}
diff --git a/indra/llinventory/tests/lluserrelations_test.cpp b/indra/llinventory/tests/lluserrelations_test.cpp
new file mode 100644
index 0000000000..80a659da65
--- /dev/null
+++ b/indra/llinventory/tests/lluserrelations_test.cpp
@@ -0,0 +1,156 @@
+/**
+ * @file lluserrelations_tut.cpp
+ * @author Phoenix
+ * @date 2006-10-12
+ * @brief Unit tests for the LLRelationship class.
+ *
+ * $LicenseInfo:firstyear=2006&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, 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 <tut/tut.hpp>
+
+#include "linden_common.h"
+#include "lluserrelations.h"
+
+namespace tut
+{
+ struct user_relationship
+ {
+ LLRelationship mRelationship;
+ };
+ typedef test_group<user_relationship> user_relationship_t;
+ typedef user_relationship_t::object user_relationship_object_t;
+ tut::user_relationship_t tut_user_relationship("relationships");
+
+ template<> template<>
+ void user_relationship_object_t::test<1>()
+ {
+ // Test the default construction
+ ensure(
+ "No granted rights to",
+ !mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "No granted rights from",
+ !mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure("No online status",!mRelationship.isOnline());
+ }
+
+ template<> template<>
+ void user_relationship_object_t::test<2>()
+ {
+ // Test some granting
+ mRelationship.grantRights(
+ LLRelationship::GRANT_ONLINE_STATUS,
+ LLRelationship::GRANT_MODIFY_OBJECTS);
+ ensure(
+ "Granted rights to has online",
+ mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights from does not have online",
+ !mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights to does not have modify",
+ !mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_MODIFY_OBJECTS));
+ ensure(
+ "Granted rights from has modify",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_MODIFY_OBJECTS));
+ }
+
+ template<> template<>
+ void user_relationship_object_t::test<3>()
+ {
+ // Test revoking
+ mRelationship.grantRights(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MAP_LOCATION,
+ LLRelationship::GRANT_ONLINE_STATUS);
+ ensure(
+ "Granted rights to has online and map",
+ mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MAP_LOCATION));
+ ensure(
+ "Granted rights from has online",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+
+ mRelationship.revokeRights(
+ LLRelationship::GRANT_MAP_LOCATION,
+ LLRelationship::GRANT_NONE);
+ ensure(
+ "Granted rights revoked map",
+ !mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MAP_LOCATION));
+ ensure(
+ "Granted rights revoked still has online",
+ mRelationship.isRightGrantedTo(
+ LLRelationship::GRANT_ONLINE_STATUS));
+
+ mRelationship.grantRights(
+ LLRelationship::GRANT_NONE,
+ LLRelationship::GRANT_MODIFY_OBJECTS);
+ ensure(
+ "Granted rights from still has online",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights from has full grant",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS
+ | LLRelationship::GRANT_MODIFY_OBJECTS));
+ mRelationship.revokeRights(
+ LLRelationship::GRANT_NONE,
+ LLRelationship::GRANT_MODIFY_OBJECTS);
+ ensure(
+ "Granted rights from still has online",
+ mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_ONLINE_STATUS));
+ ensure(
+ "Granted rights from no longer modify",
+ !mRelationship.isRightGrantedFrom(
+ LLRelationship::GRANT_MODIFY_OBJECTS));
+ }
+
+ template<> template<>
+ void user_relationship_object_t::test<4>()
+ {
+ ensure("No online status", !mRelationship.isOnline());
+ mRelationship.online(true);
+ ensure("Online status", mRelationship.isOnline());
+ mRelationship.online(false);
+ ensure("No online status", !mRelationship.isOnline());
+ }
+
+/*
+ template<> template<>
+ void user_relationship_object_t::test<>()
+ {
+ }
+*/
+}