aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs183
1 files changed, 183 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
new file mode 100644
index 0000000..cdebe25
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
@@ -0,0 +1,183 @@
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.Reflection;
30using NUnit.Framework;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Region.Framework.Scenes;
35using OpenSim.Tests.Common;
36
37namespace OpenSim.Region.Framework.Scenes.Tests
38{
39 /// <summary>
40 /// Tests for undo/redo
41 /// </summary>
42 public class SceneObjectUndoRedoTests : OpenSimTestCase
43 {
44 [Test]
45 public void TestUndoRedoResizeSceneObject()
46 {
47 TestHelpers.InMethod();
48// TestHelpers.EnableLogging();
49
50 Vector3 firstSize = new Vector3(2, 3, 4);
51 Vector3 secondSize = new Vector3(5, 6, 7);
52
53 Scene scene = new SceneHelpers().SetupScene();
54 scene.MaxUndoCount = 20;
55 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
56
57 // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG,
58 // which is the way that AddSceneObject() sets up the object (i.e. it creates the SOP first). However,
59 // this is somewhat by chance. Really, we shouldn't be storing undo states at all if the object is not
60 // in a scene.
61 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
62
63 g1.GroupResize(firstSize);
64 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1));
65
66 g1.GroupResize(secondSize);
67 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2));
68
69 g1.RootPart.Undo();
70 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1));
71 Assert.That(g1.GroupScale, Is.EqualTo(firstSize));
72
73 g1.RootPart.Redo();
74 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2));
75 Assert.That(g1.GroupScale, Is.EqualTo(secondSize));
76 }
77
78 [Test]
79 public void TestUndoLimit()
80 {
81 TestHelpers.InMethod();
82
83 Vector3 firstSize = new Vector3(2, 3, 4);
84 Vector3 secondSize = new Vector3(5, 6, 7);
85 Vector3 thirdSize = new Vector3(8, 9, 10);
86 Vector3 fourthSize = new Vector3(11, 12, 13);
87
88 Scene scene = new SceneHelpers().SetupScene();
89 scene.MaxUndoCount = 2;
90 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
91
92 g1.GroupResize(firstSize);
93 g1.GroupResize(secondSize);
94 g1.GroupResize(thirdSize);
95 g1.GroupResize(fourthSize);
96
97 g1.RootPart.Undo();
98 g1.RootPart.Undo();
99 g1.RootPart.Undo();
100
101 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
102 Assert.That(g1.GroupScale, Is.EqualTo(secondSize));
103 }
104
105 [Test]
106 public void TestNoUndoOnObjectsNotInScene()
107 {
108 TestHelpers.InMethod();
109
110 Vector3 firstSize = new Vector3(2, 3, 4);
111 Vector3 secondSize = new Vector3(5, 6, 7);
112// Vector3 thirdSize = new Vector3(8, 9, 10);
113// Vector3 fourthSize = new Vector3(11, 12, 13);
114
115 Scene scene = new SceneHelpers().SetupScene();
116 scene.MaxUndoCount = 20;
117 SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1));
118
119 g1.GroupResize(firstSize);
120 g1.GroupResize(secondSize);
121
122 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
123
124 g1.RootPart.Undo();
125
126 Assert.That(g1.GroupScale, Is.EqualTo(secondSize));
127 }
128
129 [Test]
130 public void TestUndoBeyondAvailable()
131 {
132 TestHelpers.InMethod();
133
134 Vector3 newSize = new Vector3(2, 3, 4);
135
136 Scene scene = new SceneHelpers().SetupScene();
137 scene.MaxUndoCount = 20;
138 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
139 Vector3 originalSize = g1.GroupScale;
140
141 g1.RootPart.Undo();
142
143 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
144 Assert.That(g1.GroupScale, Is.EqualTo(originalSize));
145
146 g1.GroupResize(newSize);
147 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1));
148 Assert.That(g1.GroupScale, Is.EqualTo(newSize));
149
150 g1.RootPart.Undo();
151 g1.RootPart.Undo();
152
153 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
154 Assert.That(g1.GroupScale, Is.EqualTo(originalSize));
155 }
156
157 [Test]
158 public void TestRedoBeyondAvailable()
159 {
160 TestHelpers.InMethod();
161
162 Vector3 newSize = new Vector3(2, 3, 4);
163
164 Scene scene = new SceneHelpers().SetupScene();
165 scene.MaxUndoCount = 20;
166 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
167 Vector3 originalSize = g1.GroupScale;
168
169 g1.RootPart.Redo();
170
171 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
172 Assert.That(g1.GroupScale, Is.EqualTo(originalSize));
173
174 g1.GroupResize(newSize);
175 g1.RootPart.Undo();
176 g1.RootPart.Redo();
177 g1.RootPart.Redo();
178
179 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1));
180 Assert.That(g1.GroupScale, Is.EqualTo(newSize));
181 }
182 }
183} \ No newline at end of file