aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Tests/Common
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Tests/Common')
-rw-r--r--OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs2
-rw-r--r--OpenSim/Tests/Common/Helpers/SceneHelpers.cs54
-rw-r--r--OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs41
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs48
-rw-r--r--OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs28
5 files changed, 95 insertions, 78 deletions
diff --git a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
index 6cc7ff2..1b960b1 100644
--- a/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/EntityTransferHelpers.cs
@@ -82,7 +82,7 @@ namespace OpenSim.Tests.Common
82 Scene neighbourScene; 82 Scene neighbourScene;
83 SceneManager.Instance.TryGetScene(x, y, out neighbourScene); 83 SceneManager.Instance.TryGetScene(x, y, out neighbourScene);
84 84
85 TestClient neighbourTc = new TestClient(newAgent, neighbourScene, SceneManager.Instance); 85 TestClient neighbourTc = new TestClient(newAgent, neighbourScene);
86 neighbourTcs.Add(neighbourTc); 86 neighbourTcs.Add(neighbourTc);
87 neighbourScene.AddNewClient(neighbourTc, PresenceType.User); 87 neighbourScene.AddNewClient(neighbourTc, PresenceType.User);
88 }; 88 };
diff --git a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
index bdd9093..d9bb85e 100644
--- a/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/SceneHelpers.cs
@@ -447,9 +447,6 @@ namespace OpenSim.Tests.Common
447 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test 447 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
448 /// </summary> 448 /// </summary>
449 /// <remarks> 449 /// <remarks>
450 /// This can be used for tests where there is only one region or where there are multiple non-neighbour regions
451 /// and teleport doesn't take place.
452 ///
453 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will 450 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
454 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data. 451 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
455 /// </remarks> 452 /// </remarks>
@@ -462,22 +459,6 @@ namespace OpenSim.Tests.Common
462 } 459 }
463 460
464 /// <summary> 461 /// <summary>
465 /// Add a root agent where the details of the agent connection (apart from the id) are unimportant for the test
466 /// </summary>
467 /// <remarks>
468 /// XXX: Use the version of this method that takes the UserAccount structure wherever possible - this will
469 /// make the agent circuit data (e.g. first, lastname) consistent with the user account data.
470 /// </remarks>
471 /// <param name="scene"></param>
472 /// <param name="agentId"></param>
473 /// <param name="sceneManager"></param>
474 /// <returns></returns>
475 public static ScenePresence AddScenePresence(Scene scene, UUID agentId, SceneManager sceneManager)
476 {
477 return AddScenePresence(scene, GenerateAgentData(agentId), sceneManager);
478 }
479
480 /// <summary>
481 /// Add a root agent. 462 /// Add a root agent.
482 /// </summary> 463 /// </summary>
483 /// <param name="scene"></param> 464 /// <param name="scene"></param>
@@ -508,31 +489,7 @@ namespace OpenSim.Tests.Common
508 /// <returns></returns> 489 /// <returns></returns>
509 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData) 490 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData)
510 { 491 {
511 return AddScenePresence(scene, agentData, null); 492 return AddScenePresence(scene, new TestClient(agentData, scene), agentData);
512 }
513
514 /// <summary>
515 /// Add a root agent.
516 /// </summary>
517 /// <remarks>
518 /// This function
519 ///
520 /// 1) Tells the scene that an agent is coming. Normally, the login service (local if standalone, from the
521 /// userserver if grid) would give initial login data back to the client and separately tell the scene that the
522 /// agent was coming.
523 ///
524 /// 2) Connects the agent with the scene
525 ///
526 /// This function performs actions equivalent with notifying the scene that an agent is
527 /// coming and then actually connecting the agent to the scene. The one step missed out is the very first
528 /// </remarks>
529 /// <param name="scene"></param>
530 /// <param name="agentData"></param>
531 /// <param name="sceneManager"></param>
532 /// <returns></returns>
533 public static ScenePresence AddScenePresence(Scene scene, AgentCircuitData agentData, SceneManager sceneManager)
534 {
535 return AddScenePresence(scene, new TestClient(agentData, scene, sceneManager), agentData, sceneManager);
536 } 493 }
537 494
538 /// <summary> 495 /// <summary>
@@ -552,10 +509,9 @@ namespace OpenSim.Tests.Common
552 /// </remarks> 509 /// </remarks>
553 /// <param name="scene"></param> 510 /// <param name="scene"></param>
554 /// <param name="agentData"></param> 511 /// <param name="agentData"></param>
555 /// <param name="sceneManager"></param>
556 /// <returns></returns> 512 /// <returns></returns>
557 public static ScenePresence AddScenePresence( 513 public static ScenePresence AddScenePresence(
558 Scene scene, IClientAPI client, AgentCircuitData agentData, SceneManager sceneManager) 514 Scene scene, IClientAPI client, AgentCircuitData agentData)
559 { 515 {
560 // We emulate the proper login sequence here by doing things in four stages 516 // We emulate the proper login sequence here by doing things in four stages
561 517
@@ -578,10 +534,6 @@ namespace OpenSim.Tests.Common
578 /// Introduce an agent into the scene by adding a new client. 534 /// Introduce an agent into the scene by adding a new client.
579 /// </summary> 535 /// </summary>
580 /// <returns>The scene presence added</returns> 536 /// <returns>The scene presence added</returns>
581 /// <param name='sceneManager'>
582 /// Scene manager. Can be null if there is only one region in the test or multiple regions that are not
583 /// neighbours and where no teleporting takes place.
584 /// </param>
585 /// <param name='scene'></param> 537 /// <param name='scene'></param>
586 /// <param name='testClient'></param> 538 /// <param name='testClient'></param>
587 /// <param name='agentData'></param> 539 /// <param name='agentData'></param>
@@ -607,7 +559,7 @@ namespace OpenSim.Tests.Common
607 acd.child = true; 559 acd.child = true;
608 560
609 // XXX: ViaLogin may not be correct for child agents 561 // XXX: ViaLogin may not be correct for child agents
610 TestClient client = new TestClient(acd, scene, null); 562 TestClient client = new TestClient(acd, scene);
611 return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin); 563 return IntroduceClientToScene(scene, client, acd, TeleportFlags.ViaLogin);
612 } 564 }
613 565
diff --git a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
index a1794c9..b3b75af 100644
--- a/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs
@@ -218,12 +218,37 @@ namespace OpenSim.Tests.Common
218 public static InventoryFolderBase CreateInventoryFolder( 218 public static InventoryFolderBase CreateInventoryFolder(
219 IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders) 219 IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
220 { 220 {
221 return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders);
222 }
223
224 /// <summary>
225 /// Create inventory folders starting from the user's root folder.
226 /// </summary>
227 /// <param name="inventoryService"></param>
228 /// <param name="userId"></param>
229 /// <param name="folderId"></param>
230 /// <param name="path">
231 /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
232 /// </param>
233 /// <param name="useExistingFolders">
234 /// If true, then folders in the path which already the same name are
235 /// used. This applies to the terminal folder as well.
236 /// If false, then all folders in the path are created, even if there is already a folder at a particular
237 /// level with the same name.
238 /// </param>
239 /// <returns>
240 /// The folder created. If the path contains multiple folders then the last one created is returned.
241 /// Will return null if the root folder could not be found.
242 /// </returns>
243 public static InventoryFolderBase CreateInventoryFolder(
244 IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders)
245 {
221 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId); 246 InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
222 247
223 if (null == rootFolder) 248 if (null == rootFolder)
224 return null; 249 return null;
225 250
226 return CreateInventoryFolder(inventoryService, rootFolder, path, useExistingFolders); 251 return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders);
227 } 252 }
228 253
229 /// <summary> 254 /// <summary>
@@ -235,6 +260,7 @@ namespace OpenSim.Tests.Common
235 /// TODO: May need to make it an option to create duplicate folders. 260 /// TODO: May need to make it an option to create duplicate folders.
236 /// </remarks> 261 /// </remarks>
237 /// <param name="inventoryService"></param> 262 /// <param name="inventoryService"></param>
263 /// <param name="folderId">ID of the folder to create</param>
238 /// <param name="parentFolder"></param> 264 /// <param name="parentFolder"></param>
239 /// <param name="path"> 265 /// <param name="path">
240 /// The folder to create. 266 /// The folder to create.
@@ -249,7 +275,7 @@ namespace OpenSim.Tests.Common
249 /// The folder created. If the path contains multiple folders then the last one created is returned. 275 /// The folder created. If the path contains multiple folders then the last one created is returned.
250 /// </returns> 276 /// </returns>
251 public static InventoryFolderBase CreateInventoryFolder( 277 public static InventoryFolderBase CreateInventoryFolder(
252 IInventoryService inventoryService, InventoryFolderBase parentFolder, string path, bool useExistingFolders) 278 IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
253 { 279 {
254 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None); 280 string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
255 281
@@ -262,9 +288,16 @@ namespace OpenSim.Tests.Common
262 { 288 {
263// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name); 289// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
264 290
291 UUID folderIdForCreate;
292
293 if (components.Length > 1)
294 folderIdForCreate = UUID.Random();
295 else
296 folderIdForCreate = folderId;
297
265 folder 298 folder
266 = new InventoryFolderBase( 299 = new InventoryFolderBase(
267 UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0); 300 folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
268 301
269 inventoryService.AddFolder(folder); 302 inventoryService.AddFolder(folder);
270 } 303 }
@@ -274,7 +307,7 @@ namespace OpenSim.Tests.Common
274// } 307// }
275 308
276 if (components.Length > 1) 309 if (components.Length > 1)
277 return CreateInventoryFolder(inventoryService, folder, components[1], useExistingFolders); 310 return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders);
278 else 311 else
279 return folder; 312 return folder;
280 } 313 }
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index dce2fd7..179a91f 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -47,9 +47,9 @@ namespace OpenSim.Tests.Common.Mock
47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing"); 47 EventWaitHandle wh = new EventWaitHandle (false, EventResetMode.AutoReset, "Crossing");
48 48
49 private Scene m_scene; 49 private Scene m_scene;
50 private SceneManager m_sceneManager;
51 50
52 // Properties so that we can get at received data for test purposes 51 // Properties so that we can get at received data for test purposes
52 public List<uint> ReceivedKills { get; private set; }
53 public List<UUID> ReceivedOfflineNotifications { get; private set; } 53 public List<UUID> ReceivedOfflineNotifications { get; private set; }
54 public List<UUID> ReceivedOnlineNotifications { get; private set; } 54 public List<UUID> ReceivedOnlineNotifications { get; private set; }
55 public List<UUID> ReceivedFriendshipTerminations { get; private set; } 55 public List<UUID> ReceivedFriendshipTerminations { get; private set; }
@@ -61,6 +61,7 @@ namespace OpenSim.Tests.Common.Mock
61 // Test client specific events - for use by tests to implement some IClientAPI behaviour. 61 // Test client specific events - for use by tests to implement some IClientAPI behaviour.
62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion; 62 public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour; 63 public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
64 public event Action<GridInstantMessage> OnReceivedInstantMessage;
64 65
65// disable warning: public events, part of the public API 66// disable warning: public events, part of the public API
66#pragma warning disable 67 67#pragma warning disable 67
@@ -197,6 +198,7 @@ namespace OpenSim.Tests.Common.Mock
197 public event EstateCovenantRequest OnEstateCovenantRequest; 198 public event EstateCovenantRequest OnEstateCovenantRequest;
198 public event EstateChangeInfo OnEstateChangeInfo; 199 public event EstateChangeInfo OnEstateChangeInfo;
199 public event EstateManageTelehub OnEstateManageTelehub; 200 public event EstateManageTelehub OnEstateManageTelehub;
201 public event CachedTextureRequest OnCachedTextureRequest;
200 202
201 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; 203 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
202 204
@@ -435,33 +437,21 @@ namespace OpenSim.Tests.Common.Mock
435 /// <summary> 437 /// <summary>
436 /// Constructor 438 /// Constructor
437 /// </summary> 439 /// </summary>
438 /// <remarks>
439 /// Can be used for a test where there is only one region or where there are multiple regions that are not
440 /// neighbours and where no teleporting takes place. In other situations, the constructor that takes in a
441 /// scene manager should be used.
442 /// </remarks>
443 /// <param name="agentData"></param>
444 /// <param name="scene"></param>
445 public TestClient(AgentCircuitData agentData, Scene scene) : this(agentData, scene, null) {}
446
447 /// <summary>
448 /// Constructor
449 /// </summary>
450 /// <param name="agentData"></param> 440 /// <param name="agentData"></param>
451 /// <param name="scene"></param> 441 /// <param name="scene"></param>
452 /// <param name="sceneManager"></param> 442 /// <param name="sceneManager"></param>
453 public TestClient(AgentCircuitData agentData, Scene scene, SceneManager sceneManager) 443 public TestClient(AgentCircuitData agentData, Scene scene)
454 { 444 {
455 m_agentId = agentData.AgentID; 445 m_agentId = agentData.AgentID;
456 m_firstName = agentData.firstname; 446 m_firstName = agentData.firstname;
457 m_lastName = agentData.lastname; 447 m_lastName = agentData.lastname;
458 m_circuitCode = agentData.circuitcode; 448 m_circuitCode = agentData.circuitcode;
459 m_scene = scene; 449 m_scene = scene;
460 m_sceneManager = sceneManager;
461 SessionId = agentData.SessionID; 450 SessionId = agentData.SessionID;
462 SecureSessionId = agentData.SecureSessionID; 451 SecureSessionId = agentData.SecureSessionID;
463 CapsSeedUrl = agentData.CapsPath; 452 CapsSeedUrl = agentData.CapsPath;
464 453
454 ReceivedKills = new List<uint>();
465 ReceivedOfflineNotifications = new List<UUID>(); 455 ReceivedOfflineNotifications = new List<UUID>();
466 ReceivedOnlineNotifications = new List<UUID>(); 456 ReceivedOnlineNotifications = new List<UUID>();
467 ReceivedFriendshipTerminations = new List<UUID>(); 457 ReceivedFriendshipTerminations = new List<UUID>();
@@ -487,6 +477,18 @@ namespace OpenSim.Tests.Common.Mock
487 OnCompleteMovementToRegion(this, true); 477 OnCompleteMovementToRegion(this, true);
488 } 478 }
489 479
480 /// <summary>
481 /// Emulate sending an IM from the viewer to the simulator.
482 /// </summary>
483 /// <param name='im'></param>
484 public void HandleImprovedInstantMessage(GridInstantMessage im)
485 {
486 ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
487
488 if (handlerInstantMessage != null)
489 handlerInstantMessage(this, im);
490 }
491
490 public virtual void ActivateGesture(UUID assetId, UUID gestureId) 492 public virtual void ActivateGesture(UUID assetId, UUID gestureId)
491 { 493 {
492 } 494 }
@@ -499,6 +501,11 @@ namespace OpenSim.Tests.Common.Mock
499 { 501 {
500 } 502 }
501 503
504 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
505 {
506
507 }
508
502 public virtual void Kick(string message) 509 public virtual void Kick(string message)
503 { 510 {
504 } 511 }
@@ -513,11 +520,11 @@ namespace OpenSim.Tests.Common.Mock
513 520
514 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) 521 public virtual void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
515 { 522 {
516
517 } 523 }
518 524
519 public virtual void SendKillObject(ulong regionHandle, List<uint> localID) 525 public virtual void SendKillObject(List<uint> localID)
520 { 526 {
527 ReceivedKills.AddRange(localID);
521 } 528 }
522 529
523 public virtual void SetChildAgentThrottle(byte[] throttle) 530 public virtual void SetChildAgentThrottle(byte[] throttle)
@@ -526,15 +533,13 @@ namespace OpenSim.Tests.Common.Mock
526 533
527 public void SetAgentThrottleSilent(int throttle, int setting) 534 public void SetAgentThrottleSilent(int throttle, int setting)
528 { 535 {
529
530
531 } 536 }
537
532 public byte[] GetThrottlesPacked(float multiplier) 538 public byte[] GetThrottlesPacked(float multiplier)
533 { 539 {
534 return new byte[0]; 540 return new byte[0];
535 } 541 }
536 542
537
538 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) 543 public virtual void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
539 { 544 {
540 } 545 }
@@ -547,7 +552,8 @@ namespace OpenSim.Tests.Common.Mock
547 552
548 public void SendInstantMessage(GridInstantMessage im) 553 public void SendInstantMessage(GridInstantMessage im)
549 { 554 {
550 555 if (OnReceivedInstantMessage != null)
556 OnReceivedInstantMessage(im);
551 } 557 }
552 558
553 public void SendGenericMessage(string method, UUID invoice, List<string> message) 559 public void SendGenericMessage(string method, UUID invoice, List<string> message)
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
index ccbdf81..2be5524 100644
--- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -53,6 +53,9 @@ namespace OpenSim.Tests.Common.Mock
53 53
54 public XInventoryFolder[] GetFolders(string[] fields, string[] vals) 54 public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
55 { 55 {
56// Console.WriteLine(
57// "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals));
58
56 List<XInventoryFolder> origFolders 59 List<XInventoryFolder> origFolders
57 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); 60 = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList());
58 61
@@ -104,7 +107,30 @@ namespace OpenSim.Tests.Common.Mock
104 } 107 }
105 108
106 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } 109 public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
107 public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); } 110
111 public bool MoveFolder(string id, string newParent)
112 {
113 // Don't use GetFolders() here - it takes a clone!
114 XInventoryFolder folder = m_allFolders[new UUID(id)];
115
116 if (folder == null)
117 return false;
118
119 folder.parentFolderID = new UUID(newParent);
120
121// XInventoryFolder[] newParentFolders
122// = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
123
124// Console.WriteLine(
125// "Moved folder {0} {1}, to {2} {3}",
126// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
127
128 // TODO: Really need to implement folder version incrementing, though this should be common code anyway,
129 // not reimplemented in each db plugin.
130
131 return true;
132 }
133
108 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } 134 public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
109 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } 135 public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
110 } 136 }