public void HandleItemCloseRequestedTest() { using (var setup = new TestSetupHelper("TabView Tests")) { UIObject firstTab = FindElement.ByName("FirstTab"); Button closeButton = FindCloseButton(firstTab); Verify.IsNotNull(closeButton); CheckBox tabCloseRequestedCheckBox = FindElement.ByName <CheckBox>("HandleTabCloseRequestedCheckBox"); tabCloseRequestedCheckBox.Uncheck(); CheckBox tabItemCloseRequestedCheckBox = FindElement.ByName <CheckBox>("HandleTabItemCloseRequestedCheckBox"); tabItemCloseRequestedCheckBox.Check(); Wait.ForIdle(); Log.Comment("TabViewItem.CloseRequested should be raised when the close button is pressed."); closeButton.InvokeAndWait(); ElementCache.Refresh(); firstTab = TryFindElement.ByName("FirstTab"); Verify.IsNull(firstTab); } }
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); Log.Comment("Changing tab header to short/long."); Button shortLongButton = FindElement.ByName <Button>("ShortLongTextButton"); shortLongButton.InvokeAndWait(); ElementCache.Refresh(); diff = Math.Abs(smallerTab.BoundingRectangle.Width - 100); Verify.IsLessThanOrEqual(diff, 1, "Smaller text should have min width of 100"); diff = Math.Abs(largerTab.BoundingRectangle.Width - 240); Verify.IsLessThanOrEqual(diff, 1, "Smaller text should have max width of 240"); // With largerTab now rendering wider, the scroll buttons should appear: Verify.IsTrue(AreScrollButtonsVisible(), "Scroll buttons should appear"); // 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"); } }