public static void SourceImage(GameObject go, string sourceName) { var image = UITestUtils.FindGameObjectWithComponentInParents <Image>(go); var sr = UITestUtils.FindGameObjectWithComponentInParents <SpriteRenderer>(go); if (image != null) { Assert.IsNotNull(image.sprite, "SourceImage: Image " + UITestUtils.GetGameObjectFullPath(go) + " has no sprite."); Assert.AreEqual(image.sprite.name, sourceName, "SourceImage: Image " + UITestUtils.GetGameObjectFullPath(go) + " has sprite: " + image.sprite.name + " - but expected: " + sourceName); return; } if (sr != null) { Assert.IsNotNull(sr.sprite, "SourceImage: SpriteRenderer " + UITestUtils.GetGameObjectFullPath(go) + " has no sprite."); Assert.AreEqual(sr.sprite.name, sourceName, "SourceImage: SpriteRenderer " + UITestUtils.GetGameObjectFullPath(go) + " has sprite: " + sr.sprite.name + " - but expected: " + sourceName); return; } Assert.Fail("SourceImage: Game object " + UITestUtils.GetGameObjectFullPath(go) + " has no Image and SpriteRenderer component."); }
public override bool IsAvailable(GameObject go) { if (!go) { return(false); } var toggleGo = UITestUtils.FindGameObjectWithComponentInParents <Toggle>(go); return(toggleGo && toggleGo.gameObject.activeInHierarchy); }
public override bool IsAvailable(GameObject go) { if (!go) { return(false); } var image = UITestUtils.FindGameObjectWithComponentInParents <Image>(go); var sr = UITestUtils.FindGameObjectWithComponentInParents <SpriteRenderer>(go); return(image || sr); }
protected override bool Check() { var go = UITestUtils.FindEnabledGameObjectByPath(path); var image = UITestUtils.FindGameObjectWithComponentInParents <Image>(go); var sr = UITestUtils.FindGameObjectWithComponentInParents <SpriteRenderer>(go); if (image != null) { if (image.mainTexture == null) { reason = "SourceImage: Image " + UITestUtils.GetGameObjectFullPath(go) + " has no texture."; return(false); } if (image.mainTexture.name != sourceName) { reason = "SourceImage: Image " + UITestUtils.GetGameObjectFullPath(go) + " has texture: " + image.mainTexture.name + " - but expected: " + sourceName; return(false); } return(true); } if (sr != null) { if (sr.sprite == null) { reason = "SourceImage: SpriteRenderer " + UITestUtils.GetGameObjectFullPath(go) + " has no sprite."; return(false); } if (sr.sprite.name != sourceName) { reason = "SourceImage: SpriteRenderer " + UITestUtils.GetGameObjectFullPath(go) + " has sprite: " + sr.sprite.name + " - but expected: " + sourceName; return(false); } return(true); } reason = "SourceImage: Game object " + UITestUtils.GetGameObjectFullPath(go) + " has no Image and SpriteRenderer component."; return(false); }
/// <summary> /// Checks that `GameObject` has `Toggle` component and its `isOn` value equals to expected /// </summary> /// <param name="go">`GameObject` with `Toggle` component</param> /// <param name="expectedIsOn">Expected value of the toggle</param> public static void Toggle(GameObject go, bool expectedIsOn) { var toggle = UITestUtils.FindGameObjectWithComponentInParents <Toggle>(go); if (toggle == null) { Assert.Fail("CheckToggle: Game object " + UITestUtils.GetGameObjectFullPath(go) + " has no Toggle component."); } if (toggle.isOn != expectedIsOn) { Assert.Fail("CheckToggle: Toggle " + UITestUtils.GetGameObjectFullPath(go) + " is " + (toggle.isOn ? "On" : "Off") + " - but expected " + " is " + (expectedIsOn ? "On" : "Off")); } }
public override AbstractGenerator CreateGenerator(GameObject go) { var image = UITestUtils.FindGameObjectWithComponentInParents <Image>(go); var sr = UITestUtils.FindGameObjectWithComponentInParents <SpriteRenderer>(go); if (image != null) { if (image.mainTexture != null) { return (new CreateWaitVariable <UnityAnimationStartWaiter>() .Append(new MethodName()) .Path(go) .String(image.mainTexture.name) .Float(10)); } return (new CreateWaitVariable <UnityAnimationStartWaiter>() .Append(new MethodName()) .Path(go) .String(String.Empty) .Float(10)); } if (sr != null) { if (sr.sprite != null) { return (new CreateWaitVariable <UnityAnimationStartWaiter>() .Append(new MethodName()) .Path(go) .String(sr.sprite.name) .Float(10)); } return (new CreateWaitVariable <UnityAnimationStartWaiter>() .Append(new MethodName()) .Path(go) .String(String.Empty) .Float(10)); } throw new ArgumentException(); }
public override AbstractGenerator CreateGenerator(GameObject go) { var image = UITestUtils.FindGameObjectWithComponentInParents <Image>(go); var sr = UITestUtils.FindGameObjectWithComponentInParents <SpriteRenderer>(go); if (image != null) { if (image.sprite != null) { return(VoidMethod.Path(go).String(image.sprite.name)); } return(VoidMethod.Path(go).String(string.Empty)); } if (sr != null) { if (sr.sprite != null) { return(VoidMethod.Path(go).String(sr.sprite.name)); } return(VoidMethod.Path(go).String(string.Empty)); } throw new ArgumentException(); }