25 changed files with 1421 additions and 116 deletions
@ -0,0 +1,16 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="KeyboardNavigationMode.cs" company="Steven Kirk">
|
|||
// Copyright 2015 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Input |
|||
{ |
|||
public enum KeyboardNavigationMode |
|||
{ |
|||
Continue, |
|||
Cycle, |
|||
Once, |
|||
Never, |
|||
} |
|||
} |
|||
@ -1,18 +1,18 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<packages> |
|||
<package id="AutoFixture" version="3.21.1" targetFramework="net45" /> |
|||
<package id="AutoFixture.AutoMoq" version="3.21.1" targetFramework="net45" /> |
|||
<package id="Moq" version="4.2.1409.1722" targetFramework="net45" /> |
|||
<package id="Rx-Core" version="2.2.5" targetFramework="net45" /> |
|||
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" /> |
|||
<package id="Rx-Linq" version="2.2.5" targetFramework="net45" /> |
|||
<package id="Rx-Main" version="2.2.5" targetFramework="net45" /> |
|||
<package id="Rx-PlatformServices" version="2.2.5" targetFramework="net45" /> |
|||
<package id="Splat" version="1.6.1" targetFramework="net45" /> |
|||
<package id="xunit" version="2.0.0" targetFramework="net45" /> |
|||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" /> |
|||
<package id="xunit.assert" version="2.0.0" targetFramework="net45" /> |
|||
<package id="xunit.core" version="2.0.0" targetFramework="net45" /> |
|||
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" /> |
|||
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" /> |
|||
<package id="AutoFixture" version="3.30.3" targetFramework="net45" userInstalled="true" /> |
|||
<package id="AutoFixture.AutoMoq" version="3.30.3" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Moq" version="4.2.1409.1722" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Rx-Core" version="2.2.5" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Rx-Interfaces" version="2.2.5" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Rx-Linq" version="2.2.5" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Rx-Main" version="2.2.5" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Rx-PlatformServices" version="2.2.5" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Splat" version="1.6.1" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.assert" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.core" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
</packages> |
|||
@ -0,0 +1,856 @@ |
|||
// -----------------------------------------------------------------------
|
|||
// <copyright file="KeyboardNavigationTests.cs" company="Steven Kirk">
|
|||
// Copyright 2015 MIT Licence. See licence.md for more information.
|
|||
// </copyright>
|
|||
// -----------------------------------------------------------------------
|
|||
|
|||
namespace Perspex.Input.UnitTests |
|||
{ |
|||
using Perspex.Controls; |
|||
using Xunit; |
|||
|
|||
public class KeyboardNavigationTests |
|||
{ |
|||
[Fact] |
|||
public void GetNextInTabOrder_Continue_Returns_Next_Control_In_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(current = new Button { Id = "Button2" }), |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Sibling_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(current = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Continue_Returns_Next_Sibling() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(current = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
(next = new Button { Id = "Button4" }), |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Continue_Returns_First_Control_In_Next_Uncle_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(current = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
}, |
|||
}, |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Continue_Returns_Child_Of_Top_Level() |
|||
{ |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button1" }), |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(top); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Continue_Wraps() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button1" }), |
|||
new Button { Id = "Button2" }, |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
}, |
|||
}, |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
(current = new Button { Id = "Button6" }), |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Cycle_Returns_Next_Control_In_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(current = new Button { Id = "Button2" }), |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Cycle_Wraps_To_First() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button1" }), |
|||
new Button { Id = "Button2" }, |
|||
(current = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Once_Moves_To_Next_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(current = new Button { Id = "Button2" }), |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Once_Moves_To_Active_Element() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(next = new Button { Id = "Button2" }), |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
(current = new Button { Id = "Button6" }), |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
KeyboardNavigation.SetTabOnceActiveElement(container, next); |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Never_Moves_To_Next_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Never, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(current = new Button { Id = "Button2" }), |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetNextInTabOrder_Never_Skips_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Never, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
(current = new Button { Id = "Button6" }), |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
KeyboardNavigation.SetTabOnceActiveElement(container, next); |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetNextInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Continue_Returns_Previous_Control_In_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(next = new Button { Id = "Button2" }), |
|||
(current = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Continue_Returns_Last_Control_In_Previous_Sibling_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(current = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Continue_Returns_Last_Child_Of_Sibling() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
(current = new Button { Id = "Button4" }), |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Continue_Returns_Last_Control_In_Previous_Nephew_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
}, |
|||
}, |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(current = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Continue_Wraps() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(current = new Button { Id = "Button1" }), |
|||
new Button { Id = "Button2" }, |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
}, |
|||
}, |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
(next = new Button { Id = "Button6" }), |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Cycle_Returns_Previous_Control_In_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button1" }), |
|||
(current = new Button { Id = "Button2" }), |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Cycle_Wraps_To_Last() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle, |
|||
Children = new Controls |
|||
{ |
|||
(current = new Button { Id = "Button1" }), |
|||
new Button { Id = "Button2" }, |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Once_Moves_To_Previous_Container() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
new Button { Id = "Button2" }, |
|||
(next = new Button { Id = "Button3" }), |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button4" }, |
|||
(current = new Button { Id = "Button5" }), |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Once_Moves_To_Active_Element() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, |
|||
Children = new Controls |
|||
{ |
|||
new Button { Id = "Button1" }, |
|||
(next = new Button { Id = "Button2" }), |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(current = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
KeyboardNavigation.SetTabOnceActiveElement(container, next); |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
|
|||
[Fact] |
|||
public void GetPreviousInTabOrder_Once_Moves_To_First_Element() |
|||
{ |
|||
StackPanel container; |
|||
Button current; |
|||
Button next; |
|||
|
|||
var top = new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(container = new StackPanel |
|||
{ |
|||
[KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Once, |
|||
Children = new Controls |
|||
{ |
|||
(next = new Button { Id = "Button1" }), |
|||
new Button { Id = "Button2" }, |
|||
new Button { Id = "Button3" }, |
|||
} |
|||
}), |
|||
new StackPanel |
|||
{ |
|||
Children = new Controls |
|||
{ |
|||
(current = new Button { Id = "Button4" }), |
|||
new Button { Id = "Button5" }, |
|||
new Button { Id = "Button6" }, |
|||
} |
|||
}, |
|||
} |
|||
}; |
|||
|
|||
var target = new KeyboardNavigation(); |
|||
var result = target.GetPreviousInTabOrder(current); |
|||
|
|||
Assert.Equal(next, result); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,134 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props" Condition="Exists('..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" /> |
|||
<Import Project="..\..\packages\xunit.core.2.0.0\build\Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0\build\Xamarin.iOS\xunit.core.props')" /> |
|||
<Import Project="..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" /> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{AC18926A-E784-40FE-B09D-BB0FE2B599F0}</ProjectGuid> |
|||
<OutputType>Library</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>Perspex.Input.UnitTests</RootNamespace> |
|||
<AssemblyName>Perspex.Input.UnitTests</AssemblyName> |
|||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<NuGetPackageImportStamp>90580c1a</NuGetPackageImportStamp> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="Moq, Version=4.2.1502.911, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Moq.4.2.1502.911\lib\net40\Moq.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="Ploeh.AutoFixture, Version=3.30.3.0, Culture=neutral, PublicKeyToken=b24654c590009d4f, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\AutoFixture.3.30.3\lib\net40\Ploeh.AutoFixture.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="Ploeh.AutoFixture.AutoMoq, Version=3.30.3.0, Culture=neutral, PublicKeyToken=b24654c590009d4f, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\AutoFixture.AutoMoq.3.30.3\lib\net40\Ploeh.AutoFixture.AutoMoq.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="Splat, Version=1.6.2.0, Culture=neutral, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\Splat.1.6.2\lib\Net45\Splat.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Xml" /> |
|||
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL"> |
|||
<HintPath>..\..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath> |
|||
<Private>True</Private> |
|||
</Reference> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="KeyboardNavigationTests.cs" /> |
|||
<Compile Include="Properties\AssemblyInfo.cs" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="app.config" /> |
|||
<None Include="packages.config" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\Perspex.Animation\Perspex.Animation.csproj"> |
|||
<Project>{d211e587-d8bc-45b9-95a4-f297c8fa5200}</Project> |
|||
<Name>Perspex.Animation</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.Base\Perspex.Base.csproj"> |
|||
<Project>{b09b78d8-9b26-48b0-9149-d64a2f120f3f}</Project> |
|||
<Name>Perspex.Base</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.Controls\Perspex.Controls.csproj"> |
|||
<Project>{d2221c82-4a25-4583-9b43-d791e3f6820c}</Project> |
|||
<Name>Perspex.Controls</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.Input\Perspex.Input.csproj"> |
|||
<Project>{62024b2d-53eb-4638-b26b-85eeaa54866e}</Project> |
|||
<Name>Perspex.Input</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.Interactivity\Perspex.Interactivity.csproj"> |
|||
<Project>{6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b}</Project> |
|||
<Name>Perspex.Interactivity</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.Layout\Perspex.Layout.csproj"> |
|||
<Project>{42472427-4774-4c81-8aff-9f27b8e31721}</Project> |
|||
<Name>Perspex.Layout</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.SceneGraph\Perspex.SceneGraph.csproj"> |
|||
<Project>{eb582467-6abb-43a1-b052-e981ba910e3a}</Project> |
|||
<Name>Perspex.SceneGraph</Name> |
|||
</ProjectReference> |
|||
<ProjectReference Include="..\..\Perspex.Styling\Perspex.Styling.csproj"> |
|||
<Project>{f1baa01a-f176-4c6a-b39d-5b40bb1b148f}</Project> |
|||
<Name>Perspex.Styling</Name> |
|||
</ProjectReference> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> |
|||
<PropertyGroup> |
|||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> |
|||
</PropertyGroup> |
|||
<Error Condition="!Exists('..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" /> |
|||
<Error Condition="!Exists('..\..\packages\xunit.core.2.0.0\build\Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.core.2.0.0\build\Xamarin.iOS\xunit.core.props'))" /> |
|||
<Error Condition="!Exists('..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\xunit.runner.visualstudio.2.0.0\build\net20\xunit.runner.visualstudio.props'))" /> |
|||
</Target> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
|||
@ -0,0 +1,36 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
|
|||
// General Information about an assembly is controlled through the following
|
|||
// set of attributes. Change these attribute values to modify the information
|
|||
// associated with an assembly.
|
|||
[assembly: AssemblyTitle("Perspex.Input.UnitTests")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("")] |
|||
[assembly: AssemblyProduct("Perspex.Input.UnitTests")] |
|||
[assembly: AssemblyCopyright("Copyright © 2015")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// Setting ComVisible to false makes the types in this assembly not visible
|
|||
// to COM components. If you need to access a type in this assembly from
|
|||
// COM, set the ComVisible attribute to true on that type.
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|||
[assembly: Guid("ac18926a-e784-40fe-b09d-bb0fe2b599f0")] |
|||
|
|||
// Version information for an assembly consists of the following four values:
|
|||
//
|
|||
// Major Version
|
|||
// Minor Version
|
|||
// Build Number
|
|||
// Revision
|
|||
//
|
|||
// You can specify all the values or you can default the Build and Revision Numbers
|
|||
// by using the '*' as shown below:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,11 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<runtime> |
|||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|||
<dependentAssembly> |
|||
<assemblyIdentity name="Moq" publicKeyToken="69f491c39445e920" culture="neutral" /> |
|||
<bindingRedirect oldVersion="0.0.0.0-4.2.1502.911" newVersion="4.2.1502.911" /> |
|||
</dependentAssembly> |
|||
</assemblyBinding> |
|||
</runtime> |
|||
</configuration> |
|||
@ -0,0 +1,13 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<packages> |
|||
<package id="AutoFixture" version="3.30.3" targetFramework="net45" userInstalled="true" /> |
|||
<package id="AutoFixture.AutoMoq" version="3.30.3" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Moq" version="4.2.1502.911" targetFramework="net45" userInstalled="true" /> |
|||
<package id="Splat" version="1.6.2" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.abstractions" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.assert" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.core" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
<package id="xunit.runner.visualstudio" version="2.0.0" targetFramework="net45" userInstalled="true" /> |
|||
</packages> |
|||
Loading…
Reference in new issue