Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<ItemGroup>
<ProjectReference Include="..\..\Common\tests\InternalUtilitiesForTests\InternalUtilitiesForTests.csproj" />
<ProjectReference Include="..\src\System.Windows.Forms.Primitives.csproj" />
</ItemGroup>

<ItemGroup>
<Compile Include="..\..\Common\tests\CommonMemberDataAttribute.cs" Link="Common\CommonMemberDataAttribute.cs" />
<Compile Include="..\..\Common\tests\CommonTestHelper.cs" Link="Common\CommonTestHelper.cs" />
<Compile Include="..\..\Common\tests\ThreadExceptionFixture.cs" Link="Common\ThreadExceptionFixture.cs" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace System.Windows.Forms.Tests
{
public class FileDialogCustomPlaceTests : IClassFixture<ThreadExceptionFixture>
public class FileDialogCustomPlaceTests
{
[Theory]
[CommonMemberData(nameof(CommonTestHelper.GetStringWithNullTheoryData))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using WinForms.Common.Tests;
using Xunit;

namespace System.Windows.Forms.Tests
{
public class FileDialogCustomPlacesCollectionTests : IClassFixture<ThreadExceptionFixture>
public class FileDialogCustomPlacesCollectionTests
{
[Theory]
[CommonMemberData(nameof(CommonTestHelper.GetStringWithNullTheoryData))]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -476,7 +476,7 @@ private int GetChildFragmentIndex()
internal void RaiseFocusChanged()
{
ToolStrip root = _ownerItem.RootToolStrip;
if (root != null && root.SupportsUiaProviders)
if (root != null && root.IsHandleCreated && root.SupportsUiaProviders)
{
RaiseAutomationEvent(UiaCore.UIA.AutomationFocusChangedEventId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,26 @@ namespace System.Windows.Forms.Tests.AccessibleObjects
{
public class ComboBoxAccessibleObjectTests : IClassFixture<ThreadExceptionFixture>
{
public static IEnumerable<object[]> Ctor_ComboBox_TestData()
[WinFormsFact]
public void ComboBoxAccessibleObject_Ctor_Default()
{
yield return new object[] { new ComboBox() };
}

[Theory]
[MemberData(nameof(Ctor_ComboBox_TestData))]
public void ComboBoxAccessibleObject_Ctor_Default(ComboBox owner)
{
var accessibleObject = new ComboBox.ComboBoxAccessibleObject(owner);
using var control = new ComboBox();
var accessibleObject = new ComboBox.ComboBoxAccessibleObject(control);
Assert.NotNull(accessibleObject.Owner);
Assert.Equal(AccessibleRole.ComboBox, accessibleObject.Role);
}

public static IEnumerable<object[]> ComboBoxAccessibleObject_TestData()
[WinFormsTheory]
[InlineData(ComboBoxStyle.DropDown)]
[InlineData(ComboBoxStyle.DropDownList)]
public void ComboBoxAccessibleObject_ExpandCollapse_Set_CollapsedState(ComboBoxStyle comboBoxStyle)
{
ComboBox dropDownComboBox = new ComboBox
using var control = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDown
DropDownStyle = comboBoxStyle
};
yield return new object[] { dropDownComboBox.AccessibilityObject };
var accessibleObject = control.AccessibilityObject;

ComboBox dropDownListComboBox = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDownList
};
yield return new object[] { dropDownListComboBox.AccessibilityObject };
}

[Theory]
[MemberData(nameof(ComboBoxAccessibleObject_TestData))]
public void ComboBoxAccessibleObject_ExpandCollapse_Set_CollapsedState(AccessibleObject accessibleObject)
{
accessibleObject.Expand();
Assert.NotEqual(AccessibleStates.Collapsed, accessibleObject.State & AccessibleStates.Collapsed);
Assert.Equal(AccessibleStates.Expanded, accessibleObject.State & AccessibleStates.Expanded);
Expand All @@ -52,23 +39,30 @@ public void ComboBoxAccessibleObject_ExpandCollapse_Set_CollapsedState(Accessibl
Assert.NotEqual(AccessibleStates.Expanded, accessibleObject.State & AccessibleStates.Expanded);
}

[Theory]
[MemberData(nameof(ComboBoxAccessibleObject_TestData))]
public void ComboBoxAccessibleObject_FragmentNavigate_FirstChild_NotNull(AccessibleObject accessibleObject)
[WinFormsTheory]
[InlineData(ComboBoxStyle.DropDown)]
[InlineData(ComboBoxStyle.DropDownList)]
public void ComboBoxAccessibleObject_FragmentNavigate_FirstChild_NotNull(ComboBoxStyle comboBoxStyle)
{
using var control = new ComboBox
{
DropDownStyle = comboBoxStyle
};
var accessibleObject = control.AccessibilityObject;

UiaCore.IRawElementProviderFragment firstChild = accessibleObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
Assert.NotNull(firstChild);
}

[Theory]
[WinFormsTheory]
[InlineData("Test text")]
[InlineData(null)]
public void ComboBoxEditAccessibleObject_NameNotNull(string name)
{
ComboBox comboBox = new ComboBox();
comboBox.AccessibleName = name;
comboBox.CreateControl(false);
object editAccessibleName = comboBox.ChildEditAccessibleObject.GetPropertyValue(UiaCore.UIA.NamePropertyId);
using var control = new ComboBox();
control.AccessibleName = name;
control.CreateControl(false);
object editAccessibleName = control.ChildEditAccessibleObject.GetPropertyValue(UiaCore.UIA.NamePropertyId);
Assert.NotNull(editAccessibleName);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public void DataGridViewAccessibleObject_FirstAndLastChildren_AreNotNull()
Assert.NotNull(lastChild);
}

[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.IsGridPatternAvailablePropertyId)]
[InlineData((int)UiaCore.UIA.IsTablePatternAvailablePropertyId)]
public void DataGridViewAccessibleObject_Pattern_IsAvailable(int propertyId)
Expand Down Expand Up @@ -245,7 +245,7 @@ public void DataGridViewAccessibleObject_Cell_IsOffscreen_ReturnsCorrectValue()
Assert.True((bool)isOffscreen); // Out of the visible area
}

[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.TablePatternId)]
[InlineData((int)UiaCore.UIA.GridPatternId)]
public void DataGridViewAccessibleObject_IsPatternSupported(int patternId)
Expand All @@ -255,7 +255,7 @@ public void DataGridViewAccessibleObject_IsPatternSupported(int patternId)
Assert.True(accessibleObject.IsPatternSupported((UiaCore.UIA)patternId));
}

[Theory]
[WinFormsTheory]
[InlineData(true)]
[InlineData(false)]
public void DataGridViewAccessibleObject_Cell_IsReadOnly_ReturnsCorrectValue(bool isReadOnly)
Expand All @@ -278,7 +278,7 @@ public void DataGridViewAccessibleObject_Cell_IsReadOnly_ReturnsCorrectValue(boo
}
}

[Theory]
[WinFormsTheory]
[InlineData(true)]
[InlineData(false)]
public void DataGridViewAccessibleObject_Row_IsReadOnly_ReturnsCorrectValue(bool isReadOnly)
Expand All @@ -301,7 +301,7 @@ public void DataGridViewAccessibleObject_Row_IsReadOnly_ReturnsCorrectValue(bool
}
}

[Theory]
[WinFormsTheory]
[InlineData(true)]
[InlineData(false)]
public void DataGridViewAccessibleObject_Grid_IsReadOnly_ReturnsCorrectValue(bool isReadOnly)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ namespace System.Windows.Forms.Tests.AccessibleObjects
{
public class DataGridViewCellsAccessibleObjectTests : IClassFixture<ThreadExceptionFixture>
{
[Theory]
[WinFormsTheory]
[InlineData(RightToLeft.No)]
[InlineData(RightToLeft.Yes)]
public void DataGridViewCellsAccessibleObject_Ctor_Default(RightToLeft rightToLeft)
{
DataGridView dataGridView = new DataGridView
using var dataGridView = new DataGridView
{
RightToLeft = rightToLeft,
ColumnCount = 4,
Expand All @@ -39,10 +39,10 @@ public void DataGridViewCellsAccessibleObject_Ctor_Default(RightToLeft rightToLe
Assert.True(accCellWidthSum == accRowWidth - dataGridView.RowHeadersWidth);
}

[StaFact]
[WinFormsFact]
public void DataGridViewCellsAccessibleObject_IsReadOnly_property()
{
DataGridView dataGridView = new DataGridView();
using var dataGridView = new DataGridView();
dataGridView.Columns.Add(new DataGridViewTextBoxColumn());
dataGridView.Columns.Add(new DataGridViewTextBoxColumn());
dataGridView.Rows.Add(new DataGridViewRow());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ namespace System.Windows.Forms.Tests.AccessibleObjects
{
public class DataGridViewComboBoxCellAccessibleObjectTests : IClassFixture<ThreadExceptionFixture>
{
[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.IsExpandCollapsePatternAvailablePropertyId, true)]
public void GetPropertyValue_Returns_Correct_Value(int propertyID, object expectedPropertyValue)
{
DataGridView dataGridView = new DataGridView();
using var dataGridView = new DataGridView();
DataGridViewComboBoxColumn column = new DataGridViewComboBoxColumn();
dataGridView.Columns.Add(column);
dataGridView.Rows.Add();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ namespace System.Windows.Forms.Tests.AccessibleObjects
{
public class DataGridViewRowsAccessibleObjectTests : IClassFixture<ThreadExceptionFixture>
{
[Fact]
[WinFormsFact]
public void DataGridViewRowsAccessibleObject_Ctor_Default()
{
DataGridView dataGridView = new DataGridView
using DataGridView dataGridView = new DataGridView
{
RowCount = 5,
Height = 87
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void PropertyGridAccessibleObject_Ctor_Default()
Assert.Equal(propertyGrid, accessibleObject.Owner);
}

[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.TableItemPatternId)]
[InlineData((int)UiaCore.UIA.GridItemPatternId)]
public void GridEntryAccessibleObject_SupportsPattern(int pattern)
Expand All @@ -33,7 +33,7 @@ public void GridEntryAccessibleObject_SupportsPattern(int pattern)
Assert.True(accessibleObject.IsPatternSupported((UiaCore.UIA)pattern));
}

[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.GridPatternId)]
[InlineData((int)UiaCore.UIA.TablePatternId)]
public void PropertyGridAccessibleObject_SupportsPattern(int pattern)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void PropertyGridViewAccessibleObject_Ctor_NullOwnerParameter_ThrowsArgum
Assert.Throws<TargetInvocationException>(() => ctor.Invoke(new object[] { null, null }));
}

[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.IsGridPatternAvailablePropertyId)]
[InlineData((int)UiaCore.UIA.IsTablePatternAvailablePropertyId)]
public void PropertyGridViewAccessibleObject_Pattern_IsAvailable(int propertyId)
Expand All @@ -192,7 +192,7 @@ public void PropertyGridViewAccessibleObject_Pattern_IsAvailable(int propertyId)
Assert.True((bool)accessibleObject.GetPropertyValue((UiaCore.UIA)propertyId));
}

[Theory]
[WinFormsTheory]
[InlineData((int)UiaCore.UIA.TablePatternId)]
[InlineData((int)UiaCore.UIA.GridPatternId)]
public void PropertyGridViewAccessibleObject_IsPatternSupported(int patternId)
Expand Down Expand Up @@ -264,7 +264,7 @@ public void PropertyGridViewAccessibleObject_Parent_IsNotNull()
Assert.NotNull(accessibleObject.Parent);
}

[Theory]
[WinFormsTheory]
[InlineData("Some test text")]
[InlineData("")]
public void PropertyGridView_GridViewListBoxAccessibleObject_Name_ReturnsDeterminedName(string name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,22 @@ namespace System.Windows.Forms.Tests.AccessibleObjects
{
public class ToolStripAccessibleObjectTests : IClassFixture<ThreadExceptionFixture>
{
[Fact]
[WinFormsFact]
public void ToolStripAccessibleObject_Ctor_Default()
{
ToolStrip toolStrip = new ToolStrip();
using ToolStrip toolStrip = new ToolStrip();

var accessibleObject = new ToolStrip.ToolStripAccessibleObject(toolStrip);
Assert.NotNull(accessibleObject.Owner);
Assert.Equal(AccessibleRole.ToolBar, accessibleObject.Role);
}

public static IEnumerable<object[]> ToolStripAccessibleObject_TestData()
[WinFormsFact]
public void ToolStripAccessibleObject_FragmentNavigate_FirstChild_ThumbButton()
{
ToolStrip toolStrip = new ToolStrip();
yield return new object[] { toolStrip.AccessibilityObject };
}
using ToolStrip toolStrip = new ToolStrip();
var accessibleObject = toolStrip.AccessibilityObject;

[Theory]
[MemberData(nameof(ToolStripAccessibleObject_TestData))]
public void ToolStripAccessibleObject_FragmentNavigate_FirstChild_ThumbButton(AccessibleObject accessibleObject)
{
UiaCore.IRawElementProviderFragment firstChild = accessibleObject.FragmentNavigate(UiaCore.NavigateDirection.FirstChild);
Assert.NotNull(firstChild);
Assert.Equal(UiaCore.UIA.ThumbControlTypeId, firstChild.GetPropertyValue(UiaCore.UIA.ControlTypePropertyId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ namespace System.Windows.Forms.Tests
{
public class ToolStripItemAccessibleObjectTests : IClassFixture<ThreadExceptionFixture>
{
[Fact]
[WinFormsFact]
public void ToolStripItemAccessibleObject_Ctor_ToolStripItem()
{
var item = new SubToolStripItem
using var item = new SubToolStripItem
{
AccessibleDefaultActionDescription = "DefaultActionDescription",
AccessibleDescription = "Description",
AccessibleName = "Name",
AccessibleRole = AccessibleRole.MenuBar
};

var accessibleObject = new ToolStripItem.ToolStripItemAccessibleObject(item);

Assert.Equal(Rectangle.Empty, accessibleObject.Bounds);
Assert.Equal("DefaultActionDescription", accessibleObject.DefaultAction);
Assert.Equal("Description", accessibleObject.Description);
Expand All @@ -32,7 +34,7 @@ public void ToolStripItemAccessibleObject_Ctor_ToolStripItem()
Assert.Equal(AccessibleStates.Focusable, accessibleObject.State);
}

[Fact]
[WinFormsFact]
public void ToolStripItemAccessibleObject_Ctor_NullOwnerItem_ThrowsArgumentNullException()
{
Assert.Throws<ArgumentNullException>("ownerItem", () => new ToolStripItem.ToolStripItemAccessibleObject(null));
Expand Down
Loading