/indra/test/lluserrelations_tut.cpp

https://bitbucket.org/lindenlab/viewer-beta/ · C++ · 156 lines · 110 code · 10 blank · 36 comment · 0 complexity · f3c4117f04bbc12b2cd563ac27b713de MD5 · raw file

  1. /**
  2. * @file lluserrelations_tut.cpp
  3. * @author Phoenix
  4. * @date 2006-10-12
  5. * @brief Unit tests for the LLRelationship class.
  6. *
  7. * $LicenseInfo:firstyear=2006&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #include <tut/tut.hpp>
  29. #include "linden_common.h"
  30. #include "lluserrelations.h"
  31. namespace tut
  32. {
  33. struct user_relationship
  34. {
  35. LLRelationship mRelationship;
  36. };
  37. typedef test_group<user_relationship> user_relationship_t;
  38. typedef user_relationship_t::object user_relationship_object_t;
  39. tut::user_relationship_t tut_user_relationship("relationships");
  40. template<> template<>
  41. void user_relationship_object_t::test<1>()
  42. {
  43. // Test the default construction
  44. ensure(
  45. "No granted rights to",
  46. !mRelationship.isRightGrantedTo(
  47. LLRelationship::GRANT_ONLINE_STATUS));
  48. ensure(
  49. "No granted rights from",
  50. !mRelationship.isRightGrantedFrom(
  51. LLRelationship::GRANT_ONLINE_STATUS));
  52. ensure("No online status",!mRelationship.isOnline());
  53. }
  54. template<> template<>
  55. void user_relationship_object_t::test<2>()
  56. {
  57. // Test some granting
  58. mRelationship.grantRights(
  59. LLRelationship::GRANT_ONLINE_STATUS,
  60. LLRelationship::GRANT_MODIFY_OBJECTS);
  61. ensure(
  62. "Granted rights to has online",
  63. mRelationship.isRightGrantedTo(
  64. LLRelationship::GRANT_ONLINE_STATUS));
  65. ensure(
  66. "Granted rights from does not have online",
  67. !mRelationship.isRightGrantedFrom(
  68. LLRelationship::GRANT_ONLINE_STATUS));
  69. ensure(
  70. "Granted rights to does not have modify",
  71. !mRelationship.isRightGrantedTo(
  72. LLRelationship::GRANT_MODIFY_OBJECTS));
  73. ensure(
  74. "Granted rights from has modify",
  75. mRelationship.isRightGrantedFrom(
  76. LLRelationship::GRANT_MODIFY_OBJECTS));
  77. }
  78. template<> template<>
  79. void user_relationship_object_t::test<3>()
  80. {
  81. // Test revoking
  82. mRelationship.grantRights(
  83. LLRelationship::GRANT_ONLINE_STATUS
  84. | LLRelationship::GRANT_MAP_LOCATION,
  85. LLRelationship::GRANT_ONLINE_STATUS);
  86. ensure(
  87. "Granted rights to has online and map",
  88. mRelationship.isRightGrantedTo(
  89. LLRelationship::GRANT_ONLINE_STATUS
  90. | LLRelationship::GRANT_MAP_LOCATION));
  91. ensure(
  92. "Granted rights from has online",
  93. mRelationship.isRightGrantedFrom(
  94. LLRelationship::GRANT_ONLINE_STATUS));
  95. mRelationship.revokeRights(
  96. LLRelationship::GRANT_MAP_LOCATION,
  97. LLRelationship::GRANT_NONE);
  98. ensure(
  99. "Granted rights revoked map",
  100. !mRelationship.isRightGrantedTo(
  101. LLRelationship::GRANT_ONLINE_STATUS
  102. | LLRelationship::GRANT_MAP_LOCATION));
  103. ensure(
  104. "Granted rights revoked still has online",
  105. mRelationship.isRightGrantedTo(
  106. LLRelationship::GRANT_ONLINE_STATUS));
  107. mRelationship.grantRights(
  108. LLRelationship::GRANT_NONE,
  109. LLRelationship::GRANT_MODIFY_OBJECTS);
  110. ensure(
  111. "Granted rights from still has online",
  112. mRelationship.isRightGrantedFrom(
  113. LLRelationship::GRANT_ONLINE_STATUS));
  114. ensure(
  115. "Granted rights from has full grant",
  116. mRelationship.isRightGrantedFrom(
  117. LLRelationship::GRANT_ONLINE_STATUS
  118. | LLRelationship::GRANT_MODIFY_OBJECTS));
  119. mRelationship.revokeRights(
  120. LLRelationship::GRANT_NONE,
  121. LLRelationship::GRANT_MODIFY_OBJECTS);
  122. ensure(
  123. "Granted rights from still has online",
  124. mRelationship.isRightGrantedFrom(
  125. LLRelationship::GRANT_ONLINE_STATUS));
  126. ensure(
  127. "Granted rights from no longer modify",
  128. !mRelationship.isRightGrantedFrom(
  129. LLRelationship::GRANT_MODIFY_OBJECTS));
  130. }
  131. template<> template<>
  132. void user_relationship_object_t::test<4>()
  133. {
  134. ensure("No online status", !mRelationship.isOnline());
  135. mRelationship.online(true);
  136. ensure("Online status", mRelationship.isOnline());
  137. mRelationship.online(false);
  138. ensure("No online status", !mRelationship.isOnline());
  139. }
  140. /*
  141. template<> template<>
  142. void user_relationship_object_t::test<>()
  143. {
  144. }
  145. */
  146. }