[Preserve(AllMembers = true)]
internal class CorePageView : ListView
{
+ [Preserve(AllMembers = true)]
internal class GalleryPageFactory
{
public GalleryPageFactory(Func<Page> create, string title)
};
Title = title;
+ TitleAutomationId = $"{Title}AutomationId";
}
public Func<Page> Realize { get; set; }
public string Title { get; set; }
+ public string TitleAutomationId
+ {
+ get;
+ set;
+ }
+
public override string ToString()
{
// a11y: let Narrator read a friendly string instead of the default ToString()
new GalleryPageFactory(() => new CellForceUpdateSizeGalleryPage(), "Cell Force Update Size Gallery"),
new GalleryPageFactory(() => new AppearingGalleryPage(), "Appearing Gallery"),
new GalleryPageFactory(() => new EntryCoreGalleryPage(), "Entry Gallery"),
- new GalleryPageFactory(() => new EntryCoreGalleryPage{ Visual = VisualMarker.Material }, "Entry Gallery (Material)"),
new GalleryPageFactory(() => new MaterialEntryGalleryPage(), "Entry Material Demos"),
new GalleryPageFactory(() => new NavBarTitleTestPage(), "Titles And Navbar Windows"),
new GalleryPageFactory(() => new PanGestureGalleryPage(), "Pan gesture Gallery"),
new GalleryPageFactory(() => new TableViewGallery(), "TableView Gallery - Legacy"),
new GalleryPageFactory(() => new TemplatedCarouselGallery(), "TemplatedCarouselPage Gallery - Legacy"),
new GalleryPageFactory(() => new TemplatedTabbedGallery(), "TemplatedTabbedPage Gallery - Legacy"),
- new GalleryPageFactory(() => new UnevenViewCellGallery(), "UnevenViewCell Gallery - Legacy"),
+ new GalleryPageFactory(() => new UnevenViewCellGallery(), "UnevenViewCell Gallery - Legacy"),
new GalleryPageFactory(() => new UnevenListGallery(), "UnevenList Gallery - Legacy"),
new GalleryPageFactory(() => new ViewCellGallery(), "ViewCell Gallery - Legacy"),
new GalleryPageFactory(() => new WebViewGallery(), "WebView Gallery - Legacy"),
}
})
});
+
return cell;
});
+
template.SetBinding(TextCell.TextProperty, "Title");
+ template.SetBinding(TextCell.AutomationIdProperty, "TitleAutomationId");
BindingContext = _pages;
ItemTemplate = template;
_isVisibleStateViewContainer.View.IsVisible = !_isVisibleStateViewContainer.View.IsVisible;
});
+
+ _isFocusedStateViewContainer.StateChangeButton.Command = new Command(() => {
+
+ if ((bool)isFocusedView.GetValue(VisualElement.IsFocusedProperty))
+ {
+ isFocusedView.SetValueCore(IsFocusedPropertyKey, false);
+ }
+ else
+ {
+ isFocusedView.SetValueCore(IsFocusedPropertyKey, true);
+ }
+ });
+
_focusStateViewContainer.StateChangeButton.Command = new Command (() => {
if (_focusStateViewContainer.View.IsFocused) {
_focusStateViewContainer.View.Unfocus ();
BindingContext = view,
AutomationId = name + "StateLabel"
};
- if (name != "Focus")
- stateValueLabel.SetBinding (Label.TextProperty, name, converter: new GenericValueConverter (o => o.ToString()));
+
+ if(name == "Focus" || name == "Unfocused" || name == "Focused")
+ stateValueLabel.SetBinding(Label.TextProperty, "IsFocused", converter: new GenericValueConverter(o => o.ToString()));
+ else
+ stateValueLabel.SetBinding (Label.TextProperty, name, converter: new GenericValueConverter (o => o.ToString()));
StateChangeButton = new Button {
Text = "Change State: " + name,
using NUnit.Framework;
+using Xamarin.Forms.Controls.Issues;
using Xamarin.Forms.CustomAttributes;
namespace Xamarin.Forms.Core.UITests
{
+
[TestFixture]
[Category(UITestCategories.Entry)]
internal class EntryUITests : _ViewUITests
App.NavigateToGallery(GalleryQueries.EntryGallery);
}
- // TODO
+ [Test]
+ [UiTest(typeof(Entry), "Focus")]
public override void _Focus()
{
+ var remote = new StateViewContainerRemote(App, Test.VisualElement.Focus, PlatformViewType);
+ remote.GoTo();
+ bool isFocused = System.Convert.ToBoolean( App.Query("FocusStateLabel")[0].ReadText());
+ Assert.IsFalse(isFocused);
+ remote.TapView();
+ isFocused = System.Convert.ToBoolean(App.Query("FocusStateLabel")[0].ReadText());
+ Assert.IsTrue(isFocused);
+ App.Tap("FocusStateLabel");
+ isFocused = System.Convert.ToBoolean(App.Query("FocusStateLabel")[0].ReadText());
+ Assert.IsFalse(isFocused);
}
[UiTestExempt(ExemptReason.CannotTest, "Invalid interaction")]
{
}
- // TODO
public override void _IsFocused()
{
}
{
}
+
+
// TODO
// Implement control specific ui tests
[Test]
--- /dev/null
+using NUnit.Framework;
+using Xamarin.Forms.Controls.Issues;
+using Xamarin.Forms.CustomAttributes;
+
+namespace Xamarin.Forms.Core.UITests
+{
+
+#if __ANDROID__ || __IOS__
+ [TestFixture]
+ [Category(UITestCategories.Entry)]
+ [Category(UITestCategories.Visual)]
+ internal class MaterialEntryUITests : EntryUITests
+ {
+ protected override void NavigateToGallery()
+ {
+ App.NavigateToGallery(GalleryQueries.EntryGallery, "Material");
+ }
+
+ [Test]
+ [UiTest(typeof(Entry), "Focus")]
+ public override void _Focus()
+ {
+ base._Focus();
+ }
+ }
+#endif
+}
\ No newline at end of file
{
internal static class AppExtensions
{
- public static AppRect ScreenBounds (this IApp app)
+ public static AppRect ScreenBounds(this IApp app)
{
- return app.Query (Queries.Root ()).First().Rect;
+ return app.Query(Queries.Root()).First().Rect;
}
- public static void NavigateBack (this IApp app)
+ public static void NavigateBack(this IApp app)
{
app.Back();
}
- public static void NavigateToGallery (this IApp app, string page)
+ public static void NavigateToGallery(this IApp app, string page)
+ {
+ NavigateToGallery(app, page, null);
+ }
+
+ public static void NavigateToGallery(this IApp app, string page, string visual)
{
const string goToTestButtonQuery = "* marked:'GoToTestButton'";
app.WaitForElement(q => q.Raw(goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromSeconds(10));
- var text = Regex.Match (page, "'(?<text>[^']*)'").Groups["text"].Value;
+ var text = Regex.Match(page, "'(?<text>[^']*)'").Groups["text"].Value;
app.WaitForElement("SearchBar");
- app.EnterText (q => q.Raw ("* marked:'SearchBar'"), text);
+ app.EnterText(q => q.Raw("* marked:'SearchBar'"), text);
+
+ if(!String.IsNullOrWhiteSpace(visual))
+ {
+ app.DismissKeyboard();
+ app.ActivateContextMenu($"{text}AutomationId");
+ app.Tap("Select Visual");
+ app.Tap("Material");
+ }
+ else
+ {
+ app.Tap(q => q.Raw(goToTestButtonQuery));
+ }
- app.Tap (q => q.Raw (goToTestButtonQuery));
- app.WaitForNoElement (o => o.Raw (goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromMinutes(2));
+ app.WaitForNoElement(o => o.Raw(goToTestButtonQuery), "Timed out waiting for Go To Test button to disappear", TimeSpan.FromMinutes(2));
}
{
elements = app.Query(elementQuery);
tryCount++;
- if (elements.Length == 0 && onFail != null) onFail();
+ if (elements.Length == 0 && onFail != null)
+ onFail();
}
return elements;
}
}
-}
+}
\ No newline at end of file
<Compile Include="$(MSBuildThisFileDirectory)Tests\Legacy-CellsUITests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\Legacy-UnevenListTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\MapUITests.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Tests\MaterialEntryUITests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\PickerUITests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\ProgressBarUITests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Tests\RootGalleryUITests.cs" />
using Android.Util;
using Android.Support.V4.View;
using Android.Content.Res;
+using AView = Android.Views.View;
+using Xamarin.Forms.Platform.Android.AppCompat;
namespace Xamarin.Forms.Material.Android
{
* and this is the only way to set it away from that and to whatever the user specified
* 2) The HintTextColor has a different alpha when focused vs not focused
* */
- void OnFocusChange(object sender, FocusChangeEventArgs e) =>
+ void OnFocusChange(object sender, FocusChangeEventArgs e)
+ {
Device.BeginInvokeOnMainThread(() => ApplyTheme());
+ // propagate the focus changed event to the View Renderer base class
+ if (Parent is AView.IOnFocusChangeListener focusChangeListener)
+ focusChangeListener.OnFocusChange(EditText, e.HasFocus);
+
+ }
+
internal void SetHint(string hint, VisualElement element)
{
if (HintEnabled != !String.IsNullOrWhiteSpace(hint))
+using System;
using System.ComponentModel;
using Android.Content;
using Android.Views;
UpdateHeight();
UpdateIsEnabled();
UpdateFlowDirection();
+ UpdateAutomationId();
View.SetImageVisible(false);
return View;
UpdateHeight();
else if (args.PropertyName == VisualElement.FlowDirectionProperty.PropertyName)
UpdateFlowDirection();
+ else if (args.PropertyName == VisualElement.AutomationIdProperty.PropertyName)
+ UpdateAutomationId();
+ }
+
+ void UpdateAutomationId()
+ {
+ View.ContentDescription = Cell.AutomationId;
}
void UpdateDetailText()
[Obsolete("This constructor is obsolete as of version 2.5. Please use ViewRenderer(Context) instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
protected ViewRenderer()
+
{
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
protected ViewRenderer()
{
+
}
protected virtual TNativeView CreateNativeControl()
</Style>
<DataTemplate x:Key="TextCell">
- <StackPanel>
+ <StackPanel AutomationProperties.AutomationId="{Binding AutomationId}">
<TextBlock
Text="{Binding Text}"
Style="{ThemeResource BaseTextBlockStyle}"
UpdateBackground(tvc, item);
SetAccessibility(tvc, item);
+ UpdateAutomationId(tvc, textCell);
return tvc;
}
tvc.DetailTextLabel.TextColor = textCell.DetailColor.ToUIColor(DefaultTextColor);
else if (args.PropertyName == Cell.IsEnabledProperty.PropertyName)
UpdateIsEnabled(tvc, textCell);
+ else if (args.PropertyName == TextCell.AutomationIdProperty.PropertyName)
+ UpdateAutomationId(tvc, textCell);
HandlePropertyChanged(tvc, args);
}
+ void UpdateAutomationId(CellTableViewCell tvc, TextCell cell)
+ {
+ tvc.AccessibilityIdentifier = cell.AutomationId;
+ }
protected virtual void HandlePropertyChanged(object sender, PropertyChangedEventArgs args)
{