Skip to content

Commit

Permalink
[UI Testing] Add legacy tests (alternative) (#22635)
Browse files Browse the repository at this point in the history
* Added Compatibility UITests (ported to Appium) to TestCases project

* Added tests pages

* More changes

* More changes

* More changes

* More changes

* More fixes

* More fixes

* More changes

* More changes

* More changes

* More changes

* More fixes

* Avoid problems with duplicated issues

* More changes

* More changes

* More fixes

* Fixes on Windows tests

* More fixes

* More fixes

* More changes

* Removed duplicated tests

* More fixes

* More changes

* More changes

* More changes

* More changes

* More changes

* Removed unnecessary changes

* More changes

* Ignore golden tests on macOS

* More changes

* More changes

* More changes

* Changes in AppiumLifecycleActions

* More changes

* Removed IgnoreIfPlatforms usage

* Small changes

* Fix build errors

* Fix build error

* Add missing category

* Update Issue24574.cs

* Ignore on Mac for now

---------

Co-authored-by: Shane Neuville <[email protected]>
Co-authored-by: Gerald Versluis <[email protected]>
  • Loading branch information
3 people authored Aug 6, 2024
1 parent 0dfc442 commit b0032c7
Show file tree
Hide file tree
Showing 497 changed files with 25,973 additions and 22 deletions.
21 changes: 21 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla23942.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<local:TestContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:test="clr-namespace:Maui.Controls.Sample.Issues"
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"
x:Class="Maui.Controls.Sample.Issues.Bugzilla23942">

<local:TestContentPage.Resources>
<ResourceDictionary>
<test:Bugzilla23942Options x:Key="opts"
Text="{Binding DoesItWork}" />
</ResourceDictionary>
</local:TestContentPage.Resources>

<local:TestContentPage.Content>
<StackLayout>
<test:Bugzilla23942Label x:Name="label" Options="{DynamicResource opts}" />
</StackLayout>
</local:TestContentPage.Content>

</local:TestContentPage>
97 changes: 97 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla23942.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.CustomAttributes;
using Microsoft.Maui.Controls.Internals;

namespace Maui.Controls.Sample.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 23942, "Cannot bind properties in BindableObjects added to static resources in XAML", PlatformAffected.All)]
public partial class Bugzilla23942 : TestContentPage
{
[Preserve(AllMembers = true)]
public class TestViewModel : ViewModelBase
{
string _doesItWork;
public string DoesItWork
{
get
{
return _doesItWork;
}
set
{
_doesItWork = value;
OnPropertyChanged();
}
}
}

public Bugzilla23942()
{
InitializeComponent();
}

private void InitializeView()
{
TestViewModel vm = new TestViewModel() { DoesItWork = "initial binding works" };
BindingContext = vm;
vm.DoesItWork = "success";
}

protected override void Init()
{
InitializeView();
}

protected override void OnAppearing()
{
base.OnAppearing();
var lbl = this.FindByName<Bugzilla23942Label>("label");
lbl.Text = lbl.Options.Text;
}
}

[Preserve(AllMembers = true)]
public class Bugzilla23942Options : BindableObject
{
public static readonly BindableProperty TextProperty =
BindableProperty.Create(propertyName: nameof(Text),
returnType: typeof(string),
declaringType: typeof(Bugzilla23942Options),
defaultValue: default(string));

public string Text
{
get
{
return (string)GetValue(TextProperty);
}
set
{
SetValue(TextProperty, value);
}
}
}

[Preserve(AllMembers = true)]
public class Bugzilla23942Label : Label
{
public static readonly BindableProperty OptionsProperty =
BindableProperty.Create(propertyName: nameof(Options),
returnType: typeof(Bugzilla23942Options),
declaringType: typeof(Bugzilla23942Label),
defaultValue: default(Bugzilla23942Options));

public Bugzilla23942Options Options
{
get
{
return (Bugzilla23942Options)GetValue(OptionsProperty);
}
set
{
SetValue(OptionsProperty, value);
}
}
}
}
82 changes: 82 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla25943.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 25943,
"[Android] TapGestureRecognizer does not work with a nested StackLayout", PlatformAffected.Android)]
public class Bugzilla25943 : TestContentPage
{
Label _result;
int _taps;
const string InnerLayout = "innerlayout";
const string OuterLayout = "outerlayout";
const string Success = "Success";

protected override void Init()
{
StackLayout layout = GetNestedStackLayout();

var tapGestureRecognizer = new TapGestureRecognizer();
tapGestureRecognizer.Tapped += (sender, e) =>
{
_taps = _taps + 1;
if (_taps == 2)
{
_result.Text = Success;
}
};
layout.GestureRecognizers.Add(tapGestureRecognizer);

Content = layout;
}

public StackLayout GetNestedStackLayout()
{
_result = new Label();

#pragma warning disable CS0618 // Type or member is obsolete
var innerLayout = new StackLayout
{
AutomationId = InnerLayout,
HeightRequest = 100,
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Fill,
BackgroundColor = Colors.AntiqueWhite,
Children =
{
new Label
{
Text = "inner label",
FontSize = 20,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
}
}
};
#pragma warning restore CS0618 // Type or member is obsolete

var outerLayout = new StackLayout
{
AutomationId = OuterLayout,
Orientation = StackOrientation.Vertical,
BackgroundColor = Colors.Brown,
Children =
{
_result,
innerLayout,
new Label
{
Text = "outer label",
FontSize = 20,
HorizontalOptions = LayoutOptions.Center,
}
}
};

return outerLayout;
}
}
}
22 changes: 22 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla29128.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 29128, "Slider background lays out wrong Android")]
public class Bugzilla29128 : TestContentPage
{
protected override void Init()
{
Content = new Slider
{
AutomationId = "SliderId",
BackgroundColor = Colors.Blue,
Maximum = 255,
Minimum = 0,
};
}
}
}
46 changes: 46 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla29363.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 29363, "PushModal followed immediate by PopModal crashes")]
public class Bugzilla29363 : NavigationPage
{
public Bugzilla29363() : base(new MainPage())
{
}

public class MainPage : ContentPage
{
public MainPage()
{
#pragma warning disable CS0618 // Type or member is obsolete
var layout = new StackLayout() { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand };
#pragma warning restore CS0618 // Type or member is obsolete

Button modal = new Button
{
AutomationId = "ModalPushPopTest",
Text = "Modal Push Pop Test",
FontAttributes = FontAttributes.Bold,
FontSize = 25,
HorizontalOptions = LayoutOptions.Center
};
modal.Clicked += async (object sender, EventArgs e) =>
{
var page = new ContentPage() { BackgroundColor = Colors.Red };
await Navigation.PushModalAsync(page);
await Navigation.PopModalAsync(true);
};

layout.Children.Add(modal);
Content = layout;
}
}
}
}
66 changes: 66 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla29453.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;

namespace Maui.Controls.Sample.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 29453, "Navigation.PopAsync(false) in Entry.Completed handler => System.ArgumentException", PlatformAffected.Android)]
public class Bugzilla29453 : NavigationPage
{
public Bugzilla29453() : base(new MainPage())
{
}

public class MainPage : ContentPage
{
public MainPage()
{
var page1Layout = new StackLayout
{
Children = {
new Label {
AutomationId = "Page1",
HorizontalTextAlignment = TextAlignment.Center,
Text = "Page 1"
}
}
};

var page2Layout = new StackLayout
{
Children = {
new Label {
HorizontalTextAlignment = TextAlignment.Center,
Text = "Page 2"
}
}
};

var entry = new Entry { AutomationId = "entryText" };

entry.Completed += async (sender, args) =>
{
await Navigation.PopAsync(false);
};

page2Layout.Children.Add(entry);

var page2 = new ContentPage
{
Content = page2Layout
};

var button = new Button
{
Text = "Go to page 2",
AutomationId = "btnGotoPage2",
Command = new Command(async () => await Navigation.PushAsync(page2))
};

page1Layout.Children.Add(button);
Content = page1Layout;
}
}
}
}
40 changes: 40 additions & 0 deletions src/Controls/tests/TestCases.HostApp/Issues/Bugzilla30166.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using Microsoft.Maui.Graphics;

namespace Maui.Controls.Sample.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 30166, "NavigationBar.BarBackgroundColor resets on Lollipop after popping modal page", PlatformAffected.Android)]
public class Bugzilla30166 : NavigationPage
{
public Bugzilla30166() : base(new MainPage())
{
BarBackgroundColor = Colors.Red;
}

public class MainPage : ContentPage
{
public MainPage()
{
Navigation.PushAsync(new ContentPage
{
Content = new Button
{
AutomationId = "PushModal",
Text = "Push Modal",
Command = new Command(async () => await Navigation.PushModalAsync(new ContentPage
{
Content = new Button
{
AutomationId = "Back",
Text = "Back",
Command = new Command(async () => await Navigation.PopModalAsync()),
},
})),
},
});
}
}
}
}
Loading

0 comments on commit b0032c7

Please sign in to comment.