-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Testing] Split off HandlerDoesNotLeak.DatePicker into its own UI test (
#24585) * Split off DatePicker.HandlerDoesNotLeak into its own UI test. * Changed RunMemoryTest to take in INavigation instead of NavigationPage, renamed Issue24147 to MemoryTests and changed it to take in Text from Entry to determine which Handler to use, Removed Issue22072 as that's now in MemoryTests * Renamed Issue24147 in Tests.Shared to MemoryTests, added methods to check DatePicker and WebView. Added automationids in HostApp MemoryTests
- Loading branch information
1 parent
760cbb2
commit 9d965cc
Showing
6 changed files
with
108 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
69 changes: 69 additions & 0 deletions
69
src/Controls/tests/TestCases.HostApp/Issues/MemoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[Issue(IssueTracker.None, 24147, "Test Handlers for Memory Leaks", PlatformAffected.All)] | ||
public class MemoryTests : NavigationPage | ||
{ | ||
public class MemoryTestPage : ContentPage | ||
{ | ||
Entry entryText; | ||
public MemoryTestPage() | ||
{ | ||
entryText = new Entry | ||
{ | ||
AutomationId = "DataTypeEntry", | ||
Placeholder = "Enter the data type of the Handler you want to test", | ||
}; | ||
|
||
var runMemoryTestButton = new Button | ||
{ | ||
AutomationId = "RunMemoryTestButton", | ||
Text = "Run Memory Test" | ||
}; | ||
runMemoryTestButton.Clicked += OnRunMemoryTestClicked; | ||
|
||
var stackLayout = new StackLayout | ||
{ | ||
Padding = 10, | ||
Children = { entryText, runMemoryTestButton } | ||
}; | ||
|
||
Content = stackLayout; | ||
} | ||
|
||
private void OnRunMemoryTestClicked(object sender, EventArgs e) | ||
{ | ||
string dataType = entryText.Text; | ||
RunMemoryTest(dataType); | ||
} | ||
|
||
private void RunMemoryTest(String dataType) | ||
{ | ||
switch(dataType) { | ||
case "DatePicker": | ||
this.Navigation.RunMemoryTest(() => | ||
{ | ||
return new DatePicker | ||
{ | ||
AutomationId = "DatePicker", | ||
Date = new DateTime(2021, 1, 1) | ||
}; | ||
}); | ||
break; | ||
case "WebView": // 22972: Win platform WebView cannot be release after its parent window get closed | ||
this.Navigation.RunMemoryTest(() => | ||
{ | ||
return new WebView | ||
{ | ||
HeightRequest = 500, // NOTE: non-zero size required for Windows | ||
Source = new HtmlWebViewSource { Html = "<p>hi</p>" }, | ||
}; | ||
}); | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
} | ||
public MemoryTests(): base(new MemoryTestPage()) {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22972.cs
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/MemoryTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
public class MemoryTests : _IssuesUITest | ||
{ | ||
public MemoryTests(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
protected override bool ResetAfterEachTest => true; | ||
public override string Issue => "Test Handlers for Memory Leaks"; | ||
|
||
[Test] | ||
[Category(UITestCategories.DatePicker)] | ||
public void DatePickerDoesNotLeak() | ||
{ | ||
App.WaitForElement("DataTypeEntry"); | ||
App.EnterText("DataTypeEntry", "DatePicker"); | ||
App.Tap("RunMemoryTestButton"); | ||
App.AssertMemoryTest(); | ||
} | ||
|
||
[Test] | ||
[Category(UITestCategories.WebView)] | ||
public void WebViewDoesNotLeak() | ||
{ | ||
App.WaitForElement("DataTypeEntry"); | ||
App.EnterText("DataTypeEntry", "WebView"); | ||
App.Tap("RunMemoryTestButton"); | ||
App.AssertMemoryTest(); | ||
} | ||
} | ||
} |