diff options
author | Dr Scofield | 2009-02-09 09:16:15 +0000 |
---|---|---|
committer | Dr Scofield | 2009-02-09 09:16:15 +0000 |
commit | a89d097355526d4dc52a75a9734c6a02c3008ef4 (patch) | |
tree | f12e2cf5807762e0fbaf2f304e75b618f62b4cf6 /OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs | |
parent | adding bin/ScriptEngines/*/*.{dll,state}, bin/j2kDecodeCache, (diff) | |
download | opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.zip opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.tar.gz opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.tar.bz2 opensim-SC_OLD-a89d097355526d4dc52a75a9734c6a02c3008ef4.tar.xz |
starting phase 2 of the OpenSim.Region.Environment commit: relocating
OpenSim.Region.Environment.Modules.Agent en bloc to OpenSim.Region.CoreModules
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs deleted file mode 100644 index cfac868..0000000 --- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs +++ /dev/null | |||
@@ -1,177 +0,0 @@ | |||
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 OpenSim 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 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using NUnit.Framework; | ||
31 | using NUnit.Framework.SyntaxHelpers; | ||
32 | using OpenMetaverse; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Tests.Common.Mock; | ||
35 | |||
36 | namespace OpenSim.Region.Environment.Modules.Agent.TextureSender | ||
37 | { | ||
38 | [TestFixture] | ||
39 | public class UserTextureSenderTests | ||
40 | { | ||
41 | public UUID uuid1; | ||
42 | public UUID uuid2; | ||
43 | public UUID uuid3; | ||
44 | public UUID uuid4; | ||
45 | public int npackets, testsize; | ||
46 | public TestClient client; | ||
47 | public TextureSender ts; | ||
48 | public static Random random = new Random(); | ||
49 | |||
50 | [TestFixtureSetUp] | ||
51 | public void Init() | ||
52 | { | ||
53 | AgentCircuitData agent = new AgentCircuitData(); | ||
54 | agent.AgentID = UUID.Random(); | ||
55 | agent.firstname = "testfirstname"; | ||
56 | agent.lastname = "testlastname"; | ||
57 | agent.SessionID = UUID.Zero; | ||
58 | agent.SecureSessionID = UUID.Zero; | ||
59 | agent.circuitcode = 123; | ||
60 | agent.BaseFolder = UUID.Zero; | ||
61 | agent.InventoryFolder = UUID.Zero; | ||
62 | agent.startpos = Vector3.Zero; | ||
63 | agent.CapsPath = "http://wibble.com"; | ||
64 | client = new TestClient(agent, null); | ||
65 | ts = new TextureSender(client, 0, 0); | ||
66 | testsize = random.Next(5000,15000); | ||
67 | npackets = CalculateNumPackets(testsize); | ||
68 | uuid1 = UUID.Random(); | ||
69 | uuid2 = UUID.Random(); | ||
70 | uuid3 = UUID.Random(); | ||
71 | uuid4 = UUID.Random(); | ||
72 | } | ||
73 | |||
74 | /// <summary> | ||
75 | /// Test sending package | ||
76 | /// </summary> | ||
77 | [Test] | ||
78 | public void T010_SendPkg() | ||
79 | { | ||
80 | // Normal sending | ||
81 | AssetBase abase = new AssetBase(uuid1, "asset one"); | ||
82 | byte[] abdata = new byte[testsize]; | ||
83 | random.NextBytes(abdata); | ||
84 | abase.Data = abdata; | ||
85 | bool isdone = false; | ||
86 | ts.TextureReceived(abase); | ||
87 | for (int i = 0; i < npackets; i++) { | ||
88 | isdone = ts.SendTexturePacket(); | ||
89 | } | ||
90 | |||
91 | Assert.That(isdone,Is.False); | ||
92 | isdone = ts.SendTexturePacket(); | ||
93 | Assert.That(isdone,Is.True); | ||
94 | } | ||
95 | |||
96 | [Test] | ||
97 | public void T011_UpdateReq() | ||
98 | { | ||
99 | // Test packet number start | ||
100 | AssetBase abase = new AssetBase(uuid2, "asset two"); | ||
101 | byte[] abdata = new byte[testsize]; | ||
102 | random.NextBytes(abdata); | ||
103 | abase.Data = abdata; | ||
104 | |||
105 | bool isdone = false; | ||
106 | ts.TextureReceived(abase); | ||
107 | ts.UpdateRequest(0,3); | ||
108 | |||
109 | for (int i = 0; i < npackets-3; i++) { | ||
110 | isdone = ts.SendTexturePacket(); | ||
111 | } | ||
112 | |||
113 | Assert.That(isdone,Is.False); | ||
114 | isdone = ts.SendTexturePacket(); | ||
115 | Assert.That(isdone,Is.True); | ||
116 | |||
117 | // Test discard level | ||
118 | abase = new AssetBase(uuid3, "asset three"); | ||
119 | abdata = new byte[testsize]; | ||
120 | random.NextBytes(abdata); | ||
121 | abase.Data = abdata; | ||
122 | isdone = false; | ||
123 | ts.TextureReceived(abase); | ||
124 | ts.UpdateRequest(-1,0); | ||
125 | |||
126 | Assert.That(ts.SendTexturePacket(),Is.True); | ||
127 | |||
128 | abase = new AssetBase(uuid4, "asset four"); | ||
129 | abdata = new byte[testsize]; | ||
130 | random.NextBytes(abdata); | ||
131 | abase.Data = abdata; | ||
132 | isdone = false; | ||
133 | ts.TextureReceived(abase); | ||
134 | ts.UpdateRequest(0,5); | ||
135 | |||
136 | for (int i = 0; i < npackets-5; i++) { | ||
137 | isdone = ts.SendTexturePacket(); | ||
138 | } | ||
139 | Assert.That(isdone,Is.False); | ||
140 | isdone = ts.SendTexturePacket(); | ||
141 | Assert.That(isdone,Is.True); | ||
142 | } | ||
143 | |||
144 | [Test] | ||
145 | public void T999_FinishStatus() | ||
146 | { | ||
147 | // Of the 4 assets "sent", only 2 sent the first part. | ||
148 | Assert.That(client.sentdatapkt.Count,Is.EqualTo(2)); | ||
149 | |||
150 | // Sum of all packets sent: | ||
151 | int totalpkts = (npackets) + (npackets - 2) + (npackets - 4); | ||
152 | Assert.That(client.sentpktpkt.Count,Is.EqualTo(totalpkts)); | ||
153 | } | ||
154 | |||
155 | /// <summary> | ||
156 | /// Calculate the number of packets that will be required to send the texture loaded into this sender | ||
157 | /// This is actually the number of 1000 byte packets not including an initial 600 byte packet... | ||
158 | /// Borrowed from TextureSender.cs | ||
159 | /// </summary> | ||
160 | /// <param name="length"></param> | ||
161 | /// <returns></returns> | ||
162 | private int CalculateNumPackets(int length) | ||
163 | { | ||
164 | int numPackets = 0; | ||
165 | |||
166 | if (length > 600) | ||
167 | { | ||
168 | //over 600 bytes so split up file | ||
169 | int restData = (length - 600); | ||
170 | int restPackets = ((restData + 999) / 1000); | ||
171 | numPackets = restPackets; | ||
172 | } | ||
173 | |||
174 | return numPackets; | ||
175 | } | ||
176 | } | ||
177 | } | ||