aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs143
1 files changed, 143 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
new file mode 100644
index 0000000..da8199d
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs
@@ -0,0 +1,143 @@
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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer=System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using NUnit.Framework.SyntaxHelpers;
38using OpenMetaverse;
39using OpenMetaverse.Assets;
40using OpenSim.Framework;
41using OpenSim.Framework.Communications;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Interfaces;
44using OpenSim.Region.CoreModules.Avatar.Inventory.Archiver;
45using OpenSim.Region.CoreModules.World.Serialiser;
46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
47using OpenSim.Services.Interfaces;
48using OpenSim.Tests.Common;
49using OpenSim.Tests.Common.Mock;
50using OpenSim.Tests.Common.Setup;
51
52namespace OpenSim.Region.Framework.Tests
53{
54 [TestFixture]
55 public class TaskInventoryTests
56 {
57 protected UserAccount CreateUser(Scene scene)
58 {
59 string userFirstName = "Jock";
60 string userLastName = "Stirrup";
61 string userPassword = "troll";
62 UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
63 return UserProfileTestUtils.CreateUserWithInventory(scene, userFirstName, userLastName, userId, userPassword);
64 }
65
66 protected SceneObjectGroup CreateSO1(Scene scene, UUID ownerId)
67 {
68 string part1Name = "part1";
69 UUID part1Id = UUID.Parse("10000000-0000-0000-0000-000000000000");
70 SceneObjectPart part1
71 = new SceneObjectPart(ownerId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero)
72 { Name = part1Name, UUID = part1Id };
73 return new SceneObjectGroup(part1);
74 }
75
76 protected TaskInventoryItem CreateSOItem1(Scene scene, SceneObjectPart part)
77 {
78 AssetNotecard nc = new AssetNotecard("Hello World!");
79 UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
80 UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
81 AssetBase ncAsset
82 = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
83 scene.AssetService.Store(ncAsset);
84 TaskInventoryItem ncItem
85 = new TaskInventoryItem
86 { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid,
87 Type = (int)AssetType.Notecard, InvType = (int)InventoryType.Notecard };
88 part.Inventory.AddInventoryItem(ncItem, true);
89
90 return ncItem;
91 }
92
93 /// <summary>
94 /// Test MoveTaskInventoryItem where the item has no parent folder assigned.
95 /// </summary>
96 /// This should place it in the most suitable user folder.
97 [Test]
98 public void TestMoveTaskInventoryItem()
99 {
100 TestHelper.InMethod();
101// log4net.Config.XmlConfigurator.Configure();
102
103 Scene scene = SceneSetupHelpers.SetupScene("inventory");
104 UserAccount user1 = CreateUser(scene);
105 SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID);
106 SceneObjectPart sop1 = sog1.RootPart;
107 TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1);
108 InventoryFolderBase folder
109 = InventoryArchiveUtils.FindFolderByPath(scene.InventoryService, user1.PrincipalID, "Objects")[0];
110
111 // Perform test
112 scene.MoveTaskInventoryItem(user1.PrincipalID, folder.ID, sop1, sopItem1.ItemID);
113
114 InventoryItemBase ncUserItem
115 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Objects/ncItem");
116 Assert.That(ncUserItem, Is.Not.Null, "Objects/ncItem was not found");
117 }
118
119 /// <summary>
120 /// Test MoveTaskInventoryItem where the item has no parent folder assigned.
121 /// </summary>
122 /// This should place it in the most suitable user folder.
123 [Test]
124 public void TestMoveTaskInventoryItemNoParent()
125 {
126 TestHelper.InMethod();
127// log4net.Config.XmlConfigurator.Configure();
128
129 Scene scene = SceneSetupHelpers.SetupScene("inventory");
130 UserAccount user1 = CreateUser(scene);
131 SceneObjectGroup sog1 = CreateSO1(scene, user1.PrincipalID);
132 SceneObjectPart sop1 = sog1.RootPart;
133 TaskInventoryItem sopItem1 = CreateSOItem1(scene, sop1);
134
135 // Perform test
136 scene.MoveTaskInventoryItem(user1.PrincipalID, UUID.Zero, sop1, sopItem1.ItemID);
137
138 InventoryItemBase ncUserItem
139 = InventoryArchiveUtils.FindItemByPath(scene.InventoryService, user1.PrincipalID, "Notecards/ncItem");
140 Assert.That(ncUserItem, Is.Not.Null, "Notecards/ncItem was not found");
141 }
142 }
143} \ No newline at end of file