diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/Tests')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index c9dddba..78296a4 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -34,6 +34,7 @@ using OpenMetaverse; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
37 | using OpenSim.Region.CoreModules.Framework.UserManagement; | ||
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
@@ -49,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
49 | [Test] | 50 | [Test] |
50 | public void TestCreate() | 51 | public void TestCreate() |
51 | { | 52 | { |
52 | TestHelper.InMethod(); | 53 | TestHelpers.InMethod(); |
53 | // log4net.Config.XmlConfigurator.Configure(); | 54 | // log4net.Config.XmlConfigurator.Configure(); |
54 | 55 | ||
55 | IConfigSource config = new IniConfigSource(); | 56 | IConfigSource config = new IniConfigSource(); |
@@ -57,13 +58,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
57 | config.Configs["NPC"].Set("Enabled", "true"); | 58 | config.Configs["NPC"].Set("Enabled", "true"); |
58 | 59 | ||
59 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 60 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
60 | TestScene scene = SceneSetupHelpers.SetupScene(); | 61 | UserManagementModule umm = new UserManagementModule(); |
61 | SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); | 62 | |
62 | TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); | 63 | TestScene scene = SceneHelpers.SetupScene(); |
64 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); | ||
65 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | ||
63 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 66 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
64 | 67 | ||
65 | // 8 is the index of the first baked texture in AvatarAppearance | 68 | // 8 is the index of the first baked texture in AvatarAppearance |
66 | UUID originalFace8TextureId = TestHelper.ParseTail(0x10); | 69 | UUID originalFace8TextureId = TestHelpers.ParseTail(0x10); |
67 | Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); | 70 | Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); |
68 | Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); | 71 | Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); |
69 | originalTef.TextureID = originalFace8TextureId; | 72 | originalTef.TextureID = originalFace8TextureId; |
@@ -72,21 +75,22 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
72 | // ScenePresence.SendInitialData() to reset our entire appearance. | 75 | // ScenePresence.SendInitialData() to reset our entire appearance. |
73 | scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); | 76 | scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); |
74 | 77 | ||
75 | afm.SetAppearance(originalClient, originalTe, null); | 78 | afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null); |
76 | 79 | ||
77 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 80 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
78 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); | 81 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); |
79 | 82 | ||
80 | ScenePresence npc = scene.GetScenePresence(npcId); | 83 | ScenePresence npc = scene.GetScenePresence(npcId); |
81 | 84 | ||
82 | Assert.That(npc, Is.Not.Null); | 85 | Assert.That(npc, Is.Not.Null); |
83 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); | 86 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); |
87 | Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); | ||
84 | } | 88 | } |
85 | 89 | ||
86 | [Test] | 90 | [Test] |
87 | public void TestMove() | 91 | public void TestMove() |
88 | { | 92 | { |
89 | TestHelper.InMethod(); | 93 | TestHelpers.InMethod(); |
90 | // log4net.Config.XmlConfigurator.Configure(); | 94 | // log4net.Config.XmlConfigurator.Configure(); |
91 | 95 | ||
92 | IConfigSource config = new IniConfigSource(); | 96 | IConfigSource config = new IniConfigSource(); |
@@ -94,14 +98,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
94 | config.AddConfig("NPC"); | 98 | config.AddConfig("NPC"); |
95 | config.Configs["NPC"].Set("Enabled", "true"); | 99 | config.Configs["NPC"].Set("Enabled", "true"); |
96 | 100 | ||
97 | TestScene scene = SceneSetupHelpers.SetupScene(); | 101 | TestScene scene = SceneHelpers.SetupScene(); |
98 | SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule()); | 102 | SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); |
99 | TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); | 103 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
100 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 104 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
101 | 105 | ||
102 | Vector3 startPos = new Vector3(128, 128, 30); | 106 | Vector3 startPos = new Vector3(128, 128, 30); |
103 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 107 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
104 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, originalClient.AgentId); | 108 | UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); |
105 | 109 | ||
106 | ScenePresence npc = scene.GetScenePresence(npcId); | 110 | ScenePresence npc = scene.GetScenePresence(npcId); |
107 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 111 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
@@ -113,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
113 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 117 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
114 | 118 | ||
115 | Vector3 targetPos = startPos + new Vector3(0, 0, 10); | 119 | Vector3 targetPos = startPos + new Vector3(0, 0, 10); |
116 | npcModule.MoveToTarget(npc.UUID, scene, targetPos); | 120 | npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); |
117 | 121 | ||
118 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 122 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
119 | 123 | ||
@@ -131,11 +135,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
131 | double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); | 135 | double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); |
132 | Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); | 136 | Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); |
133 | Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); | 137 | Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); |
138 | Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); | ||
134 | 139 | ||
135 | // Try a second movement | 140 | // Try a second movement |
136 | startPos = npc.AbsolutePosition; | 141 | startPos = npc.AbsolutePosition; |
137 | targetPos = startPos + new Vector3(10, 0, 0); | 142 | targetPos = startPos + new Vector3(10, 0, 0); |
138 | npcModule.MoveToTarget(npc.UUID, scene, targetPos); | 143 | npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); |
139 | 144 | ||
140 | scene.Update(); | 145 | scene.Update(); |
141 | 146 | ||