clockwerk-opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 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.Collections.Generic; |
||
30 | using System.IO; |
||
31 | using System.Reflection; |
||
32 | using System.Threading; |
||
33 | using log4net.Config; |
||
34 | using NUnit.Framework; |
||
35 | using OpenMetaverse; |
||
36 | using OpenMetaverse.Assets; |
||
37 | using OpenSim.Framework; |
||
38 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; |
||
39 | using OpenSim.Region.CoreModules.Scripting.VectorRender; |
||
40 | using OpenSim.Region.Framework.Scenes; |
||
41 | using OpenSim.Region.Framework.Scenes.Serialization; |
||
42 | using OpenSim.Tests.Common; |
||
43 | using OpenSim.Tests.Common.Mock; |
||
44 | |||
45 | namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests |
||
46 | { |
||
47 | [TestFixture] |
||
48 | public class VectorRenderModuleTests : OpenSimTestCase |
||
49 | { |
||
50 | Scene m_scene; |
||
51 | DynamicTextureModule m_dtm; |
||
52 | VectorRenderModule m_vrm; |
||
53 | |||
54 | private void SetupScene(bool reuseTextures) |
||
55 | { |
||
56 | m_scene = new SceneHelpers().SetupScene(); |
||
57 | |||
58 | m_dtm = new DynamicTextureModule(); |
||
59 | m_dtm.ReuseTextures = reuseTextures; |
||
60 | // m_dtm.ReuseLowDataTextures = reuseTextures; |
||
61 | |||
62 | m_vrm = new VectorRenderModule(); |
||
63 | |||
64 | SceneHelpers.SetupSceneModules(m_scene, m_dtm, m_vrm); |
||
65 | } |
||
66 | |||
67 | [Test] |
||
68 | public void TestDraw() |
||
69 | { |
||
70 | TestHelpers.InMethod(); |
||
71 | |||
72 | SetupScene(false); |
||
73 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
74 | UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
75 | |||
76 | m_dtm.AddDynamicTextureData( |
||
77 | m_scene.RegionInfo.RegionID, |
||
78 | so.UUID, |
||
79 | m_vrm.GetContentType(), |
||
80 | "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;", |
||
81 | "", |
||
82 | 0); |
||
83 | |||
84 | Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
85 | } |
||
86 | |||
87 | [Test] |
||
88 | public void TestRepeatSameDraw() |
||
89 | { |
||
90 | TestHelpers.InMethod(); |
||
91 | |||
92 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
||
93 | |||
94 | SetupScene(false); |
||
95 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
96 | |||
97 | m_dtm.AddDynamicTextureData( |
||
98 | m_scene.RegionInfo.RegionID, |
||
99 | so.UUID, |
||
100 | m_vrm.GetContentType(), |
||
101 | dtText, |
||
102 | "", |
||
103 | 0); |
||
104 | |||
105 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
106 | |||
107 | m_dtm.AddDynamicTextureData( |
||
108 | m_scene.RegionInfo.RegionID, |
||
109 | so.UUID, |
||
110 | m_vrm.GetContentType(), |
||
111 | dtText, |
||
112 | "", |
||
113 | 0); |
||
114 | |||
115 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
116 | } |
||
117 | |||
118 | [Test] |
||
119 | public void TestRepeatSameDrawDifferentExtraParams() |
||
120 | { |
||
121 | TestHelpers.InMethod(); |
||
122 | |||
123 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
||
124 | |||
125 | SetupScene(false); |
||
126 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
127 | |||
128 | m_dtm.AddDynamicTextureData( |
||
129 | m_scene.RegionInfo.RegionID, |
||
130 | so.UUID, |
||
131 | m_vrm.GetContentType(), |
||
132 | dtText, |
||
133 | "", |
||
134 | 0); |
||
135 | |||
136 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
137 | |||
138 | m_dtm.AddDynamicTextureData( |
||
139 | m_scene.RegionInfo.RegionID, |
||
140 | so.UUID, |
||
141 | m_vrm.GetContentType(), |
||
142 | dtText, |
||
143 | "alpha:250", |
||
144 | 0); |
||
145 | |||
146 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
147 | } |
||
148 | |||
149 | [Test] |
||
150 | public void TestRepeatSameDrawContainingImage() |
||
151 | { |
||
152 | TestHelpers.InMethod(); |
||
153 | |||
154 | string dtText |
||
155 | = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://0.0.0.0/shouldnotexist.png"; |
||
156 | |||
157 | SetupScene(false); |
||
158 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
159 | |||
160 | m_dtm.AddDynamicTextureData( |
||
161 | m_scene.RegionInfo.RegionID, |
||
162 | so.UUID, |
||
163 | m_vrm.GetContentType(), |
||
164 | dtText, |
||
165 | "", |
||
166 | 0); |
||
167 | |||
168 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
169 | |||
170 | m_dtm.AddDynamicTextureData( |
||
171 | m_scene.RegionInfo.RegionID, |
||
172 | so.UUID, |
||
173 | m_vrm.GetContentType(), |
||
174 | dtText, |
||
175 | "", |
||
176 | 0); |
||
177 | |||
178 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
179 | } |
||
180 | |||
181 | [Test] |
||
182 | public void TestDrawReusingTexture() |
||
183 | { |
||
184 | TestHelpers.InMethod(); |
||
185 | |||
186 | SetupScene(true); |
||
187 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
188 | UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
189 | |||
190 | m_dtm.AddDynamicTextureData( |
||
191 | m_scene.RegionInfo.RegionID, |
||
192 | so.UUID, |
||
193 | m_vrm.GetContentType(), |
||
194 | "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;", |
||
195 | "", |
||
196 | 0); |
||
197 | |||
198 | Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
199 | } |
||
200 | |||
201 | [Test] |
||
202 | public void TestRepeatSameDrawReusingTexture() |
||
203 | { |
||
204 | TestHelpers.InMethod(); |
||
205 | // TestHelpers.EnableLogging(); |
||
206 | |||
207 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
||
208 | |||
209 | SetupScene(true); |
||
210 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
211 | |||
212 | m_dtm.AddDynamicTextureData( |
||
213 | m_scene.RegionInfo.RegionID, |
||
214 | so.UUID, |
||
215 | m_vrm.GetContentType(), |
||
216 | dtText, |
||
217 | "", |
||
218 | 0); |
||
219 | |||
220 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
221 | |||
222 | m_dtm.AddDynamicTextureData( |
||
223 | m_scene.RegionInfo.RegionID, |
||
224 | so.UUID, |
||
225 | m_vrm.GetContentType(), |
||
226 | dtText, |
||
227 | "", |
||
228 | 0); |
||
229 | |||
230 | Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
231 | } |
||
232 | |||
233 | /// <summary> |
||
234 | /// Test a low data dynamically generated texture such that it is treated as a low data texture that causes |
||
235 | /// problems for current viewers. |
||
236 | /// </summary> |
||
237 | /// <remarks> |
||
238 | /// As we do not set DynamicTextureModule.ReuseLowDataTextures = true in this test, it should not reuse the |
||
239 | /// texture |
||
240 | /// </remarks> |
||
241 | [Test] |
||
242 | public void TestRepeatSameDrawLowDataTexture() |
||
243 | { |
||
244 | TestHelpers.InMethod(); |
||
245 | // TestHelpers.EnableLogging(); |
||
246 | |||
247 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
||
248 | |||
249 | SetupScene(true); |
||
250 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
251 | |||
252 | m_dtm.AddDynamicTextureData( |
||
253 | m_scene.RegionInfo.RegionID, |
||
254 | so.UUID, |
||
255 | m_vrm.GetContentType(), |
||
256 | dtText, |
||
257 | "1024", |
||
258 | 0); |
||
259 | |||
260 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
261 | |||
262 | m_dtm.AddDynamicTextureData( |
||
263 | m_scene.RegionInfo.RegionID, |
||
264 | so.UUID, |
||
265 | m_vrm.GetContentType(), |
||
266 | dtText, |
||
267 | "1024", |
||
268 | 0); |
||
269 | |||
270 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
271 | } |
||
272 | |||
273 | [Test] |
||
274 | public void TestRepeatSameDrawDifferentExtraParamsReusingTexture() |
||
275 | { |
||
276 | TestHelpers.InMethod(); |
||
277 | |||
278 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
||
279 | |||
280 | SetupScene(true); |
||
281 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
282 | |||
283 | m_dtm.AddDynamicTextureData( |
||
284 | m_scene.RegionInfo.RegionID, |
||
285 | so.UUID, |
||
286 | m_vrm.GetContentType(), |
||
287 | dtText, |
||
288 | "", |
||
289 | 0); |
||
290 | |||
291 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
292 | |||
293 | m_dtm.AddDynamicTextureData( |
||
294 | m_scene.RegionInfo.RegionID, |
||
295 | so.UUID, |
||
296 | m_vrm.GetContentType(), |
||
297 | dtText, |
||
298 | "alpha:250", |
||
299 | 0); |
||
300 | |||
301 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
302 | } |
||
303 | |||
304 | [Test] |
||
305 | public void TestRepeatSameDrawContainingImageReusingTexture() |
||
306 | { |
||
307 | TestHelpers.InMethod(); |
||
308 | |||
309 | string dtText |
||
310 | = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://0.0.0.0/shouldnotexist.png"; |
||
311 | |||
312 | SetupScene(true); |
||
313 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); |
||
314 | |||
315 | m_dtm.AddDynamicTextureData( |
||
316 | m_scene.RegionInfo.RegionID, |
||
317 | so.UUID, |
||
318 | m_vrm.GetContentType(), |
||
319 | dtText, |
||
320 | "", |
||
321 | 0); |
||
322 | |||
323 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; |
||
324 | |||
325 | m_dtm.AddDynamicTextureData( |
||
326 | m_scene.RegionInfo.RegionID, |
||
327 | so.UUID, |
||
328 | m_vrm.GetContentType(), |
||
329 | dtText, |
||
330 | "", |
||
331 | 0); |
||
332 | |||
333 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
||
334 | } |
||
335 | } |
||
336 | } |