diff options
author | Justin Clark-Casey (justincc) | 2012-03-22 22:33:37 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-03-22 22:33:37 +0000 |
commit | 760010d6fb6aac313d79ce0a4d0016d3809246a0 (patch) | |
tree | fd981f1b96364b1698abdb349b71864262d17471 /OpenSim/Region/ScriptEngine | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-760010d6fb6aac313d79ce0a4d0016d3809246a0.zip opensim-SC-760010d6fb6aac313d79ce0a4d0016d3809246a0.tar.gz opensim-SC-760010d6fb6aac313d79ce0a4d0016d3809246a0.tar.bz2 opensim-SC-760010d6fb6aac313d79ce0a4d0016d3809246a0.tar.xz |
Fix llGiveInventory() so that it checks the destination part for AllowInventoryDrop, not the source.
This allows llAllowInventoryDrop() to work.
Regression test added for this case.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index ca27b27..e2d0db2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -75,7 +75,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
75 | /// Test giving inventory from an object to an object where both are owned by the same user. | 75 | /// Test giving inventory from an object to an object where both are owned by the same user. |
76 | /// </summary> | 76 | /// </summary> |
77 | [Test] | 77 | [Test] |
78 | public void TestLlGiveInventorySameOwner() | 78 | public void TestLlGiveInventoryO2OSameOwner() |
79 | { | 79 | { |
80 | TestHelpers.InMethod(); | 80 | TestHelpers.InMethod(); |
81 | // log4net.Config.XmlConfigurator.Configure(); | 81 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -107,5 +107,62 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
107 | Assert.That(copiedItems.Count, Is.EqualTo(1)); | 107 | Assert.That(copiedItems.Count, Is.EqualTo(1)); |
108 | Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); | 108 | Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); |
109 | } | 109 | } |
110 | |||
111 | /// <summary> | ||
112 | /// Test giving inventory from an object to an object where they have different owners | ||
113 | /// </summary> | ||
114 | [Test] | ||
115 | public void TestLlGiveInventoryO2ODifferentOwners() | ||
116 | { | ||
117 | TestHelpers.InMethod(); | ||
118 | // log4net.Config.XmlConfigurator.Configure(); | ||
119 | |||
120 | UUID user1Id = TestHelpers.ParseTail(0x1); | ||
121 | UUID user2Id = TestHelpers.ParseTail(0x2); | ||
122 | string inventoryItemName = "item1"; | ||
123 | |||
124 | SceneObjectGroup so1 = SceneHelpers.CreateSceneObject(1, user1Id, "so1", 0x10); | ||
125 | m_scene.AddSceneObject(so1); | ||
126 | LSL_Api api = new LSL_Api(); | ||
127 | api.Initialize(m_engine, so1.RootPart, so1.RootPart.LocalId, so1.RootPart.UUID); | ||
128 | |||
129 | // Create an object embedded inside the first | ||
130 | UUID itemId = TestHelpers.ParseTail(0x20); | ||
131 | TaskInventoryHelpers.AddSceneObject(m_scene, so1.RootPart, inventoryItemName, itemId, user1Id); | ||
132 | |||
133 | // Create a second object | ||
134 | SceneObjectGroup so2 = SceneHelpers.CreateSceneObject(1, user2Id, "so2", 0x100); | ||
135 | m_scene.AddSceneObject(so2); | ||
136 | LSL_Api api2 = new LSL_Api(); | ||
137 | api2.Initialize(m_engine, so2.RootPart, so2.RootPart.LocalId, so2.RootPart.UUID); | ||
138 | |||
139 | // *** Firstly, we test where llAllowInventoryDrop() has not been called. *** | ||
140 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | ||
141 | |||
142 | { | ||
143 | // Item has copy permissions so original should stay intact. | ||
144 | List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); | ||
145 | Assert.That(originalItems.Count, Is.EqualTo(1)); | ||
146 | |||
147 | // Should have not copied | ||
148 | List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); | ||
149 | Assert.That(copiedItems.Count, Is.EqualTo(0)); | ||
150 | } | ||
151 | |||
152 | // *** Secondly, we turn on allow inventory drop in the target and retest. *** | ||
153 | api2.llAllowInventoryDrop(1); | ||
154 | api.llGiveInventory(so2.UUID.ToString(), inventoryItemName); | ||
155 | |||
156 | { | ||
157 | // Item has copy permissions so original should stay intact. | ||
158 | List<TaskInventoryItem> originalItems = so1.RootPart.Inventory.GetInventoryItems(); | ||
159 | Assert.That(originalItems.Count, Is.EqualTo(1)); | ||
160 | |||
161 | // Should now have copied. | ||
162 | List<TaskInventoryItem> copiedItems = so2.RootPart.Inventory.GetInventoryItems(inventoryItemName); | ||
163 | Assert.That(copiedItems.Count, Is.EqualTo(1)); | ||
164 | Assert.That(copiedItems[0].Name, Is.EqualTo(inventoryItemName)); | ||
165 | } | ||
166 | } | ||
110 | } | 167 | } |
111 | } \ No newline at end of file | 168 | } \ No newline at end of file |