ITouchable TestTouchable(UIObject touchableObj, Vector2 touchPosition) { foreach (Transform t in touchableObj.client.transform) { UIElement uie = t.GetComponent<UIElement>(); if (uie != null) { UIObject o = t.GetComponent<UIElement>().UIObject; if (o != null) { var touched = TestTouchable(o, touchPosition); if (touched != null) return touched; } } } ITouchable touchable = touchableObj as ITouchable; if (touchable != null) { if (touchable.hitTest(touchPosition)) return touchable as ITouchable; } return null; }
public static void show() { if ( researchButton != null ){ GameObject.Destroy(researchButton); Debug.Log("removing buttons"); } if ( buildButton != null ){ GameObject.Destroy(buildButton); } int bWidth = 75; UIObject _researchButton = new UIObject("gui/research-button", "research-button", bWidth, bWidth ); _researchButton.setPosition(new Vector2(Screen.width/2 - bWidth/2,-95)); researchButton = UI.attach(_researchButton); UIObject bButton = new UIObject("gui/build-button", "build-button", bWidth, bWidth ); bButton.setPosition(new Vector2(Screen.width / 2 + bWidth/2,-95)); buildButton = UI.attach(bButton); startTime = Time.time; // Calculate the journey length. destinationPosition = 50; destinationSpeed = 10; opacity=0; move = true; hideButtons = false; }
// Use this for initialization void Start () { uiObj = GetComponent<UIObject>(); if( uiObj == null ) { print("No UIObject Component for " + gameObject.name); } }
private IEnumerator animatePanel( UIObject sprite ) { while( true ) { yield return new WaitForSeconds( 2 ); var ani = sprite.positionTo( 0.7f, new Vector3( 200f, 0, 1 ), Easing.Quartic.easeIn ); ani.autoreverse = true; } }
private IEnumerator animatePanel( UIObject obj ) { var objectHeight = ((UIHorizontalLayout)obj).height; while( true ) { yield return new WaitForSeconds( 3 ); var ani = obj.positionTo( 0.7f, new Vector3( obj.position.x, -Screen.height + objectHeight, obj.position.z ), Easing.Quartic.easeIn ); ani.autoreverse = true; } }
public UIAnimation( UIObject sprite, float duration, UIAnimationProperty aniProperty, Color startColor, Color targetColor, System.Func<float, float> ease ) { this.sprite = sprite; this.duration = duration; _aniProperty = aniProperty; this.ease = ease; this.startColor = startColor; this.targetColor = targetColor; _running = true; startTime = Time.realtimeSinceStartup; }
public UIAnimation(UIObject sprite, float duration, UIAnimationProperty aniProperty, float startFloat, float targetFloat, System.Func<float, float> ease, bool affectedByTimeScale = true) { this.sprite = sprite; this.duration = duration; _aniProperty = aniProperty; this.ease = ease; this.affectedByTimeScale = affectedByTimeScale; this.targetFloat = targetFloat; this.startFloat = startFloat; _running = true; startTime = affectedByTimeScale ? Time.time : Time.realtimeSinceStartup; }
public UIAnimation( UIObject sprite, float duration, UIAnimationProperty aniProperty, float startFloat, float targetFloat, System.Func<float, float> ease ) { this.sprite = sprite; this.duration = duration; _aniProperty = aniProperty; this.ease = ease; this.targetFloat = targetFloat; this.startFloat = startFloat; _running = true; startTime = Time.time; }
public UIAnimation( UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, System.Func<float, float> ease ) { this.sprite = sprite; this.duration = duration; _aniProperty = aniProperty; this.ease = ease; this.target = target; this.start = start; _running = true; startTime = Time.realtimeSinceStartup; }
public static GameObject attach(UIObject o) { Vector2 userPosition = o.getPosition(); Vector3 correctedPosition = new Vector3( userPosition.x, userPosition.y, 1); GameObject inst = Instantiate(Resources.Load(o.getResourceName()), correctedPosition, Quaternion.identity) as GameObject; inst.transform.parent = group.transform; inst.transform.localScale = new Vector3(o.getWidth(), o.getHeight(), 1); inst.name = o.getName(); return inst; }
void Init() { Instance = this; }
// [TestMethod] public void VerifyRatingItemFallback() { // This test is actually performed in the test app itself, so go look at RatingControlPage.xaml.cs for the meat of it. using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone1)) { Log.Warning("Test is disabled on RS1 due to scrolling unreliability"); return; } Log.Comment("Retrieve PointerOverPlaceholderFallbackRating rating control as generic UIElement"); UIObject popRating = FindElement.ById("PointerOverPlaceholderFallbackRating"); Verify.IsNotNull(popRating, "Verifying that we found a UIElement called PointerOverPlaceholderFallbackRating"); InputHelper.ScrollToElement(popRating); popRating.Tap(); // Since on phone it's touch, I do a tap to trigger that. popRating.Click(); Wait.ForIdle(); Log.Comment("Retrieve PointerOverFallbackRating rating control as generic UIElement"); UIObject pointerOver = FindElement.ById("PointerOverFallbackRating"); Verify.IsNotNull(pointerOver, "Verifying that we found a UIElement called PointerOverFallbackRating"); InputHelper.ScrollToElement(pointerOver); pointerOver.Click(); pointerOver.Tap(); Wait.ForIdle(); TextBlock textBlock = new TextBlock(FindElement.ById("UnsetFallbackTextBlock")); Verify.AreEqual("+", textBlock.DocumentText, "Verify Unset glyph falls back onto Glyph"); TextBlock textBlock2 = new TextBlock(FindElement.ById("PlaceholderFallbackTextBlock")); Verify.AreEqual("+", textBlock2.DocumentText, "Verify Placeholder glyph falls back onto Glyph"); TextBlock textBlock3 = new TextBlock(FindElement.ById("DisabledFallbackTextBlock")); Verify.AreEqual("+", textBlock3.DocumentText, "Verify Disabled glyph falls back onto Glyph"); ElementCache.Clear(); TextBlock textBlock4 = new TextBlock(FindElement.ById("PointerOverPlaceholderFallbackTextBlock")); Verify.AreEqual("+", textBlock4.DocumentText, "Verify PointerOverPlaceholder glyph falls back onto Placeholder"); TextBlock textBlock5 = new TextBlock(FindElement.ById("PointerOverFallbackTextBlock")); Verify.AreEqual("+", textBlock5.DocumentText, "Verify PointerOver glyph falls back onto Glyph"); TextBlock textBlock6 = new TextBlock(FindElement.ById("NoFallbackTextBlock")); Verify.AreEqual("+", textBlock6.DocumentText, "Verify a glyph didn't fall back if it wasn't meant to"); // Image: Log.Comment("Retrieve PointerOverPlaceholderImageFallbackRating rating control as generic UIElement"); popRating = FindElement.ById("PointerOverPlaceholderImageFallbackRating"); Verify.IsNotNull(popRating, "Verifying that we found a UIElement called PointerOverPlaceholderImageFallbackRating"); InputHelper.ScrollToElement(popRating); Wait.ForIdle(); popRating.Tap(); // Since on phone it's touch, I do a tap to trigger that. popRating.Click(); Wait.ForIdle(); Log.Comment("Retrieve PointerOverImageFallbackRating rating control as generic UIElement"); pointerOver = FindElement.ById("PointerOverImageFallbackRating"); Verify.IsNotNull(pointerOver, "Verifying that we found a UIElement called PointerOverImageFallbackRating"); pointerOver.Tap(); pointerOver.Click(); Wait.ForIdle(); textBlock = new TextBlock(FindElement.ById("UnsetImageFallbackTextBlock")); Verify.AreEqual("+", textBlock.DocumentText, "Verify Unset image falls back onto Image"); textBlock2 = new TextBlock(FindElement.ById("PlaceholderImageFallbackTextBlock")); Verify.AreEqual("+", textBlock2.DocumentText, "Verify Placeholder image falls back onto Image"); textBlock3 = new TextBlock(FindElement.ById("DisabledImageFallbackTextBlock")); Verify.AreEqual("+", textBlock3.DocumentText, "Verify Disabled image falls back onto Image"); ElementCache.Clear(); textBlock4 = new TextBlock(FindElement.ById("PointerOverPlaceholderImageFallbackTextBlock")); Verify.AreEqual("+", textBlock4.DocumentText, "Verify PointerOverPlaceholder image falls back onto PlaceholderImage"); textBlock5 = new TextBlock(FindElement.ById("PointerOverImageFallbackTextBlock")); Verify.AreEqual("+", textBlock5.DocumentText, "Verify PointerOver image falls back onto Image"); } }
public void BuildBuilding(UIObject obj) { GameManager.SystemManager.StartBuilding(obj.TagName, obj.DataType); Debug.Log("Start Building" + obj.Name); }
public Menu(UIObject uiObject) : base(uiObject: uiObject) { }
public void UIAValuePatternTest() { using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { Log.Comment("Retrieve rating control as generic UIElement"); UIObject ratingUIObject = FindElement.ByName("TestRatingControl"); TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl")); Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl"); Log.Comment("Verify the UIA Value before user clicks the control."); ratingUIObject.SetFocus(); // Setting focus just so we can use AE.FE below Wait.ForIdle(); AutomationElement ratingPeer = AutomationElement.FocusedElement; VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Community Rating, 2.5 of 5"); if (PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2)) // engagement doesn't work pre RS3 { Log.Comment("Verify moving right 2 times with the gamepad sets the control to 3"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("3", textBlock.DocumentText); Log.Comment("Verify rating of 3 sets UIA text to 3"); VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating, 3 of 5"); // revert: Log.Comment("Resetting control to community rating"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Community Rating, 2.5 of 5"); } Log.Comment("Verify more complex navigation"); KeyboardHelper.PressKey(ratingUIObject, Key.Right); KeyboardHelper.PressKey(ratingUIObject, Key.Right); KeyboardHelper.PressKey(ratingUIObject, Key.Right); KeyboardHelper.PressKey(ratingUIObject, Key.Left); VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating, 2 of 5"); // Verify read an unset rating ratingUIObject = FindElement.ByName("RatingBindingSample"); Log.Comment("Verify the UIA Value of an unset Rating without a placeholder value"); ratingUIObject.SetFocus(); InputHelper.ScrollToElement(ratingUIObject); ratingPeer = AutomationElement.FocusedElement; VerifyValue_ValueEqualsOnAutomationElement(ratingPeer, "Rating Unset"); // Verify rounding: Log.Comment("Verifying Value_Value rounding"); UIObject round1 = FindElement.ById("ValuePatternRoundTest1"); round1.SetFocus(); AutomationElement roundAE1 = AutomationElement.FocusedElement; UIObject round2 = FindElement.ById("ValuePatternRoundTest2"); round2.SetFocus(); AutomationElement roundAE2 = AutomationElement.FocusedElement; UIObject round3 = FindElement.ById("ValuePatternRoundTest3"); round3.SetFocus(); AutomationElement roundAE3 = AutomationElement.FocusedElement; VerifyValue_ValueEqualsOnAutomationElement(roundAE1, "Rating, 1.5 of 5"); VerifyValue_ValueEqualsOnAutomationElement(roundAE2, "Rating, 1.55 of 5"); VerifyValue_ValueEqualsOnAutomationElement(roundAE3, "Rating, 1.5 of 5"); } }
// Sets up and starts a new animation in a Coroutine - Vector3 version private static UIAnimation animate( UIObject sprite, float duration, UIAnimationProperty aniProperty, Vector3 start, Vector3 target, UIEaseType ease ) { var ani = new UIAnimation( sprite, duration, aniProperty, start, target, ease ); UI.Instance.StartCoroutine( ani.animate() ); return ani; }
public void circleCreator() { uiState = (int)uiStates.createCircle; wipObject = (UIObject)new UICircle(); Cursor.SetCursor(m_World.cursors[4], new Vector2(32, 32), CursorMode.Auto); }
public void PaneTabNavigationTest() { var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios(); foreach (var testScenario in testScenarios) { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName })) { if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone2)) { Log.Warning("Skipping: Correct pane tab navigation only works in RS2 and above"); return; } SetNavViewWidth(ControlWidth.Wide); Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton")); UIObject firstItem = FindElement.ByName("Home"); UIObject settingsItem = FindElement.ByName("Settings"); UIObject nextTabTarget = FindElement.ByName("WidthComboBox"); CheckBox autoSuggestCheckBox = new CheckBox(FindElement.ByName("AutoSuggestCheckbox")); autoSuggestCheckBox.Uncheck(); Wait.ForIdle(); Log.Comment("Verify that in Expanded mode, tab navigation can leave the pane"); firstItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1); Wait.ForIdle(); Wait.RetryUntilEvalFuncSuccessOrTimeout( () => { return(togglePaneButton.HasKeyboardFocus); }, retryTimoutByMilliseconds: 3000 ); Log.Comment("Verify pressing shift-tab from the first menu item goes to the toggle button"); Verify.IsTrue(togglePaneButton.HasKeyboardFocus); settingsItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Log.Comment("Verify pressing tab from settings goes to the first tab stop in the content area"); Verify.IsTrue(nextTabTarget.HasKeyboardFocus); SetNavViewWidth(ControlWidth.Medium); CheckBox isPaneOpenCheckBox = new CheckBox(FindElement.ById("IsPaneOpenCheckBox")); isPaneOpenCheckBox.Check(); Wait.ForIdle(); Log.Comment("Verify that in an overlay mode, tab navigation cannot leave the pane while the pane is open"); firstItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1); Wait.ForIdle(); Log.Comment("Verify pressing shift-tab from the first menu item goes to settings"); Verify.IsTrue(settingsItem.HasKeyboardFocus); settingsItem.SetFocus(); Wait.ForIdle(); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Log.Comment("Verify pressing tab from settings goes to the first menu item"); Verify.IsTrue(firstItem.HasKeyboardFocus); } } }
public static void LoadAssets(ContentManager content) { SpriteFonts = new Dictionary <string, SpriteFont>(); try { string[] spriteFontFiles = Directory.GetFiles(content.RootDirectory + "\\SpriteFonts", "*.*", SearchOption.AllDirectories); for (int i = 0; i < spriteFontFiles.Length; i++) { // Remove the Content\\ from the start spriteFontFiles[i] = spriteFontFiles[i].Remove(0, 8); // Remove the .xnb at the end spriteFontFiles[i] = spriteFontFiles[i].Split('.')[0]; SpriteFonts.Add(spriteFontFiles[i], content.Load <SpriteFont>(spriteFontFiles[i])); } } catch { } Textures = new Dictionary <string, Texture2D>(); try { string[] textureFiles = Directory.GetFiles(content.RootDirectory + "\\Sprites", "*.*", SearchOption.AllDirectories); for (int i = 0; i < textureFiles.Length; i++) { // Remove the Content\\ from the start textureFiles[i] = textureFiles[i].Remove(0, 8); // Remove the .xnb at the end textureFiles[i] = textureFiles[i].Split('.')[0]; Textures.Add(textureFiles[i], content.Load <Texture2D>(textureFiles[i])); } } catch { } // Can't tell whether this will load all the data in as BaseData or will be clever and load as it should be Data = new Dictionary <string, BaseData>(); try { string[] dataFiles = Directory.GetFiles(content.RootDirectory + "\\Data", "*.*", SearchOption.AllDirectories); for (int i = 0; i < dataFiles.Length; i++) { // Remove the Content\\ from the start dataFiles[i] = dataFiles[i].Remove(0, 8); // Remove the .xnb at the end dataFiles[i] = dataFiles[i].Split('.')[0]; Data.Add(dataFiles[i], content.Load <BaseData>(dataFiles[i])); } } catch { } // These must go here cos we need textures and stuff UIObject.LoadPresetContent(); Button.LoadPresetContent(); Menu.LoadPresetContent(); }
public static UIObject ByNameAndClassName(string name, string className, bool shouldWait) { UIObject root = TestEnvironment.Application.ApplicationFrameWindow ?? TestEnvironment.Application.CoreWindow; return(ByNameAndClassName(root, name, className, shouldWait)); }
// Use this for initialization void Start () { uiObject = GetComponent<UIObject>(); mat = GetComponent<Renderer>().material; }
public static void Found(string idOrName, FindBy findBy) { UIObject ui = findBy == FindBy.Name ? TryFindElement.ByName(idOrName) : TryFindElement.ById(idOrName); Verify.IsNotNull(ui, "Expected to find element with " + findBy.ToString() + " '" + idOrName + "'"); }
public BreadcrumbBarItem Create(UIObject element) { return(new BreadcrumbBarItem(element)); }
public BreadcrumbBarItem(UIObject uiObject) : base(uiObject) { this.Initialize(); }
// Use this for initialization void Start() { uiObject = GetComponent<UIObject>(); originalScale = widget.transform.localScale; widget.transform.localScale = Vector3.zero; }
public ItemContainerImplementation(UIObject uiObject) : base(uiObject: uiObject, patternIdentifier: ItemContainerPattern.Pattern) { }
// Figures out the start value and kicks off the animation - Color version private static UIAnimation animate( UIObject sprite, bool animateTo, float duration, UIAnimationProperty aniProperty, Color target, UIEaseType ease ) { // Grab the current value Color current = sprite.color; Color start = ( animateTo ) ? current : target; // If we are doing a 'from', the target is our current position if( !animateTo ) target = current; return animate( sprite, duration, aniProperty, start, target, ease ); }
protected virtual void Awake() { _object = target as UIObject; }
// Use this for initialization void Start() { // Create the UIText objects needed here. graph15White = new UIText( uiTextWhite, "Graphite15", "Graphite15.png" ); graph26 = new UIText( uiTextBlack, "Graphite26", "Graphite26.png" ); graph20 = new UIText( uiTextBlack, "Graphite20", "Graphite20.png" ); graph26White = new UIText( uiTextWhite, "Graphite26", "Graphite26.png" ); graph20.alignMode = UITextAlignMode.Center; graph26.alignMode = UITextAlignMode.Center; // Create the panel parents landingParent = new UIObject(); startScreenParent = new UIObject(); // Call the creation methods createLandingScreen(); createStartScreen(); }
protected virtual void OnEnable() { _object = target as UIObject; }
public void ArrowKeyHierarchicalNavigationTest() { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", "HierarchicalNavigationView Markup Test" })) { //TODO: Re-enable for RS2 once arrow key behavior is matched with above versions if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone3)) { Log.Warning("Test is disabled because the repeater arrow behavior is currently different for rs2."); return; } // Set up tree and get references to all required elements UIObject item1 = FindElement.ByName("Menu Item 1"); Log.Comment("Expand Menu Item 1"); InputHelper.LeftClick(item1); Wait.ForIdle(); UIObject item2 = FindElement.ByName("Menu Item 2"); UIObject item3 = FindElement.ByName("Menu Item 3"); Log.Comment("Expand Menu Item 2"); InputHelper.LeftClick(item2); Wait.ForIdle(); UIObject item4 = FindElement.ByName("Menu Item 4"); UIObject item5 = FindElement.ByName("Menu Item 5"); // Set up initial focus Log.Comment("Set focus on the pane toggle button"); Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton")); togglePaneButton.SetFocus(); Wait.ForIdle(); // Start down arrow key navigation test Log.Comment("Verify that down arrow navigates to Menu Item 1"); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item1.HasKeyboardFocus); Log.Comment("Verify that down arrow navigates to Menu Item 2"); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item2.HasKeyboardFocus); Log.Comment("Verify that down arrow navigates to Menu Item 4"); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item4.HasKeyboardFocus); Log.Comment("Verify that down arrow navigates to Menu Item 5"); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item5.HasKeyboardFocus); Log.Comment("Verify that down arrow navigates to Menu Item 3"); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item3.HasKeyboardFocus); // Start up arrow key navigation test Log.Comment("Verify that up arrow navigates to Menu Item 5"); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item5.HasKeyboardFocus); Log.Comment("Verify that up arrow navigates to Menu Item 4"); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item4.HasKeyboardFocus); Log.Comment("Verify that up arrow navigates to Menu Item 2"); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item2.HasKeyboardFocus); Log.Comment("Verify that up arrow navigates to Menu Item 1"); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item1.HasKeyboardFocus); Log.Comment("Verify that up arrow navigates to the pane toggle button"); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(togglePaneButton.HasKeyboardFocus); } }
protected virtual void OnDisable() { _object = null; }
//RatingControlTests.GamepadTest unreliable test #155 //[TestMethod] public void GamepadTest() { using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { if (!PlatformConfiguration.IsOsVersionGreaterThan(OSVersion.Redstone2)) { Log.Warning("Test is disabled on RS2 or older because Rating's engagement model relies on OnPreviewKey* virtuals"); return; } UIObject ratingUIObject = FindElement.ByName("TestRatingControl"); Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl"); TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl")); Log.Comment("Verify gamepad engagement"); ratingUIObject.SetFocus(); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify gamepad one change and cancel"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.B); Wait.ForIdle(); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify gamepad one change and accept"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("2", textBlock.DocumentText); Log.Comment("Verify gamepad multiple changes"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("3", textBlock.DocumentText); Log.Comment("Verify gamepad left stick and dpad work"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadLeft); GamepadHelper.PressButton(ratingUIObject, GamepadButton.LeftThumbstickRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.LeftThumbstickRight); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("4", textBlock.DocumentText); Log.Comment("Verify gamepad dpad up down do nothing"); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadUp); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("4", textBlock.DocumentText); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); GamepadHelper.PressButton(ratingUIObject, GamepadButton.DPadDown); GamepadHelper.PressButton(ratingUIObject, GamepadButton.A); Wait.ForIdle(); Verify.AreEqual("4", textBlock.DocumentText); } }
public DescendantsNavigator(UIObject root, UICondition treeCondition) { Validate.ArgumentNotNull(parameter: root, parameterName: nameof(root)); Initialize(root: root.AutomationElement, treeCondition: treeCondition); }
public void BasicInteractionTest() { using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { Log.Comment("Retrieve rating control as generic UIElement"); UIObject ratingUIObject = FindElement.ByName("TestRatingControl"); Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl"); Log.Comment("Retrieve the text block as a TextBlock"); TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl")); Log.Comment("Verify a tap on the third star sets Rating to 3"); InputHelper.Tap(ratingUIObject, 60, RATING_ITEM_HEIGHT / 2); Verify.AreEqual("3", textBlock.DocumentText); Log.Comment("Verify a tap on the third star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, 60, RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); Button phButton = new Button(FindElement.ByName("PHButton")); InputHelper.Tap(phButton); Log.Comment("Verify a tap on the first star sets Rating to 1"); InputHelper.Tap(ratingUIObject, 12, RATING_ITEM_HEIGHT / 2); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify a swipe off the left sets Rating to NOTHING"); InputHelper.Pan(ratingUIObject, 200, Direction.West); Verify.AreEqual("!", textBlock.DocumentText); Log.Comment("Verify a right key on an unset Rating, sets rating to 1"); KeyboardHelper.PressKey(ratingUIObject, Key.Right); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify a left key on an RTL rating increases the rating."); Button rtlbutton = new Button(FindElement.ByName("RTLButton")); rtlbutton.Invoke(); Wait.ForIdle(); KeyboardHelper.PressKey(ratingUIObject, Key.Left); Verify.AreEqual("2", textBlock.DocumentText); Log.Comment("Verify home/end keys in RTL"); KeyboardHelper.PressKey(ratingUIObject, Key.Home); Verify.AreEqual("!", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.End); Verify.AreEqual("5", textBlock.DocumentText); Log.Comment("Verify up down keys in RTL"); KeyboardHelper.PressKey(ratingUIObject, Key.Down); Verify.AreEqual("4", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.Up); Verify.AreEqual("5", textBlock.DocumentText); rtlbutton.Invoke(); Wait.ForIdle(); Log.Comment("Verify home/end keys in LTR"); KeyboardHelper.PressKey(ratingUIObject, Key.Home); Verify.AreEqual("!", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.End); Verify.AreEqual("5", textBlock.DocumentText); Log.Comment("Verify up down keys in LTR"); KeyboardHelper.PressKey(ratingUIObject, Key.Down); Verify.AreEqual("4", textBlock.DocumentText); KeyboardHelper.PressKey(ratingUIObject, Key.Up); Verify.AreEqual("5", textBlock.DocumentText); } }
public WindowImplementation(UIObject uiObject) : base(uiObject: uiObject, patternIdentifier: WindowPattern.Pattern) { }
public UIObjectStateChangedArgs(UIObject uiObject) { m_uiObject = uiObject; }
public void ScrollWhileUsingExpressionAnimationSources() { Log.Comment("Selecting Scroller tests"); using (var setup = new TestSetupHelper("Scroller Tests")) { SetOutputDebugStringLevel("Verbose"); Log.Comment("Navigating to ScrollerExpressionAnimationSourcesPage"); UIObject navigateToExpressionAnimationSourcesUIObject = FindElement.ByName("navigateToExpressionAnimationSources"); Verify.IsNotNull(navigateToExpressionAnimationSourcesUIObject, "Verifying that navigateToExpressionAnimationSources Button was found"); Button navigateToExpressionAnimationSourcesButton = new Button(navigateToExpressionAnimationSourcesUIObject); navigateToExpressionAnimationSourcesButton.Invoke(); Wait.ForIdle(); SetLoggingLevel(isPrivateLoggingEnabled: true); Log.Comment("Retrieving Scroller"); Scroller scrollerUIObject = new Scroller(FindElement.ByName("scroller")); Verify.IsNotNull(scrollerUIObject, "Verifying that Scroller was found"); Verify.IsTrue(scrollerUIObject.HorizontallyScrollable, "Verifying HorizontallyScrollable is true"); Verify.IsTrue(scrollerUIObject.HorizontalViewSize > 0.0, "Verifying HorizontalViewSize is positive"); Verify.AreEqual(scrollerUIObject.HorizontalScrollPercent, 0.0, "Verifying HorizontalScrollPercent is zero"); Log.Comment("Waiting for final layout"); WaitForEditValue(editName: "txtLayoutCompleted", editValue: "Yes"); Edit textBox = new Edit(FindElement.ById("txtViewport")); Log.Comment("Viewport: " + textBox.Value); textBox = new Edit(FindElement.ById("txtExtent")); Log.Comment("Extent: " + textBox.Value); textBox = new Edit(FindElement.ById("txtBarVisualWidth")); Log.Comment("Scrolling Scroller horizontally and vertically"); scrollerUIObject.SetScrollPercent(10.0, 20.0); Log.Comment("Waiting for HorizontalScrollPercent={0} to change", scrollerUIObject.HorizontalScrollPercent); Wait.ForScrollChanged(scrollerUIObject, ScrollProperty.HorizontalScrollPercent); Log.Comment("Final HorizontalScrollPercent={0}", scrollerUIObject.HorizontalScrollPercent); Log.Comment("Final VerticalScrollPercent={0}", scrollerUIObject.VerticalScrollPercent); if (Math.Abs(scrollerUIObject.HorizontalScrollPercent - 10.0) >= 0.0001 || Math.Abs(scrollerUIObject.VerticalScrollPercent - 20.0) >= 0.0001) { LogAndClearTraces(); } SetLoggingLevel(isPrivateLoggingEnabled: false); Verify.IsTrue(scrollerUIObject.HorizontallyScrollable, "Verifying HorizontallyScrollable is true"); Verify.IsTrue(scrollerUIObject.HorizontalViewSize > 0.0, "Verifying HorizontalViewSize is positive"); Verify.IsLessThan(Math.Abs(scrollerUIObject.HorizontalScrollPercent - 10.0), 0.0001, "Verifying HorizontalScrollPercent is close to 10.0"); Verify.IsTrue(scrollerUIObject.VerticallyScrollable, "Verifying VerticallyScrollable is true"); Verify.IsTrue(scrollerUIObject.VerticalViewSize > 0.0, "Verifying VerticalViewSize is positive"); Verify.IsLessThan(Math.Abs(scrollerUIObject.VerticalScrollPercent - 20.0), 0.0001, "Verifying VerticalScrollPercent is close to 20.0"); Log.Comment("Returning to the main Scroller test page"); TestSetupHelper.GoBack(); // Output-debug-string-level "None" is automatically restored when landing back on the Scroller test page. } }
// Use this for initialization void Start () { uiObject = GetComponent<UIObject>(); }
public static void RotateWheel(UIObject obj, int mouseWheelDelta) { Log.Comment("RotateWheel on {0} with mouseWheelDelta: {1}.", obj.GetIdentifier(), mouseWheelDelta); MouseWheelInput.RotateWheel(obj, mouseWheelDelta); Wait.ForIdle(); }
protected void recurseAndClipChildren( UIObject child ) { foreach( Transform t in child.client.transform ) { UIElement uie = t.GetComponent<UIElement>(); if( uie != null ) { UIObject o = t.GetComponent<UIElement>().UIObject; if( o != null ) { UISprite s = o as UISprite; if( s != null ) { clipChild( s ); } else { UITextInstance ti = o as UITextInstance; if( ti != null ) { // Special handeling for text foreach( UISprite glyph in ti.textSprites ) clipChild( glyph ); } recurseAndClipChildren( ti ); } } } } }
public Scroller Create(UIObject element) { return(new Scroller(element)); }
// Figures out the start value and kicks off the animation - float version private static UIAnimation animate( UIObject sprite, bool animateTo, float duration, UIAnimationProperty aniProperty, float target, UIEaseType ease ) { float current = 0.0f; // Grab the current value switch( aniProperty ) { case UIAnimationProperty.Alpha: current = sprite.color.a; break; } float start = ( animateTo ) ? current : target; // If we are doing a 'from', the target is our current position if( !animateTo ) target = current; return animate( sprite, duration, aniProperty, start, target, ease ); }
public Scroller(UIObject uiObject) : base(uiObject) { this.Initialize(); }
// Figures out the start value and kicks off the animation - Vector3 version private static UIAnimation animate( UIObject sprite, bool animateTo, float duration, UIAnimationProperty aniProperty, Vector3 target, UIEaseType ease ) { Vector3 current = Vector3.zero; // Grab the current value switch( aniProperty ) { case UIAnimationProperty.Position: current = sprite.localPosition; break; case UIAnimationProperty.Scale: current = sprite.scale; break; case UIAnimationProperty.EulerAngles: current = sprite.eulerAngles; break; } Vector3 start = ( animateTo ) ? current : target; // If we are doing a 'from', the target is our current position if( !animateTo ) target = current; return animate( sprite, duration, aniProperty, start, target, ease ); }
public void triangleCreator() { uiState = (int)uiStates.createTriangle; wipObject = (UIObject)new UITriangle(); Cursor.SetCursor(m_World.cursors[1], new Vector2(32, 32), CursorMode.Auto); }
public Menu Create(UIObject element) { return(new Menu(uiObject: element)); }
public void TabNavigationTest() { var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios(); foreach (var testScenario in testScenarios) { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName })) { //TODO: Update RS3 and below tab behavior to match RS4+ if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4)) { Log.Warning("Test is disabled because the repeater tab behavior is current different rs3 and below."); return; } SetNavViewWidth(ControlWidth.Wide); Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton")); UIObject searchBox = FindElement.ByNameAndClassName("PaneAutoSuggestBox", "TextBox"); UIObject firstItem = FindElement.ByName("Home"); UIObject settingsItem = FindElement.ByName("Settings"); togglePaneButton.SetFocus(); Wait.ForIdle(); Log.Comment("Verify that pressing tab while TogglePaneButton has focus moves to the search box"); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Verify.IsTrue(searchBox.HasKeyboardFocus); Log.Comment("Verify that pressing tab while the search box has focus moves to the first menu item"); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Verify.IsTrue(firstItem.HasKeyboardFocus); Log.Comment("Verify that pressing tab twice more will move focus to the settings item"); KeyboardHelper.PressKey(Key.Tab, ModifierKey.None, 2); Wait.ForIdle(); Verify.IsTrue(settingsItem.HasKeyboardFocus); // TODO: Re-enable test part and remove workaround once saving tab state is fixed Log.Comment("Move Focus to first item"); firstItem.SetFocus(); Wait.ForIdle(); //Log.Comment("Verify that pressing SHIFT+tab twice will move focus to the first menu item"); //KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 2); //Wait.ForIdle(); //Verify.IsTrue(firstItem.HasKeyboardFocus); Log.Comment("Verify that pressing SHIFT+tab will move focus to the search box"); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1); Wait.ForIdle(); Verify.IsTrue(searchBox.HasKeyboardFocus); Log.Comment("Verify that pressing SHIFT+tab will move focus to the TogglePaneButton"); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 1); Wait.ForIdle(); Verify.IsTrue(togglePaneButton.HasKeyboardFocus); } } }
public WinClass(UIObject ui) : base(ui) { }
void Start() { // IMPORTANT: depth is 1 on top higher numbers on the bottom. This means the lower the number is the closer it gets to the camera. var y = UIRelative.yPercentFrom( UIyAnchor.Top, .05f ); var playButton = UIButton.create( "playUp.png", "playDown.png", 0, (int)y ); playButton.highlightedTouchOffsets = new UIEdgeOffsets( 30 ); playButton.onTouchUpInside += ( sender ) => Debug.Log( "clicked the button: " + sender ); #if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER // hover state example for illustration purposes. the playButton will get the scoresDown image when hovered over playButton.hoveredUVframe = UI.firstToolkit.uvRectForFilename( "scoresDown.png" ); #endif // Scores button var scores = UIContinuousButton.create( "scoresUp.png", "scoresDown.png", 0, 0 ); scores.positionFromTopLeft( .24f, .02f ); scores.centerize(); // centerize the button so we can scale it from the center scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 ); scores.onTouchUpInside += onTouchUpInsideScoresButton; scores.onTouchIsDown += ( sender ) => Debug.Log( "touch is down: " + Time.time ); scores.touchDownSound = scoresSound; // Options button var optionsButton = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 ); optionsButton.positionFromTopLeft( .43f, .02f ); optionsButton.onTouchUpInside += onTouchUpInsideOptionsButton; optionsButton.touchDownSound = optionsSound; // Knob var knob = UIKnob.create( "knobUp.png", "knobDown.png", 0, 0 ); knob.positionFromTopLeft( .39f, .5f ); knob.normalTouchOffsets = new UIEdgeOffsets( 10 ); // give the knob a bit extra touch area knob.highlightedTouchOffsets = new UIEdgeOffsets( 30 ); knob.onKnobChanged += onKnobChanged; knob.value = 0.3f; // Horizontal Slider var hSlider = UISlider.create( "sliderKnob.png", "hSlider.png", 0, 0, UISliderLayout.Horizontal ); hSlider.positionFromTopLeft( .7f, .02f ); hSlider.highlightedTouchOffsets = new UIEdgeOffsets( 30, 20, 30, 20 ); hSlider.onChange += ( sender, val ) => Debug.Log( val ); hSlider.value = 0.6f; // Vertical Slider var vSlider = UISlider.create( "vSliderKnob.png", "vSlider.png", 0, 0, UISliderLayout.Vertical ); vSlider.positionFromTopRight( .17f, .05f ); vSlider.highlightedTouchOffsets = new UIEdgeOffsets( 20, 30, 20, 30 ); vSlider.continuous = true; vSlider.onChange += ( sender, val ) => Debug.Log( val ); vSlider.value = 0.3f; // Toggle Button var toggleButton = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 ); toggleButton.positionFromTopRight( .3f, .2f ); toggleButton.onToggle += ( sender, newValue ) => hSlider.hidden = !newValue; toggleButton.selected = true; // Progress/Health bar var progressBar = UIProgressBar.create( "progressBar.png", "progressBarBorder.png", 5, 3, 0, 0 ); progressBar.positionFromBottomLeft( .05f, .02f ); progressBar.resizeTextureOnChange = true; progressBar.value = 0.4f; // animated sprite var animatedSprite = UI.firstToolkit.addSprite( "Gai_1.png", 0, 0, 1 ); var anim = animatedSprite.addSpriteAnimation( "anim", 0.15f, "Gai_1.png", "Gai_2.png", "Gai_3.png", "Gai_4.png", "Gai_5.png", "Gai_6.png", "Gai_7.png", "Gai_8.png", "Gai_9.png", "Gai_10.png", "Gai_11.png", "Gai_12.png" ); animatedSprite.positionFromBottomRight( .0f, .25f ); anim.loopReverse = true; // optinally loop in reverse animatedSprite.playSpriteAnimation( "anim", 5 ); // Test movement StartCoroutine( marqueePlayButton( playButton ) ); StartCoroutine( animateProgressBar( progressBar ) ); StartCoroutine( pulseOptionButton( optionsButton ) ); // UIObjects can be used like panels to group other UIObjects var panel = new UIObject(); scores.parentUIObject = panel; optionsButton.parentUIObject = panel; StartCoroutine( animatePanel( panel ) ); }
public void diamondCreator() { uiState = (int)uiStates.createDiamond; wipObject = (UIObject)new UIDiamond(); Cursor.SetCursor(m_World.cursors[2], new Vector2(32, 32), CursorMode.Auto); }
public void ArrowKeyNavigationTest() { var testScenarios = RegressionTestScenario.BuildLeftNavRegressionTestScenarios(); foreach (var testScenario in testScenarios) { using (var setup = new TestSetupHelper(new[] { "NavigationView Tests", testScenario.TestPageName })) { //TODO: Update RS3 and below tab behavior to match RS4+ if (!PlatformConfiguration.IsOsVersionGreaterThanOrEqual(OSVersion.Redstone4)) { Log.Warning("Test is disabled because the repeater tab behavior is current different rs3 and below."); return; } SetNavViewWidth(ControlWidth.Wide); Button togglePaneButton = new Button(FindElement.ById("TogglePaneButton")); togglePaneButton.SetFocus(); Wait.ForIdle(); // Grab references to all the menu items in the test UI UIObject searchBox = FindElement.ByNameAndClassName("PaneAutoSuggestBox", "TextBox"); UIObject item1 = FindElement.ByName("Home"); UIObject item2 = FindElement.ByName("Apps"); UIObject item3 = FindElement.ByName("Games"); UIObject item4 = FindElement.ByName("Music"); UIObject item5 = FindElement.ByName("Movies"); UIObject item6 = FindElement.ByName("TV"); UIObject settingsItem = FindElement.ByName("Settings"); Log.Comment("Verify that tab from the TogglePaneButton goes to the search box"); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Verify.IsTrue(searchBox.HasKeyboardFocus); Log.Comment("Verify that tab from search box goes to the first item"); KeyboardHelper.PressKey(Key.Tab); Wait.ForIdle(); Verify.IsTrue(item1.HasKeyboardFocus); Log.Comment("Verify that down arrow can navigate through all items"); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item2.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item3.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item4.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item5.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Down); Wait.ForIdle(); Verify.IsTrue(item6.HasKeyboardFocus); Log.Comment("Verify that tab twice from the last menu item goes to the settings item"); KeyboardHelper.PressKey(Key.Tab, ModifierKey.None, 2); Wait.ForIdle(); Verify.IsTrue(settingsItem.HasKeyboardFocus); // TODO: Re-enable test part and remove workaround once saving tab state is fixed Log.Comment("Move Focus to TV item"); item6.SetFocus(); Wait.ForIdle(); //Log.Comment("Verify that shift+tab twice from the settings item goes to the last menu item"); //KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift, 2); //Wait.ForIdle(); //Verify.IsTrue(item6.HasKeyboardFocus); Log.Comment("Verify that up arrow can navigate through all items"); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item5.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item4.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item3.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item2.HasKeyboardFocus); KeyboardHelper.PressKey(Key.Up); Wait.ForIdle(); Verify.IsTrue(item1.HasKeyboardFocus); Log.Comment("Verify that shift+tab from the first menu item goes to the search box"); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift); Wait.ForIdle(); Verify.IsTrue(searchBox.HasKeyboardFocus); Log.Comment("Verify that shift+tab from the search box goes to the TogglePaneButton"); KeyboardHelper.PressKey(Key.Tab, ModifierKey.Shift); Wait.ForIdle(); Verify.IsTrue(togglePaneButton.HasKeyboardFocus); } } }
void InitUI() { UIObject __ui = new UIObject(); __ui.Init(this.transform); }
public WinClass(UIObject uiobject) { this.uImain = uiobject; this.CarNum = 0; }
public void KeyboardTest() { using (var setup = new TestSetupHelper("TabView Tests")) { Log.Comment("Set focus inside the TabView"); UIObject tabContent = FindElement.ByName("FirstTabContent"); tabContent.SetFocus(); TabItem firstTab = FindElement.ByName <TabItem>("FirstTab"); TabItem secondTab = FindElement.ByName <TabItem>("SecondTab"); TabItem lastTab = FindElement.ByName <TabItem>("LastTab"); Button addButton = FindElement.ById <Button>("AddButton"); Verify.IsTrue(firstTab.IsSelected, "First Tab should be selected initially"); Button firstTabButton = FindElement.ByName <Button>("FirstTabButton"); Verify.IsTrue(firstTabButton.HasKeyboardFocus, "Focus should start in the First Tab"); // Ctrl+Tab to the second tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control); Verify.IsTrue(secondTab.IsSelected, "Ctrl+Tab should move selection to Second Tab"); Button secondTabButton = FindElement.ByName <Button>("SecondTabButton"); Verify.IsTrue(secondTabButton.HasKeyboardFocus, "Focus should move to the content of the Second Tab"); // Ctrl+Shift+Tab to the first tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control | ModifierKey.Shift); Verify.IsTrue(firstTab.IsSelected, "Ctrl+Shift+Tab should move selection to First Tab"); Verify.IsTrue(firstTabButton.HasKeyboardFocus, "Focus should move to the content of the First Tab"); // Ctrl+Shift+Tab to the last tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control | ModifierKey.Shift); Verify.IsTrue(lastTab.IsSelected, "Ctrl+Shift+Tab should move selection to Last Tab"); Verify.IsTrue(lastTab.HasKeyboardFocus, "Focus should move to the last tab (since it has no focusable content)"); // Ctrl+Tab to the first tab: KeyboardHelper.PressKey(Key.Tab, ModifierKey.Control); Verify.IsTrue(firstTab.IsSelected, "Ctrl+Tab should move selection to First Tab"); Verify.IsTrue(firstTab.HasKeyboardFocus, "Focus should move to the first tab"); KeyboardHelper.PressKey(Key.Up); Verify.IsTrue(firstTab.HasKeyboardFocus, "Up key should not move focus"); KeyboardHelper.PressKey(Key.Down); Verify.IsTrue(firstTab.HasKeyboardFocus, "Down key should not move focus"); KeyboardHelper.PressKey(Key.Right); Verify.IsTrue(secondTab.HasKeyboardFocus, "Right Key should move focus to the second tab"); KeyboardHelper.PressKey(Key.Left); Verify.IsTrue(firstTab.HasKeyboardFocus, "Left Key should move focus to the first tab"); addButton.SetFocus(); Verify.IsTrue(addButton.HasKeyboardFocus, "AddButton should have keyboard focus"); KeyboardHelper.PressKey(Key.Left); Verify.IsTrue(lastTab.HasKeyboardFocus, "Left Key from AddButton should move focus to last tab"); KeyboardHelper.PressKey(Key.Right); Verify.IsTrue(addButton.HasKeyboardFocus, "Right Key from Last Tab should move focus to Add Button"); firstTab.SetFocus(); // Ctrl+f4 to close the tab: Log.Comment("Verify that pressing ctrl-f4 closes the tab"); KeyboardHelper.PressKey(Key.F4, ModifierKey.Control); Wait.ForIdle(); VerifyElement.NotFound("FirstTab", FindBy.Name); // Move focus to the second tab content secondTabButton.SetFocus(); Wait.ForIdle(); } }
public void CanClearEveryValueTest() { using (var setup = new TestSetupHelper("RatingControl Tests")) // This literally clicks the button corresponding to the test page. { if (PlatformConfiguration.IsOSVersionLessThan(OSVersion.Redstone2)) { // For some reason this test sometimes fails on RS1 when the "bounding box" of the // RatingControl has negative values, but it's not worth the investigation to fix: Log.Comment("Test is disabled on RS1 due to reliability issues"); return; } TextBlock tb = new TextBlock(FindElement.ById("FrameDetails")); Log.Comment("FrameDetails: " + tb.DocumentText); Log.Comment("Retrieve rating control as generic UIElement"); UIObject ratingUIObject = FindElement.ByName("TestRatingControl"); Verify.IsNotNull(ratingUIObject, "Verifying that we found a UIElement called TestRatingControl"); Log.Comment("Retrieve the text block as a TextBlock"); TextBlock textBlock = new TextBlock(FindElement.ByName("TestTextBlockControl")); Wait.ForIdle(); Log.Comment("Verify a tap on the first star sets Rating to 1"); InputHelper.Tap(ratingUIObject, (0 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("1", textBlock.DocumentText); Log.Comment("Verify a tap on the first star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, (0 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); Log.Comment("Verify a tap on the second star sets Rating to 2"); InputHelper.Tap(ratingUIObject, (1 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("2", textBlock.DocumentText); Log.Comment("Verify a tap on the second star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, (1 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); Log.Comment("Verify a tap on the third star sets Rating to 3"); InputHelper.Tap(ratingUIObject, (2 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("3", textBlock.DocumentText); Log.Comment("Verify a tap on the third star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, (2 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); Log.Comment("Verify a tap on the fourth star sets Rating to 4"); InputHelper.Tap(ratingUIObject, (3 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("4", textBlock.DocumentText); Log.Comment("Verify a tap on the fourth star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, (3 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); Log.Comment("Verify a tap on the fifth star sets Rating to 5"); InputHelper.Tap(ratingUIObject, (4 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("5", textBlock.DocumentText); Log.Comment("Verify a tap on the second star sets Rating to 2.5 (placeholder value)"); InputHelper.Tap(ratingUIObject, (4 * RATING_ITEM_WIDTH) + (RATING_ITEM_WIDTH / 2), RATING_ITEM_HEIGHT / 2); Verify.AreEqual("!2.5", textBlock.DocumentText); } }
protected void registChild(UIObject child) { _childrenDic.put(child.name, child); child.setParent(this); }
public ItemsView Create(UIObject element) { return(new ItemsView(uiObject: element)); }
public void TabSizeAndScrollButtonsTest() { using (var setup = new TestSetupHelper("TabView Tests")) { UIObject smallerTab = FindElement.ByName("FirstTab"); UIObject largerTab = FindElement.ByName("LongHeaderTab"); FindElement.ByName <Button>("SetTabViewWidth").InvokeAndWait(); Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should not be visible"); Log.Comment("Equal size tabs should all be the same size."); int diff = Math.Abs(largerTab.BoundingRectangle.Width - smallerTab.BoundingRectangle.Width); Verify.IsLessThanOrEqual(diff, 1); Log.Comment("Changing tab width mode to SizeToContent."); ComboBox tabWidthComboBox = FindElement.ByName <ComboBox>("TabWidthComboBox"); tabWidthComboBox.SelectItemByName("SizeToContent"); Wait.ForIdle(); Log.Comment("Tab with larger content should be wider."); Verify.IsGreaterThan(largerTab.BoundingRectangle.Width, smallerTab.BoundingRectangle.Width); // With largerTab now rendering wider, the scroll buttons should appear: Verify.IsTrue(AreScrollButtonsVisible(), "Scroll buttons should appear"); // Scroll all the way to the left and verify decrease/increase button visual state FindElement.ByName <Button>("ScrollTabViewToTheLeft").InvokeAndWait(); Wait.ForIdle(); Verify.IsFalse(IsScrollDecreaseButtonEnabled(), "Scroll decrease button should be disabled"); Verify.IsTrue(IsScrollIncreaseButtonEnabled(), "Scroll increase button should be enabled"); // Scroll to the middle position and verify decrease/increase button visual state FindElement.ByName <Button>("ScrollTabViewToTheMiddle").InvokeAndWait(); Wait.ForIdle(); Verify.IsTrue(IsScrollDecreaseButtonEnabled(), "Scroll decrease button should be enabled"); Verify.IsTrue(IsScrollIncreaseButtonEnabled(), "Scroll increase button should be enabled"); // Scroll all the way to the right and verify decrease/increase button visual state FindElement.ByName <Button>("ScrollTabViewToTheRight").InvokeAndWait(); Wait.ForIdle(); Verify.IsTrue(IsScrollDecreaseButtonEnabled(), "Scroll decrease button should be enabled"); Verify.IsFalse(IsScrollIncreaseButtonEnabled(), "Scroll increase button should be disabled"); // Close a tab to make room. The scroll buttons should disappear: Log.Comment("Closing a tab:"); Button closeButton = FindCloseButton(FindElement.ByName("LongHeaderTab")); closeButton.InvokeAndWait(); VerifyElement.NotFound("LongHeaderTab", FindBy.Name); Log.Comment("Scroll buttons should disappear"); Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should disappear"); // Make sure the scroll buttons can show up in 'Equal' sizing mode. Log.Comment("Changing tab width mode to Equal"); tabWidthComboBox.SelectItemByName("Equal"); Wait.ForIdle(); Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should not be visible"); var addButton = FindElement.ByName <Button>("Add New Tab"); Verify.IsNotNull(addButton, "addButton should be available"); Log.Comment("Adding a tab"); addButton.InvokeAndWait(); Verify.IsFalse(AreScrollButtonsVisible(), "Scroll buttons should not be visible"); Log.Comment("Adding another tab"); addButton.InvokeAndWait(); Verify.IsTrue(AreScrollButtonsVisible(), "Scroll buttons should appear"); } }
public static UIObject GetUIObject(UIObject parent, int index) { Debug.Assert(parent != null); Debug.Assert(index >= 0 && parent.Children.Count > index); return parent.Children[index]; }