diff options
Diffstat (limited to 'OpenSim/Tests/Common/Mock')
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestClient.cs | 24 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestScene.cs | 6 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | 132 |
3 files changed, 148 insertions, 14 deletions
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 49a8d26..2714429 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs | |||
@@ -320,7 +320,7 @@ namespace OpenSim.Tests.Common.Mock | |||
320 | public event MuteListEntryRemove OnRemoveMuteListEntry; | 320 | public event MuteListEntryRemove OnRemoveMuteListEntry; |
321 | public event GodlikeMessage onGodlikeMessage; | 321 | public event GodlikeMessage onGodlikeMessage; |
322 | public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; | 322 | public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; |
323 | 323 | public event GenericCall2 OnUpdateThrottles; | |
324 | #pragma warning restore 67 | 324 | #pragma warning restore 67 |
325 | 325 | ||
326 | /// <value> | 326 | /// <value> |
@@ -521,6 +521,12 @@ namespace OpenSim.Tests.Common.Mock | |||
521 | public virtual void SetChildAgentThrottle(byte[] throttle) | 521 | public virtual void SetChildAgentThrottle(byte[] throttle) |
522 | { | 522 | { |
523 | } | 523 | } |
524 | |||
525 | public void SetAgentThrottleSilent(int throttle, int setting) | ||
526 | { | ||
527 | |||
528 | |||
529 | } | ||
524 | public byte[] GetThrottlesPacked(float multiplier) | 530 | public byte[] GetThrottlesPacked(float multiplier) |
525 | { | 531 | { |
526 | return new byte[0]; | 532 | return new byte[0]; |
@@ -531,13 +537,9 @@ namespace OpenSim.Tests.Common.Mock | |||
531 | { | 537 | { |
532 | } | 538 | } |
533 | 539 | ||
534 | public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, | 540 | public virtual void SendChatMessage( |
535 | UUID fromAgentID, byte source, byte audible) | 541 | string message, byte type, Vector3 fromPos, string fromName, |
536 | { | 542 | UUID fromAgentID, UUID ownerID, byte source, byte audible) |
537 | } | ||
538 | |||
539 | public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName, | ||
540 | UUID fromAgentID, byte source, byte audible) | ||
541 | { | 543 | { |
542 | } | 544 | } |
543 | 545 | ||
@@ -939,12 +941,12 @@ namespace OpenSim.Tests.Common.Mock | |||
939 | Close(); | 941 | Close(); |
940 | } | 942 | } |
941 | 943 | ||
942 | public void Close(bool c) | 944 | public void Close() |
943 | { | 945 | { |
944 | Close(); | 946 | Close(true, false); |
945 | } | 947 | } |
946 | 948 | ||
947 | public void Close() | 949 | public void Close(bool sendStop, bool force) |
948 | { | 950 | { |
949 | // Fire the callback for this connection closing | 951 | // Fire the callback for this connection closing |
950 | // This is necesary to get the presence detector to notice that a client has logged out. | 952 | // This is necesary to get the presence detector to notice that a client has logged out. |
diff --git a/OpenSim/Tests/Common/Mock/TestScene.cs b/OpenSim/Tests/Common/Mock/TestScene.cs index eea68c3..d4b5648 100644 --- a/OpenSim/Tests/Common/Mock/TestScene.cs +++ b/OpenSim/Tests/Common/Mock/TestScene.cs | |||
@@ -41,9 +41,9 @@ namespace OpenSim.Tests.Common.Mock | |||
41 | public TestScene( | 41 | public TestScene( |
42 | RegionInfo regInfo, AgentCircuitManager authen, | 42 | RegionInfo regInfo, AgentCircuitManager authen, |
43 | SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, | 43 | SceneCommunicationService sceneGridService, ISimulationDataService simDataService, IEstateDataService estateDataService, |
44 | ModuleLoader moduleLoader, bool dumpAssetsToFile, | 44 | bool dumpAssetsToFile, |
45 | IConfigSource config, string simulatorVersion) | 45 | IConfigSource config, string simulatorVersion) |
46 | : base(regInfo, authen, sceneGridService, simDataService, estateDataService, moduleLoader, | 46 | : base(regInfo, authen, sceneGridService, simDataService, estateDataService, |
47 | dumpAssetsToFile, config, simulatorVersion) | 47 | dumpAssetsToFile, config, simulatorVersion) |
48 | { | 48 | { |
49 | } | 49 | } |
@@ -73,4 +73,4 @@ namespace OpenSim.Tests.Common.Mock | |||
73 | get { return m_asyncSceneObjectDeleter; } | 73 | get { return m_asyncSceneObjectDeleter; } |
74 | } | 74 | } |
75 | } | 75 | } |
76 | } \ No newline at end of file | 76 | } |
diff --git a/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs new file mode 100644 index 0000000..f9bf768 --- /dev/null +++ b/OpenSim/Tests/Common/Mock/TestXInventoryDataPlugin.cs | |||
@@ -0,0 +1,132 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Data; | ||
36 | |||
37 | namespace OpenSim.Tests.Common.Mock | ||
38 | { | ||
39 | public class TestXInventoryDataPlugin : IXInventoryData | ||
40 | { | ||
41 | private Dictionary<UUID, XInventoryFolder> m_allFolders = new Dictionary<UUID, XInventoryFolder>(); | ||
42 | private Dictionary<UUID, XInventoryItem> m_allItems = new Dictionary<UUID, XInventoryItem>(); | ||
43 | |||
44 | public TestXInventoryDataPlugin(string conn, string realm) {} | ||
45 | |||
46 | public XInventoryItem[] GetItems(string[] fields, string[] vals) | ||
47 | { | ||
48 | List<XInventoryItem> origItems = Get<XInventoryItem>(fields, vals, m_allItems.Values.ToList()); | ||
49 | |||
50 | return origItems.Select(i => i.Clone()).ToArray(); | ||
51 | } | ||
52 | |||
53 | public XInventoryFolder[] GetFolders(string[] fields, string[] vals) | ||
54 | { | ||
55 | List<XInventoryFolder> origFolders | ||
56 | = Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList()); | ||
57 | |||
58 | return origFolders.Select(f => f.Clone()).ToArray(); | ||
59 | } | ||
60 | |||
61 | private List<T> Get<T>(string[] fields, string[] vals, List<T> inputEntities) | ||
62 | { | ||
63 | List<T> entities = inputEntities; | ||
64 | |||
65 | for (int i = 0; i < fields.Length; i++) | ||
66 | { | ||
67 | entities | ||
68 | = entities.Where( | ||
69 | e => | ||
70 | { | ||
71 | FieldInfo fi = typeof(T).GetField(fields[i]); | ||
72 | if (fi == null) | ||
73 | throw new NotImplementedException(string.Format("No field {0} for val {1}", fields[i], vals[i])); | ||
74 | |||
75 | return fi.GetValue(e).ToString() == vals[i]; | ||
76 | } | ||
77 | ).ToList(); | ||
78 | } | ||
79 | |||
80 | return entities; | ||
81 | } | ||
82 | |||
83 | public bool StoreFolder(XInventoryFolder folder) | ||
84 | { | ||
85 | m_allFolders[folder.folderID] = folder.Clone(); | ||
86 | |||
87 | // Console.WriteLine("Added folder {0} {1}", folder.folderName, folder.folderID); | ||
88 | |||
89 | return true; | ||
90 | } | ||
91 | |||
92 | public bool StoreItem(XInventoryItem item) | ||
93 | { | ||
94 | m_allItems[item.inventoryID] = item.Clone(); | ||
95 | |||
96 | // Console.WriteLine("Added item {0} {1}, creator {2}, owner {3}", item.inventoryName, item.inventoryID, item.creatorID, item.avatarID); | ||
97 | |||
98 | return true; | ||
99 | } | ||
100 | |||
101 | public bool DeleteFolders(string field, string val) | ||
102 | { | ||
103 | return DeleteFolders(new string[] { field }, new string[] { val }); | ||
104 | } | ||
105 | |||
106 | public bool DeleteFolders(string[] fields, string[] vals) | ||
107 | { | ||
108 | XInventoryFolder[] foldersToDelete = GetFolders(fields, vals); | ||
109 | Array.ForEach(foldersToDelete, f => m_allFolders.Remove(f.folderID)); | ||
110 | |||
111 | return true; | ||
112 | } | ||
113 | |||
114 | public bool DeleteItems(string field, string val) | ||
115 | { | ||
116 | return DeleteItems(new string[] { field }, new string[] { val }); | ||
117 | } | ||
118 | |||
119 | public bool DeleteItems(string[] fields, string[] vals) | ||
120 | { | ||
121 | XInventoryItem[] itemsToDelete = GetItems(fields, vals); | ||
122 | Array.ForEach(itemsToDelete, i => m_allItems.Remove(i.inventoryID)); | ||
123 | |||
124 | return true; | ||
125 | } | ||
126 | |||
127 | public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); } | ||
128 | public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); } | ||
129 | public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); } | ||
130 | public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); } | ||
131 | } | ||
132 | } \ No newline at end of file | ||