зеркало из https://github.com/DeGsoft/maui-linux.git
Merge branch '4.0.0'
This commit is contained in:
Коммит
383fc0d6b7
|
@ -60,6 +60,26 @@ namespace Xamarin.Forms.Core.UnitTests
|
|||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task GlobalNavigateTwice()
|
||||
{
|
||||
|
||||
var shell = new Shell();
|
||||
var item1 = CreateShellItem(asImplicit: true, shellContentRoute: "rootlevelcontent1");
|
||||
|
||||
shell.Items.Add(item1);
|
||||
Routing.RegisterRoute("cat", typeof(ContentPage));
|
||||
Routing.RegisterRoute("details", typeof(ContentPage));
|
||||
|
||||
await shell.GoToAsync("cat");
|
||||
await shell.GoToAsync("details");
|
||||
|
||||
Assert.AreEqual("app:///rootlevelcontent1/cat/details", shell.CurrentState.Location.ToString());
|
||||
await shell.GoToAsync("//rootlevelcontent1/details");
|
||||
Assert.AreEqual("app:///rootlevelcontent1/details", shell.CurrentState.Location.ToString());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public async Task GlobalRegisterAbsoluteMatching()
|
||||
{
|
||||
|
|
|
@ -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" />
|
||||
|
|
|
@ -420,7 +420,7 @@ namespace Xamarin.Forms
|
|||
}
|
||||
else
|
||||
{
|
||||
await CurrentItem.CurrentItem.GoToAsync(navigationRequest.Request.GlobalRoutes, queryData, animate);
|
||||
await CurrentItem.CurrentItem.GoToAsync(navigationRequest, queryData, animate);
|
||||
}
|
||||
|
||||
//if (Routing.CompareWithRegisteredRoutes(shellItemRoute))
|
||||
|
|
|
@ -75,13 +75,12 @@ namespace Xamarin.Forms
|
|||
if (shellContent == null)
|
||||
return Task.FromResult(true);
|
||||
|
||||
|
||||
if(request.Request.GlobalRoutes.Count > 0)
|
||||
if (request.Request.GlobalRoutes.Count > 0)
|
||||
{
|
||||
// TODO get rid of this hack and fix so if there's a stack the current page doesn't display
|
||||
Device.BeginInvokeOnMainThread(async () =>
|
||||
{
|
||||
await GoToAsync(request.Request.GlobalRoutes, queryData, false);
|
||||
await GoToAsync(request, queryData, false);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -226,8 +225,9 @@ namespace Xamarin.Forms
|
|||
return (ShellSection)(ShellContent)page;
|
||||
}
|
||||
|
||||
public virtual async Task GoToAsync(List<string> routes, IDictionary<string, string> queryData, bool animate)
|
||||
internal async Task GoToAsync(NavigationRequest request, IDictionary<string, string> queryData, bool animate)
|
||||
{
|
||||
List<string> routes = request.Request.GlobalRoutes;
|
||||
if (routes == null || routes.Count == 0)
|
||||
{
|
||||
await Navigation.PopToRootAsync(animate);
|
||||
|
@ -248,9 +248,12 @@ namespace Xamarin.Forms
|
|||
continue;
|
||||
}
|
||||
|
||||
while (_navStack.Count > i + 1)
|
||||
if (request.StackRequest == NavigationRequest.WhatToDoWithTheStack.ReplaceIt)
|
||||
{
|
||||
await OnPopAsync(false);
|
||||
while (_navStack.Count > i + 1)
|
||||
{
|
||||
await OnPopAsync(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче