aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorSean Dague2009-01-13 19:55:07 +0000
committerSean Dague2009-01-13 19:55:07 +0000
commit9dff38ca1427e73dbf297f095a1e4c63eb994020 (patch)
tree6f6be408e85c51d0b6c1d392fe60ac010aeb0891 /OpenSim
parent* minor: remove some mono compiler warnings (diff)
downloadopensim-SC-9dff38ca1427e73dbf297f095a1e4c63eb994020.zip
opensim-SC-9dff38ca1427e73dbf297f095a1e4c63eb994020.tar.gz
opensim-SC-9dff38ca1427e73dbf297f095a1e4c63eb994020.tar.bz2
opensim-SC-9dff38ca1427e73dbf297f095a1e4c63eb994020.tar.xz
* Extended TextureSenderTests and modified TestClient.cs with new methods
From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs134
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs60
2 files changed, 167 insertions, 27 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs
index 4049dfc..c15bd46 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/Tests/TextureSenderTests.cs
@@ -25,9 +25,13 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
29using System.Collections;
28using NUnit.Framework; 30using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers;
29using OpenMetaverse; 32using OpenMetaverse;
30using OpenSim.Framework; 33using OpenSim.Framework;
34
31using OpenSim.Tests.Common.Mock; 35using OpenSim.Tests.Common.Mock;
32 36
33namespace OpenSim.Region.Environment.Modules.Agent.TextureSender 37namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
@@ -35,11 +39,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
35 [TestFixture] 39 [TestFixture]
36 public class UserTextureSenderTests 40 public class UserTextureSenderTests
37 { 41 {
38 [Test] 42 public UUID uuid1;
39 /// <summary> 43 public UUID uuid2;
40 /// More a placeholder, really 44 public UUID uuid3;
41 /// </summary> 45 public UUID uuid4;
42 public void DummyTest() 46 public int npackets, testsize;
47 public TestClient client;
48 public TextureSender ts;
49 public static Random random = new Random();
50
51 [TestFixtureSetUp]
52 public void Init()
43 { 53 {
44 AgentCircuitData agent = new AgentCircuitData(); 54 AgentCircuitData agent = new AgentCircuitData();
45 agent.AgentID = UUID.Random(); 55 agent.AgentID = UUID.Random();
@@ -52,8 +62,116 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
52 agent.InventoryFolder = UUID.Zero; 62 agent.InventoryFolder = UUID.Zero;
53 agent.startpos = Vector3.Zero; 63 agent.startpos = Vector3.Zero;
54 agent.CapsPath = "http://wibble.com"; 64 agent.CapsPath = "http://wibble.com";
55 65 client = new TestClient(agent);
56 new TextureSender(new TestClient(agent), 0, 0); 66 ts = new TextureSender(client, 0, 0);
67 testsize = random.Next(5000,15000);
68 npackets = CalculateNumPackets(testsize);
69 uuid1 = UUID.Random();
70 uuid2 = UUID.Random();
71 uuid3 = UUID.Random();
72 uuid4 = UUID.Random();
73 }
74
75 /// <summary>
76 /// Test sending package
77 /// </summary>
78 [Test]
79 public void T010_SendPkg()
80 {
81 // Normal sending
82 AssetBase abase = new AssetBase(uuid1, "asset one");
83 byte[] abdata = new byte[testsize];
84 random.NextBytes(abdata);
85 abase.Data = abdata;
86 bool isdone = false;
87 ts.TextureReceived(abase);
88 for (int i = 0; i < npackets; i++) {
89 isdone = ts.SendTexturePacket();
90 }
91
92 Assert.That(isdone,Is.False);
93 isdone = ts.SendTexturePacket();
94 Assert.That(isdone,Is.True);
95 }
96
97 [Test]
98 public void T011_UpdateReq()
99 {
100 // Test packet number start
101 AssetBase abase = new AssetBase(uuid2, "asset two");
102 byte[] abdata = new byte[testsize];
103 random.NextBytes(abdata);
104 abase.Data = abdata;
105
106 bool isdone = false;
107 ts.TextureReceived(abase);
108 ts.UpdateRequest(0,3);
109
110 for (int i = 0; i < npackets-3; i++) {
111 isdone = ts.SendTexturePacket();
112 }
113
114 Assert.That(isdone,Is.False);
115 isdone = ts.SendTexturePacket();
116 Assert.That(isdone,Is.True);
117
118 // Test discard level
119 abase = new AssetBase(uuid3, "asset three");
120 abdata = new byte[testsize];
121 random.NextBytes(abdata);
122 abase.Data = abdata;
123 isdone = false;
124 ts.TextureReceived(abase);
125 ts.UpdateRequest(-1,0);
126
127 Assert.That(ts.SendTexturePacket(),Is.True);
128
129 abase = new AssetBase(uuid4, "asset four");
130 abdata = new byte[testsize];
131 random.NextBytes(abdata);
132 abase.Data = abdata;
133 isdone = false;
134 ts.TextureReceived(abase);
135 ts.UpdateRequest(0,5);
136
137 for (int i = 0; i < npackets-5; i++) {
138 isdone = ts.SendTexturePacket();
139 }
140 Assert.That(isdone,Is.False);
141 isdone = ts.SendTexturePacket();
142 Assert.That(isdone,Is.True);
143 }
144
145 [Test]
146 public void T999_FinishStatus()
147 {
148 // Of the 4 assets "sent", only 2 sent the first part.
149 Assert.That(client.sentdatapkt.Count,Is.EqualTo(2));
150
151 // Sum of all packets sent:
152 int totalpkts = (npackets) + (npackets - 2) + (npackets - 4);
153 Assert.That(client.sentpktpkt.Count,Is.EqualTo(totalpkts));
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;
57 } 175 }
58 } 176 }
59} \ No newline at end of file 177}
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index a9ee837..428f599 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -39,6 +39,10 @@ namespace OpenSim.Tests.Common.Mock
39 { 39 {
40 private Scene m_scene; 40 private Scene m_scene;
41 41
42 // Mock testing variables
43 public List<ImageDataPacket> sentdatapkt = new List<ImageDataPacket>();
44 public List<ImagePacketPacket> sentpktpkt = new List<ImagePacketPacket>();
45
42// disable warning: public events, part of the public API 46// disable warning: public events, part of the public API
43#pragma warning disable 67 47#pragma warning disable 67
44 48
@@ -215,7 +219,7 @@ namespace OpenSim.Tests.Common.Mock
215 public event ActivateGesture OnActivateGesture; 219 public event ActivateGesture OnActivateGesture;
216 public event DeactivateGesture OnDeactivateGesture; 220 public event DeactivateGesture OnDeactivateGesture;
217 public event ObjectOwner OnObjectOwner; 221 public event ObjectOwner OnObjectOwner;
218 222
219 public event DirPlacesQuery OnDirPlacesQuery; 223 public event DirPlacesQuery OnDirPlacesQuery;
220 public event DirFindQuery OnDirFindQuery; 224 public event DirFindQuery OnDirFindQuery;
221 public event DirLandQuery OnDirLandQuery; 225 public event DirLandQuery OnDirLandQuery;
@@ -229,7 +233,7 @@ namespace OpenSim.Tests.Common.Mock
229 public event OfferCallingCard OnOfferCallingCard; 233 public event OfferCallingCard OnOfferCallingCard;
230 public event AcceptCallingCard OnAcceptCallingCard; 234 public event AcceptCallingCard OnAcceptCallingCard;
231 public event DeclineCallingCard OnDeclineCallingCard; 235 public event DeclineCallingCard OnDeclineCallingCard;
232 236
233 public event SoundTrigger OnSoundTrigger; 237 public event SoundTrigger OnSoundTrigger;
234 238
235 public event StartLure OnStartLure; 239 public event StartLure OnStartLure;
@@ -284,7 +288,7 @@ namespace OpenSim.Tests.Common.Mock
284 { 288 {
285 get { return m_firstName; } 289 get { return m_firstName; }
286 } 290 }
287 private string m_firstName; 291 private string m_firstName;
288 292
289 public virtual string LastName 293 public virtual string LastName
290 { 294 {
@@ -359,7 +363,7 @@ namespace OpenSim.Tests.Common.Mock
359 { 363 {
360 myID = agentData.AgentID; 364 myID = agentData.AgentID;
361 m_firstName = agentData.firstname; 365 m_firstName = agentData.firstname;
362 m_lastName = agentData.lastname; 366 m_lastName = agentData.lastname;
363 } 367 }
364 368
365 public virtual void ActivateGesture(UUID assetId, UUID gestureId) 369 public virtual void ActivateGesture(UUID assetId, UUID gestureId)
@@ -420,12 +424,12 @@ namespace OpenSim.Tests.Common.Mock
420 424
421 public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp) 425 public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp)
422 { 426 {
423 427
424 } 428 }
425 429
426 public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, UUID transactionID, bool fromGroup, byte[] binaryBucket) 430 public void SendInstantMessage(UUID fromAgent, string message, UUID toAgent, string fromName, byte dialog, uint timeStamp, UUID transactionID, bool fromGroup, byte[] binaryBucket)
427 { 431 {
428 432
429 } 433 }
430 434
431 public void SendGenericMessage(string method, List<string> message) 435 public void SendGenericMessage(string method, List<string> message)
@@ -563,7 +567,7 @@ namespace OpenSim.Tests.Common.Mock
563 public virtual void SendBulkUpdateInventory(InventoryItemBase item) 567 public virtual void SendBulkUpdateInventory(InventoryItemBase item)
564 { 568 {
565 } 569 }
566 570
567 public void SendBulkUpdateInventory(InventoryFolderBase folderBase) 571 public void SendBulkUpdateInventory(InventoryFolderBase folderBase)
568 {} 572 {}
569 573
@@ -590,7 +594,7 @@ namespace OpenSim.Tests.Common.Mock
590 int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) 594 int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
591 { 595 {
592 } 596 }
593 597
594 public virtual void SendNameReply(UUID profileId, string firstname, string lastname) 598 public virtual void SendNameReply(UUID profileId, string firstname, string lastname)
595 { 599 {
596 } 600 }
@@ -660,16 +664,34 @@ namespace OpenSim.Tests.Common.Mock
660 664
661 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec) 665 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
662 { 666 {
667 ImageDataPacket im = new ImageDataPacket();
668 im.Header.Reliable = false;
669 im.ImageID.Packets = numParts;
670 im.ImageID.ID = ImageUUID;
671
672 if (ImageSize > 0)
673 im.ImageID.Size = ImageSize;
674
675 im.ImageData.Data = ImageData;
676 im.ImageID.Codec = imageCodec;
677 im.Header.Zerocoded = true;
678 sentdatapkt.Add(im);
663 } 679 }
664 680
665 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) 681 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
666 { 682 {
683 ImagePacketPacket im = new ImagePacketPacket();
684 im.Header.Reliable = false;
685 im.ImageID.Packet = partNumber;
686 im.ImageID.ID = imageUuid;
687 im.ImageData.Data = imageData;
688 sentpktpkt.Add(im);
667 } 689 }
668 690
669 public void SendImageNotFound(UUID imageid) 691 public void SendImageNotFound(UUID imageid)
670 { 692 {
671 } 693 }
672 694
673 public void SendShutdownConnectionNotice() 695 public void SendShutdownConnectionNotice()
674 { 696 {
675 } 697 }
@@ -726,10 +748,10 @@ namespace OpenSim.Tests.Common.Mock
726 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase) 748 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong time, uint dlen, uint ylen, float phase)
727 { 749 {
728 } 750 }
729 751
730 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks) 752 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
731 { 753 {
732 } 754 }
733 755
734 public void SendViewerTime(int phase) 756 public void SendViewerTime(int phase)
735 { 757 {
@@ -804,11 +826,11 @@ namespace OpenSim.Tests.Common.Mock
804 public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args) 826 public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
805 { 827 {
806 } 828 }
807 829
808 public void SendEstateCovenantInformation(UUID covenant) 830 public void SendEstateCovenantInformation(UUID covenant)
809 { 831 {
810 } 832 }
811 833
812 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner) 834 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, string abuseEmail, UUID estateOwner)
813 { 835 {
814 } 836 }
@@ -816,19 +838,19 @@ namespace OpenSim.Tests.Common.Mock
816 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) 838 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, LandData landData, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
817 { 839 {
818 } 840 }
819 841
820 public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID) 842 public void SendLandAccessListData(List<UUID> avatars, uint accessFlag, int localLandID)
821 { 843 {
822 } 844 }
823 845
824 public void SendForceClientSelectObjects(List<uint> objectIDs) 846 public void SendForceClientSelectObjects(List<uint> objectIDs)
825 { 847 {
826 } 848 }
827 849
828 public void SendLandObjectOwners(Dictionary<UUID, int> ownersAndCount) 850 public void SendLandObjectOwners(Dictionary<UUID, int> ownersAndCount)
829 { 851 {
830 } 852 }
831 853
832 public void SendLandParcelOverlay(byte[] data, int sequence_id) 854 public void SendLandParcelOverlay(byte[] data, int sequence_id)
833 { 855 {
834 } 856 }