From a7e145bdfdb994f4c171d32740790cffc3fc4ad3 Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Fri, 12 Dec 2008 18:48:29 +0000 Subject: * refactor: pull out common user profile test code into utility functions --- .../Communications/Cache/CachedUserInfo.cs | 1 - .../Tests/Cache/UserProfileCacheServiceTests.cs | 61 ++++++---------------- OpenSim/Region/Environment/Scenes/EventManager.cs | 4 ++ OpenSim/Region/Environment/Scenes/SceneBase.cs | 8 +-- 4 files changed, 25 insertions(+), 49 deletions(-) diff --git a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs index d597aad..b6ac6c9 100644 --- a/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs +++ b/OpenSim/Framework/Communications/Cache/CachedUserInfo.cs @@ -141,7 +141,6 @@ namespace OpenSim.Framework.Communications.Cache } } - /// /// Recursively, in depth-first order, add all the folders we've received (stored /// in a dictionary indexed by parent ID) into the tree that describes user folder diff --git a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs index 9c07734..6632643 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/UserProfileCacheServiceTests.cs @@ -48,20 +48,17 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetUserDetails() { - UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); + UUID nonExistingUserId = UUID.Parse("00000000-0000-0000-0000-000000000001"); UUID existingUserId = UUID.Parse("00000000-0000-0000-0000-000000000002"); - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); - + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo existingUserInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, existingUserId); + + Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); + CachedUserInfo nonExistingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(nonExistingUserId); - Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, existingUserId); - CachedUserInfo existingUserInfo = commsManager.UserProfileCacheService.GetUserDetails(existingUserId); - Assert.That(existingUserInfo, Is.Not.Null, "Existing user info unexpectedly not found"); + Assert.That(nonExistingUserInfo, Is.Null, "Non existing user info unexpectedly found"); } /// @@ -70,18 +67,9 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestRequestInventoryForUser() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000003"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); Assert.That(userInfo.HasReceivedInventory, Is.True); } @@ -91,19 +79,12 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestCreateFolder() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000004"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - TestInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(inventoryDataPlugin); + IUserDataPlugin userDataPlugin = new TestUserDataPlugin(); + IInventoryDataPlugin inventoryDataPlugin = new TestInventoryDataPlugin(); - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + CommunicationsManager commsManager + = UserProfileTestUtils.SetupServices(userDataPlugin, inventoryDataPlugin); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010"); Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False); @@ -119,18 +100,8 @@ namespace OpenSim.Framework.Communications.Tests [Test] public void TestGetChildFolder() { - UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000005"); - - CommunicationsManager commsManager = new TestCommunicationsManager(); - LocalUserServices lus = (LocalUserServices)commsManager.UserService; - lus.AddPlugin(new TestUserDataPlugin()); - ((LocalInventoryService)commsManager.InventoryService).AddPlugin(new TestInventoryDataPlugin()); - - lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId); - - commsManager.UserProfileCacheService.RequestInventoryForUser(userId); - - CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId); + CommunicationsManager commsManager = UserProfileTestUtils.SetupServices(); + CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011"); diff --git a/OpenSim/Region/Environment/Scenes/EventManager.cs b/OpenSim/Region/Environment/Scenes/EventManager.cs index ad25670..b493f84 100644 --- a/OpenSim/Region/Environment/Scenes/EventManager.cs +++ b/OpenSim/Region/Environment/Scenes/EventManager.cs @@ -233,18 +233,21 @@ namespace OpenSim.Region.Environment.Scenes /// public delegate void RegisterCapsEvent(UUID agentID, Caps caps); public event RegisterCapsEvent OnRegisterCaps; + /// /// DeregisterCapsEvent is called by Scene when the caps /// handler for an agent are removed. /// public delegate void DeregisterCapsEvent(UUID agentID, Caps caps); public event DeregisterCapsEvent OnDeregisterCaps; + /// /// ChatFromWorldEvent is called via Scene when a chat message /// from world comes in. /// public delegate void ChatFromWorldEvent(Object sender, OSChatMessage chat); public event ChatFromWorldEvent OnChatFromWorld; + /// /// ChatFromClientEvent is triggered via ChatModule (or /// substitutes thereof) when a chat message @@ -252,6 +255,7 @@ namespace OpenSim.Region.Environment.Scenes /// public delegate void ChatFromClientEvent(Object sender, OSChatMessage chat); public event ChatFromClientEvent OnChatFromClient; + /// /// ChatBroadcastEvent is called via Scene when a broadcast chat message /// from world comes in diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index 805ca5d..9528a0d 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs @@ -76,13 +76,15 @@ namespace OpenSim.Region.Environment.Scenes /// public ILandChannel LandChannel; - protected EventManager m_eventManager; - + /// + /// Manage events that occur in this scene (avatar movement, script rez, etc.). Commonly used by region modules + /// to subscribe to scene events. + /// public EventManager EventManager { get { return m_eventManager; } } - + protected EventManager m_eventManager; protected ScenePermissions m_permissions; public ScenePermissions Permissions -- cgit v1.1