diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | 85 |
1 files changed, 43 insertions, 42 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index 2aef4b0..f4e14d4 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -46,55 +46,55 @@ using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | |||
46 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
47 | using OpenSim.Tests.Common; | 47 | using OpenSim.Tests.Common; |
48 | using OpenSim.Tests.Common.Mock; | 48 | using OpenSim.Tests.Common.Mock; |
49 | using OpenSim.Tests.Common.Setup; | ||
50 | 49 | ||
51 | namespace OpenSim.Region.Framework.Tests | 50 | namespace OpenSim.Region.Framework.Tests |
52 | { | 51 | { |
53 | [TestFixture] | 52 | [TestFixture] |
54 | public class TaskInventoryTests | 53 | public class TaskInventoryTests |
55 | { | 54 | { |
56 | protected UserAccount CreateUser(Scene scene) | 55 | [Test] |
57 | { | 56 | public void TestRezObjectFromInventoryItem() |
58 | string userFirstName = "Jock"; | ||
59 | string userLastName = "Stirrup"; | ||
60 | string userPassword = "troll"; | ||
61 | UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020"); | ||
62 | return UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword); | ||
63 | } | ||
64 | |||
65 | protected SceneObjectGroup CreateSO1(Scene scene, UUID ownerId) | ||
66 | { | ||
67 | string part1Name = "part1"; | ||
68 | UUID part1Id = UUID.Parse("10000000-0000-0000-0000-000000000000"); | ||
69 | SceneObjectPart part1 | ||
70 | = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero) | ||
71 | { Name = part1Name, UUID = part1Id }; | ||
72 | return new SceneObjectGroup(part1); | ||
73 | } | ||
74 | |||
75 | protected TaskInventoryItem CreateSOItem1(Scene scene, SceneObjectPart part) | ||
76 | { | 57 | { |
77 | AssetNotecard nc = new AssetNotecard(); | 58 | TestHelper.InMethod(); |
78 | nc.BodyText = "Hello World!"; | 59 | // log4net.Config.XmlConfigurator.Configure(); |
79 | nc.Encode(); | ||
80 | UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000"); | ||
81 | UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000"); | ||
82 | AssetBase ncAsset | ||
83 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | ||
84 | scene.AssetService.Store(ncAsset); | ||
85 | TaskInventoryItem ncItem | ||
86 | = new TaskInventoryItem | ||
87 | { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid, | ||
88 | Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard }; | ||
89 | part.Inventory.AddInventoryItem(ncItem, true); | ||
90 | 60 | ||
91 | return ncItem; | 61 | Scene scene = SceneSetupHelpers.SetupScene(); |
62 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); | ||
63 | SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); | ||
64 | SceneObjectPart sop1 = sog1.RootPart; | ||
65 | |||
66 | // Create an object embedded inside the first | ||
67 | UUID taskSceneObjectItemId = UUID.Parse("00000000-0000-0000-0000-100000000000"); | ||
68 | TaskInventoryItem taskSceneObjectItem | ||
69 | = TaskInventoryHelpers.AddSceneObject(scene, sop1, "tso", taskSceneObjectItemId); | ||
70 | |||
71 | scene.AddSceneObject(sog1); | ||
72 | |||
73 | Vector3 rezPos = new Vector3(10, 10, 10); | ||
74 | Quaternion rezRot = new Quaternion(0.5f, 0.5f, 0.5f, 0.5f); | ||
75 | Vector3 rezVel = new Vector3(2, 2, 2); | ||
76 | |||
77 | scene.RezObject(sop1, taskSceneObjectItem, rezPos, rezRot, rezVel, 0); | ||
78 | |||
79 | SceneObjectGroup rezzedObject = scene.GetSceneObjectGroup("tso"); | ||
80 | |||
81 | Assert.That(rezzedObject, Is.Not.Null); | ||
82 | Assert.That(rezzedObject.AbsolutePosition, Is.EqualTo(rezPos)); | ||
83 | |||
84 | // Velocity doesn't get applied, probably because there is no physics in tests (yet) | ||
85 | // Assert.That(rezzedObject.Velocity, Is.EqualTo(rezVel)); | ||
86 | Assert.That(rezzedObject.Velocity, Is.EqualTo(Vector3.Zero)); | ||
87 | |||
88 | // Confusingly, this isn't the rezzedObject.Rotation | ||
89 | Assert.That(rezzedObject.RootPart.RotationOffset, Is.EqualTo(rezRot)); | ||
92 | } | 90 | } |
93 | 91 | ||
94 | /// <summary> | 92 | /// <summary> |
95 | /// Test MoveTaskInventoryItem where the item has no parent folder assigned. | 93 | /// Test MoveTaskInventoryItem where the item has no parent folder assigned. |
96 | /// </summary> | 94 | /// </summary> |
95 | /// <remarks> | ||
97 | /// This should place it in the most suitable user folder. | 96 | /// This should place it in the most suitable user folder. |
97 | /// </remarks> | ||
98 | [Test] | 98 | [Test] |
99 | public void TestMoveTaskInventoryItem() | 99 | public void TestMoveTaskInventoryItem() |
100 | { | 100 | { |
@@ -102,10 +102,11 @@ namespace OpenSim.Region.Framework.Tests | |||
102 | // log4net.Config.XmlConfigurator.Configure(); | 102 | // log4net.Config.XmlConfigurator.Configure(); |
103 | 103 | ||
104 | Scene scene = SceneSetupHelpers.SetupScene(); | 104 | Scene scene = SceneSetupHelpers.SetupScene(); |
105 | UserAccount user1 = CreateUser(scene); | 105 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
106 | SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); | 106 | SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); |
107 | SceneObjectPart sop1 = sog1.RootPart; | 107 | SceneObjectPart sop1 = sog1.RootPart; |
108 | TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); | 108 | TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); |
109 | |||
109 | InventoryFolderBase folder | 110 | InventoryFolderBase folder |
110 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; | 111 | = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0]; |
111 | 112 | ||
@@ -128,10 +129,10 @@ namespace OpenSim.Region.Framework.Tests | |||
128 | // log4net.Config.XmlConfigurator.Configure(); | 129 | // log4net.Config.XmlConfigurator.Configure(); |
129 | 130 | ||
130 | Scene scene = SceneSetupHelpers.SetupScene(); | 131 | Scene scene = SceneSetupHelpers.SetupScene(); |
131 | UserAccount user1 = CreateUser(scene); | 132 | UserAccount user1 = UserAccountHelpers.CreateUserWithInventory(scene); |
132 | SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID); | 133 | SceneObjectGroup sog1 = SceneSetupHelpers.CreateSceneObject(1, user1.PrincipalID); |
133 | SceneObjectPart sop1 = sog1.RootPart; | 134 | SceneObjectPart sop1 = sog1.RootPart; |
134 | TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1); | 135 | TaskInventoryItem sopItem1 = TaskInventoryHelpers.AddNotecard(scene, sop1); |
135 | 136 | ||
136 | // Perform test | 137 | // Perform test |
137 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); | 138 | scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID); |