aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-09-26 21:28:43 +0100
committerJustin Clark-Casey (justincc)2012-09-26 21:28:43 +0100
commit90dd5844d64643246fb8bccf356614eb7e07d61c (patch)
tree91ad63ac145bd0a51f6c025989b40e8b9e14ee77 /OpenSim/Region
parentMerge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff)
downloadopensim-SC_OLD-90dd5844d64643246fb8bccf356614eb7e07d61c.zip
opensim-SC_OLD-90dd5844d64643246fb8bccf356614eb7e07d61c.tar.gz
opensim-SC_OLD-90dd5844d64643246fb8bccf356614eb7e07d61c.tar.bz2
opensim-SC_OLD-90dd5844d64643246fb8bccf356614eb7e07d61c.tar.xz
Add basic undo/redo regression tests.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs12
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs130
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs3
3 files changed, 137 insertions, 8 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 411dcc7..63eb387 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -3191,9 +3191,9 @@ namespace OpenSim.Region.Framework.Scenes
3191 } 3191 }
3192 } 3192 }
3193 3193
3194 // m_log.DebugFormat( 3194// m_log.DebugFormat(
3195 // "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}", 3195// "[SCENE OBJECT PART]: Storing undo state for {0} {1}, forGroup {2}, initial stack size {3}",
3196 // Name, LocalId, forGroup, m_undo.Count); 3196// Name, LocalId, forGroup, m_undo.Count);
3197 3197
3198 if (ParentGroup.GetSceneMaxUndo() > 0) 3198 if (ParentGroup.GetSceneMaxUndo() > 0)
3199 { 3199 {
@@ -3204,9 +3204,9 @@ namespace OpenSim.Region.Framework.Scenes
3204 if (m_redo.Count > 0) 3204 if (m_redo.Count > 0)
3205 m_redo.Clear(); 3205 m_redo.Clear();
3206 3206
3207 // m_log.DebugFormat( 3207// m_log.DebugFormat(
3208 // "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}", 3208// "[SCENE OBJECT PART]: Stored undo state for {0} {1}, forGroup {2}, stack size now {3}",
3209 // Name, LocalId, forGroup, m_undo.Count); 3209// Name, LocalId, forGroup, m_undo.Count);
3210 } 3210 }
3211 } 3211 }
3212 } 3212 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
new file mode 100644
index 0000000..1e317c6
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUndoRedoTests.cs
@@ -0,0 +1,130 @@
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;
36using OpenSim.Tests.Common.Mock;
37
38namespace OpenSim.Region.Framework.Scenes.Tests
39{
40 /// <summary>
41 /// Tests for undo/redo
42 /// </summary>
43 public class SceneObjectUndoRedoTests : OpenSimTestCase
44 {
45 [Test]
46 public void TestUndoRedoResizeSceneObject()
47 {
48 TestHelpers.InMethod();
49// TestHelpers.EnableLogging();
50
51 Vector3 firstSize = new Vector3(2, 3, 4);
52 Vector3 secondSize = new Vector3(5, 6, 7);
53
54 Scene scene = new SceneHelpers().SetupScene();
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 TestUndoBeyondAvailable()
80 {
81 TestHelpers.InMethod();
82
83 Vector3 newSize = new Vector3(2, 3, 4);
84
85 Scene scene = new SceneHelpers().SetupScene();
86 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
87 Vector3 originalSize = g1.GroupScale;
88
89 g1.RootPart.Undo();
90
91 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
92 Assert.That(g1.GroupScale, Is.EqualTo(originalSize));
93
94 g1.GroupResize(newSize);
95 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1));
96 Assert.That(g1.GroupScale, Is.EqualTo(newSize));
97
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(originalSize));
103 }
104
105 [Test]
106 public void TestRedoBeyondAvailable()
107 {
108 TestHelpers.InMethod();
109
110 Vector3 newSize = new Vector3(2, 3, 4);
111
112 Scene scene = new SceneHelpers().SetupScene();
113 SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene);
114 Vector3 originalSize = g1.GroupScale;
115
116 g1.RootPart.Redo();
117
118 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0));
119 Assert.That(g1.GroupScale, Is.EqualTo(originalSize));
120
121 g1.GroupResize(newSize);
122 g1.RootPart.Undo();
123 g1.RootPart.Redo();
124 g1.RootPart.Redo();
125
126 Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1));
127 Assert.That(g1.GroupScale, Is.EqualTo(newSize));
128 }
129 }
130} \ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
index c7eaff9..2b79271 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectUserGroupTests.cs
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock;
44namespace OpenSim.Region.Framework.Scenes.Tests 44namespace OpenSim.Region.Framework.Scenes.Tests
45{ 45{
46 [TestFixture] 46 [TestFixture]
47 public class SceneObjectUserGroupTests 47 public class SceneObjectUserGroupTests : OpenSimTestCase
48 { 48 {
49 /// <summary> 49 /// <summary>
50 /// Test share with group object functionality 50 /// Test share with group object functionality
@@ -54,7 +54,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
54 public void TestShareWithGroup() 54 public void TestShareWithGroup()
55 { 55 {
56 TestHelpers.InMethod(); 56 TestHelpers.InMethod();
57// log4net.Config.XmlConfigurator.Configure();
58 57
59 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001"); 58 UUID userId = UUID.Parse("10000000-0000-0000-0000-000000000001");
60 59