opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 OpenMetaverse; |
||
32 | using OpenSim.Framework; |
||
33 | using OpenSim.Framework.Communications; |
||
34 | using OpenSim.Region.Framework.Scenes; |
||
35 | using OpenSim.Tests.Common; |
||
36 | using OpenSim.Tests.Common.Mock; |
||
37 | |||
38 | namespace 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 | scene.MaxUndoCount = 20; |
||
56 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); |
||
57 | |||
58 | // TODO: It happens to be the case that we are not storing undo states for SOPs which are not yet in a SOG, |
||
59 | // which is the way that AddSceneObject() sets up the object (i.e. it creates the SOP first). However, |
||
60 | // this is somewhat by chance. Really, we shouldn't be storing undo states at all if the object is not |
||
61 | // in a scene. |
||
62 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); |
||
63 | |||
64 | g1.GroupResize(firstSize); |
||
65 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); |
||
66 | |||
67 | g1.GroupResize(secondSize); |
||
68 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); |
||
69 | |||
70 | g1.RootPart.Undo(); |
||
71 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); |
||
72 | Assert.That(g1.GroupScale, Is.EqualTo(firstSize)); |
||
73 | |||
74 | g1.RootPart.Redo(); |
||
75 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(2)); |
||
76 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); |
||
77 | } |
||
78 | |||
79 | [Test] |
||
80 | public void TestUndoLimit() |
||
81 | { |
||
82 | TestHelpers.InMethod(); |
||
83 | |||
84 | Vector3 firstSize = new Vector3(2, 3, 4); |
||
85 | Vector3 secondSize = new Vector3(5, 6, 7); |
||
86 | Vector3 thirdSize = new Vector3(8, 9, 10); |
||
87 | Vector3 fourthSize = new Vector3(11, 12, 13); |
||
88 | |||
89 | Scene scene = new SceneHelpers().SetupScene(); |
||
90 | scene.MaxUndoCount = 2; |
||
91 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); |
||
92 | |||
93 | g1.GroupResize(firstSize); |
||
94 | g1.GroupResize(secondSize); |
||
95 | g1.GroupResize(thirdSize); |
||
96 | g1.GroupResize(fourthSize); |
||
97 | |||
98 | g1.RootPart.Undo(); |
||
99 | g1.RootPart.Undo(); |
||
100 | g1.RootPart.Undo(); |
||
101 | |||
102 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); |
||
103 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); |
||
104 | } |
||
105 | |||
106 | [Test] |
||
107 | public void TestNoUndoOnObjectsNotInScene() |
||
108 | { |
||
109 | TestHelpers.InMethod(); |
||
110 | |||
111 | Vector3 firstSize = new Vector3(2, 3, 4); |
||
112 | Vector3 secondSize = new Vector3(5, 6, 7); |
||
113 | // Vector3 thirdSize = new Vector3(8, 9, 10); |
||
114 | // Vector3 fourthSize = new Vector3(11, 12, 13); |
||
115 | |||
116 | Scene scene = new SceneHelpers().SetupScene(); |
||
117 | scene.MaxUndoCount = 20; |
||
118 | SceneObjectGroup g1 = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); |
||
119 | |||
120 | g1.GroupResize(firstSize); |
||
121 | g1.GroupResize(secondSize); |
||
122 | |||
123 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); |
||
124 | |||
125 | g1.RootPart.Undo(); |
||
126 | |||
127 | Assert.That(g1.GroupScale, Is.EqualTo(secondSize)); |
||
128 | } |
||
129 | |||
130 | [Test] |
||
131 | public void TestUndoBeyondAvailable() |
||
132 | { |
||
133 | TestHelpers.InMethod(); |
||
134 | |||
135 | Vector3 newSize = new Vector3(2, 3, 4); |
||
136 | |||
137 | Scene scene = new SceneHelpers().SetupScene(); |
||
138 | scene.MaxUndoCount = 20; |
||
139 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); |
||
140 | Vector3 originalSize = g1.GroupScale; |
||
141 | |||
142 | g1.RootPart.Undo(); |
||
143 | |||
144 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); |
||
145 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); |
||
146 | |||
147 | g1.GroupResize(newSize); |
||
148 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); |
||
149 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); |
||
150 | |||
151 | g1.RootPart.Undo(); |
||
152 | g1.RootPart.Undo(); |
||
153 | |||
154 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); |
||
155 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); |
||
156 | } |
||
157 | |||
158 | [Test] |
||
159 | public void TestRedoBeyondAvailable() |
||
160 | { |
||
161 | TestHelpers.InMethod(); |
||
162 | |||
163 | Vector3 newSize = new Vector3(2, 3, 4); |
||
164 | |||
165 | Scene scene = new SceneHelpers().SetupScene(); |
||
166 | scene.MaxUndoCount = 20; |
||
167 | SceneObjectGroup g1 = SceneHelpers.AddSceneObject(scene); |
||
168 | Vector3 originalSize = g1.GroupScale; |
||
169 | |||
170 | g1.RootPart.Redo(); |
||
171 | |||
172 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(0)); |
||
173 | Assert.That(g1.GroupScale, Is.EqualTo(originalSize)); |
||
174 | |||
175 | g1.GroupResize(newSize); |
||
176 | g1.RootPart.Undo(); |
||
177 | g1.RootPart.Redo(); |
||
178 | g1.RootPart.Redo(); |
||
179 | |||
180 | Assert.That(g1.RootPart.UndoCount, Is.EqualTo(1)); |
||
181 | Assert.That(g1.GroupScale, Is.EqualTo(newSize)); |
||
182 | } |
||
183 | } |
||
184 | } |