00001
00034 #include <tut/tut.h>
00035
00036 #include "linden_common.h"
00037 #include "lluserrelations.h"
00038
00039 namespace tut
00040 {
00041 struct user_relationship
00042 {
00043 LLRelationship mRelationship;
00044 };
00045 typedef test_group<user_relationship> user_relationship_t;
00046 typedef user_relationship_t::object user_relationship_object_t;
00047 tut::user_relationship_t tut_user_relationship("relationships");
00048
00049 template<> template<>
00050 void user_relationship_object_t::test<1>()
00051 {
00052
00053 ensure(
00054 "No granted rights to",
00055 !mRelationship.isRightGrantedTo(
00056 LLRelationship::GRANT_ONLINE_STATUS));
00057 ensure(
00058 "No granted rights from",
00059 !mRelationship.isRightGrantedFrom(
00060 LLRelationship::GRANT_ONLINE_STATUS));
00061 ensure("No online status",!mRelationship.isOnline());
00062 }
00063
00064 template<> template<>
00065 void user_relationship_object_t::test<2>()
00066 {
00067
00068 mRelationship.grantRights(
00069 LLRelationship::GRANT_ONLINE_STATUS,
00070 LLRelationship::GRANT_MODIFY_OBJECTS);
00071 ensure(
00072 "Granted rights to has online",
00073 mRelationship.isRightGrantedTo(
00074 LLRelationship::GRANT_ONLINE_STATUS));
00075 ensure(
00076 "Granted rights from does not have online",
00077 !mRelationship.isRightGrantedFrom(
00078 LLRelationship::GRANT_ONLINE_STATUS));
00079 ensure(
00080 "Granted rights to does not have modify",
00081 !mRelationship.isRightGrantedTo(
00082 LLRelationship::GRANT_MODIFY_OBJECTS));
00083 ensure(
00084 "Granted rights from has modify",
00085 mRelationship.isRightGrantedFrom(
00086 LLRelationship::GRANT_MODIFY_OBJECTS));
00087 }
00088
00089 template<> template<>
00090 void user_relationship_object_t::test<3>()
00091 {
00092
00093 mRelationship.grantRights(
00094 LLRelationship::GRANT_ONLINE_STATUS
00095 | LLRelationship::GRANT_MAP_LOCATION,
00096 LLRelationship::GRANT_ONLINE_STATUS);
00097 ensure(
00098 "Granted rights to has online and map",
00099 mRelationship.isRightGrantedTo(
00100 LLRelationship::GRANT_ONLINE_STATUS
00101 | LLRelationship::GRANT_MAP_LOCATION));
00102 ensure(
00103 "Granted rights from has online",
00104 mRelationship.isRightGrantedFrom(
00105 LLRelationship::GRANT_ONLINE_STATUS));
00106
00107 mRelationship.revokeRights(
00108 LLRelationship::GRANT_MAP_LOCATION,
00109 LLRelationship::GRANT_NONE);
00110 ensure(
00111 "Granted rights revoked map",
00112 !mRelationship.isRightGrantedTo(
00113 LLRelationship::GRANT_ONLINE_STATUS
00114 | LLRelationship::GRANT_MAP_LOCATION));
00115 ensure(
00116 "Granted rights revoked still has online",
00117 mRelationship.isRightGrantedTo(
00118 LLRelationship::GRANT_ONLINE_STATUS));
00119
00120 mRelationship.grantRights(
00121 LLRelationship::GRANT_NONE,
00122 LLRelationship::GRANT_MODIFY_OBJECTS);
00123 ensure(
00124 "Granted rights from still has online",
00125 mRelationship.isRightGrantedFrom(
00126 LLRelationship::GRANT_ONLINE_STATUS));
00127 ensure(
00128 "Granted rights from has full grant",
00129 mRelationship.isRightGrantedFrom(
00130 LLRelationship::GRANT_ONLINE_STATUS
00131 | LLRelationship::GRANT_MODIFY_OBJECTS));
00132 mRelationship.revokeRights(
00133 LLRelationship::GRANT_NONE,
00134 LLRelationship::GRANT_MODIFY_OBJECTS);
00135 ensure(
00136 "Granted rights from still has online",
00137 mRelationship.isRightGrantedFrom(
00138 LLRelationship::GRANT_ONLINE_STATUS));
00139 ensure(
00140 "Granted rights from no longer modify",
00141 !mRelationship.isRightGrantedFrom(
00142 LLRelationship::GRANT_MODIFY_OBJECTS));
00143 }
00144
00145 template<> template<>
00146 void user_relationship_object_t::test<4>()
00147 {
00148 ensure("No online status", !mRelationship.isOnline());
00149 mRelationship.online(true);
00150 ensure("Online status", mRelationship.isOnline());
00151 mRelationship.online(false);
00152 ensure("No online status", !mRelationship.isOnline());
00153 }
00154
00155
00156
00157
00158
00159
00160
00161 }