From 67789201c3ae40bd4697f3479eb183599baa3658 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Mon, 29 Apr 2013 22:14:13 +0100
Subject: Add TestRejectGivenFolder() and TestAcceptGivenFolder() regression
tests
---
.../Tests/Common/Helpers/UserInventoryHelpers.cs | 41 +++++++++++++++++++---
.../Tests/Common/Mock/TestXInventoryDataPlugin.cs | 28 ++++++++++++++-
2 files changed, 64 insertions(+), 5 deletions(-)
(limited to 'OpenSim/Tests')
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
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
{
+ return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders);
+ }
+
+ ///
+ /// Create inventory folders starting from the user's root folder.
+ ///
+ ///
+ ///
+ ///
+ ///
+ /// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
+ ///
+ ///
+ /// If true, then folders in the path which already the same name are
+ /// used. This applies to the terminal folder as well.
+ /// If false, then all folders in the path are created, even if there is already a folder at a particular
+ /// level with the same name.
+ ///
+ ///
+ /// The folder created. If the path contains multiple folders then the last one created is returned.
+ /// Will return null if the root folder could not be found.
+ ///
+ public static InventoryFolderBase CreateInventoryFolder(
+ IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders)
+ {
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
if (null == rootFolder)
return null;
- return CreateInventoryFolder(inventoryService, rootFolder, path, useExistingFolders);
+ return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders);
}
///
@@ -235,6 +260,7 @@ namespace OpenSim.Tests.Common
/// TODO: May need to make it an option to create duplicate folders.
///
///
+ /// ID of the folder to create
///
///
/// The folder to create.
@@ -249,7 +275,7 @@ namespace OpenSim.Tests.Common
/// The folder created. If the path contains multiple folders then the last one created is returned.
///
public static InventoryFolderBase CreateInventoryFolder(
- IInventoryService inventoryService, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
+ IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
{
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
@@ -262,9 +288,16 @@ namespace OpenSim.Tests.Common
{
// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
+ UUID folderIdForCreate;
+
+ if (components.Length > 1)
+ folderIdForCreate = UUID.Random();
+ else
+ folderIdForCreate = folderId;
+
folder
= new InventoryFolderBase(
- UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
+ folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
inventoryService.AddFolder(folder);
}
@@ -274,7 +307,7 @@ namespace OpenSim.Tests.Common
// }
if (components.Length > 1)
- return CreateInventoryFolder(inventoryService, folder, components[1], useExistingFolders);
+ return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders);
else
return folder;
}
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
index ccbdf81..30b1f38 100644
--- a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs
@@ -53,6 +53,9 @@ namespace OpenSim.Tests.Common.Mock
public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
{
+// Console.WriteLine(
+// "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals));
+
List origFolders
= Get(fields, vals, m_allFolders.Values.ToList());
@@ -104,7 +107,30 @@ namespace OpenSim.Tests.Common.Mock
}
public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
- public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); }
+
+ public bool MoveFolder(string id, string newParent)
+ {
+ // Don't use GetFolders() here - it takes a clone!
+ XInventoryFolder folder = m_allFolders[new UUID(id)];
+
+ if (folder == null)
+ return false;
+
+ folder.parentFolderID = new UUID(newParent);
+
+ XInventoryFolder[] newParentFolders
+ = GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
+
+// Console.WriteLine(
+// "Moved folder {0} {1}, to {2} {3}",
+// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
+
+ // TODO: Really need to implement folder version incrementing, though this should be common code anyway,
+ // not reimplemented in each db plugin.
+
+ return true;
+ }
+
public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
}
--
cgit v1.1