Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Testing] Enabling ported UITests from Xamarin.UITests to Appium - 16 #26029

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,37 @@ namespace Maui.Controls.Sample.Issues;


[Issue(IssueTracker.Bugzilla, 38731, "iOS.NavigationRenderer.GetAppearedOrDisappearedTask NullReferenceExceptionObject", PlatformAffected.iOS)]
public class Bugzilla38731 : TestContentPage
public class Bugzilla38731 : TestNavigationPage
{
protected override void Init()
{
var label = new Label();
label.Text = "Page one...";
label.HorizontalTextAlignment = TextAlignment.Center;
Navigation.PushAsync(new PageOne());
}

var button = new Button();
button.AutomationId = "btn1";
button.Text = "Navigate to page two";
button.Clicked += Button_Clicked;
public class PageOne : ContentPage
{
public PageOne()
{
var label = new Label();
label.Text = "Page one...";
label.HorizontalTextAlignment = TextAlignment.Center;

var content = new StackLayout();
content.Children.Add(label);
content.Children.Add(button);
var button = new Button();
button.AutomationId = "btn1";
button.Text = "Navigate to page two";
button.Clicked += Button_Clicked;

Title = "Page one";
Content = content;
}
var content = new StackLayout();
content.Children.Add(label);
content.Children.Add(button);

void Button_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new PageTwo());
Title = "Page one";
Content = content;
}
void Button_Clicked(object sender, EventArgs e)
{
Navigation.PushAsync(new PageTwo());
}
}

public class PageTwo : ContentPage
Expand Down Expand Up @@ -88,6 +95,7 @@ public PageFour()
{
var label = new Label();
label.Text = "Last page... Tap back very quick";
label.AutomationId = "FinalPage";
label.HorizontalTextAlignment = TextAlignment.Center;

var content = new StackLayout();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,127 +6,122 @@ namespace Maui.Controls.Sample.Issues
[Issue(IssueTracker.Bugzilla, 40005, "Navigation Bar back button does not show when using InsertPageBefore")]
public class Bugzilla40005 : NavigationPage
{
public Bugzilla40005() : base(new MainPage())
public const string GoToPage2 = "Go to Page 2";
public const string PageOneLabel = "Page 1";
public const string PageTwoLabel = "Page 2";
public const string InsertedPageLabel = "Inserted page";
public const string TestInstructions = "Click " + GoToPage2 + " and you should still see a back bar button";

public Bugzilla40005() : base(new Page1())
{

}


public class MainPage : ContentPage
public class Page1 : ContentPage
{
public const string GoToPage2 = "Go to Page 2";
public const string PageOneLabel = "Page 1";
public const string PageTwoLabel = "Page 2";
public const string InsertedPageLabel = "Inserted page";
public const string TestInstructions = "Click " + GoToPage2 + " and you should still see a back bar button";

bool pageInserted;

public MainPage()
public Page1()
{
Application.Current.MainPage = new NavigationPage(new Page1());
}

public class Page1 : ContentPage
{
bool pageInserted;

public Page1()
var btn = new Button()
{
var btn = new Button()
{
AutomationId = GoToPage2,
Text = GoToPage2
};
btn.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new Page2());
};
AutomationId = GoToPage2,
Text = GoToPage2
};
btn.Clicked += async (sender, e) =>
{
await Navigation.PushAsync(new Page2());
};

Content = new StackLayout
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label
{
VerticalOptions = LayoutOptions.Center,
Children =
AutomationId = PageOneLabel,
HorizontalTextAlignment = TextAlignment.Center,
Text = PageOneLabel
},
btn,
new Label
{
new Label
{
AutomationId = PageOneLabel,
HorizontalTextAlignment = TextAlignment.Center,
Text = PageOneLabel
},
btn,
new Label
{
AutomationId = TestInstructions,
HorizontalTextAlignment = TextAlignment.Center,
Text = TestInstructions
}
AutomationId = TestInstructions,
HorizontalTextAlignment = TextAlignment.Center,
Text = TestInstructions
}
};
}
};
}

protected override void OnAppearing()
protected override void OnAppearing()
{
base.OnAppearing();
if (!pageInserted)
{
base.OnAppearing();
if (!pageInserted)
{
Navigation.InsertPageBefore(new InsertedPage(), this);
pageInserted = true;
}
Navigation.InsertPageBefore(new InsertedPage(), this);
pageInserted = true;
}
}

protected override bool OnBackButtonPressed()
{
Debug.WriteLine($"Hardware BackButton Pressed on {PageOneLabel}");
return base.OnBackButtonPressed();
}
protected override bool OnBackButtonPressed()
{
Debug.WriteLine($"Hardware BackButton Pressed on {PageOneLabel}");
return base.OnBackButtonPressed();
}
}

public class InsertedPage : ContentPage
public class InsertedPage : ContentPage
{
public InsertedPage()
{
public InsertedPage()
Content = new StackLayout
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label
{
new Label
{
HorizontalTextAlignment = TextAlignment.Center,
Text = InsertedPageLabel
}
HorizontalTextAlignment = TextAlignment.Center,
Text = InsertedPageLabel
}
};
}
};
}

protected override bool OnBackButtonPressed()
{
Debug.WriteLine($"Hardware BackButton Pressed on {InsertedPageLabel}");
return base.OnBackButtonPressed();
}
protected override bool OnBackButtonPressed()
{
Debug.WriteLine($"Hardware BackButton Pressed on {InsertedPageLabel}");
return base.OnBackButtonPressed();
}
}

public class Page2 : ContentPage
public class Page2 : ContentPage
{
public Page2()
{
public Page2()
Content = new StackLayout
{
Content = new StackLayout
{
VerticalOptions = LayoutOptions.Center,
Children =
VerticalOptions = LayoutOptions.Center,
Children =
{
new Label
{
new Label
{
AutomationId = PageTwoLabel,
HorizontalTextAlignment = TextAlignment.Center,
Text = PageTwoLabel
}
AutomationId = PageTwoLabel,
HorizontalTextAlignment = TextAlignment.Center,
Text = PageTwoLabel
}
};
}
};
}

protected override bool OnBackButtonPressed()
{
Debug.WriteLine($"Hardware BackButton Pressed on {PageTwoLabel}");
return base.OnBackButtonPressed();
}
protected override bool OnBackButtonPressed()
{
Debug.WriteLine($"Hardware BackButton Pressed on {PageTwoLabel}");
return base.OnBackButtonPressed();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Bugzilla40173 : TestContentPage

protected override void Init()
{
var outputLabel = new Label() { AutomationId = "outputlabel" };
var outputLabel = new Label() { Text="Default", AutomationId = "outputlabel" };
var testButton = new Button
{
Text = "Can't Touch This",
Expand Down Expand Up @@ -78,22 +78,34 @@ protected override void Init()
testListView.ItemsSource = items;
testListView.ItemTemplate = new DataTemplate(() =>
{

var grid = new Grid
{
HeightRequest = 60
};

var itemLabel = new Label
{
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Start
};
itemLabel.SetBinding(Label.TextProperty, ".");
var boxView = new BoxView
{
Color = Colors.Pink.MultiplyAlpha(0.5f)
};
boxView.SetBinding(BoxView.AutomationIdProperty, ".");

grid.Children.Add(itemLabel);
grid.Children.Add(boxView);

var result = new ViewCell
{
View = new Grid
{
Children =
{
new BoxView
{
AutomationId = ListTapTarget,
Color = Colors.Pink.MultiplyAlpha(0.5f)
}
}
}
View = grid
};

return result;

});

testListView.ItemSelected += (sender, args) => outputLabel.Text = ListTapSuccessText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public TestPage()
new Label { Text = "Hello Page" },
new Button { Text = "Change Title", AutomationId = "Change Title", Command = new Command(() =>
{
Title = $"New Title: {DateTime.Now.Second}";
AutomationId = Title;
Title = "New Title";
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public Bugzilla52419Page1()
new Button
{
Text = "Push new page",
AutomationId = "PushNewPage",
Command = new Command(() => Navigation.PushAsync(new Bugzilla52419Page1()))
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

using NUnit.Framework;
using UITest.Appium;
using UITest.Core;
Expand All @@ -15,16 +15,16 @@ public Bugzilla32040(TestDevice testDevice) : base(testDevice)

[Test]
[Category(UITestCategories.Cells)]
[FailsOnIOSWhenRunningOnXamarinUITest]
[FailsOnWindowsWhenRunningOnXamarinUITest]
public void TappedWorksForEntryAndSwithCellTest()
{
{
App.WaitForElement("blahblah");
App.Tap("blahblah");
App.Tap("yaddayadda");
App.Tap("blahblah");
App.WaitForElement("Tapped");

App.Tap("Click Here");

Assert.That(App.FindElements("Tapped").Count,
Is.GreaterThanOrEqualTo(2));
//FindElements consistently returns a zero count, despite the "Tapped" text being visible in the UI.
//Assert.That(App.FindElements("Tapped").Count, Is.GreaterThanOrEqualTo(2));
App.WaitForTextToBePresentInElement("yaddayadda", "Tapped");
}
}
*/
Loading
Loading