diff options
author | Justin Clark-Casey (justincc) | 2012-03-30 00:40:19 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-03-30 00:42:55 +0100 |
commit | 59157d9d63c0e038ca0a619bfae1be3ed6f77677 (patch) | |
tree | 76e7ba7de91aedad887a6ac0633598d53ce30df3 /OpenSim/Region/CoreModules/Avatar/Friends/Tests | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC_OLD-59157d9d63c0e038ca0a619bfae1be3ed6f77677.zip opensim-SC_OLD-59157d9d63c0e038ca0a619bfae1be3ed6f77677.tar.gz opensim-SC_OLD-59157d9d63c0e038ca0a619bfae1be3ed6f77677.tar.bz2 opensim-SC_OLD-59157d9d63c0e038ca0a619bfae1be3ed6f77677.tar.xz |
Add simple login test with online friends. Add IFriendsModule.GrantRights() for granting rights via a module call.
Rename IFriendsModule.GetFriendPerms() -> GetRightsGrantedByFriend() to be more self-documenting and consistent with friends module terminology.
Add some method doc.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Friends/Tests')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index 94a78cb..45b4264 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using Nini.Config; | 30 | using Nini.Config; |
31 | using NUnit.Framework; | 31 | using NUnit.Framework; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Data.Null; | ||
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Region.CoreModules.Avatar.Friends; | 35 | using OpenSim.Region.CoreModules.Avatar.Friends; |
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
@@ -63,6 +64,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
63 | [SetUp] | 64 | [SetUp] |
64 | public void Init() | 65 | public void Init() |
65 | { | 66 | { |
67 | // We must clear friends data between tests since Data.Null holds it in static properties. This is necessary | ||
68 | // so that different services and simulator can share the data in standalone mode. This is pretty horrible | ||
69 | // effectively the statics are global variables. | ||
70 | NullFriendsData.Clear(); | ||
71 | |||
66 | IConfigSource config = new IniConfigSource(); | 72 | IConfigSource config = new IniConfigSource(); |
67 | config.AddConfig("Modules"); | 73 | config.AddConfig("Modules"); |
68 | // Not strictly necessary since FriendsModule assumes it is the default (!) | 74 | // Not strictly necessary since FriendsModule assumes it is the default (!) |
@@ -110,8 +116,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
110 | 116 | ||
111 | m_fm.AddFriendship(sp1.ControllingClient, user2Id); | 117 | m_fm.AddFriendship(sp1.ControllingClient, user2Id); |
112 | 118 | ||
113 | m_scene.RemoveClient(sp1.UUID, true); | 119 | // Not necessary for this test. CanSeeOnline is automatically granted. |
114 | m_scene.RemoveClient(sp2.UUID, true); | 120 | // m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline); |
121 | |||
122 | // We must logout from the client end so that the presence service is correctly updated by the presence | ||
123 | // detector. This is listening to the OnConnectionClosed event on the client. | ||
124 | ((TestClient)sp1.ControllingClient).Logout(); | ||
125 | ((TestClient)sp2.ControllingClient).Logout(); | ||
126 | // m_scene.RemoveClient(sp1.UUID, true); | ||
127 | // m_scene.RemoveClient(sp2.UUID, true); | ||
115 | 128 | ||
116 | ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id); | 129 | ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id); |
117 | 130 | ||
@@ -120,33 +133,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | |||
120 | Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0)); | 133 | Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0)); |
121 | } | 134 | } |
122 | 135 | ||
123 | // [Test] | 136 | [Test] |
124 | // public void TestLoginWithOnlineFriends() | 137 | public void TestLoginWithOnlineFriends() |
125 | // { | 138 | { |
126 | // TestHelpers.InMethod(); | 139 | TestHelpers.InMethod(); |
127 | // log4net.Config.XmlConfigurator.Configure(); | 140 | // log4net.Config.XmlConfigurator.Configure(); |
141 | |||
142 | UUID user1Id = TestHelpers.ParseTail(0x1); | ||
143 | UUID user2Id = TestHelpers.ParseTail(0x2); | ||
144 | |||
145 | // UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id); | ||
146 | // UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); | ||
128 | // | 147 | // |
129 | // UUID user1Id = TestHelpers.ParseTail(0x1); | 148 | // m_fm.AddFriendship(user1Id, user2Id); |
130 | // UUID user2Id = TestHelpers.ParseTail(0x2); | 149 | |
131 | // | 150 | ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id); |
132 | //// UserAccountHelpers.CreateUserWithInventory(m_scene, user1Id); | 151 | ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, user2Id); |
133 | //// UserAccountHelpers.CreateUserWithInventory(m_scene, user2Id); | 152 | |
134 | //// | 153 | m_fm.AddFriendship(sp1.ControllingClient, user2Id); |
135 | //// m_fm.AddFriendship(user1Id, user2Id); | 154 | |
136 | // | 155 | // Not necessary for this test. CanSeeOnline is automatically granted. |
137 | // ScenePresence sp1 = SceneHelpers.AddScenePresence(m_scene, user1Id); | 156 | // m_fm.GrantRights(sp1.ControllingClient, user2Id, (int)FriendRights.CanSeeOnline); |
138 | // SceneHelpers.AddScenePresence(m_scene, user2Id); | 157 | |
139 | // | 158 | // We must logout from the client end so that the presence service is correctly updated by the presence |
140 | // m_fm.AddFriendship(sp1.ControllingClient, user2Id); | 159 | // detector. This is listening to the OnConnectionClosed event on the client. |
141 | //// m_fm.LocalGrantRights | 160 | // ((TestClient)sp1.ControllingClient).Logout(); |
142 | // | 161 | ((TestClient)sp2.ControllingClient).Logout(); |
143 | // m_scene.RemoveClient(sp1.UUID, true); | 162 | // m_scene.RemoveClient(user2Id, true); |
144 | // | 163 | |
145 | // ScenePresence sp1Redux = SceneHelpers.AddScenePresence(m_scene, user1Id); | 164 | ScenePresence sp2Redux = SceneHelpers.AddScenePresence(m_scene, user2Id); |
146 | // | 165 | |
147 | // Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0)); | 166 | Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0)); |
148 | // Assert.That(((TestClient)sp1Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1)); | 167 | Assert.That(((TestClient)sp2Redux.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1)); |
149 | // } | 168 | } |
150 | 169 | ||
151 | [Test] | 170 | [Test] |
152 | public void TestAddFriendshipWhileOnline() | 171 | public void TestAddFriendshipWhileOnline() |