PageRenderTime 129ms CodeModel.GetById 115ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 29#include <tut/tut.hpp>
 30
 31#include "linden_common.h"
 32#include "lluserrelations.h"
 33
 34namespace tut
 35{
 36	struct user_relationship
 37	{
 38		LLRelationship mRelationship;
 39	};
 40	typedef test_group<user_relationship> user_relationship_t;
 41	typedef user_relationship_t::object user_relationship_object_t;
 42	tut::user_relationship_t tut_user_relationship("relationships");
 43
 44	template<> template<>
 45	void user_relationship_object_t::test<1>()
 46	{
 47		// Test the default construction
 48		ensure(
 49			"No granted rights to",
 50			!mRelationship.isRightGrantedTo(
 51				LLRelationship::GRANT_ONLINE_STATUS));
 52		ensure(
 53			"No granted rights from",
 54			!mRelationship.isRightGrantedFrom(
 55				LLRelationship::GRANT_ONLINE_STATUS));
 56		ensure("No online status",!mRelationship.isOnline());
 57	}
 58
 59	template<> template<>
 60	void user_relationship_object_t::test<2>()
 61	{
 62		// Test some granting
 63		mRelationship.grantRights(
 64			LLRelationship::GRANT_ONLINE_STATUS,
 65			LLRelationship::GRANT_MODIFY_OBJECTS);
 66		ensure(
 67			"Granted rights to has online",
 68			mRelationship.isRightGrantedTo(
 69				LLRelationship::GRANT_ONLINE_STATUS));
 70		ensure(
 71			"Granted rights from does not have online",
 72			!mRelationship.isRightGrantedFrom(
 73				LLRelationship::GRANT_ONLINE_STATUS));
 74		ensure(
 75			"Granted rights to does not have modify",
 76			!mRelationship.isRightGrantedTo(
 77				LLRelationship::GRANT_MODIFY_OBJECTS));
 78		ensure(
 79			"Granted rights from has modify",
 80			mRelationship.isRightGrantedFrom(
 81				LLRelationship::GRANT_MODIFY_OBJECTS));
 82	}
 83
 84	template<> template<>
 85	void user_relationship_object_t::test<3>()
 86	{
 87		// Test revoking
 88		mRelationship.grantRights(
 89			LLRelationship::GRANT_ONLINE_STATUS
 90			| LLRelationship::GRANT_MAP_LOCATION,
 91			LLRelationship::GRANT_ONLINE_STATUS);
 92		ensure(
 93			"Granted rights to has online and map",
 94			mRelationship.isRightGrantedTo(
 95				LLRelationship::GRANT_ONLINE_STATUS
 96				| LLRelationship::GRANT_MAP_LOCATION));
 97		ensure(
 98			"Granted rights from has online",
 99			mRelationship.isRightGrantedFrom(
100				LLRelationship::GRANT_ONLINE_STATUS));
101
102		mRelationship.revokeRights(
103			LLRelationship::GRANT_MAP_LOCATION,
104			LLRelationship::GRANT_NONE);
105		ensure(
106			"Granted rights revoked map",
107			!mRelationship.isRightGrantedTo(
108				LLRelationship::GRANT_ONLINE_STATUS
109				| LLRelationship::GRANT_MAP_LOCATION));
110		ensure(
111			"Granted rights revoked still has online",
112			mRelationship.isRightGrantedTo(
113				LLRelationship::GRANT_ONLINE_STATUS));
114
115		mRelationship.grantRights(
116			LLRelationship::GRANT_NONE,
117			LLRelationship::GRANT_MODIFY_OBJECTS);
118		ensure(
119			"Granted rights from still has online",
120			mRelationship.isRightGrantedFrom(
121				LLRelationship::GRANT_ONLINE_STATUS));
122		ensure(
123			"Granted rights from has full grant",
124			mRelationship.isRightGrantedFrom(
125				LLRelationship::GRANT_ONLINE_STATUS
126				| LLRelationship::GRANT_MODIFY_OBJECTS));
127		mRelationship.revokeRights(
128			LLRelationship::GRANT_NONE,
129			LLRelationship::GRANT_MODIFY_OBJECTS);
130		ensure(
131			"Granted rights from still has online",
132			mRelationship.isRightGrantedFrom(
133				LLRelationship::GRANT_ONLINE_STATUS));
134		ensure(
135			"Granted rights from no longer modify",
136			!mRelationship.isRightGrantedFrom(
137				LLRelationship::GRANT_MODIFY_OBJECTS));	
138	}
139
140	template<> template<>
141	void user_relationship_object_t::test<4>()
142	{
143		ensure("No online status", !mRelationship.isOnline());
144		mRelationship.online(true);
145		ensure("Online status", mRelationship.isOnline());
146		mRelationship.online(false);
147		ensure("No online status", !mRelationship.isOnline());
148	}
149
150/*
151	template<> template<>
152	void user_relationship_object_t::test<>()
153	{
154	}
155*/
156}