简体   繁体   English

使用Xamarin.UITest与MvvmCross绑定

[英]Using Xamarin.UITest with MvvmCross Binding

I'm using the Xamarin.UITest framework to assert if some button is disabled or enabled. 我正在使用Xamarin.UITest框架断言是否禁用或启用了某个按钮。 Unfortunately it seems that this is not working if the "Enabled" Property of the button is set via binding trough MVX (binding is working - button is really disabled). 不幸的是,看来,如果按钮的“已启用”属性是通过结合槽MVX 设置是不工作 (绑定工作-按钮实在是禁用)。

Example axml with two buttons: 带有两个按钮的示例axml:

    <xxx.Widgets.Button
        android:id="@+id/btnSave"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="Save"
        style="@style/DefaultButton"
        local:MvxBind="Click SaveAndContinueCommand; Enabled SaveButtonActive" />
    <xxx.Widgets.Button
        android:id="@+id/btnTest"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:text="Test"
        style="@style/DefaultButton"
        android:enabled="false" />

Query with Xamarin.UITest: 使用Xamarin.UITest查询:

var button = App.Query(v => v.Button("Save")).FirstOrDefault();
Assert.IsFalse(button.Enabled); // -> Button is always enabled

var testButton = App.Query(v => v.Button("Test")).FirstOrDefault();
Assert.IsFalse(button.Enabled); // -> Button is disabled. Correct!

Do I need to pay attention on something different? 我需要注意不同的东西吗? Has anyone experience with the combination of MVX and Xamarin.UITest? 有没有人体验过MVX和Xamarin.UITest的结合?

I don't typically check button properties at the UI test level. 我通常不会在UI测试级别检查按钮属性。 I would check that in the core tests where I know that works. 我会在核心测试中检查我知道哪些有效。 With that being said, you could actually tap the button with the UI test and verify that nothing happens if that's possible. 话虽如此,您实际上可以通过UI测试点击按钮,并验证如果可能的话没有任何反应。

The next thing I would try is fire up your app with Calabash enabled, navigate to this screen and query the buttons to verify you are checking the properties that you should be. 我要尝试的下一件事是启用Calabash启动你的应用程序,导航到这个屏幕并查询按钮以验证你正在检查你应该是的属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM