aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-01-19 19:00:11 +0000
committerJustin Clark-Casey (justincc)2012-01-19 19:00:11 +0000
commit9356963bd36e5c3b8c2b27bfcc2efa60ffbd02d6 (patch)
tree10fbe60949d8ad43ca5d076dd685a1edd11e5d6a /OpenSim/Region/ClientStack/Linden/UDP
parentRegionReady: (diff)
downloadopensim-SC-9356963bd36e5c3b8c2b27bfcc2efa60ffbd02d6.zip
opensim-SC-9356963bd36e5c3b8c2b27bfcc2efa60ffbd02d6.tar.gz
opensim-SC-9356963bd36e5c3b8c2b27bfcc2efa60ffbd02d6.tar.bz2
opensim-SC-9356963bd36e5c3b8c2b27bfcc2efa60ffbd02d6.tar.xz
Add basic request and send image regression tests for LLImageManager
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs6
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs6
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs92
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2bin0 -> 24410 bytes
4 files changed, 98 insertions, 6 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
index 185a909..bbd2c43 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
82 /// <param name="packetsToSend">Maximum number of packets to send during this call</param> 82 /// <param name="packetsToSend">Maximum number of packets to send during this call</param>
83 /// <param name="packetsSent">Number of packets sent during this call</param> 83 /// <param name="packetsSent">Number of packets sent during this call</param>
84 /// <returns>True if the transfer completes at the current discard level, otherwise false</returns> 84 /// <returns>True if the transfer completes at the current discard level, otherwise false</returns>
85 public bool SendPackets(LLClientView client, int packetsToSend, out int packetsSent) 85 public bool SendPackets(IClientAPI client, int packetsToSend, out int packetsSent)
86 { 86 {
87 packetsSent = 0; 87 packetsSent = 0;
88 88
@@ -212,7 +212,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
212 } 212 }
213 } 213 }
214 214
215 private bool SendFirstPacket(LLClientView client) 215 private bool SendFirstPacket(IClientAPI client)
216 { 216 {
217 if (client == null) 217 if (client == null)
218 return false; 218 return false;
@@ -247,7 +247,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
247 return false; 247 return false;
248 } 248 }
249 249
250 private bool SendPacket(LLClientView client) 250 private bool SendPacket(IClientAPI client)
251 { 251 {
252 if (client == null) 252 if (client == null)
253 return false; 253 return false;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
index db428f1..30d3712 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs
@@ -55,16 +55,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 private bool m_shuttingdown; 56 private bool m_shuttingdown;
57 private AssetBase m_missingImage; 57 private AssetBase m_missingImage;
58 private LLClientView m_client; //Client we're assigned to 58 private IClientAPI m_client; //Client we're assigned to
59 private IAssetService m_assetCache; //Asset Cache 59 private IAssetService m_assetCache; //Asset Cache
60 private IJ2KDecoder m_j2kDecodeModule; //Our J2K module 60 private IJ2KDecoder m_j2kDecodeModule; //Our J2K module
61 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); 61 private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer());
62 private object m_syncRoot = new object(); 62 private object m_syncRoot = new object();
63 63
64 public LLClientView Client { get { return m_client; } } 64 public IClientAPI Client { get { return m_client; } }
65 public AssetBase MissingImage { get { return m_missingImage; } } 65 public AssetBase MissingImage { get { return m_missingImage; } }
66 66
67 public LLImageManager(LLClientView client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) 67 public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule)
68 { 68 {
69 m_client = client; 69 m_client = client;
70 m_assetCache = pAssetCache; 70 m_assetCache = pAssetCache;
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..bdc9c7d
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
@@ -0,0 +1,92 @@
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 [Test]
49 public void TestRequestAndSendImage()
50 {
51 TestHelpers.InMethod();
52// XmlConfigurator.Configure();
53
54 UUID imageId = TestHelpers.ParseTail(0x1);
55 string creatorId = TestHelpers.ParseTail(0x2).ToString();
56 UUID userId = TestHelpers.ParseTail(0x3);
57
58 J2KDecoderModule j2kdm = new J2KDecoderModule();
59
60 Scene scene = SceneHelpers.SetupScene();
61 SceneHelpers.SetupSceneModules(scene, j2kdm);
62
63 TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
64 LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm);
65
66 using (
67 Stream resource
68 = GetType().Assembly.GetManifestResourceStream(
69 "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2"))
70 {
71 using (BinaryReader br = new BinaryReader(resource))
72 {
73 AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId);
74 asset.Data = br.ReadBytes(99999999);
75 scene.AssetService.Store(asset);
76 }
77 }
78
79 TextureRequestArgs args = new TextureRequestArgs();
80 args.RequestedAssetID = TestHelpers.ParseTail(0x1);
81 args.DiscardLevel = 0;
82 args.PacketNumber = 1;
83 args.Priority = 5;
84 args.requestSequence = 1;
85
86 llim.EnqueueReq(args);
87 llim.ProcessImageQueue(20);
88
89 Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1));
90 }
91 }
92} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2 b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2
new file mode 100644
index 0000000..8c63104
--- /dev/null
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/Resources/4-tile2.jp2
Binary files differ