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

[UI Testing] Add legacy tests #21840

Closed
wants to merge 53 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
8e73179
Just added a couple of tests
jsuarezruiz Mar 25, 2024
f035bad
Focus on Android and iOS (for now)
jsuarezruiz Mar 25, 2024
60ff9e8
Added legacy tests to the pipeline
jsuarezruiz Mar 25, 2024
2263ab0
Merge branch 'main' into fix-21410
jsuarezruiz Mar 26, 2024
d92b07b
Merge branch 'main' into fix-21410
jsuarezruiz Apr 3, 2024
7fd44be
Merge branch 'main' into fix-21410
jsuarezruiz Apr 8, 2024
6ea9c69
Merge branch 'main' into fix-21410
jsuarezruiz Apr 8, 2024
db7768f
More changes
jsuarezruiz Apr 8, 2024
ce091b5
More changes
jsuarezruiz Apr 9, 2024
bec656f
Fixed build
jsuarezruiz Apr 10, 2024
715a611
Created ui-tests-legacy-steps.yml
jsuarezruiz Apr 10, 2024
656a11c
More changes
jsuarezruiz Apr 10, 2024
d749eea
More changes
jsuarezruiz Apr 10, 2024
3a9edda
Merge branch 'main' into fix-21410
jsuarezruiz Apr 10, 2024
668332b
Updated Appium to RC7
jsuarezruiz Apr 10, 2024
781621c
Update ui-tests.yml
jfversluis Apr 10, 2024
5b5c7e9
Fixed test on Android
jsuarezruiz Apr 11, 2024
a4b5f6d
Fixed test
jsuarezruiz Apr 11, 2024
c7a5fb5
More changes
jsuarezruiz Apr 11, 2024
0ebe135
More changes
jsuarezruiz Apr 11, 2024
fa49de7
Updated snapshot
jsuarezruiz Apr 11, 2024
b8c6711
More fixes
jsuarezruiz Apr 11, 2024
381ae62
Clean code
jsuarezruiz Apr 11, 2024
e63d0a0
Run test only on iOS
jsuarezruiz Apr 11, 2024
ffb72b7
Added pending constant
jsuarezruiz Apr 11, 2024
4967b79
Fix build error
jfversluis Apr 11, 2024
b5e9b40
More changes
jsuarezruiz Apr 11, 2024
ff2fa4f
Update ControlGallery.iOS.Appium.UITests.csproj
jfversluis Apr 12, 2024
831979c
Added the tests
jsuarezruiz Apr 12, 2024
497928f
Pending fixes
jsuarezruiz Apr 12, 2024
e6d6a82
More changes
jsuarezruiz Apr 15, 2024
fed8268
More fixes
jsuarezruiz Apr 15, 2024
7bc5678
Avoid duplicated issue description
jsuarezruiz Apr 15, 2024
f79f55e
More fixes
jsuarezruiz Apr 15, 2024
2ad4b28
More fixes
jsuarezruiz Apr 15, 2024
20d9cf6
More fixes
jsuarezruiz Apr 15, 2024
4f4142c
Set tests page as MainPage
jsuarezruiz Apr 15, 2024
7df39aa
More fixes
jsuarezruiz Apr 16, 2024
c49ad11
More fixes
jsuarezruiz Apr 16, 2024
ca28e71
More fixes
jsuarezruiz Apr 16, 2024
da725a4
Merge branch 'main' into add-more-legacy-tests
jsuarezruiz Apr 16, 2024
9491bf8
Fix merge issue
jsuarezruiz Apr 16, 2024
2ca2294
More changes
jsuarezruiz Apr 16, 2024
ff2b9bd
More changes
jsuarezruiz Apr 18, 2024
4b55620
More changes
jsuarezruiz Apr 18, 2024
e0649a4
More fixes
jsuarezruiz Apr 18, 2024
fba2bb1
More fixes
jsuarezruiz Apr 18, 2024
e08dded
More fixes
jsuarezruiz Apr 19, 2024
75638ca
More changes
jsuarezruiz Apr 19, 2024
35343f5
More changes
jsuarezruiz Apr 19, 2024
2bf236f
Merge branch 'main' into add-more-legacy-tests
jsuarezruiz Apr 23, 2024
f78ccb1
Merge branch 'main' into add-more-legacy-tests
jsuarezruiz May 17, 2024
35649fe
Fixed the build
jsuarezruiz May 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Microsoft.Maui.Controls.ControlGallery.Android

[Activity(Label = "Microsoft Maui Controls Compatibility Gallery", Icon = "@drawable/icon", Theme = "@style/MyTheme",
MainLauncher = true, HardwareAccelerated = true,
LaunchMode = LaunchMode.SingleTask,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.UiMode)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[]
Expand Down
43 changes: 38 additions & 5 deletions src/Compatibility/ControlGallery/src/Core/CoreGallery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,24 @@ public CoreRootPage(Page rootPage, NavigationBehavior navigationBehavior = Navig

var corePageView = new CorePageView(rootPage, navigationBehavior);

var resetCheckBox = new CheckBox
{
AutomationId = "ResetMainPage",
VerticalOptions = LayoutOptions.Center,
};
var resetLabel = new Label
{
Text = "Reset MainPage",
VerticalOptions = LayoutOptions.Center,
};
var resetLayout = new HorizontalStackLayout
{
resetCheckBox,
resetLabel
};
resetLayout.HorizontalOptions = LayoutOptions.End;
resetLayout.Margin = new Microsoft.Maui.Thickness(12);

var searchBar = new SearchBar()
{
AutomationId = "SearchBar"
Expand All @@ -566,28 +584,43 @@ public CoreRootPage(Page rootPage, NavigationBehavior navigationBehavior = Navig
AutomationId = "GoToTestButton",
Command = new Command(async () =>
{
bool resetMainPage = resetCheckBox.IsChecked;

if (!string.IsNullOrEmpty(searchBar.Text))
{
if (!(await corePageView.PushPage(searchBar.Text)))
{
foreach (CoreViewContainer item in CoreRootView.ItemsSource)
var testCaseScreen = new TestCases.TestCaseScreen(resetMainPage);
await Task.Delay(50); // Load all the issues before try to navigate.

if (TestCases.TestCaseScreen.PageToAction.ContainsKey(searchBar.Text?.Trim()))
{
TestCases.TestCaseScreen.PageToAction[searchBar.Text?.Trim()]();
}
else
{
if (item.Name == searchBar.Text)
foreach (CoreViewContainer item in CoreRootView.ItemsSource)
{
CoreRootView.SelectedItem = item;
break;
if (item.Name == searchBar.Text)
{
CoreRootView.SelectedItem = item;
break;
}
}
}
}
}
else
await Navigation.PushModalAsync(TestCases.GetTestCases());
{
await Navigation.PushModalAsync(TestCases.GetTestCases(resetMainPage));
}
})
};

var stackLayout = new StackLayout()
{
Children = {
resetLayout,
testCasesButton,
searchBar,
new Button {
Expand Down
103 changes: 59 additions & 44 deletions src/Compatibility/ControlGallery/src/Core/TestCases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,64 +29,75 @@ static TextCell MakeIssueCell(string text, string detail, Action tapped)
return cell;
}

Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type)
Action ActivatePageAndNavigate(IssueAttribute issueAttribute, Type type, bool reset = false)
{
Action navigationAction = null;

if (issueAttribute.NavigationBehavior == NavigationBehavior.PushAsync)
if (reset)
{
return async () =>
return () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushAsync(page);
Application.Current.MainPage = page;
Comment on lines 37 to +40
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Main changes to avoid navigation and set the Issue page as MainPage directly.

};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.PushModalAsync)
else
{
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushModalAsync(page);
};
}
Action navigationAction = null;

if (issueAttribute.NavigationBehavior == NavigationBehavior.Default)
{
return async () =>
if (issueAttribute.NavigationBehavior == NavigationBehavior.PushAsync)
{
var page = ActivatePage(type);
TrackOnInsights(page);
if (page is ContentPage || page is CarouselPage)
return async () =>
{

var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushAsync(page);
};
}

}
else if (page is Shell)
{
Application.Current.MainPage = page;
}
else
if (issueAttribute.NavigationBehavior == NavigationBehavior.PushModalAsync)
{
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
await Navigation.PushModalAsync(page);
}
};
}
};
}

if (issueAttribute.NavigationBehavior == NavigationBehavior.SetApplicationRoot)
{
return () =>
if (issueAttribute.NavigationBehavior == NavigationBehavior.Default)
{
var page = ActivatePage(type);
TrackOnInsights(page);
Application.Current.MainPage = page;
};
}
return async () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);

if (page is ContentPage || page is CarouselPage)
{
await Navigation.PushAsync(page);
}
else if (page is Shell)
{
Application.Current.MainPage = page;
}
else
{
await Navigation.PushModalAsync(page);
}
};
}

return navigationAction;
if (issueAttribute.NavigationBehavior == NavigationBehavior.SetApplicationRoot)
{
return () =>
{
var page = ActivatePage(type);
TrackOnInsights(page);
Application.Current.MainPage = page;
};
}

return navigationAction;
}
}

static void TrackOnInsights(Page page)
Expand Down Expand Up @@ -159,8 +170,10 @@ void VerifyNoDuplicates()
});
}

public TestCaseScreen()
public TestCaseScreen(bool resetMainPage = false)
{
ResetMainPage = resetMainPage;

AutomationId = "TestCasesIssueList";

Intent = TableIntent.Settings;
Expand All @@ -178,13 +191,15 @@ public TestCaseScreen()
IssueTestNumber = attribute.IssueTestNumber,
Name = attribute.DisplayName,
Description = attribute.Description,
Action = ActivatePageAndNavigate(attribute, type)
Action = ActivatePageAndNavigate(attribute, type, ResetMainPage)
}).ToList();

VerifyNoDuplicates();

FilterIssues();
}

internal bool ResetMainPage { get; set; }

public void FilterTracker(IssueTracker tracker)
{
Expand Down Expand Up @@ -293,7 +308,7 @@ from issueModel in _issues
bool IsExempt(string name) => _exemptNames.Contains(name);
}

public static NavigationPage GetTestCases()
public static NavigationPage GetTestCases(bool resetMainPage = false)
{
TestCaseScreen testCaseScreen = null;
var rootLayout = new StackLayout();
Expand Down Expand Up @@ -347,7 +362,7 @@ public static NavigationPage GetTestCases()
rootLayout.Children.Add(searchBar);
rootLayout.Children.Add(searchButton);

testCaseScreen = new TestCaseScreen();
testCaseScreen = new TestCaseScreen(resetMainPage);

rootLayout.Children.Add(CreateTrackerFilter(testCaseScreen));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected override void Init()
var listview = new ListView();
listview.ItemTemplate = new DataTemplate(typeof(ItemTemplate));
listview.ItemsSource = new string[] { "item1", "item2", "item3", "item4", "item5", null, null };
var btnBack = new Button { Text = "back", Command = new Command(() => Navigation.PopAsync()) };
var btnBack = new Button { AutomationId = "back", Text = "back", Command = new Command(() => Navigation.PopAsync()) };
listview.ItemSelected += (s, e) => Navigation.PushAsync(new ContentPage { Content = btnBack });
var btnPush = new Button
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Page2(string title)
Children =
{
new Label { Text = $"This is page {count}." },
new Button { Text = "Click", Command = new Command(() => Navigation.PushAsync(new Page2(title))) }
new Button { AutomationId = "Click", Text = "Click", Command = new Command(() => Navigation.PushAsync(new Page2(title))) }
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ protected override void Init()
};

Button makeBig = new Button();
makeBig.AutomationId = "Tap";
makeBig.Text = "Tap";
//
// Clicking button first time does not scroll event though scrollView.Height is already set.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ protected override void Init()

Button modal = new Button
{
AutomationId = "ModalPushPopTest",
Text = "Modal Push Pop Test",
FontAttributes = FontAttributes.Bold,
FontSize = 25,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ protected override void Init()
{
Children = {
new Label {
AutomationId ="Page1",
HorizontalTextAlignment = TextAlignment.Center,
Text = "Page 1"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ protected override void Init()
{
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()),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ protected override void Init()
var page1 = new ContentPage() { Title = "Page1" };

var successLabel = new Label();
var startPopOnAppearing = new Button() { Text = "Start PopOnAppearing Test" };
var startModalStack = new Button() { Text = "Start ModalStack Test" };
var startPopOnAppearing = new Button() { AutomationId = "StartPopOnAppearingTest", Text = "Start PopOnAppearing Test" };
var startModalStack = new Button() { AutomationId = "StartModalStackTest", Text = "Start ModalStack Test" };

page1.Content = new StackLayout()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ protected override void Init()
VerticalOptions = LayoutOptions.Center,
Children = {
new Button {
AutomationId ="SwitchMainPage",
Text = "Switch Main Page",
Command = new Command (() => SwitchMainPage ())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Page3 : ContentPage
{
private Page3()
{
Content = new Label { Text = "Page 3" };
Content = new Label { AutomationId = "Page3", Text = "Page 3" };
}

public static async Task<Page3> CreateAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ protected override void Init()

var button0 = new Button
{
AutomationId = "Button0",
Text = "Button 0",
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.Fill
};

var button1 = new Button
{
AutomationId = "Button1",
Text = "Button 1",
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.Fill
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class Bugzilla35472 : TestNavigationPage
protected override void Init()
{
// Set up the scroll viewer page
var scrollToButton = new Button() { Text = "Now push this button" };
var scrollToButton = new Button() { AutomationId = "NowPushButton", Text = "Now push this button" };

var stackLayout = new StackLayout();

Expand All @@ -46,6 +46,7 @@ protected override void Init()
// Set up the start page
var goButton = new Button()
{
AutomationId = "PushButton",
Text = "Push this button"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ protected override void Init()
Text = "Tap the frame below. The label with the text 'No taps yet' should change its text to 'Frame was tapped'."
};
var frame = new Frame() { };
var frameLabel = new Label() { Text = "Tap here" };
var frameLabel = new Label() { AutomationId = "TapHere", Text = "Tap here" };

frame.Content = new StackLayout() { Children = { frameLabel } };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ protected override void Init()
};

var button = new Button
{
{
AutomationId = "SELECT",
Text = "SELECT"
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public Bz39489Content()
Interlocked.Increment(ref s_count);
Debug.WriteLine($">>>>> Bz39489Content Bz39489Content 54: Constructor, count is {s_count}");

var button = new Button { Text = "New Page" };
var button = new Button { AutomationId = "NewPage", Text = "New Page" };

var gcbutton = new Button { Text = "GC" };
var gcbutton = new Button { AutomationId = "GC", Text = "GC" };

var map = new Bz39489Map();

Expand Down
Loading
Loading