diff options
Diffstat (limited to 'OpenSim/Tests')
-rw-r--r-- | OpenSim/Tests/Common/Helpers/UserInventoryHelpers.cs | 41 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | 28 |
2 files changed, 64 insertions, 5 deletions
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/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 | |||
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 | } |