aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs129
1 files changed, 129 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs
new file mode 100644
index 0000000..b3b99f4
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserTests.cs
@@ -0,0 +1,129 @@
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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using Nini.Config;
32using NUnit.Framework;
33using NUnit.Framework.SyntaxHelpers;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Region.CoreModules.World.Permissions;
38using OpenSim.Region.Framework.Scenes;
39using OpenSim.Tests.Common;
40using OpenSim.Tests.Common.Mock;
41using OpenSim.Tests.Common.Setup;
42
43namespace OpenSim.Region.Framework.Scenes.Tests
44{
45 /// <summary>
46 /// Tests manipulation of scene objects by users.
47 /// </summary>
48 ///
49 /// This is at a level above the SceneObjectBasicTests, which act on the scene directly.
50 /// FIXME: These tests are very incomplete - they only test for a few conditions.
51 [TestFixture]
52 public class SceneObjectUserTests
53 {
54 /// <summary>
55 /// Test deleting an object from a scene.
56 /// </summary>
57 [Test]
58 public void TestDeRezSceneObject()
59 {
60 TestHelper.InMethod();
61// log4net.Config.XmlConfigurator.Configure();
62
63 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
64
65 TestScene scene = SceneSetupHelpers.SetupScene();
66 IConfigSource configSource = new IniConfigSource();
67 IConfig config = configSource.AddConfig("Startup");
68 config.Set("serverside_object_permissions", true);
69 SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
70 TestClient client = SceneSetupHelpers.AddRootAgent(scene, userId);
71
72 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
73 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
74 sogd.Enabled = false;
75
76 SceneObjectPart part
77 = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
78 part.Name = "obj1";
79 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
80 List<uint> localIds = new List<uint>();
81 localIds.Add(part.LocalId);
82
83 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
84 sogd.InventoryDeQueueAndDelete();
85
86 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
87 Assert.That(retrievedPart, Is.Null);
88 }
89
90 /// <summary>
91 /// Test deleting an object from a scene where the deleter is not the owner
92 /// </summary>
93 ///
94 /// This test assumes that the deleter is not a god.
95 [Test]
96 public void TestDeRezSceneObjectNotOwner()
97 {
98 TestHelper.InMethod();
99// log4net.Config.XmlConfigurator.Configure();
100
101 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
102 UUID objectOwnerId = UUID.Parse("20000000-0000-0000-0000-000000000001");
103
104 TestScene scene = SceneSetupHelpers.SetupScene();
105 IConfigSource configSource = new IniConfigSource();
106 IConfig config = configSource.AddConfig("Startup");
107 config.Set("serverside_object_permissions", true);
108 SceneSetupHelpers.SetupSceneModules(scene, configSource, new object[] { new PermissionsModule() });
109 TestClient client = SceneSetupHelpers.AddRootAgent(scene, userId);
110
111 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
112 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
113 sogd.Enabled = false;
114
115 SceneObjectPart part
116 = new SceneObjectPart(objectOwnerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero);
117 part.Name = "obj1";
118 scene.AddNewSceneObject(new SceneObjectGroup(part), false);
119 List<uint> localIds = new List<uint>();
120 localIds.Add(part.LocalId);
121
122 scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero);
123 sogd.InventoryDeQueueAndDelete();
124
125 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
126 Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID));
127 }
128 }
129} \ No newline at end of file