diff options
author | Justin Clark-Casey (justincc) | 2012-01-19 21:23:40 +0000 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-01-19 21:23:40 +0000 |
commit | 503faaea62502e1e86fc11bee1a322e060836f62 (patch) | |
tree | bf575ad271ef3b952d8247fcec933eea524fc568 /OpenSim/Region/ClientStack/Linden/UDP/Tests | |
parent | Add LLImageManager regression test for discard case (diff) | |
download | opensim-SC_OLD-503faaea62502e1e86fc11bee1a322e060836f62.zip opensim-SC_OLD-503faaea62502e1e86fc11bee1a322e060836f62.tar.gz opensim-SC_OLD-503faaea62502e1e86fc11bee1a322e060836f62.tar.bz2 opensim-SC_OLD-503faaea62502e1e86fc11bee1a322e060836f62.tar.xz |
refactor: separate out common parts of LLImageManagerTests
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | 88 |
1 files changed, 40 insertions, 48 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 118333c..f176964 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -45,24 +45,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class LLImageManagerTests | 46 | public class LLImageManagerTests |
47 | { | 47 | { |
48 | [Test] | 48 | private AssetBase m_testImageAsset; |
49 | public void TestRequestAndSendImage() | 49 | private LLImageManager llim; |
50 | { | 50 | private TestClient tc; |
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 | 51 | ||
52 | [TestFixtureSetUp] | ||
53 | public void FixtureInit() | ||
54 | { | ||
66 | using ( | 55 | using ( |
67 | Stream resource | 56 | Stream resource |
68 | = GetType().Assembly.GetManifestResourceStream( | 57 | = GetType().Assembly.GetManifestResourceStream( |
@@ -70,14 +59,42 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
70 | { | 59 | { |
71 | using (BinaryReader br = new BinaryReader(resource)) | 60 | using (BinaryReader br = new BinaryReader(resource)) |
72 | { | 61 | { |
73 | AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); | 62 | m_testImageAsset |
74 | asset.Data = br.ReadBytes(99999999); | 63 | = new AssetBase( |
75 | scene.AssetService.Store(asset); | 64 | TestHelpers.ParseTail(0x1), |
65 | "Test Image", | ||
66 | (sbyte)AssetType.Texture, | ||
67 | TestHelpers.ParseTail(0x2).ToString()); | ||
68 | |||
69 | m_testImageAsset.Data = br.ReadBytes(99999999); | ||
76 | } | 70 | } |
77 | } | 71 | } |
72 | } | ||
73 | |||
74 | [SetUp] | ||
75 | public void SetUp() | ||
76 | { | ||
77 | UUID userId = TestHelpers.ParseTail(0x3); | ||
78 | |||
79 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | ||
80 | |||
81 | Scene scene = SceneHelpers.SetupScene(); | ||
82 | SceneHelpers.SetupSceneModules(scene, j2kdm); | ||
83 | |||
84 | scene.AssetService.Store(m_testImageAsset); | ||
85 | |||
86 | tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | ||
87 | llim = new LLImageManager(tc, scene.AssetService, j2kdm); | ||
88 | } | ||
89 | |||
90 | [Test] | ||
91 | public void TestRequestAndSendImage() | ||
92 | { | ||
93 | TestHelpers.InMethod(); | ||
94 | // XmlConfigurator.Configure(); | ||
78 | 95 | ||
79 | TextureRequestArgs args = new TextureRequestArgs(); | 96 | TextureRequestArgs args = new TextureRequestArgs(); |
80 | args.RequestedAssetID = TestHelpers.ParseTail(0x1); | 97 | args.RequestedAssetID = m_testImageAsset.FullID; |
81 | args.DiscardLevel = 0; | 98 | args.DiscardLevel = 0; |
82 | args.PacketNumber = 1; | 99 | args.PacketNumber = 1; |
83 | args.Priority = 5; | 100 | args.Priority = 5; |
@@ -95,33 +112,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
95 | TestHelpers.InMethod(); | 112 | TestHelpers.InMethod(); |
96 | // XmlConfigurator.Configure(); | 113 | // XmlConfigurator.Configure(); |
97 | 114 | ||
98 | UUID imageId = TestHelpers.ParseTail(0x1); | ||
99 | string creatorId = TestHelpers.ParseTail(0x2).ToString(); | ||
100 | UUID userId = TestHelpers.ParseTail(0x3); | ||
101 | |||
102 | J2KDecoderModule j2kdm = new J2KDecoderModule(); | ||
103 | |||
104 | Scene scene = SceneHelpers.SetupScene(); | ||
105 | SceneHelpers.SetupSceneModules(scene, j2kdm); | ||
106 | |||
107 | TestClient tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene); | ||
108 | LLImageManager llim = new LLImageManager(tc, scene.AssetService, j2kdm); | ||
109 | |||
110 | using ( | ||
111 | Stream resource | ||
112 | = GetType().Assembly.GetManifestResourceStream( | ||
113 | "OpenSim.Region.ClientStack.LindenUDP.Tests.Resources.4-tile2.jp2")) | ||
114 | { | ||
115 | using (BinaryReader br = new BinaryReader(resource)) | ||
116 | { | ||
117 | AssetBase asset = new AssetBase(imageId, "Test Image", (sbyte)AssetType.Texture, creatorId); | ||
118 | asset.Data = br.ReadBytes(99999999); | ||
119 | scene.AssetService.Store(asset); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | TextureRequestArgs args = new TextureRequestArgs(); | 115 | TextureRequestArgs args = new TextureRequestArgs(); |
124 | args.RequestedAssetID = imageId; | 116 | args.RequestedAssetID = m_testImageAsset.FullID; |
125 | args.DiscardLevel = 0; | 117 | args.DiscardLevel = 0; |
126 | args.PacketNumber = 1; | 118 | args.PacketNumber = 1; |
127 | args.Priority = 5; | 119 | args.Priority = 5; |
@@ -130,7 +122,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
130 | 122 | ||
131 | // Now create a discard request | 123 | // Now create a discard request |
132 | TextureRequestArgs discardArgs = new TextureRequestArgs(); | 124 | TextureRequestArgs discardArgs = new TextureRequestArgs(); |
133 | discardArgs.RequestedAssetID = imageId; | 125 | discardArgs.RequestedAssetID = m_testImageAsset.FullID; |
134 | discardArgs.DiscardLevel = -1; | 126 | discardArgs.DiscardLevel = -1; |
135 | discardArgs.PacketNumber = 1; | 127 | discardArgs.PacketNumber = 1; |
136 | discardArgs.Priority = 0; | 128 | discardArgs.Priority = 0; |