summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselAsync.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselAsync.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselAsync.cs114
1 files changed, 114 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselAsync.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselAsync.cs
new file mode 100644
index 00000000..d6e9b19a
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/CarouselAsync.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Diagnostics;
+using System.Linq;
+using System.Threading.Tasks;
+using Xamarin.Forms.CustomAttributes;
+
+#if UITEST
+using NUnit.Framework;
+using Xamarin.UITest;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers=true)]
+ [Issue (IssueTracker.None, 0, "Carousel Async Add Page Issue", PlatformAffected.All, NavigationBehavior.PushModalAsync)]
+ public class CarouselAsync : TestCarouselPage
+ {
+ protected override void Init ()
+ {
+ Children.Add (new ContentPage {
+ BackgroundColor = Color.Red,
+ Content = new Label {
+ Text = "Page One"
+ }
+ });
+ Children.Add (new ContentPage {
+ BackgroundColor = Color.Green,
+ Content = new Label {
+ Text = "Page Two"
+ }
+ });
+ Update (this);
+ }
+
+ static void Update (CarouselPage page)
+ {
+ Device.StartTimer (TimeSpan.FromSeconds (1), () => {
+ page.Children.Remove (page.Children.Skip (1).First () as ContentPage);
+ Device.StartTimer (TimeSpan.FromSeconds (1), () => {
+ page.Children.Add (new ContentPage {
+ BackgroundColor = Color.Blue,
+ Content = new Label {
+ Text = "Page Two - Added"
+ }
+ });
+ page.Children.Add (new ContentPage {
+ BackgroundColor = Color.Gray,
+ Content = new Label {
+ Text = "Page Three - Added"
+ }
+ });
+ return false;
+ });
+ return false;
+ });
+ }
+
+#if UITEST
+ [Test]
+ [Description ("All elements renderered")]
+ public void CarouselAsycTestsAllElementsPresent ()
+ {
+ RunningApp.WaitForElement (q => q.Marked ("Page One"));
+ RunningApp.Screenshot ("All elements present");
+ }
+
+ [Test]
+ [Description ("Async Pages inserted into a CarouselPage")]
+ public void CarouselAsycTestsAllPagesExistAfterAsyncAdding ()
+ {
+ RunningApp.WaitForElement (q => q.Marked ("Page One"));
+
+ var window = RunningApp.Query (q => q.Raw ("*").Index (0));
+ var width = window [0].Rect.Width;
+ var height = window [0].Rect.Height;
+
+ System.Threading.Thread.Sleep (3000);
+
+ // TODO Implement swipe left and swipe right
+ //App.DragFromTo (width - 10.0f, height / 2.0f, 10.0f, height / 2.0f);
+ //App.WaitForElement (q => q.Marked ("Page Two - Added"));
+ //App.Screenshot ("At Page 2");
+
+ //Thread.Sleep (3000);
+
+ //App.DragFromTo (width - 10.0f, height / 2.0f, 10.0f, height / 2.0f);
+ //App.WaitForElement (q => q.Marked ("Page Three - Added"));
+ //App.Screenshot ("At Page 3");
+ }
+
+/*******************************************************/
+/**************** Landscape tests **********************/
+/*******************************************************/
+
+ [Test]
+ [Description ("All elements renderered - landscape")]
+ public void CarouselAsycTestsAllElementsPresentLandscape ()
+ {
+ RunningApp.SetOrientationLandscape ();
+ CarouselAsycTestsAllElementsPresent ();
+ RunningApp.SetOrientationPortrait ();
+ }
+
+ [Test]
+ [Description ("Async Pages inserted into a CarouselPage - landscape")]
+ public void CarouselAsycTestsAllPagesExistAfterAsyncAddingLandscape ()
+ {
+ RunningApp.SetOrientationLandscape ();
+ CarouselAsycTestsAllPagesExistAfterAsyncAdding ();
+ RunningApp.SetOrientationPortrait ();
+ }
+#endif
+ }
+}