forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Frames' content update (dotnet#20501)
* [iOS] Fixed updating frame's content (dotnet#19127) * Added a UiTest (dotnet#19127) * Code refactor --------- Co-authored-by: Javier Suárez <[email protected]>
- Loading branch information
1 parent
1ddd9a0
commit e8c96c5
Showing
4 changed files
with
132 additions
and
10 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19127.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,32 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue19127" | ||
xmlns:ns="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<VerticalStackLayout | ||
VerticalOptions="Center"> | ||
<Button Text="{Binding IsCameraEnabled, StringFormat='Toggle Camera View ({0})'}" | ||
Command="{Binding EnableCamera}" | ||
AutomationId="button" /> | ||
|
||
<Frame x:Name="frame" | ||
HeightRequest="191"> | ||
<Frame.Triggers> | ||
<DataTrigger TargetType="Frame" Binding="{Binding IsCameraEnabled}" Value="False"> | ||
<Setter Property="Content"> | ||
<Grid BackgroundColor="Gray"> | ||
<Label AutomationId="label1" Text="Camera is Disabled" TextColor="White" /> | ||
</Grid> | ||
</Setter> | ||
</DataTrigger> | ||
<DataTrigger TargetType="Frame" Binding="{Binding IsCameraEnabled}" Value="True"> | ||
<Setter Property="Content"> | ||
<Grid BackgroundColor="HotPink"> | ||
<Label AutomationId="label2" Text="Camera is Enabled" TextColor="White" /> | ||
</Grid> | ||
</Setter> | ||
</DataTrigger> | ||
</Frame.Triggers> | ||
</Frame> | ||
</VerticalStackLayout> | ||
</ContentPage> |
47 changes: 47 additions & 0 deletions
47
src/Controls/samples/Controls.Sample.UITests/Issues/Issue19127.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,47 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.Xaml; | ||
|
||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 19127, "Triggers are not working on Frame control", PlatformAffected.iOS)] | ||
public partial class Issue19127 : ContentPage | ||
{ | ||
public Issue19127() | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new Issue19127Settings(); | ||
} | ||
} | ||
|
||
public class Issue19127Settings : INotifyPropertyChanged | ||
{ | ||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public Command EnableCamera { get; set; } | ||
|
||
private bool _isCameraEnabled; | ||
public bool IsCameraEnabled | ||
{ | ||
get { return _isCameraEnabled; } | ||
set | ||
{ | ||
_isCameraEnabled = value; | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsCameraEnabled))); | ||
} | ||
} | ||
|
||
public Issue19127Settings() | ||
{ | ||
IsCameraEnabled = false; | ||
EnableCamera = new Command(() => ToggleEnableCamera()); | ||
} | ||
|
||
private void ToggleEnableCamera() | ||
{ | ||
IsCameraEnabled = !_isCameraEnabled; | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.AppiumTests.Issues | ||
{ | ||
public class Issue19127 : _IssuesUITest | ||
{ | ||
public override string Issue => "Triggers are not working on Frame control"; | ||
|
||
public Issue19127(TestDevice device) : base(device) | ||
{ | ||
} | ||
|
||
[Test] | ||
public void ContentOfFrameShouldChange() | ||
{ | ||
_ = App.WaitForElement("button"); | ||
|
||
var textBeforeClick = App.FindElement("label1").GetText(); | ||
|
||
App.Click("button"); | ||
|
||
var textAfterClick = App.FindElement("label2").GetText(); | ||
|
||
Assert.AreEqual(textBeforeClick, "Camera is Disabled"); | ||
Assert.AreEqual(textAfterClick, "Camera is Enabled"); | ||
} | ||
} | ||
} |