summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs')
-rw-r--r--Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs178
1 files changed, 178 insertions, 0 deletions
diff --git a/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs b/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs
new file mode 100644
index 00000000..5ae8f506
--- /dev/null
+++ b/Xamarin.Forms.Core.iOS.UITests/Tests/ButtonUITests.cs
@@ -0,0 +1,178 @@
+using System;
+using System.CodeDom;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Threading;
+using System.Reflection;
+
+using NUnit.Framework;
+
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.UITest.Android;
+using Xamarin.UITest.Queries;
+using Xamarin.UITest.iOS;
+
+namespace Xamarin.Forms.Core.UITests
+{
+ [TestFixture]
+ [Category ("Button")]
+ internal class ButtonUITests : _ViewUITests
+ {
+ public ButtonUITests ()
+ {
+ PlatformViewType = Views.Button;
+ }
+
+ protected override void NavigateToGallery ()
+ {
+ App.NavigateToGallery (GalleryQueries.ButtonGallery);
+ }
+
+ // View Tests
+ [UiTestExempt (ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _Focus () {}
+
+ [UiTestExempt (ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _GestureRecognizers () {}
+
+ [UiTestExempt (ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _IsFocused () {}
+
+ [UiTestExempt (ExemptReason.CannotTest, "Invalid interaction")]
+ public override void _UnFocus () {}
+
+ // Button Tests
+ [Test]
+ [UiTest (typeof(Button),"BorderColor")]
+ [UiTestBroken (BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")]
+ [UiTestBroken (BrokenReason.CalabashiOSUnsupported, "iOS nil result")]
+ public void BorderColor ()
+ {
+ //TODO iOS
+ var remote = new ViewContainerRemote (App, Test.Button.BorderColor, PlatformViewType);
+ remote.GoTo ();
+
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "BorderRadius")]
+ [UiTestBroken (BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")]
+ public void BorderRadius ()
+ {
+ var remote = new ViewContainerRemote (App, Test.Button.BorderRadius, PlatformViewType);
+ remote.GoTo ();
+
+ if (App is iOSApp) {
+ var borderRadius = remote.GetProperty<float> (Button.BorderRadiusProperty);
+ Assert.AreEqual (20.0f, borderRadius);
+ }
+
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "BorderWidth")]
+ [UiTestBroken (BrokenReason.CalabashAndroidUnsupported, "Figure out how to get Android Drawables")]
+ public void BorderWidth ()
+ {
+ var remote = new ViewContainerRemote (App, Test.Button.BorderWidth, PlatformViewType);
+ remote.GoTo ();
+
+ if (App is iOSApp) {
+ var borderWidth = remote.GetProperty<float> (Button.BorderWidthProperty);
+ Assert.AreEqual (15.0f, borderWidth);
+ }
+
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "Clicked")]
+ public void Clicked ()
+ {
+ var remote = new EventViewContainerRemote (App, Test.Button.Clicked, PlatformViewType);
+ remote.GoTo ();
+
+ var textBeforeClick = remote.GetEventLabel ().Text;
+ Assert.AreEqual ("Event: Clicked (none)", textBeforeClick);
+
+ // Click Button
+ remote.TapView ();
+
+ var textAfterClick = remote.GetEventLabel ().Text;
+ Assert.AreEqual ("Event: Clicked (fired 1)", textAfterClick);
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "Command")]
+ public void Command ()
+ {
+ var remote = new ViewContainerRemote (App, Test.Button.Command, PlatformViewType);
+ remote.GoTo ();
+
+ remote.TapView ();
+
+ App.WaitForElement (q => q.Marked ("Hello Command"));
+ App.Tap (q => q.Marked ("Destroy"));
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "Font")]
+ public void Font ()
+ {
+ //TODO iOS
+ var remote = new ViewContainerRemote (App, Test.Button.Font, PlatformViewType);
+ remote.GoTo ();
+
+ if (App is AndroidApp) {
+ var isBold = remote.GetProperty<bool> (Button.FontProperty);
+ Assert.True (isBold);
+ } else {
+ var font = remote.GetProperty<Font> (Button.FontProperty);
+ Assert.True (font.FontAttributes.HasFlag (FontAttributes.Bold));
+ }
+
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "Image")]
+ [UiTestExempt (ExemptReason.TimeConsuming, "Need way to check Android resources")]
+ public void Image ()
+ {
+ //TODO iOS
+ var remote = new ViewContainerRemote (App, Test.Button.Image, PlatformViewType);
+ remote.GoTo ();
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "Text")]
+ public void Text ()
+ {
+ var remote = new ViewContainerRemote (App, Test.Button.Text, PlatformViewType);
+ remote.GoTo ();
+
+ var buttonText = remote.GetProperty<string> (Button.TextProperty);
+ Assert.AreEqual ("Text", buttonText);
+ }
+
+ [Test]
+ [UiTest (typeof (Button), "TextColor")]
+ public void TextColor ()
+ {
+ //TODO iOS
+ if (App is AndroidApp) {
+ var remote = new ViewContainerRemote (App, Test.Button.TextColor, PlatformViewType);
+ remote.GoTo ();
+
+ var buttonTextColor = remote.GetProperty<Color> (Button.TextColorProperty);
+ Assert.AreEqual (Color.Pink, buttonTextColor);
+ }
+ }
+
+ protected override void FixtureTeardown ()
+ {
+ App.NavigateBack ();
+ base.FixtureTeardown ();
+ }
+ }
+} \ No newline at end of file