-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
unity/Assets/UnitTests/Procedural/Physics/TestOpenClose.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using System; | ||
using UnityEngine; | ||
using UnityEngine.TestTools; | ||
using UnityStandardAssets.Characters.FirstPerson; | ||
using System.Linq; | ||
|
||
namespace Tests { | ||
public class TestOpenClose : TestBase { | ||
[SetUp] | ||
public override void Setup() { | ||
UnityEngine.SceneManagement.SceneManager.LoadScene("FloorPlan1_physics"); | ||
} | ||
|
||
[UnityTest] | ||
public IEnumerator TestOpening() { | ||
|
||
yield return step(new Dictionary<string, object>() { | ||
{ "action", "Initialize"}, | ||
{ "agentMode", "arm"}, | ||
{ "agentControllerType", "mid-level"}, | ||
{ "renderInstanceSegmentation", true} | ||
}); | ||
yield return new WaitForSeconds(2f); | ||
|
||
yield return step(new Dictionary<string, object>() { | ||
{ "action", "MoveAgent"}, | ||
{ "right", -0.7f}, | ||
{ "disableRendering", true}, | ||
{ "returnToStart", true} | ||
}); | ||
|
||
//yield return new WaitForSeconds(2f); | ||
yield return step(new Dictionary<string, object>() { | ||
{ "action", "MoveArm"}, | ||
{ "coordinateSpace", "world"}, | ||
{ "disableRendering", true}, | ||
{ "position", new Vector3(-1.3149f, 0.6049995f, 0.04580003f)} | ||
}); | ||
|
||
//yield return new WaitForSeconds(2f); | ||
yield return step(new Dictionary<string, object>() { | ||
{ "action", "LookDown"}, | ||
{ "degrees", 30f} | ||
}); | ||
|
||
//yield return new WaitForSeconds(2f); | ||
yield return step(new Dictionary<string, object>() { | ||
{ "action", "OpenObject"}, | ||
{ "objectId", "Cabinet|-01.55|+00.50|+00.38"}, | ||
{ "useGripper", true}, | ||
{ "returnToStart", true}, | ||
{ "stopAtNonStaticCol", false} | ||
}); | ||
yield return new WaitForSeconds(2f); | ||
|
||
Transform testCabinetDoor = GameObject.Find("Cabinet_242ff8ff").transform.Find("CabinetDoor"); | ||
bool testCabinetDoorOpened = Mathf.Approximately((testCabinetDoor.localEulerAngles.y + 360) % 360, 270); | ||
Assert.AreEqual(testCabinetDoorOpened, true); | ||
|
||
yield return true; | ||
} | ||
|
||
protected string serializeObject(object obj) { | ||
var jsonResolver = new ShouldSerializeContractResolver(); | ||
return Newtonsoft.Json.JsonConvert.SerializeObject( | ||
obj, | ||
Newtonsoft.Json.Formatting.None, | ||
new Newtonsoft.Json.JsonSerializerSettings() { | ||
ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, | ||
ContractResolver = jsonResolver | ||
} | ||
); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
unity/Assets/UnitTests/Procedural/Physics/TestOpenClose.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.