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

[X] passing test for 18976 #19785

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui18976.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?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"
xmlns:local="clr-namespace:Microsoft.Maui.Controls.Xaml.UnitTests"
x:Class="Microsoft.Maui.Controls.Xaml.UnitTests.Maui18976">

<StackLayout Padding="30,0" Spacing="25">
<CheckBox x:Name="checkbox"/>

<Button x:Name="button" Text="Click me">
<Button.Triggers>
<DataTrigger Binding="{Binding IsChecked, Source={x:Reference checkbox}}" Value="True" TargetType="Button">
<Setter Property="IsEnabled" Value="False"/>
</DataTrigger>
</Button.Triggers>
</Button>
</StackLayout>
</ContentPage>
60 changes: 60 additions & 0 deletions src/Controls/tests/Xaml.UnitTests/Issues/Maui18976.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using Microsoft.Maui.ApplicationModel;
using Microsoft.Maui.Controls.Core.UnitTests;
using Microsoft.Maui.Controls.Shapes;
using Microsoft.Maui.Devices;
using Microsoft.Maui.Dispatching;

using Microsoft.Maui.Graphics;
using Microsoft.Maui.UnitTests;
using NUnit.Framework;

namespace Microsoft.Maui.Controls.Xaml.UnitTests
{
public partial class Maui18976 : ContentPage
{
public Maui18976()
{
InitializeComponent();
}

public Maui18976(bool useCompiledXaml)
{
//this stub will be replaced at compile time
}

[TestFixture]
class Test
{
[SetUp]
public void Setup()
{
Application.SetCurrentApplication(new MockApplication());
DispatcherProvider.SetCurrent(new DispatcherProviderStub());
}


[TearDown] public void TearDown() => AppInfo.SetCurrent(null);

[Test]
public void DataTriggerRestoreValue([Values(false, true)] bool useCompiledXaml)
{
var page = new Maui18976(useCompiledXaml);
Assert.That(page.checkbox.IsChecked, Is.False);
Assert.That(page.button.IsEnabled, Is.True);

page.checkbox.IsChecked = true;
Assert.That(page.checkbox.IsChecked, Is.True);
Assert.That(page.button.IsEnabled, Is.False);

page.checkbox.IsChecked = false;
Assert.That(page.checkbox.IsChecked, Is.False);
Assert.That(page.button.IsEnabled, Is.True);
}
}
}
}