diff options
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla29257.cs')
-rw-r--r-- | Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla29257.cs | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla29257.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla29257.cs new file mode 100644 index 00000000..012ed59e --- /dev/null +++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla29257.cs @@ -0,0 +1,100 @@ +using System; + +using Xamarin.Forms.CustomAttributes; +using System.Collections.Generic; + +#if UITEST +using Xamarin.UITest; +using NUnit.Framework; +#endif + +namespace Xamarin.Forms.Controls +{ + [Preserve (AllMembers = true)] + [Issue (IssueTracker.Bugzilla, 29257, "CarouselPage.CurrentPage Does Not Work Properly When Used Inside a NavigationPage ")] + public class Bugzilla29257 : TestContentPage + { + List<string> _menuItems = new List<string> { + "Page 1", "Page 2", "Page 3", "Page 4", "Page 5" + }; + + ListView _menu; + + protected override void Init () + { + _menu = new ListView { ItemsSource = _menuItems }; + + _menu.ItemSelected += PageSelected; + + Content = _menu; + } + + async void PageSelected(object sender, SelectedItemChangedEventArgs e) + { + var selection = e.SelectedItem as string; + + switch (selection) + { + case "Page 1": + await Navigation.PushAsync(new TestPage(0)); + break; + + case "Page 2": + await Navigation.PushAsync(new TestPage(1)); + break; + + case "Page 3": + await Navigation.PushAsync(new TestPage(2)); + break; + + case "Page 4": + await Navigation.PushAsync(new TestPage(3)); + break; + + case "Page 5": + await Navigation.PushAsync(new TestPage(4)); + break; + } + _menu.SelectedItem = null; + } + + public class TestPage : CarouselPage + { + public TestPage() + { + Children.Add(new ContentPage { Content = new Label { Text = "This is page 1" , BackgroundColor = Color.Red} }); + Children.Add(new ContentPage { Content = new Label { Text = "This is page 2" , BackgroundColor = Color.Green} }); + Children.Add(new ContentPage { Content = new Label { Text = "This is page 3" , BackgroundColor = Color.Blue} }); + Children.Add(new ContentPage { Content = new Label { Text = "This is page 4" , BackgroundColor = Color.Pink} }); + Children.Add(new ContentPage { Content = new Label { Text = "This is page 5" , BackgroundColor = Color.Yellow } }); + + } + + public TestPage(int page) : this() + { + CurrentPage = Children[page]; + } + } + +#if UITEST + [Test] + public void Bugzilla29257Test () + { + RunningApp.Tap (q => q.Marked ("Page 1")); + RunningApp.WaitForElement (q => q.Marked ("This is page 1")); + RunningApp.Back (); + RunningApp.Tap (q => q.Marked ("Page 2")); + RunningApp.WaitForElement (q => q.Marked ("This is page 2")); + RunningApp.Back (); + RunningApp.Tap (q => q.Marked ("Page 3")); + RunningApp.WaitForElement (q => q.Marked ("This is page 3")); + RunningApp.Back (); + RunningApp.Tap (q => q.Marked ("Page 4")); + RunningApp.WaitForElement (q => q.Marked ("This is page 4")); + RunningApp.Back (); + RunningApp.Tap (q => q.Marked ("Page 5")); + RunningApp.WaitForElement (q => q.Marked ("This is page 5")); + } +#endif + } +} |