From 381f74276b94f9f635b08c4bccf3040fce5d59fb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 19 Jan 2012 21:14:09 +0000 Subject: Add LLImageManager regression test for discard case --- .../Linden/UDP/Tests/LLImageManagerTests.cs | 53 ++++++++++++++++++++++ 1 file changed, 53 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index bdc9c7d..118333c 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs @@ -88,5 +88,58 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(1)); } + + [Test] + public void TestRequestAndDiscardImage() + { + TestHelpers.InMethod(); +// XmlConfigurator.Configure(); + + UUID imageId = TestHelpers.ParseTail(0x1); + string creatorId = TestHelpers.ParseTail(0x2).ToString(); + UUID userId = TestHelpers.ParseTail(0x3); + + J2KDecoderModule j2kdm = new J2KDecoderModule(); + + Scene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, j2kdm); + + TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); + LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm); + + using ( + Stream resource + = GetType().Assembly.GetManifestResourceStream( + "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2")) + { + using (BinaryReader br = new BinaryReader(resource)) + { + AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); + asset.Data = br.ReadBytes(99999999); + scene.AssetService.Store(asset); + } + } + + TextureRequestArgs args = new TextureRequestArgs(); + args.RequestedAssetID = imageId; + args.DiscardLevel = 0; + args.PacketNumber = 1; + args.Priority = 5; + args.requestSequence = 1; + llim.EnqueueReq(args); + + // Now create a discard request + TextureRequestArgs discardArgs = new TextureRequestArgs(); + discardArgs.RequestedAssetID = imageId; + discardArgs.DiscardLevel = -1; + discardArgs.PacketNumber = 1; + discardArgs.Priority = 0; + discardArgs.requestSequence = 2; + llim.EnqueueReq(discardArgs); + + llim.ProcessImageQueue(20); + + Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); + } } } \ No newline at end of file -- cgit v1.1