diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index 71f1098..d944087 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | |||
@@ -132,6 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
132 | MessageTransferModule mtm = new MessageTransferModule(); | 132 | MessageTransferModule mtm = new MessageTransferModule(); |
133 | GroupsModule gm = new GroupsModule(); | 133 | GroupsModule gm = new GroupsModule(); |
134 | GroupsMessagingModule gmm = new GroupsMessagingModule(); | 134 | GroupsMessagingModule gmm = new GroupsMessagingModule(); |
135 | MockGroupsServicesConnector mgsc = new MockGroupsServicesConnector(); | ||
135 | 136 | ||
136 | IConfigSource configSource = new IniConfigSource(); | 137 | IConfigSource configSource = new IniConfigSource(); |
137 | 138 | ||
@@ -149,6 +150,83 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
149 | config.Set("MessagingEnabled", true); | 150 | config.Set("MessagingEnabled", true); |
150 | } | 151 | } |
151 | 152 | ||
153 | SceneHelpers.SetupSceneModules(scene, configSource, mgsc, mtm, gm, gmm); | ||
154 | |||
155 | UUID userId = TestHelpers.ParseTail(0x1); | ||
156 | string subjectText = "newman"; | ||
157 | string messageText = "Hello"; | ||
158 | string combinedSubjectMessage = string.Format("{0}|{1}", subjectText, messageText); | ||
159 | |||
160 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | ||
161 | TestClient tc = (TestClient)sp.ControllingClient; | ||
162 | |||
163 | UUID groupID = gm.CreateGroup(tc, "group1", null, true, UUID.Zero, 0, true, true, true); | ||
164 | gm.JoinGroupRequest(tc, groupID); | ||
165 | |||
166 | // Create a second user who doesn't want to receive notices | ||
167 | ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x2)); | ||
168 | TestClient tc2 = (TestClient)sp2.ControllingClient; | ||
169 | gm.JoinGroupRequest(tc2, groupID); | ||
170 | gm.SetGroupAcceptNotices(tc2, groupID, false, true); | ||
171 | |||
172 | List<GridInstantMessage> spReceivedMessages = new List<GridInstantMessage>(); | ||
173 | tc.OnReceivedInstantMessage += im => spReceivedMessages.Add(im); | ||
174 | |||
175 | List<GridInstantMessage> sp2ReceivedMessages = new List<GridInstantMessage>(); | ||
176 | tc2.OnReceivedInstantMessage += im => sp2ReceivedMessages.Add(im); | ||
177 | |||
178 | GridInstantMessage noticeIm = new GridInstantMessage(); | ||
179 | noticeIm.fromAgentID = userId.Guid; | ||
180 | noticeIm.toAgentID = groupID.Guid; | ||
181 | noticeIm.message = combinedSubjectMessage; | ||
182 | noticeIm.dialog = (byte)InstantMessageDialog.GroupNotice; | ||
183 | |||
184 | tc.HandleImprovedInstantMessage(noticeIm); | ||
185 | |||
186 | Assert.That(spReceivedMessages.Count, Is.EqualTo(1)); | ||
187 | Assert.That(spReceivedMessages[0].message, Is.EqualTo(combinedSubjectMessage)); | ||
188 | |||
189 | List<GroupNoticeData> notices = mgsc.GetGroupNotices(UUID.Zero, groupID); | ||
190 | Assert.AreEqual(1, notices.Count); | ||
191 | |||
192 | // OpenSimulator (possibly also SL) transport the notice ID as the session ID! | ||
193 | Assert.AreEqual(notices[0].NoticeID.Guid, spReceivedMessages[0].imSessionID); | ||
194 | |||
195 | Assert.That(sp2ReceivedMessages.Count, Is.EqualTo(0)); | ||
196 | } | ||
197 | |||
198 | /// <summary> | ||
199 | /// Run test with the MessageOnlineUsersOnly flag set. | ||
200 | /// </summary> | ||
201 | [Test] | ||
202 | public void TestSendGroupNoticeOnlineOnly() | ||
203 | { | ||
204 | TestHelpers.InMethod(); | ||
205 | // TestHelpers.EnableLogging(); | ||
206 | |||
207 | TestScene scene = new SceneHelpers().SetupScene(); | ||
208 | |||
209 | MessageTransferModule mtm = new MessageTransferModule(); | ||
210 | GroupsModule gm = new GroupsModule(); | ||
211 | GroupsMessagingModule gmm = new GroupsMessagingModule(); | ||
212 | |||
213 | IConfigSource configSource = new IniConfigSource(); | ||
214 | |||
215 | { | ||
216 | IConfig config = configSource.AddConfig("Messaging"); | ||
217 | config.Set("MessageTransferModule", mtm.Name); | ||
218 | } | ||
219 | |||
220 | { | ||
221 | IConfig config = configSource.AddConfig("Groups"); | ||
222 | config.Set("Enabled", true); | ||
223 | config.Set("Module", gm.Name); | ||
224 | config.Set("DebugEnabled", true); | ||
225 | config.Set("MessagingModule", gmm.Name); | ||
226 | config.Set("MessagingEnabled", true); | ||
227 | config.Set("MessageOnlineUsersOnly", true); | ||
228 | } | ||
229 | |||
152 | SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); | 230 | SceneHelpers.SetupSceneModules(scene, configSource, new MockGroupsServicesConnector(), mtm, gm, gmm); |
153 | 231 | ||
154 | UUID userId = TestHelpers.ParseTail(0x1); | 232 | UUID userId = TestHelpers.ParseTail(0x1); |