提交 184187fb 编写于 作者: A Andres Pineda

test(AppBarButton): assert Binding with no DataContext

上级 8ff5e832
......@@ -11,11 +11,22 @@
<Grid>
<CommandBar Content="Page with AppBarButton">
<CommandBar.PrimaryCommands>
<AppBarButton Visibility="{Binding ButtonVisibility, FallbackValue=Collapsed}">
<AppBarButton Visibility="{Binding ButtonVisibility, FallbackValue=Collapsed}"
x:Name="innerBarButton"
x:FieldModifier="public">
<TextBlock x:Name="innerTextBlock"
x:FieldModifier="public"
Text="{Binding ButtonText}" />
</AppBarButton>
<AppBarButton Label="Order"
Foreground="White">
<AppBarButton.Icon>
<BitmapIcon ShowAsMonochrome="True"
x:Name="innerIcon"
x:FieldModifier="public"
UriSource="{Binding CommandBarIcon}" />
</AppBarButton.Icon>
</AppBarButton>
</CommandBar.PrimaryCommands>
</CommandBar>
</Grid>
......
......@@ -33,17 +33,47 @@ namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
page.DataContext = new MyContext();
await WindowHelper.WaitForIdle();
var tb = page.innerTextBlock;
var icon = page.innerIcon;
Assert.IsNotNull(tb);
Assert.IsNotNull(icon);
Assert.AreEqual("Archaeopteryx", tb.Text);
Assert.IsTrue(tb.ActualWidth > 0);
Assert.IsTrue(tb.ActualHeight > 0);
}
}
[TestMethod]
#if __MACOS__
[Ignore("Currently fails on macOS, part of #9282 epic")]
#endif
public async Task Check_Binding_No_DataContext()
{
using (StyleHelper.UseNativeFrameNavigation())
{
var frame = new Frame();
WindowHelper.WindowContent = frame;
await WindowHelper.WaitForIdle();
frame.Navigate(typeof(Page_With_AppBarButton_Visibility_Bound));
await WindowHelper.WaitForIdle();
var page = frame.Content as Page_With_AppBarButton_Visibility_Bound;
page.DataContext = null;
Assert.IsNotNull(page);
await WindowHelper.WaitForIdle();
var tb = page.innerTextBlock;
var icon = page.innerIcon;
var barButton1 = page.innerBarButton;
Assert.IsNotNull(tb);
Assert.IsNotNull(icon);
Assert.IsNotNull(barButton1);
Assert.AreEqual(Visibility.Collapsed, barButton1.Visibility);
}
}
private class MyContext
{
public Visibility ButtonVisibility => Visibility.Visible;
public string ButtonText => "Archaeopteryx";
public string CommandBarIcon => "ms-appx:///Assets/linux.png";
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册