aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-14 20:56:56 +0000
committerJustin Clark-Casey (justincc)2011-11-14 20:56:56 +0000
commit89632f3ea8c355e5e860eb787aa21f90e79762d8 (patch)
treeff57923dd8ce7ca63e5b57bc2f2d05f745065691 /OpenSim/Region/CoreModules/Avatar
parentMerge branch 'remove-scene-viewer' (diff)
downloadopensim-SC-89632f3ea8c355e5e860eb787aa21f90e79762d8.zip
opensim-SC-89632f3ea8c355e5e860eb787aa21f90e79762d8.tar.gz
opensim-SC-89632f3ea8c355e5e860eb787aa21f90e79762d8.tar.bz2
opensim-SC-89632f3ea8c355e5e860eb787aa21f90e79762d8.tar.xz
Add test for removing a friendship.
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs30
2 files changed, 31 insertions, 11 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 7a2a46e..529d7cf 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -241,7 +241,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
241 client.OnInstantMessage += OnInstantMessage; 241 client.OnInstantMessage += OnInstantMessage;
242 client.OnApproveFriendRequest += OnApproveFriendRequest; 242 client.OnApproveFriendRequest += OnApproveFriendRequest;
243 client.OnDenyFriendRequest += OnDenyFriendRequest; 243 client.OnDenyFriendRequest += OnDenyFriendRequest;
244 client.OnTerminateFriendship += OnTerminateFriendship; 244 client.OnTerminateFriendship += (thisClient, agentID, exfriendID) => RemoveFriendship(thisClient, exfriendID);
245 client.OnGrantUserRights += OnGrantUserRights; 245 client.OnGrantUserRights += OnGrantUserRights;
246 246
247 Util.FireAndForget(delegate { FetchFriendslist(client); }); 247 Util.FireAndForget(delegate { FetchFriendslist(client); });
@@ -635,10 +635,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
635 } 635 }
636 } 636 }
637 } 637 }
638 638
639 private void OnTerminateFriendship(IClientAPI client, UUID agentID, UUID exfriendID) 639 public void RemoveFriendship(IClientAPI client, UUID exfriendID)
640 { 640 {
641 if (!DeleteFriendship(agentID, exfriendID)) 641 if (!DeleteFriendship(client.AgentId, exfriendID))
642 client.SendAlertMessage("Unable to terminate friendship on this sim."); 642 client.SendAlertMessage("Unable to terminate friendship on this sim.");
643 643
644 // Update local cache 644 // Update local cache
@@ -661,9 +661,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
661 if (friendSession != null) 661 if (friendSession != null)
662 { 662 {
663 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 663 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
664 m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); 664 m_FriendsSimConnector.FriendshipTerminated(region, client.AgentId, exfriendID);
665 } 665 }
666 } 666 }
667 } 667 }
668 668
669 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights) 669 private void OnGrantUserRights(IClientAPI remoteClient, UUID requester, UUID target, int rights)
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
index c945dcf..682fbab 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs
@@ -71,12 +71,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
71 71
72 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); 72 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
73 73
74 Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0)); 74 Assert.That(((TestClient)sp.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
75 Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(0)); 75 Assert.That(((TestClient)sp.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(0));
76 } 76 }
77 77
78 [Test] 78 [Test]
79 public void TestAddFriendWhileOnline() 79 public void TestAddFriendshipWhileOnline()
80 { 80 {
81 TestHelpers.InMethod(); 81 TestHelpers.InMethod();
82// log4net.Config.XmlConfigurator.Configure(); 82// log4net.Config.XmlConfigurator.Configure();
@@ -91,8 +91,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests
91 // notification. 91 // notification.
92 m_fm.AddFriendship(sp.ControllingClient, user2Id); 92 m_fm.AddFriendship(sp.ControllingClient, user2Id);
93 93
94 Assert.That(((TestClient)sp.ControllingClient).OfflineNotificationsReceived.Count, Is.EqualTo(0)); 94 Assert.That(((TestClient)sp.ControllingClient).ReceivedOfflineNotifications.Count, Is.EqualTo(0));
95 Assert.That(((TestClient)sp.ControllingClient).OnlineNotificationsReceived.Count, Is.EqualTo(1)); 95 Assert.That(((TestClient)sp.ControllingClient).ReceivedOnlineNotifications.Count, Is.EqualTo(1));
96 }
97
98 [Test]
99 public void TestRemoveFriendshipWhileOnline()
100 {
101 TestHelpers.InMethod();
102// log4net.Config.XmlConfigurator.Configure();
103
104 UUID user1Id = TestHelpers.ParseTail(0x1);
105 UUID user2Id = TestHelpers.ParseTail(0x2);
106
107 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, user1Id);
108 SceneHelpers.AddScenePresence(m_scene, user2Id);
109
110 m_fm.AddFriendship(sp.ControllingClient, user2Id);
111 m_fm.RemoveFriendship(sp.ControllingClient, user2Id);
112
113 TestClient user1Client = sp.ControllingClient as TestClient;
114 Assert.That(user1Client.ReceivedFriendshipTerminations.Count, Is.EqualTo(1));
115 Assert.That(user1Client.ReceivedFriendshipTerminations[0], Is.EqualTo(user2Id));
96 } 116 }
97 } 117 }
98} \ No newline at end of file 118} \ No newline at end of file