summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39499.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39499.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39499.cs134
1 files changed, 134 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39499.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39499.cs
new file mode 100644
index 00000000..44fa2899
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla39499.cs
@@ -0,0 +1,134 @@
+´╗┐using System;
+
+using Xamarin.Forms.CustomAttributes;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Collections.ObjectModel;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ [Issue (IssueTracker.Bugzilla, 39499, "CarouselViewTest")]
+ public sealed class CarouselViewContentPage : TestContentPage // or TestMasterDetailPage, etc ...
+ {
+ [Preserve (AllMembers = true)]
+ public sealed class Item
+ {
+ static int s_id = 0;
+
+ int id;
+
+ internal Item()
+ {
+ id = s_id++;
+ }
+
+ public int Id => id;
+ }
+
+ [Preserve (AllMembers = true)]
+ public sealed class ItemView : ContentView
+ {
+ public ItemView ()
+ {
+ var idLabel = new Label () { StyleId = "id", TextColor = Color.White };
+ idLabel.SetBinding (Label.TextProperty, nameof(Item.Id));
+
+ var stackLayout = new StackLayout {
+ Children = {
+ new Label { Text = "Target" },
+ new Label { Text = "Stack" }
+ },
+ BackgroundColor = Color.Red
+ };
+
+ var button = CreateButton ("Hide Target Stack", () => {
+ stackLayout.IsVisible = false;
+ });
+
+ Content = new StackLayout {
+ Children = {
+ idLabel,
+ button,
+ stackLayout,
+ }
+ };
+ }
+
+ Button CreateButton(string text, Action clicked)
+ {
+ var button = new Button ();
+ button.Text = text;
+ button.Clicked += (s, e) => {
+ clicked ();
+ };
+ return button;
+ }
+ }
+
+ static readonly IList<Item> Items = new ObservableCollection<Item> () {
+ new Item(),
+ new Item(),
+ };
+
+ Button CreateButton(string text, Action onClicked = null)
+ {
+ var button = new Button {
+ Text = text
+ };
+
+ if (onClicked != null)
+ button.Clicked += (s, e) => onClicked();
+
+ return button;
+ }
+
+ protected override void Init ()
+ {
+ BackgroundColor = Color.Blue;
+
+ var carouselView = new CarouselView {
+ BackgroundColor = Color.Purple,
+ ItemsSource = Items,
+ ItemTemplate = new DataTemplate(typeof(ItemView)),
+ Position = 0
+ };
+
+ var moveBar = new StackLayout {
+ Orientation = StackOrientation.Horizontal,
+ HorizontalOptions = LayoutOptions.FillAndExpand,
+ Children = {
+ CreateButton ("<<", () => carouselView.Position = 0),
+ CreateButton ("<", () => { try { carouselView.Position--; } catch { } }),
+ CreateButton (">", () => { try { carouselView.Position++; } catch { } }),
+ CreateButton (">>", () => carouselView.Position = Items.Count - 1)
+ }
+ };
+
+ Content = new StackLayout {
+ Children = {
+ carouselView,
+ moveBar,
+ }
+ };
+ }
+
+#if UITEST
+ //[Test]
+ public void CarouselViewTest ()
+ {
+ var app = RunningApp;
+ app.Screenshot ("I am at Issue 1");
+ app.WaitForElement (q => q.Marked ("Remove"));
+
+ app.Screenshot ("I see the Label");
+ }
+#endif
+ }
+}