Merge branch '3.6.0' into 4.0.0
This commit is contained in:
Коммит
cf5cb580dc
|
@ -0,0 +1,229 @@
|
|||
using NUnit.Framework;
|
||||
using System.Linq;
|
||||
|
||||
namespace Xamarin.Forms.Core.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class TabIndexTests : BaseTestFixture
|
||||
{
|
||||
|
||||
[Test]
|
||||
public void GetTabIndexesOnParentPage_ImplicitZero()
|
||||
{
|
||||
var target = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 1 },
|
||||
new Label { TabIndex = 0 },
|
||||
new Label { TabIndex = 3 },
|
||||
new Label { TabIndex = 2 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = target };
|
||||
|
||||
var tabIndexes = target.GetTabIndexesOnParentPage(out int _);
|
||||
|
||||
//StackLayout is technically the first element with TabIndex 0.
|
||||
Assert.AreEqual(target, tabIndexes[0][0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTabIndexesOnParentPage_ExplicitZero()
|
||||
{
|
||||
Label target = new Label { TabIndex = 0 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 1 },
|
||||
target,
|
||||
new Label { TabIndex = 3 },
|
||||
new Label { TabIndex = 2 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int _);
|
||||
|
||||
Assert.AreEqual(target, tabIndexes[0][1]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTabIndexesOnParentPage_NegativeTabIndex()
|
||||
{
|
||||
Label target = new Label { TabIndex = -1 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 1 },
|
||||
target,
|
||||
new Label { TabIndex = 3 },
|
||||
new Label { TabIndex = 2 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int _);
|
||||
|
||||
Assert.AreEqual(target, tabIndexes[-1][0]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextElement_Forward_NextTabIndex()
|
||||
{
|
||||
Label target = new Label { TabIndex = 1 };
|
||||
Label nextElement = new Label { TabIndex = 2 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 1 },
|
||||
target,
|
||||
new Label { TabIndex = 3 },
|
||||
nextElement,
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int maxAttempts);
|
||||
|
||||
int _ = target.TabIndex;
|
||||
|
||||
var found = target.FindNextElement(true, tabIndexes, ref _);
|
||||
|
||||
Assert.AreEqual(nextElement, found);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextElement_Forward_DeclarationOrder()
|
||||
{
|
||||
Label target = new Label { TabIndex = 1 };
|
||||
Label nextElement = new Label { TabIndex = 2 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 1 },
|
||||
target,
|
||||
nextElement,
|
||||
new Label { TabIndex = 2 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int maxAttempts);
|
||||
|
||||
int _ = target.TabIndex;
|
||||
|
||||
var found = target.FindNextElement(true, tabIndexes, ref _);
|
||||
|
||||
Assert.AreEqual(nextElement, found);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextElement_Forward_TabIndex()
|
||||
{
|
||||
Label target = new Label { TabIndex = 1 };
|
||||
Label nextElement = new Label { TabIndex = 2 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 1 },
|
||||
target,
|
||||
nextElement,
|
||||
new Label { TabIndex = 2 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int maxAttempts);
|
||||
|
||||
int tabIndex = target.TabIndex;
|
||||
|
||||
var found = target.FindNextElement(true, tabIndexes, ref tabIndex);
|
||||
|
||||
Assert.AreEqual(2, tabIndex);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextElement_Backward_NextTabIndex()
|
||||
{
|
||||
Label target = new Label { TabIndex = 2 };
|
||||
Label nextElement = new Label { TabIndex = 1 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 3 },
|
||||
target,
|
||||
new Label { TabIndex = 3 },
|
||||
nextElement,
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int maxAttempts);
|
||||
|
||||
int _ = target.TabIndex;
|
||||
|
||||
var found = target.FindNextElement(false, tabIndexes, ref _);
|
||||
|
||||
Assert.AreEqual(nextElement, found);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextElement_Backward_DeclarationOrder()
|
||||
{
|
||||
Label target = new Label { TabIndex = 2 };
|
||||
Label nextElement = new Label { TabIndex = 1 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 3 },
|
||||
target,
|
||||
nextElement,
|
||||
new Label { TabIndex = 1 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int maxAttempts);
|
||||
|
||||
int _ = target.TabIndex;
|
||||
|
||||
var found = target.FindNextElement(false, tabIndexes, ref _);
|
||||
|
||||
Assert.AreEqual(nextElement, found);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindNextElement_Backward_TabIndex()
|
||||
{
|
||||
Label target = new Label { TabIndex = 2 };
|
||||
Label nextElement = new Label { TabIndex = 1 };
|
||||
var stackLayout = new StackLayout
|
||||
{
|
||||
Children = {
|
||||
new Label { TabIndex = 3 },
|
||||
target,
|
||||
nextElement,
|
||||
new Label { TabIndex = 2 },
|
||||
}
|
||||
};
|
||||
|
||||
var page = new ContentPage { Content = stackLayout };
|
||||
|
||||
var tabIndexes = stackLayout.GetTabIndexesOnParentPage(out int maxAttempts);
|
||||
|
||||
int tabIndex = target.TabIndex;
|
||||
|
||||
var found = target.FindNextElement(false, tabIndexes, ref tabIndex);
|
||||
|
||||
Assert.AreEqual(1, tabIndex);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,6 +86,7 @@
|
|||
<Compile Include="RegionTests.cs" />
|
||||
<Compile Include="ShellTests.cs" />
|
||||
<Compile Include="SpanTests.cs" />
|
||||
<Compile Include="TabIndexTests.cs" />
|
||||
<Compile Include="TitleViewUnitTests.cs" />
|
||||
<Compile Include="TemplatedViewUnitTests.cs" />
|
||||
<Compile Include="TemplatedPageUnitTests.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче