diff options
author | Justin Clark-Casey (justincc) | 2009-08-11 16:45:16 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-08-11 16:45:16 +0100 |
commit | 226c082ed417f4a5f2295595e45eca2fcb1e42c9 (patch) | |
tree | 4bbe2f59176589e497a2f4fd16b3adfe3989c5cd /OpenSim/Region/CoreModules/Avatar | |
parent | Added some needed comments to SceneSetupHelper (actually just retriggering pa... (diff) | |
download | opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.zip opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.gz opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.bz2 opensim-SC-226c082ed417f4a5f2295595e45eca2fcb1e42c9.tar.xz |
Establish CachedUserInfo.OnInventoryReceived event so that region/test inventory code can be written with the async inventory fetch
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | 46 |
1 files changed, 36 insertions, 10 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 1480512..8ac9b1f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -54,6 +54,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
54 | [TestFixture] | 54 | [TestFixture] |
55 | public class InventoryArchiverTests | 55 | public class InventoryArchiverTests |
56 | { | 56 | { |
57 | private void InventoryReceived(UUID userId) | ||
58 | { | ||
59 | lock (this) | ||
60 | { | ||
61 | Monitor.PulseAll(this); | ||
62 | } | ||
63 | } | ||
64 | |||
57 | private void SaveCompleted( | 65 | private void SaveCompleted( |
58 | bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) | 66 | bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException) |
59 | { | 67 | { |
@@ -61,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
61 | { | 69 | { |
62 | Monitor.PulseAll(this); | 70 | Monitor.PulseAll(this); |
63 | } | 71 | } |
64 | } | 72 | } |
65 | 73 | ||
66 | /// <summary> | 74 | /// <summary> |
67 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). | 75 | /// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet). |
@@ -82,8 +90,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
82 | string userFirstName = "Jock"; | 90 | string userFirstName = "Jock"; |
83 | string userLastName = "Stirrup"; | 91 | string userLastName = "Stirrup"; |
84 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 92 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
93 | CachedUserInfo userInfo; | ||
94 | |||
95 | lock (this) | ||
96 | { | ||
97 | userInfo | ||
98 | = UserProfileTestUtils.CreateUserWithInventory( | ||
99 | cm, userFirstName, userLastName, userId, InventoryReceived); | ||
100 | Monitor.Wait(this, 60000); | ||
101 | } | ||
102 | |||
103 | /* | ||
85 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); | 104 | cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId); |
86 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId); | 105 | CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId, InventoryReceived); |
87 | userInfo.FetchInventory(); | 106 | userInfo.FetchInventory(); |
88 | for (int i = 0 ; i < 50 ; i++) | 107 | for (int i = 0 ; i < 50 ; i++) |
89 | { | 108 | { |
@@ -92,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
92 | Thread.Sleep(200); | 111 | Thread.Sleep(200); |
93 | } | 112 | } |
94 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | 113 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); |
114 | */ | ||
95 | 115 | ||
96 | // Create asset | 116 | // Create asset |
97 | SceneObjectGroup object1; | 117 | SceneObjectGroup object1; |
@@ -337,15 +357,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
337 | Assert.That(user2Profile.SurName == user2LastName); | 357 | Assert.That(user2Profile.SurName == user2LastName); |
338 | 358 | ||
339 | CachedUserInfo userInfo | 359 | CachedUserInfo userInfo |
340 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); | 360 | = scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName); |
341 | userInfo.FetchInventory(); | 361 | userInfo.OnInventoryReceived += InventoryReceived; |
342 | for (int i = 0 ; i < 50 ; i++) | 362 | |
363 | lock (this) | ||
343 | { | 364 | { |
344 | if (userInfo.HasReceivedInventory == true) | 365 | userInfo.FetchInventory(); |
345 | break; | 366 | Monitor.Wait(this, 60000); |
346 | Thread.Sleep(200); | ||
347 | } | 367 | } |
348 | Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)"); | 368 | |
349 | InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); | 369 | InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName); |
350 | 370 | ||
351 | Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); | 371 | Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId)); |
@@ -365,8 +385,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
365 | TestHelper.InMethod(); | 385 | TestHelper.InMethod(); |
366 | Scene scene = SceneSetupHelpers.SetupScene(""); | 386 | Scene scene = SceneSetupHelpers.SetupScene(""); |
367 | CommunicationsManager commsManager = scene.CommsManager; | 387 | CommunicationsManager commsManager = scene.CommsManager; |
388 | CachedUserInfo userInfo; | ||
368 | 389 | ||
369 | CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager); | 390 | lock (this) |
391 | { | ||
392 | userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived); | ||
393 | Monitor.Wait(this, 60000); | ||
394 | } | ||
395 | |||
370 | //userInfo.FetchInventory(); | 396 | //userInfo.FetchInventory(); |
371 | /* | 397 | /* |
372 | for (int i = 0 ; i < 50 ; i++) | 398 | for (int i = 0 ; i < 50 ; i++) |