diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | 148 |
1 files changed, 148 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs new file mode 100644 index 0000000..105446d --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -0,0 +1,148 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Reflection; | ||
30 | using NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Communications; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | ||
38 | using OpenSim.Tests.Common; | ||
39 | using OpenSim.Tests.Common.Mock; | ||
40 | using OpenSim.Tests.Common.Setup; | ||
41 | |||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
43 | { | ||
44 | /// <summary> | ||
45 | /// Basic scene object tests (create, read and delete but not update). | ||
46 | /// </summary> | ||
47 | [TestFixture] | ||
48 | public class SceneObjectBasicTests | ||
49 | { | ||
50 | /// <summary> | ||
51 | /// Test adding an object to a scene. | ||
52 | /// </summary> | ||
53 | [Test, LongRunning] | ||
54 | public void TestAddSceneObject() | ||
55 | { | ||
56 | TestHelper.InMethod(); | ||
57 | |||
58 | Scene scene = SceneSetupHelpers.SetupScene(); | ||
59 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | ||
60 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
61 | |||
62 | //m_log.Debug("retrievedPart : {0}", retrievedPart); | ||
63 | // If the parts have the same UUID then we will consider them as one and the same | ||
64 | Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); | ||
65 | } | ||
66 | |||
67 | /// <summary> | ||
68 | /// Test deleting an object from a scene. | ||
69 | /// </summary> | ||
70 | [Test] | ||
71 | public void TestDeleteSceneObject() | ||
72 | { | ||
73 | TestHelper.InMethod(); | ||
74 | |||
75 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
76 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | ||
77 | scene.DeleteSceneObject(part.ParentGroup, false); | ||
78 | |||
79 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
80 | Assert.That(retrievedPart, Is.Null); | ||
81 | } | ||
82 | |||
83 | /// <summary> | ||
84 | /// Test deleting an object asynchronously | ||
85 | /// </summary> | ||
86 | [Test] | ||
87 | public void TestDeleteSceneObjectAsync() | ||
88 | { | ||
89 | TestHelper.InMethod(); | ||
90 | |||
91 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
92 | |||
93 | TestScene scene = SceneSetupHelpers.SetupScene(); | ||
94 | |||
95 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
96 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
97 | sogd.Enabled = false; | ||
98 | |||
99 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | ||
100 | |||
101 | IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); | ||
102 | scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); | ||
103 | |||
104 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
105 | Assert.That(retrievedPart, Is.Not.Null); | ||
106 | |||
107 | sogd.InventoryDeQueueAndDelete(); | ||
108 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | ||
109 | Assert.That(retrievedPart2, Is.Null); | ||
110 | } | ||
111 | |||
112 | /// <summary> | ||
113 | /// Test deleting an object asynchronously to user inventory. | ||
114 | /// </summary> | ||
115 | //[Test] | ||
116 | //public void TestDeleteSceneObjectAsyncToUserInventory() | ||
117 | //{ | ||
118 | // TestHelper.InMethod(); | ||
119 | // //log4net.Config.XmlConfigurator.Configure(); | ||
120 | |||
121 | // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
122 | // string myObjectName = "Fred"; | ||
123 | |||
124 | // TestScene scene = SceneSetupHelpers.SetupScene(); | ||
125 | // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName); | ||
126 | |||
127 | // Assert.That( | ||
128 | // scene.CommsManager.UserAdminService.AddUser( | ||
129 | // "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), | ||
130 | // Is.EqualTo(agentId)); | ||
131 | |||
132 | // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); | ||
133 | |||
134 | // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId); | ||
135 | // Assert.That(userInfo, Is.Not.Null); | ||
136 | // Assert.That(userInfo.RootFolder, Is.Not.Null); | ||
137 | |||
138 | // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); | ||
139 | |||
140 | // // Check that we now have the taken part in our inventory | ||
141 | // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name)); | ||
142 | |||
143 | // // Check that the taken part has actually disappeared | ||
144 | // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
145 | // Assert.That(retrievedPart, Is.Null); | ||
146 | //} | ||
147 | } | ||
148 | } | ||