Skip to content

Commit 436df6a

Browse files
LogishaSelvarajSF4525PureWeen
authored andcommitted
[Testing] Enabling more UI Tests by removing platform specific condition - 15 (#27965)
* enable the test case for all platforms * enable ScrollViewObjectDisposed.cs * updated the changes * modified * added the snapshot * added snapshot * modified changes * Update Issue17453.cs * modified Issue17453.cs
1 parent 326ce8a commit 436df6a

File tree

14 files changed

+74
-65
lines changed

14 files changed

+74
-65
lines changed
25.4 KB
Loading
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
namespace Maui.Controls.Sample.Issues
22
{
33
[Issue(IssueTracker.Github, 6458, "[Android] Fix load TitleIcon on non app compact", PlatformAffected.Android)]
4-
public class Issue6458 : TestContentPage // or TestFlyoutPage, etc ...
4+
public class Issue6458 : TestNavigationPage // or TestFlyoutPage, etc ...
55
{
66
protected override void Init()
77
{
8-
NavigationPage.SetTitleIconImageSource(this,
8+
var contentPage = new ContentPage
9+
{
10+
Content = new Label
11+
{
12+
AutomationId = "IssuePageLabel",
13+
Text = "Make sure you run this on Non AppCompact Activity"
14+
}
15+
};
16+
17+
NavigationPage.SetTitleIconImageSource(contentPage,
918
new FileImageSource
1019
{
1120
File = "bank.png",
1221
AutomationId = "banktitleicon"
1322
});
14-
Content = new Label
15-
{
16-
AutomationId = "IssuePageLabel",
17-
Text = "Make sure you run this on Non AppCompact Activity"
18-
};
23+
24+
this.PushAsync(contentPage);
1925
}
2026
}
2127
}

src/Controls/tests/TestCases.HostApp/Issues/ScrollViewObjectDisposed.cs

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,42 @@ public class ScrollViewObjectDisposed : ContentPage
77
const string Instructions = "Tap the button. If the app does not crash and the red label displays \"Success\", this test has passed.";
88
const string Success = "Success";
99
const string TestButtonId = "TestButtonId";
10-
11-
readonly Label _status = new Label() { Text = "Test is running...", BackgroundColor = Colors.Red, TextColor = Colors.White };
12-
readonly ScrollView _scroll = new ScrollView();
10+
Label _status;
11+
ScrollView _scroll;
1312

1413
public ScrollViewObjectDisposed()
1514
{
16-
_scroll.Content = _status;
17-
1815
InitTest();
1916
}
2017

2118
void InitTest()
2219
{
23-
Button nextButton = new Button { Text = "Next", AutomationId = TestButtonId };
24-
nextButton.Clicked += NextButton_Clicked;
20+
_status = new Label() { Text = "Test is running...", BackgroundColor = Colors.Red, TextColor = Colors.White };
2521

26-
StackLayout stack = new StackLayout
22+
_scroll = new ScrollView
2723
{
28-
Children = { new Label { Text = Instructions }, _scroll, nextButton }
24+
Content = _status
2925
};
3026

31-
Content = stack;
27+
Button nextButton = new Button { Text = "Next", AutomationId = TestButtonId };
28+
nextButton.Clicked += NextButton_Clicked;
29+
var stack = new StackLayout
30+
{
31+
Children =
32+
{
33+
new Label { Text = Instructions },
34+
_scroll,
35+
nextButton
36+
}
37+
};
38+
this.Content = stack;
3239
}
33-
3440
void NextButton_Clicked(object sender, EventArgs e)
3541
{
3642
_status.Text = string.Empty;
37-
3843
InitTest();
39-
4044
_status.Text = Success;
4145
}
4246
}
43-
}
47+
}
48+
11.5 KB
Loading

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue16561.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Drawing;
1+
#if TEST_FAILS_ON_CATALYST //related issue: https://github.com/dotnet/maui/issues/17435
2+
using System.Drawing;
23
using NUnit.Framework;
34
using NUnit.Framework.Legacy;
45
using OpenQA.Selenium.Appium.Interactions;
@@ -86,3 +87,4 @@ static void AssertCorrectTapLocation(string tapData, float expectedX, float expe
8687
}
8788
}
8889
}
90+
#endif
Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if ANDROID
2-
using NUnit.Framework;
1+
using NUnit.Framework;
32
using NUnit.Framework.Legacy;
43
using UITest.Appium;
54
using UITest.Core;
@@ -11,6 +10,7 @@ class Issue17453 : _IssuesUITest
1110
public Issue17453(TestDevice device) : base(device) { }
1211

1312
public override string Issue => "Clear Entry text tapping the clear button not working";
13+
protected override bool ResetAfterEachTest => true;
1414

1515
[Test]
1616
[Category(UITestCategories.Entry)]
@@ -19,12 +19,12 @@ public void EntryClearButtonWorksEntryDoesntClearWhenNotClickingOnClear()
1919
// https://github.com/dotnet/maui/issues/17453
2020

2121
App.WaitForElement("WaitForStubControl");
22-
string? rtlEntryText = App.FindElement("RtlEntry").GetText();
22+
string? rtlEntryText = App.WaitForElement("RtlEntry").GetText();
2323

2424
if (String.IsNullOrWhiteSpace(rtlEntryText))
2525
App.EnterText("RtlEntry", "Simple Text");
2626

27-
var rtlEntryRect = App.FindElement("RtlEntry").GetRect();
27+
var rtlEntryRect = App.WaitForElement("RtlEntry").GetRect();
2828
App.EnterText("RtlEntry", "Simple Text");
2929

3030
// Set focus
@@ -33,7 +33,7 @@ public void EntryClearButtonWorksEntryDoesntClearWhenNotClickingOnClear()
3333
// Tap on the entry but not on the clear button
3434
App.TapCoordinates(rtlEntryRect.CenterX(), rtlEntryRect.CenterY());
3535

36-
rtlEntryText = App.FindElement("RtlEntry").GetText();
36+
rtlEntryText = App.WaitForElement("RtlEntry").GetText();
3737

3838
ClassicAssert.IsNotEmpty(rtlEntryText);
3939
}
@@ -46,50 +46,57 @@ public void EntryClearButtonWorks()
4646

4747
App.WaitForElement("WaitForStubControl");
4848

49-
string? rtlEntryText = App.FindElement("RtlEntry").GetText();
49+
string? rtlEntryText = App.WaitForElement("RtlEntry").GetText();
5050

5151
if (String.IsNullOrWhiteSpace(rtlEntryText))
5252
App.EnterText("RtlEntry", "Simple Text");
5353

54-
var rtlEntryRect = App.FindElement("RtlEntry").GetRect();
54+
var rtlEntryRect = App.WaitForElement("RtlEntry").GetRect();
5555

5656
// Set focus
57-
App.TapCoordinates(rtlEntryRect.X, rtlEntryRect.Y);
57+
App.TapCoordinates(rtlEntryRect.CenterX(), rtlEntryRect.CenterY());
5858

59+
App.WaitForElement("RtlEntry");
5960
// Tap Clear Button
60-
var margin = 30;
61-
App.TapCoordinates(rtlEntryRect.X + margin, rtlEntryRect.Y + margin);
61+
var margin = 10;
62+
App.TapCoordinates(rtlEntryRect.X + margin, rtlEntryRect.CenterY());
6263

63-
rtlEntryText = App.FindElement("RtlEntry").GetText();
64+
rtlEntryText = App.WaitForElement("RtlEntry").GetText();
6465

6566
ClassicAssert.IsEmpty(rtlEntryText);
6667
}
6768

6869
[Test]
6970
[Category(UITestCategories.Entry)]
70-
public async Task EntryWithMarginClearButtonWorks()
71+
public void EntryWithMarginClearButtonWorks()
7172
{
7273
// https://github.com/dotnet/maui/issues/25225
7374

7475
App.WaitForElement("WaitForStubControl");
7576

76-
string? entryText = App.FindElement("EntryWithMargin").GetText();
77+
string? entryText = App.WaitForElement("EntryWithMargin").GetText();
7778
if (String.IsNullOrWhiteSpace(entryText))
7879
App.EnterText("EntryWithMargin", "Simple Text");
7980

80-
var entryRect = App.FindElement("EntryWithMargin").GetRect();
81+
var entryRect = App.WaitForElement("EntryWithMargin").GetRect();
8182

8283
// Set focus
83-
App.TapCoordinates(entryRect.Width, entryRect.Y);
84-
await Task.Delay(500);
84+
App.TapCoordinates(entryRect.CenterX(), entryRect.CenterY());
85+
86+
App.WaitForElement("EntryWithMargin");
8587

88+
#if ANDROID
89+
if (App.IsKeyboardShown())
90+
{
91+
App.DismissKeyboard();
92+
}
93+
#endif
8694
// Tap Clear Button
87-
App.TapCoordinates(entryRect.Width, entryRect.Y);
95+
App.TapCoordinates(entryRect.X + entryRect.Width - 17, entryRect.CenterY());
8896

89-
entryText = App.FindElement("EntryWithMargin").GetText();
97+
entryText = App.WaitForElement("EntryWithMargin").GetText();
9098

9199
ClassicAssert.IsEmpty(entryText);
92100
}
93101
}
94-
}
95-
#endif
102+
}

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19214.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#if IOS
1+
#if IOS || (ANDROID && TEST_FAILS_ON_ANDROID)//android related issue: https://github.com/dotnet/maui/issues/27951
2+
//The test is applicable only to mobile platforms like iOS and Android.
23
using System.Drawing;
34
using NUnit.Framework;
45
using NUnit.Framework.Legacy;

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19214_2.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if IOS
1+
#if IOS //This sample is specific to the iOS platform and handles text input behavior by accessing the native UITextView.
22
using System.Drawing;
33
using NUnit.Framework;
44
using NUnit.Framework.Legacy;

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19214_3.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if IOS
1+
#if IOS //This sample is specific to the iOS platform and handles text input behavior by accessing the native UITextView.
22
using System.Drawing;
33
using NUnit.Framework;
44
using NUnit.Framework.Legacy;

src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19956.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#if IOS
1+
#if IOS || (ANDROID && TEST_FAILS_ON_ANDROID)//android related issue: https://github.com/dotnet/maui/issues/27951
2+
//The test is applicable only to mobile platforms like iOS and Android.
23
using System.Drawing;
34
using NUnit.Framework;
45
using UITest.Appium;
@@ -103,4 +104,4 @@ void CheckForBottomEntry (AppiumApp app)
103104
ClassicAssert.Less(bottomEntryRect.Bottom, keyboardPosition!.Value.Y);
104105
}
105106
}
106-
#endif
107+
#endif

0 commit comments

Comments
 (0)