-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14000 from unoplatform/dev/jela/hr-template
Adjust DataTemplate reload
- Loading branch information
Showing
11 changed files
with
142 additions
and
27 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 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 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 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 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 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 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
47 changes: 47 additions & 0 deletions
47
src/Uno.UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Given_DataTemplate.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,47 @@ | ||
| ||
using System.Reflection.Metadata; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Uno.Extensions; | ||
using Uno.UI.Helpers; | ||
using Uno.UI.RuntimeTests.Tests.HotReload.Frame.HRApp.Tests; | ||
using Uno.UI.RuntimeTests.Tests.HotReload.Frame.Pages; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.HotReload.Frame.HRApp.Tests; | ||
|
||
[TestClass] | ||
[RunsOnUIThread] | ||
public class Given_DataTemplate : BaseTestClass | ||
{ | ||
/// <summary> | ||
/// Change the Text of a TextBlock inside a UserControl, where the UserControl | ||
/// is nested inside a Viewbox | ||
/// </summary> | ||
[TestMethod] | ||
public async Task When_Change_DataTemplate() | ||
{ | ||
var ct = new CancellationTokenSource(TimeSpan.FromSeconds(10)).Token; | ||
|
||
// We're not storing the instance explicitly, as the HR engine replaces | ||
// the top level content of the window. We keep poking at the UnitTestsUIContentHelper.Content | ||
// as it gets updated with reloaded content. | ||
UnitTestsUIContentHelper.Content = new HR_Frame_Pages_DataTemplate(); | ||
|
||
var originalText = "** Original Text **"; | ||
var updatedText = "** Updated Text **"; | ||
|
||
// Check the initial text of the TextBlock | ||
await UnitTestsUIContentHelper.Content.ValidateTextOnChildTextBlock(originalText, 0); | ||
|
||
// Check the updated text of the TextBlock | ||
await HotReloadHelper.UpdateServerFileAndRevert<HR_Frame_Pages_DataTemplate>( | ||
originalText, | ||
updatedText, | ||
() => UnitTestsUIContentHelper.Content.ValidateTextOnChildTextBlock(updatedText, 0), | ||
ct); | ||
|
||
// Validate that content been returned to the original text | ||
await UnitTestsUIContentHelper.Content.ValidateTextOnChildTextBlock(originalText, 0); | ||
|
||
await Task.Yield(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
....UI.RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_DataTemplate.xaml
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,18 @@ | ||
<Page x:Class="Uno.UI.RuntimeTests.Tests.HotReload.Frame.Pages.HR_Frame_Pages_DataTemplate" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Uno.UI.RuntimeTests.Tests.HotReload.Frame.Pages" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d"> | ||
<Page.Resources> | ||
<DataTemplate x:Key="myTemplate"> | ||
<TextBlock Text="** Original Text **" /> | ||
</DataTemplate> | ||
</Page.Resources> | ||
<StackPanel> | ||
<ContentControl ContentTemplate="{StaticResource myTemplate}" Content="21"> | ||
</ContentControl> | ||
</StackPanel> | ||
</Page> | ||
|
12 changes: 12 additions & 0 deletions
12
....RuntimeTests/Tests/HotReload/Frame/HRApp/Tests/Pages/HR_Frame_Pages_DataTemplate.xaml.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,12 @@ | ||
using Windows.UI.Xaml; | ||
using Windows.UI.Xaml.Controls; | ||
|
||
namespace Uno.UI.RuntimeTests.Tests.HotReload.Frame.Pages; | ||
|
||
public sealed partial class HR_Frame_Pages_DataTemplate : Page | ||
{ | ||
public HR_Frame_Pages_DataTemplate() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} |
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