Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved WindowsFormsIntegration area #230

Merged
merged 18 commits into from
Dec 7, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions Microsoft.DotNet.Wpf.Test.sln
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtEvents", "src\Test\Eleme
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtWindowsFormsIntegration", "src\Test\WindowsFormsIntegration\DRT\WindowsFormsIntegration\DrtWindowsFormsIntegration.csproj", "{F24751C5-F8FB-4496-8A2B-E2CF5BBB8CC1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindowsFormsIntegrationTests", "src\Test\WindowsFormsIntegration\FeatureTests\WindowsFormsIntegration\WindowsFormsIntegrationTests.csproj", "{D8033CF3-16FB-4D53-B11B-3CE51F333984}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestDriver", "src\Test\WindowsFormsIntegration\FeatureTests\TestDriver\TestDriver.csproj", "{C83650D9-B6D4-41EA-AE6C-4A3C7363DEF3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtChangeable", "src\Test\mil\DRT\changeable\DrtChangeable.csproj", "{689DFFB3-7117-4E4C-99FA-AB19C10ACC2F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DrtVisualTreeChange", "src\Test\Diagnostics\DRT\VisualTreeChange\DrtVisualTreeChange.csproj", "{0073C2B8-F2AC-463A-97D3-884AE5A488D9}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ public sealed class ElementHostTestSuite : DrtTestSuite
{
public ElementHostTestSuite() : base("ElementHostTestSuite") { }

ElementHost elementHost;
SWF.Form form;
SWC.Button button;
ElementHost _elementHost;
SWF.Form _form;
SWC.Button _button;
public override DrtTest[] PrepareTests()
{
form = new SWF.Form();
elementHost = new ElementHost();
button = new SWC.Button();
button.Content = "Avalon button";
elementHost.Child = button;
form.Controls.Add(elementHost);
form.Show();
_form = new SWF.Form();
_elementHost = new ElementHost();
_button = new SWC.Button();
_button.Content = "Avalon button";
_elementHost.Child = _button;
_form.Controls.Add(_elementHost);
_form.Show();

return new DrtTest[]
{
Expand All @@ -47,31 +47,31 @@ public override DrtTest[] PrepareTests()

private void TestVisibility()
{
elementHost.Visible = false;
DRT.Assert(!elementHost.Child.IsVisible, "PropertyMapping didn't work for ElementHost visible (false)");
elementHost.Visible = true;
DRT.Assert(elementHost.Child.IsVisible, "PropertyMapping didn't work for ElementHost visible (true)");
_elementHost.Visible = false;
DRT.Assert(!_elementHost.Child.IsVisible, "PropertyMapping didn't work for ElementHost visible (false)");
_elementHost.Visible = true;
DRT.Assert(_elementHost.Child.IsVisible, "PropertyMapping didn't work for ElementHost visible (true)");
}

private void TestResize()
{
elementHost.AutoSize = true;
form.PerformLayout();
_elementHost.AutoSize = true;
_form.PerformLayout();
SWF.Application.DoEvents();
double originalWidth = button.ActualWidth;
form.PerformLayout();
button.Content += " with a bunch of text";
double originalWidth = _button.ActualWidth;
_form.PerformLayout();
_button.Content += " with a bunch of text";
SWF.Application.DoEvents();
DRT.Assert(button.ActualWidth > originalWidth, "ElementHost layout issue: Width didn't grow as hosted element grew");
DRT.Assert(_button.ActualWidth > originalWidth, "ElementHost layout issue: Width didn't grow as hosted element grew");

elementHost.AutoSize = false;
elementHost.Width = 150;
form.PerformLayout();
_elementHost.AutoSize = false;
_elementHost.Width = 150;
_form.PerformLayout();
SWF.Application.DoEvents();
originalWidth = button.ActualWidth;
form.PerformLayout();
button.Content += " and even more text";
originalWidth = _button.ActualWidth;
_form.PerformLayout();
_button.Content += " and even more text";
SWF.Application.DoEvents();
DRT.AssertEqual(originalWidth, button.ActualWidth, "ElementHost layout issue: Width grew when host's Width was explicitly set");
DRT.AssertEqual(originalWidth, _button.ActualWidth, "ElementHost layout issue: Width grew when host's Width was explicitly set");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,39 @@ public sealed class WindowsFormsHostTestSuite : DrtTestSuite
{
public WindowsFormsHostTestSuite() : base("WindowsFormsHostTestSuite") { }

SWC.DockPanel dockPanel;
SWC.Button avButton;
SWF.Button wfButton;
Window window;
WindowsFormsHost windowsFormsHost;
SWC.DockPanel _dockPanel;
SWC.Button _avButton;
SWF.Button _wfButton;
Window _window;
WindowsFormsHost _windowsFormsHost;

public override DrtTest[] PrepareTests()
{
//Avalon DockPanel added to Window
dockPanel = new SWC.DockPanel();
window = new Window();
window.Width = 300d;
window.Height = 200d;
window.Content = dockPanel;
_dockPanel = new SWC.DockPanel();
_window = new Window();
_window.Width = 300d;
_window.Height = 200d;
_window.Content = _dockPanel;

//Avalon Button added to dock to the BOTTOM of the panel
avButton = new SWC.Button();
avButton.Content = "Avalon Button";
SWC.DockPanel.SetDock(avButton, SWC.Dock.Bottom);
dockPanel.Children.Add(avButton);
_avButton = new SWC.Button();
_avButton.Content = "Avalon Button";
SWC.DockPanel.SetDock(_avButton, SWC.Dock.Bottom);
_dockPanel.Children.Add(_avButton);

//WinFormsHost added to dock to the LEFT of the panel
windowsFormsHost = new WindowsFormsHost();
SWC.DockPanel.SetDock(windowsFormsHost, SWC.Dock.Left);
dockPanel.Children.Add(windowsFormsHost);
_windowsFormsHost = new WindowsFormsHost();
SWC.DockPanel.SetDock(_windowsFormsHost, SWC.Dock.Left);
_dockPanel.Children.Add(_windowsFormsHost);

//WinForm Button added to Host
wfButton = new SWF.Button();
wfButton.Text = "&Windows Forms Button";
wfButton.Dock = SWF.DockStyle.Fill;
_wfButton = new SWF.Button();
_wfButton.Text = "&Windows Forms Button";
_wfButton.Dock = SWF.DockStyle.Fill;

windowsFormsHost.Child = wfButton;
window.Show();
_windowsFormsHost.Child = _wfButton;
_window.Show();

return new DrtTest[]
{
Expand All @@ -71,45 +71,45 @@ public override DrtTest[] PrepareTests()

private void TestRightToLeft()
{
dockPanel.FlowDirection = SW.FlowDirection.RightToLeft;
DRT.AssertEqual(SWF.RightToLeft.Yes, windowsFormsHost.Child.RightToLeft, "Property mapping for RightToLeft didn't work");
dockPanel.FlowDirection = SW.FlowDirection.LeftToRight;
DRT.AssertEqual(SWF.RightToLeft.No, windowsFormsHost.Child.RightToLeft, "Property mapping for RightToLeft didn't work");
_dockPanel.FlowDirection = SW.FlowDirection.RightToLeft;
DRT.AssertEqual(SWF.RightToLeft.Yes, _windowsFormsHost.Child.RightToLeft, "Property mapping for RightToLeft didn't work");
_dockPanel.FlowDirection = SW.FlowDirection.LeftToRight;
DRT.AssertEqual(SWF.RightToLeft.No, _windowsFormsHost.Child.RightToLeft, "Property mapping for RightToLeft didn't work");
}

private void TestVisibility()
{
windowsFormsHost.Visibility = SW.Visibility.Hidden;
DRT.Assert(!windowsFormsHost.Child.Visible, "Property mapping for Visible (false) didn't work");
windowsFormsHost.Visibility = SW.Visibility.Visible;
DRT.Assert(windowsFormsHost.Child.Visible, "Property mapping for Visible (true) didn't work");
_windowsFormsHost.Visibility = SW.Visibility.Hidden;
DRT.Assert(!_windowsFormsHost.Child.Visible, "Property mapping for Visible (false) didn't work");
_windowsFormsHost.Visibility = SW.Visibility.Visible;
DRT.Assert(_windowsFormsHost.Child.Visible, "Property mapping for Visible (true) didn't work");
}

private void TestForeground()
{
SWM.Color color = SWM.Color.FromRgb(255, 0, 0);
SWM.Color colorEnd = SWM.Color.FromRgb(128, 255, 0);
SWM.LinearGradientBrush fancyBrush = new SWM.LinearGradientBrush(color, colorEnd, 0);
windowsFormsHost.Foreground = fancyBrush;
_windowsFormsHost.Foreground = fancyBrush;
//Ensure this doesn't throw
}

private void TestFont()
{
windowsFormsHost.FontWeight = SW.FontWeights.Bold;
DRT.AssertEqual(SD.FontStyle.Bold, windowsFormsHost.Child.Font.Style, "Property mapping for FontStyle didn't work");
_windowsFormsHost.FontWeight = SW.FontWeights.Bold;
DRT.AssertEqual(SD.FontStyle.Bold, _windowsFormsHost.Child.Font.Style, "Property mapping for FontStyle didn't work");
}

private void TestResize()
{
int originalWidth = windowsFormsHost.Child.Width;
window.Width += 100;
DRT.Assert(windowsFormsHost.Child.Width > originalWidth, "WindowsFormsHost layout issue: Width didn't grow as parent's Width grew");
windowsFormsHost.Width = 250;
int originalWidth = _windowsFormsHost.Child.Width;
_window.Width += 100;
DRT.Assert(_windowsFormsHost.Child.Width > originalWidth, "WindowsFormsHost layout issue: Width didn't grow as parent's Width grew");
_windowsFormsHost.Width = 250;
SWF.Application.DoEvents();
originalWidth = windowsFormsHost.Child.Width;
window.Width += 100;
originalWidth = _windowsFormsHost.Child.Width;
_window.Width += 100;
SWF.Application.DoEvents();
DRT.AssertEqual(originalWidth, windowsFormsHost.Child.Width, "WindowsFormsHost layout issue: Child Width grew when host's Width was explicitly set");
DRT.AssertEqual(originalWidth, _windowsFormsHost.Child.Width, "WindowsFormsHost layout issue: Child Width grew when host's Width was explicitly set");
}
}
2 changes: 1 addition & 1 deletion src/Test/WindowsFormsIntegration/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<Project>
<Import Condition="Exists('../Directory.Build.props')" Project="../Directory.Build.props" />
</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<Import Condition="Exists('../Directory.Build.props')" Project="../Directory.Build.props" />
<PropertyGroup>
<PublishDir>$(WpfFeatureTestBasePublishPath)\WindowsFormsIntegration</PublishDir>
</PropertyGroup>
</Project>
Loading
Loading