diff options
author | Justin Clark-Casey (justincc) | 2012-01-19 21:57:12 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-01-19 21:57:12 +0000 |
commit | d38e2c0c91b684d54974865d3ac2fb88c3354c21 (patch) | |
tree | 43a517d5df2b8b6d9444446c9d23ad7b394a883d /OpenSim/Region/ClientStack | |
parent | refactor: separate out common parts of LLImageManagerTests (diff) | |
download | opensim-SC-d38e2c0c91b684d54974865d3ac2fb88c3354c21.zip opensim-SC-d38e2c0c91b684d54974865d3ac2fb88c3354c21.tar.gz opensim-SC-d38e2c0c91b684d54974865d3ac2fb88c3354c21.tar.bz2 opensim-SC-d38e2c0c91b684d54974865d3ac2fb88c3354c21.tar.xz |
Add image not in database test for LLImageManager
Diffstat (limited to 'OpenSim/Region/ClientStack')
3 files changed, 52 insertions, 13 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs index bbd2c43..8dd76d8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/J2KImage.cs | |||
@@ -377,6 +377,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
377 | 377 | ||
378 | private void AssetReceived(string id, Object sender, AssetBase asset) | 378 | private void AssetReceived(string id, Object sender, AssetBase asset) |
379 | { | 379 | { |
380 | // m_log.DebugFormat( | ||
381 | // "[J2KIMAGE]: Received asset {0} ({1} bytes)", id, asset != null ? asset.Data.Length.ToString() : "n/a"); | ||
382 | |||
380 | UUID assetID = UUID.Zero; | 383 | UUID assetID = UUID.Zero; |
381 | if (asset != null) | 384 | if (asset != null) |
382 | { | 385 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 7bfb844..a48251f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs | |||
@@ -55,18 +55,29 @@ 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 IClientAPI m_client; //Client we're assigned to | 58 | private IAssetService m_assetCache; |
59 | private IAssetService m_assetCache; //Asset Cache | 59 | private IJ2KDecoder m_j2kDecodeModule; |
60 | private IJ2KDecoder m_j2kDecodeModule; //Our J2K module | 60 | |
61 | /// <summary> | ||
62 | /// Priority queue for determining which image to send first. | ||
63 | /// </summary> | ||
61 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); | 64 | private C5.IntervalHeap<J2KImage> m_priorityQueue = new C5.IntervalHeap<J2KImage>(10, new J2KImageComparer()); |
65 | |||
66 | /// <summary> | ||
67 | /// Used to control thread access to the priority queue. | ||
68 | /// </summary> | ||
62 | private object m_syncRoot = new object(); | 69 | private object m_syncRoot = new object(); |
63 | 70 | ||
64 | public IClientAPI Client { get { return m_client; } } | 71 | /// <summary> |
72 | /// Client served by this image manager | ||
73 | /// </summary> | ||
74 | public IClientAPI Client { get; private set; } | ||
75 | |||
65 | public AssetBase MissingImage { get { return m_missingImage; } } | 76 | public AssetBase MissingImage { get { return m_missingImage; } } |
66 | 77 | ||
67 | public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) | 78 | public LLImageManager(IClientAPI client, IAssetService pAssetCache, IJ2KDecoder pJ2kDecodeModule) |
68 | { | 79 | { |
69 | m_client = client; | 80 | Client = client; |
70 | m_assetCache = pAssetCache; | 81 | m_assetCache = pAssetCache; |
71 | 82 | ||
72 | if (pAssetCache != null) | 83 | if (pAssetCache != null) |
@@ -90,7 +101,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
90 | 101 | ||
91 | // Do a linear search for this texture download | 102 | // Do a linear search for this texture download |
92 | lock (m_syncRoot) | 103 | lock (m_syncRoot) |
104 | { | ||
93 | m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); | 105 | m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest); |
106 | } | ||
94 | 107 | ||
95 | if (imgrequest != null) | 108 | if (imgrequest != null) |
96 | { | 109 | { |
@@ -178,8 +191,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
178 | imgrequest = new J2KImage(this); | 191 | imgrequest = new J2KImage(this); |
179 | imgrequest.J2KDecoder = m_j2kDecodeModule; | 192 | imgrequest.J2KDecoder = m_j2kDecodeModule; |
180 | imgrequest.AssetService = m_assetCache; | 193 | imgrequest.AssetService = m_assetCache; |
181 | imgrequest.AgentID = m_client.AgentId; | 194 | imgrequest.AgentID = Client.AgentId; |
182 | imgrequest.InventoryAccessModule = m_client.Scene.RequestModuleInterface<IInventoryAccessModule>(); | 195 | imgrequest.InventoryAccessModule = Client.Scene.RequestModuleInterface<IInventoryAccessModule>(); |
183 | imgrequest.DiscardLevel = newRequest.DiscardLevel; | 196 | imgrequest.DiscardLevel = newRequest.DiscardLevel; |
184 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); | 197 | imgrequest.StartPacket = Math.Max(1, newRequest.PacketNumber); |
185 | imgrequest.Priority = newRequest.Priority; | 198 | imgrequest.Priority = newRequest.Priority; |
@@ -210,7 +223,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
210 | if (image.IsDecoded) | 223 | if (image.IsDecoded) |
211 | { | 224 | { |
212 | int sent; | 225 | int sent; |
213 | bool imageDone = image.SendPackets(m_client, packetsToSend - packetsSent, out sent); | 226 | bool imageDone = image.SendPackets(Client, packetsToSend - packetsSent, out sent); |
214 | packetsSent += sent; | 227 | packetsSent += sent; |
215 | 228 | ||
216 | // If the send is complete, destroy any knowledge of this transfer | 229 | // If the send is complete, destroy any knowledge of this transfer |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index f176964..1b68d68 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -46,6 +46,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
46 | public class LLImageManagerTests | 46 | public class LLImageManagerTests |
47 | { | 47 | { |
48 | private AssetBase m_testImageAsset; | 48 | private AssetBase m_testImageAsset; |
49 | private Scene scene; | ||
49 | private LLImageManager llim; | 50 | private LLImageManager llim; |
50 | private TestClient tc; | 51 | private TestClient tc; |
51 | 52 | ||
@@ -78,21 +79,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
78 | 79 | ||
79 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | 80 | J2KDecoderModule j2kdm = new J2KDecoderModule(); |
80 | 81 | ||
81 | Scene scene = SceneHelpers.SetupScene(); | 82 | scene = SceneHelpers.SetupScene(); |
82 | SceneHelpers.SetupSceneModules(scene, j2kdm); | 83 | SceneHelpers.SetupSceneModules(scene, j2kdm); |
83 | 84 | ||
84 | scene.AssetService.Store(m_testImageAsset); | ||
85 | |||
86 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | 85 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); |
87 | llim = new LLImageManager(tc, scene.AssetService, j2kdm); | 86 | llim = new LLImageManager(tc, scene.AssetService, j2kdm); |
88 | } | 87 | } |
89 | 88 | ||
90 | [Test] | 89 | [Test] |
91 | public void TestRequestAndSendImage() | 90 | public void TestSendImage() |
92 | { | 91 | { |
93 | TestHelpers.InMethod(); | 92 | TestHelpers.InMethod(); |
94 | // XmlConfigurator.Configure(); | 93 | // XmlConfigurator.Configure(); |
95 | 94 | ||
95 | scene.AssetService.Store(m_testImageAsset); | ||
96 | |||
96 | TextureRequestArgs args = new TextureRequestArgs(); | 97 | TextureRequestArgs args = new TextureRequestArgs(); |
97 | args.RequestedAssetID = m_testImageAsset.FullID; | 98 | args.RequestedAssetID = m_testImageAsset.FullID; |
98 | args.DiscardLevel = 0; | 99 | args.DiscardLevel = 0; |
@@ -107,11 +108,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
107 | } | 108 | } |
108 | 109 | ||
109 | [Test] | 110 | [Test] |
110 | public void TestRequestAndDiscardImage() | 111 | public void TestDiscardImage() |
111 | { | 112 | { |
112 | TestHelpers.InMethod(); | 113 | TestHelpers.InMethod(); |
113 | // XmlConfigurator.Configure(); | 114 | // XmlConfigurator.Configure(); |
114 | 115 | ||
116 | scene.AssetService.Store(m_testImageAsset); | ||
117 | |||
115 | TextureRequestArgs args = new TextureRequestArgs(); | 118 | TextureRequestArgs args = new TextureRequestArgs(); |
116 | args.RequestedAssetID = m_testImageAsset.FullID; | 119 | args.RequestedAssetID = m_testImageAsset.FullID; |
117 | args.DiscardLevel = 0; | 120 | args.DiscardLevel = 0; |
@@ -133,5 +136,25 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
133 | 136 | ||
134 | Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); | 137 | Assert.That(tc.SentImageDataPackets.Count, Is.EqualTo(0)); |
135 | } | 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 | } | ||
136 | } | 159 | } |
137 | } \ No newline at end of file | 160 | } \ No newline at end of file |