aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs160
1 files changed, 160 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
new file mode 100644
index 0000000..1b68d68
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
@@ -0,0 +1,160 @@
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.IO;
30using System.Net;
31using System.Reflection;
32using log4net.Config;
33using Nini.Config;
34using NUnit.Framework;
35using OpenMetaverse;
36using OpenMetaverse.Packets;
37using OpenSim.Framework;
38using OpenSim.Region.CoreModules.Agent.TextureSender;
39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Tests.Common;
41using OpenSim.Tests.Common.Mock;
42
43namespace OpenSim.Region.ClientStack.LindenUDP.Tests
44{
45 [TestFixture]
46 public class LLImageManagerTests
47 {
48 private AssetBase m_testImageAsset;
49 private Scene scene;
50 private LLImageManager llim;
51 private TestClient tc;
52
53 [TestFixtureSetUp]
54 public void FixtureInit()
55 {
56 using (
57 Stream resource
58 = GetType().Assembly.GetManifestResourceStream(
59 "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2"))
60 {
61 using (BinaryReader br = new BinaryReader(resource))
62 {
63 m_testImageAsset
64 = new AssetBase(
65 TestHelpers.ParseTail(0x1),
66 "Test Image",
67 (sbyte)AssetType.Texture,
68 TestHelpers.ParseTail(0x2).ToString());
69
70 m_testImageAsset.Data = br.ReadBytes(99999999);
71 }
72 }
73 }
74
75 [SetUp]
76 public void SetUp()
77 {
78 UUID userId = TestHelpers.ParseTail(0x3);
79
80 J2KDecoderModule j2kdm = new J2KDecoderModule();
81
82 scene = SceneHelpers.SetupScene();
83 SceneHelpers.SetupSceneModules(scene, j2kdm);
84
85 tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
86 llim = new LLImageManager(tc, scene.AssetService, j2kdm);
87 }
88
89 [Test]
90 public void TestSendImage()
91 {
92 TestHelpers.InMethod();
93// XmlConfigurator.Configure();
94
95 scene.AssetService.Store(m_testImageAsset);
96
97 TextureRequestArgs args = new TextureRequestArgs();
98 args.RequestedAssetID = m_testImageAsset.FullID;
99 args.DiscardLevel = 0;
100 args.PacketNumber = 1;
101 args.Priority = 5;
102 args.requestSequence = 1;
103
104 llim.EnqueueReq(args);
105 llim.ProcessImageQueue(20);
106
107 Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1));
108 }
109
110 [Test]
111 public void TestDiscardImage()
112 {
113 TestHelpers.InMethod();
114// XmlConfigurator.Configure();
115
116 scene.AssetService.Store(m_testImageAsset);
117
118 TextureRequestArgs args = new TextureRequestArgs();
119 args.RequestedAssetID = m_testImageAsset.FullID;
120 args.DiscardLevel = 0;
121 args.PacketNumber = 1;
122 args.Priority = 5;
123 args.requestSequence = 1;
124 llim.EnqueueReq(args);
125
126 // Now create a discard request
127 TextureRequestArgs discardArgs = new TextureRequestArgs();
128 discardArgs.RequestedAssetID = m_testImageAsset.FullID;
129 discardArgs.DiscardLevel = -1;
130 discardArgs.PacketNumber = 1;
131 discardArgs.Priority = 0;
132 discardArgs.requestSequence = 2;
133 llim.EnqueueReq(discardArgs);
134
135 llim.ProcessImageQueue(20);
136
137 Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
138 }
139
140 [Test]
141 public void TestMissingImage()
142 {
143 TestHelpers.InMethod();
144// XmlConfigurator.Configure();
145
146 TextureRequestArgs args = new TextureRequestArgs();
147 args.RequestedAssetID = m_testImageAsset.FullID;
148 args.DiscardLevel = 0;
149 args.PacketNumber = 1;
150 args.Priority = 5;
151 args.requestSequence = 1;
152
153 llim.EnqueueReq(args);
154 llim.ProcessImageQueue(20);
155
156 Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0));
157 Assert.That(tc.SentImageNotInDatabasePackets.Count, Is.EqualTo(1));
158 }
159 }
160} \ No newline at end of file