-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0856e36
commit bfed85e
Showing
6 changed files
with
186 additions
and
5 deletions.
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
source/AutomationTest/Xceed.Wpf.AvalonDock.Test/DockingUtilitiesTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
namespace Xceed.Wpf.AvalonDock.Test | ||
{ | ||
using System; | ||
using System.Windows.Controls; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Xceed.Wpf.AvalonDock.Layout; | ||
|
||
[TestClass] | ||
public sealed class DockingUtilitiesTest | ||
{ | ||
[TestMethod] | ||
public void CalculatedDockMinWidthHeightTest() | ||
{ | ||
double defaultDockMinHeight = 25; | ||
double defaultDockMinWidth = 25; | ||
|
||
const double documentPaneDockMinHeight = 200; | ||
const double documentPaneDockMinWidth = 400; | ||
LayoutDocumentPane layoutDocumentPane = new LayoutDocumentPane { DockMinHeight = documentPaneDockMinHeight, DockMinWidth = documentPaneDockMinWidth }; | ||
layoutDocumentPane.InsertChildAt( 0, new LayoutDocument { ContentId = "Document" } ); | ||
|
||
LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup(); | ||
layoutDocumentPaneGroup.InsertChildAt( 0, layoutDocumentPane ); | ||
|
||
const double anchorablePaneDockMinHeight = 80; | ||
const double anchorablePaneDockMinWidth = 160; | ||
LayoutAnchorablePane layoutAnchorablePane = new LayoutAnchorablePane { DockMinHeight = anchorablePaneDockMinHeight, DockMinWidth = anchorablePaneDockMinWidth }; | ||
layoutAnchorablePane.InsertChildAt( 0, new LayoutAnchorable { ContentId = "Anchorable" } ); | ||
|
||
LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup(); | ||
layoutAnchorablePaneGroup.InsertChildAt( 0, layoutAnchorablePane ); | ||
|
||
LayoutPanel layoutPanel = new LayoutPanel(); | ||
layoutPanel.InsertChildAt( 0, layoutDocumentPaneGroup ); | ||
layoutPanel.InsertChildAt( 1, layoutAnchorablePaneGroup ); | ||
|
||
Assert.AreEqual( defaultDockMinWidth, layoutPanel.DockMinWidth ); | ||
Assert.AreEqual( defaultDockMinHeight, layoutPanel.DockMinHeight ); | ||
Assert.AreEqual( documentPaneDockMinWidth + anchorablePaneDockMinWidth, layoutPanel.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( Math.Max(documentPaneDockMinHeight, anchorablePaneDockMinHeight), layoutPanel.CalculatedDockMinHeight() ); | ||
|
||
Assert.AreEqual( documentPaneDockMinWidth, layoutDocumentPane.DockMinWidth ); | ||
Assert.AreEqual( documentPaneDockMinHeight, layoutDocumentPane.DockMinHeight ); | ||
Assert.AreEqual( layoutDocumentPane.DockMinWidth, layoutDocumentPane.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( layoutDocumentPane.DockMinHeight, layoutDocumentPane.CalculatedDockMinHeight() ); | ||
|
||
Assert.AreEqual( defaultDockMinWidth, layoutDocumentPaneGroup.DockMinWidth ); | ||
Assert.AreEqual( defaultDockMinWidth, layoutDocumentPaneGroup.DockMinHeight ); | ||
Assert.AreEqual( documentPaneDockMinWidth, layoutDocumentPaneGroup.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( documentPaneDockMinHeight, layoutDocumentPaneGroup.CalculatedDockMinHeight() ); | ||
|
||
Assert.AreEqual( anchorablePaneDockMinWidth, layoutAnchorablePane.DockMinWidth ); | ||
Assert.AreEqual( anchorablePaneDockMinHeight, layoutAnchorablePane.DockMinHeight ); | ||
Assert.AreEqual( layoutAnchorablePane.DockMinWidth, layoutAnchorablePane.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( layoutAnchorablePane.DockMinHeight, layoutAnchorablePane.CalculatedDockMinHeight() ); | ||
|
||
Assert.AreEqual( defaultDockMinWidth, layoutAnchorablePaneGroup.DockMinWidth ); | ||
Assert.AreEqual( defaultDockMinWidth, layoutAnchorablePaneGroup.DockMinHeight ); | ||
Assert.AreEqual( anchorablePaneDockMinWidth, layoutAnchorablePaneGroup.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( anchorablePaneDockMinHeight, layoutAnchorablePaneGroup.CalculatedDockMinHeight() ); | ||
|
||
layoutPanel.RemoveChild( layoutDocumentPaneGroup ); | ||
Assert.AreEqual( anchorablePaneDockMinWidth, layoutPanel.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( anchorablePaneDockMinHeight, layoutPanel.CalculatedDockMinHeight() ); | ||
} | ||
|
||
[TestMethod] | ||
public void UpdateDocMinWidthHeightTest() | ||
{ | ||
double documentPaneDockMinHeight = 100; | ||
double documentPaneDockMinWidth = 101; | ||
LayoutDocumentPane layoutDocumentPane = new LayoutDocumentPane { DockMinHeight = documentPaneDockMinHeight, DockMinWidth = documentPaneDockMinWidth }; | ||
layoutDocumentPane.InsertChildAt( 0, new LayoutDocument { ContentId = "Document" } ); | ||
|
||
LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup(); | ||
layoutDocumentPaneGroup.InsertChildAt( 0, layoutDocumentPane ); | ||
|
||
double anchorablePane1DockMinHeight = 150; | ||
double anchorablePane1DockMinWidth = 151; | ||
LayoutAnchorablePane layoutAnchorablePane1 = new LayoutAnchorablePane { DockMinHeight = anchorablePane1DockMinHeight, DockMinWidth = anchorablePane1DockMinWidth }; | ||
layoutAnchorablePane1.InsertChildAt( 0, new LayoutAnchorable { ContentId = "Anchorable1" } ); | ||
|
||
double anchorablePane2DockMinHeight = 200; | ||
double anchorablePane2DockMinWidth = 201; | ||
LayoutAnchorablePane layoutAnchorablePane2 = new LayoutAnchorablePane { DockMinHeight = anchorablePane2DockMinHeight, DockMinWidth = anchorablePane2DockMinWidth }; | ||
layoutAnchorablePane2.InsertChildAt( 0, new LayoutAnchorable { ContentId = "Anchorable2" } ); | ||
|
||
LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup { Orientation = Orientation.Horizontal }; | ||
layoutAnchorablePaneGroup.InsertChildAt( 0, layoutAnchorablePane1 ); | ||
layoutAnchorablePaneGroup.InsertChildAt( 0, layoutAnchorablePane2 ); | ||
|
||
LayoutPanel layoutPanel = new LayoutPanel { Orientation = Orientation.Vertical }; | ||
layoutPanel.InsertChildAt( 0, layoutDocumentPaneGroup ); | ||
layoutPanel.InsertChildAt( 1, layoutAnchorablePaneGroup ); | ||
|
||
Assert.AreEqual( anchorablePane2DockMinWidth + anchorablePane1DockMinWidth, layoutAnchorablePaneGroup.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( Math.Max( anchorablePane2DockMinHeight, anchorablePane1DockMinHeight ), layoutAnchorablePaneGroup.CalculatedDockMinHeight() ); | ||
|
||
Assert.AreEqual( documentPaneDockMinWidth, layoutDocumentPaneGroup.CalculatedDockMinWidth() ); | ||
Assert.AreEqual( documentPaneDockMinHeight, layoutDocumentPaneGroup.CalculatedDockMinHeight() ); | ||
|
||
Assert.AreEqual( | ||
Math.Max( anchorablePane1DockMinWidth + anchorablePane2DockMinWidth, documentPaneDockMinWidth ), | ||
layoutPanel.CalculatedDockMinWidth() ); | ||
|
||
Assert.AreEqual( documentPaneDockMinHeight + anchorablePane2DockMinHeight, layoutPanel.CalculatedDockMinHeight() ); | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
source/AutomationTest/Xceed.Wpf.AvalonDock.Test/LayoutAnchorableTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Windows; | ||
using System.Windows.Data; | ||
|
||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
using Xceed.Wpf.AvalonDock.Controls; | ||
using Xceed.Wpf.AvalonDock.Converters; | ||
using Xceed.Wpf.AvalonDock.Layout; | ||
|
||
namespace Xceed.Wpf.AvalonDock.Test | ||
{ | ||
[TestClass] | ||
public sealed class LayoutAnchorableTest | ||
{ | ||
[TestMethod] | ||
public void ClearBindingOfHiddenWindowTest() | ||
{ | ||
LayoutAnchorable layoutAnchorable = new LayoutAnchorable | ||
{ | ||
FloatingWidth = 50, | ||
FloatingHeight = 100, | ||
ContentId = "Test" | ||
}; | ||
|
||
LayoutAnchorablePane layoutAnchorablePane = new LayoutAnchorablePane( layoutAnchorable ); | ||
LayoutAnchorablePaneGroup layoutAnchorablePaneGroup = new LayoutAnchorablePaneGroup( layoutAnchorablePane ); | ||
LayoutAnchorableFloatingWindow layoutFloatingWindow = new LayoutAnchorableFloatingWindow | ||
{ | ||
RootPanel = layoutAnchorablePaneGroup | ||
}; | ||
|
||
var ctor = typeof( LayoutAnchorableFloatingWindowControl ) | ||
.GetTypeInfo() | ||
.GetConstructors( BindingFlags.NonPublic | BindingFlags.Instance ) | ||
.First( x => x.GetParameters().Length == 1 ); | ||
|
||
LayoutAnchorableFloatingWindowControl floatingWindowControl = ctor.Invoke( new object[] {layoutFloatingWindow} ) as LayoutAnchorableFloatingWindowControl; | ||
floatingWindowControl.SetBinding( | ||
UIElement.VisibilityProperty, | ||
new Binding( "IsVisible" ) | ||
{ | ||
Source = floatingWindowControl.Model, | ||
Converter = new BoolToVisibilityConverter(), | ||
Mode = BindingMode.OneWay, | ||
ConverterParameter = Visibility.Hidden | ||
} ); | ||
|
||
BindingExpression visibilityBinding = floatingWindowControl.GetBindingExpression( UIElement.VisibilityProperty ); | ||
Assert.IsNotNull( visibilityBinding ); | ||
|
||
layoutAnchorable.Show(); | ||
layoutAnchorable.Hide(); | ||
|
||
visibilityBinding = floatingWindowControl.GetBindingExpression( UIElement.VisibilityProperty ); | ||
Assert.IsNotNull( visibilityBinding ); | ||
|
||
floatingWindowControl.Hide(); | ||
|
||
visibilityBinding = floatingWindowControl.GetBindingExpression( UIElement.VisibilityProperty ); | ||
Assert.IsNull( visibilityBinding ); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters