maui-linux/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issu.../Issue1898.cs

124 строки
4.3 KiB
C#
Исходник Обычный вид История

using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
using Xamarin.Forms.PlatformConfiguration;
using Xamarin.Forms.PlatformConfiguration.AndroidSpecific;
using AToolbarPlacement = Xamarin.Forms.PlatformConfiguration.AndroidSpecific.ToolbarPlacement;
using Xamarin.Forms.PlatformConfiguration.WindowsSpecific;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.Forms.Core.UITests;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1898, "TabbedPage Page not watching icon changes", PlatformAffected.Android, issueTestNumber: 1)]
public class Issue1898 : TestTabbedPage
{
protected override void Init() =>
Issue1898Setup.SetupTabbedPage(this, AToolbarPlacement.Top);
#if UITEST
[Test]
public void TabIconsAndTitlesChange() =>
Issue1898Setup.RunUITests(RunningApp);
#endif
}
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1898, "TabbedPage Page not watching icon changes", issueTestNumber: 2)]
public partial class Issue1898_2 : TestTabbedPage
{
protected override void Init() =>
Issue1898Setup.SetupTabbedPage(this, AToolbarPlacement.Bottom);
#if UITEST && __ANDROID__
[Test]
public void TabBottomIconsAndTitlesChange() =>
Issue1898Setup.RunUITests(RunningApp);
#endif
}
[Preserve(AllMembers = true)]
internal class Issue1898Setup
{
#if UITEST
internal static void RunUITests(IApp RunningApp)
{
RunningApp.WaitForElement(Title1);
RunningApp.Tap(ChangeTitle1);
RunningApp.Tap(ChangeIcon1);
RunningApp.Tap(ChangeIconPage2);
RunningApp.Tap(ChangeIcon1Null);
RunningApp.WaitForElement(ChangeTitle1);
RunningApp.Tap(Title2);
RunningApp.Tap(ChangeTitle2);
RunningApp.Tap(ChangeIcon2);
RunningApp.Tap(ChangeIconPage1);
RunningApp.Tap(ChangeIcon2Null);
RunningApp.WaitForElement(ChangeTitle2);
}
#endif
const string Title1 = "Title 1";
const string ChangeTitle1 = "Change Title 1";
const string ChangeIcon1 = "Change Icon 1";
const string ChangeIconPage2 = "Change Icon on Page 2";
const string ChangeIcon1Null = "Null Icon 1";
const string Title2 = "Title 2";
const string ChangeTitle2 = "Change Title 2";
const string ChangeIcon2 = "Change Icon 2";
const string ChangeIconPage1 = "Change Icon on Page 1";
const string ChangeIcon2Null = "Null Icon 2";
internal static void SetupTabbedPage(TabbedPage tabbedPage, AToolbarPlacement placement)
{
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
ContentPage Issue1898PageOne = new ContentPage() { Title = Title1, IconImageSource = "bank.png" };
ContentPage Issue1898PageTwo = new ContentPage() { Title = Title2, IconImageSource = "bank.png" };
Issue1898PageOne.Content =
new StackLayout
{
Margin = 20,
Children =
{
new Label(){ Text = "Click through each button on each tab to make sure they do what they say they do" },
new Button(){ Text = ChangeTitle1, Command = new Command(() => Issue1898PageOne.Title = ChangeTitle1) },
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
new Button(){ Text = ChangeIcon1, Command = new Command(() => Issue1898PageOne.IconImageSource = "coffee.png")},
new Button(){ Text = ChangeIconPage2, Command = new Command(() => Issue1898PageTwo.IconImageSource = "coffee.png")},
new Button(){ Text = ChangeIcon1Null, Command = new Command(() => Issue1898PageOne.IconImageSource = null)},
}
};
Issue1898PageTwo.Content =
new StackLayout
{
Margin = 20,
Children =
{
new Button(){ Text = ChangeTitle2, Command = new Command(() => Issue1898PageTwo.Title = ChangeTitle2) },
[WIP] Unify the image handling (#4915) * Initial code to get unifiied image handling - not yet tested - still using FileImageSource in some areas * Updated the button renderers and added tests for Android * Updated a few more of the Android renderers - also added an `IsEmpty` property to the ImageSource to indicate if this source actually contains data that can be used to try and load an image - added a few more "tests" - includes the changes for #4916 * A few more changes * Keep the default page for the sample app * Changing everything to ImageSource and going from there - Android, iOS, UWP and WPF are compiling - GTK, Mac and Tizen are not yet finished - Added a new interface for UWP to return an IconElement in addition to ImageSource (for app bar buttons) - not tested yet, nor are there any tests * Renamed the property to be more useful * All of Android is now async - still only minimal tests - also removed the bits that are in https://github.com/xamarin/Xamarin.Forms/pull/4948 * Update Xamarin.Forms.Platform.cs * A few fixes to whitespace and nameof() * Updated iOS and UWP wirth async image sources * A few fixes and WPF support * A few fixes for Android after the big merge * Updated a few more loaders: - ios - macos - tizen - gtk * Fix a few things after the merge * - cast type to FileImageSource * fix setting of title content if icon doesn't load * fix IButtonLayoutManager to return correct control * remove cast and add pack api * - fix timing issues with layout/invalidation * - remove aggresive element invalidations for now * first set of api changes * obsolete old apis and create new ones for ImageSource * obsolete messages and static ordering fix * add tests * switch default on windows to show images on tabs * - XStatic obsolete fix * fix NPC test and bring back alert check on uwp Fixes #3207 Fixes #4689
2019-04-26 23:46:13 +03:00
new Button(){ Text = ChangeIcon2, Command = new Command(() => Issue1898PageTwo.IconImageSource = "bank.png")},
new Button(){ Text = ChangeIconPage1, Command = new Command(() => Issue1898PageOne.IconImageSource = "calculator.png")},
new Button(){ Text = ChangeIcon2Null, Command = new Command(() => Issue1898PageTwo.IconImageSource = null)},
}
};
tabbedPage.Children.Add(Issue1898PageOne);
tabbedPage.Children.Add(Issue1898PageTwo);
#pragma warning disable CS0618 // Type or member is obsolete
tabbedPage.On<Android>().SetBarItemColor(Color.Blue);
tabbedPage.On<Android>().SetBarSelectedItemColor(Color.Green);
#pragma warning restore CS0618 // Type or member is obsolete
tabbedPage.On<Android>().SetToolbarPlacement(placement);
tabbedPage.On<Windows>().SetHeaderIconsEnabled(true);
}
}
}