OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
VectorRenderModuleTests.cs
Go to the documentation of this file.
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 
44 namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests
45 {
46  [TestFixture]
48  {
49  Scene m_scene;
51  VectorRenderModule m_vrm;
52 
53  private void SetupScene(bool reuseTextures)
54  {
55  m_scene = new SceneHelpers().SetupScene();
56 
57  m_dtm = new DynamicTextureModule();
58  m_dtm.ReuseTextures = reuseTextures;
59 // m_dtm.ReuseLowDataTextures = reuseTextures;
60 
61  m_vrm = new VectorRenderModule();
62 
63  SceneHelpers.SetupSceneModules(m_scene, m_dtm, m_vrm);
64  }
65 
66  [Test]
67  public void TestDraw()
68  {
69  TestHelpers.InMethod();
70 
71  SetupScene(false);
72  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
73  UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
74 
75  m_dtm.AddDynamicTextureData(
76  m_scene.RegionInfo.RegionID,
77  so.UUID,
78  m_vrm.GetContentType(),
79  "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;",
80  "",
81  0);
82 
83  Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
84  }
85 
86  [Test]
87  public void TestRepeatSameDraw()
88  {
89  TestHelpers.InMethod();
90 
91  string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
92 
93  SetupScene(false);
94  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
95 
96  m_dtm.AddDynamicTextureData(
97  m_scene.RegionInfo.RegionID,
98  so.UUID,
99  m_vrm.GetContentType(),
100  dtText,
101  "",
102  0);
103 
104  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
105 
106  m_dtm.AddDynamicTextureData(
107  m_scene.RegionInfo.RegionID,
108  so.UUID,
109  m_vrm.GetContentType(),
110  dtText,
111  "",
112  0);
113 
114  Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
115  }
116 
117  [Test]
119  {
120  TestHelpers.InMethod();
121 
122  string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
123 
124  SetupScene(false);
125  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
126 
127  m_dtm.AddDynamicTextureData(
128  m_scene.RegionInfo.RegionID,
129  so.UUID,
130  m_vrm.GetContentType(),
131  dtText,
132  "",
133  0);
134 
135  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
136 
137  m_dtm.AddDynamicTextureData(
138  m_scene.RegionInfo.RegionID,
139  so.UUID,
140  m_vrm.GetContentType(),
141  dtText,
142  "alpha:250",
143  0);
144 
145  Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
146  }
147 
148  [Test]
150  {
151  TestHelpers.InMethod();
152 
153  string dtText
154  = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://0.0.0.0/shouldnotexist.png";
155 
156  SetupScene(false);
157  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
158 
159  m_dtm.AddDynamicTextureData(
160  m_scene.RegionInfo.RegionID,
161  so.UUID,
162  m_vrm.GetContentType(),
163  dtText,
164  "",
165  0);
166 
167  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
168 
169  m_dtm.AddDynamicTextureData(
170  m_scene.RegionInfo.RegionID,
171  so.UUID,
172  m_vrm.GetContentType(),
173  dtText,
174  "",
175  0);
176 
177  Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
178  }
179 
180  [Test]
182  {
183  TestHelpers.InMethod();
184 
185  SetupScene(true);
186  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
187  UUID originalTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
188 
189  m_dtm.AddDynamicTextureData(
190  m_scene.RegionInfo.RegionID,
191  so.UUID,
192  m_vrm.GetContentType(),
193  "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;",
194  "",
195  0);
196 
197  Assert.That(originalTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
198  }
199 
200  [Test]
202  {
203  TestHelpers.InMethod();
204 // TestHelpers.EnableLogging();
205 
206  string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
207 
208  SetupScene(true);
209  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
210 
211  m_dtm.AddDynamicTextureData(
212  m_scene.RegionInfo.RegionID,
213  so.UUID,
214  m_vrm.GetContentType(),
215  dtText,
216  "",
217  0);
218 
219  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
220 
221  m_dtm.AddDynamicTextureData(
222  m_scene.RegionInfo.RegionID,
223  so.UUID,
224  m_vrm.GetContentType(),
225  dtText,
226  "",
227  0);
228 
229  Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
230  }
231 
240  [Test]
242  {
243  TestHelpers.InMethod();
244 // TestHelpers.EnableLogging();
245 
246  string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
247 
248  SetupScene(true);
249  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
250 
251  m_dtm.AddDynamicTextureData(
252  m_scene.RegionInfo.RegionID,
253  so.UUID,
254  m_vrm.GetContentType(),
255  dtText,
256  "1024",
257  0);
258 
259  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
260 
261  m_dtm.AddDynamicTextureData(
262  m_scene.RegionInfo.RegionID,
263  so.UUID,
264  m_vrm.GetContentType(),
265  dtText,
266  "1024",
267  0);
268 
269  Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
270  }
271 
272  [Test]
274  {
275  TestHelpers.InMethod();
276 
277  string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;";
278 
279  SetupScene(true);
280  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
281 
282  m_dtm.AddDynamicTextureData(
283  m_scene.RegionInfo.RegionID,
284  so.UUID,
285  m_vrm.GetContentType(),
286  dtText,
287  "",
288  0);
289 
290  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
291 
292  m_dtm.AddDynamicTextureData(
293  m_scene.RegionInfo.RegionID,
294  so.UUID,
295  m_vrm.GetContentType(),
296  dtText,
297  "alpha:250",
298  0);
299 
300  Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
301  }
302 
303  [Test]
305  {
306  TestHelpers.InMethod();
307 
308  string dtText
309  = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World; Image http://0.0.0.0/shouldnotexist.png";
310 
311  SetupScene(true);
312  SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene);
313 
314  m_dtm.AddDynamicTextureData(
315  m_scene.RegionInfo.RegionID,
316  so.UUID,
317  m_vrm.GetContentType(),
318  dtText,
319  "",
320  0);
321 
322  UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID;
323 
324  m_dtm.AddDynamicTextureData(
325  m_scene.RegionInfo.RegionID,
326  so.UUID,
327  m_vrm.GetContentType(),
328  dtText,
329  "",
330  0);
331 
332  Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID));
333  }
334  }
335 }
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
void TestRepeatSameDrawLowDataTexture()
Test a low data dynamically generated texture such that it is treated as a low data texture that caus...
Helpers for setting up scenes.
Definition: SceneHelpers.cs:60
Interactive OpenSim region server
Definition: OpenSim.cs:55