summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs
diff options
context:
space:
mode:
authorJason Smith <jason.smith@xamarin.com>2016-03-22 13:02:25 -0700
committerJason Smith <jason.smith@xamarin.com>2016-03-22 16:13:41 -0700
commit17fdde66d94155fc62a034fa6658995bef6fd6e5 (patch)
treeb5e5073a2a7b15cdbe826faa5c763e270a505729 /Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs
downloadxamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.gz
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.tar.bz2
xamarin-forms-17fdde66d94155fc62a034fa6658995bef6fd6e5.zip
Initial import
Diffstat (limited to 'Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs')
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs130
1 files changed, 130 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs
new file mode 100644
index 00000000..86e8bcb4
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla31602.cs
@@ -0,0 +1,130 @@
+´╗┐using System;
+
+using Xamarin.Forms.CustomAttributes;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows.Input;
+
+#if UITEST
+using Xamarin.UITest;
+using Xamarin.UITest.iOS;
+using NUnit.Framework;
+#endif
+
+namespace Xamarin.Forms.Controls
+{
+ [Preserve (AllMembers = true)]
+ [Issue (IssueTracker.Bugzilla, 31602, "not possible to programmatically open master page after iPad landscape -> portrait rotation, also tests 31664")]
+ public class Bugzilla31602 : TestMasterDetailPage
+ {
+ protected override void Init ()
+ {
+ BindingContext = new MasterViewModel1 ();
+ ((MasterViewModel1)BindingContext).MasterPage = this;
+
+ Master = new SidemenuPage ();
+ Detail = new NavigationPage (new DetailPage1 (Master as SidemenuPage));
+ }
+
+ public class SidemenuPage : ContentPage
+ {
+ public SidemenuPage ()
+ {
+ Title = "Side";
+ Icon = "menuIcon.png";
+ var lbl = new Label { Text = "SideMenu" };
+ var btn = new Button { Text = "Menu Opener" };
+
+ btn.SetBinding (Button.CommandProperty, new Binding ("OpenSideMenuCommand"));
+
+ var stackpanel = new StackLayout { VerticalOptions = LayoutOptions.Center };
+
+ stackpanel.Children.Add (btn);
+ stackpanel.Children.Add (lbl);
+ Content = stackpanel;
+ }
+
+ public void ChangeIcon() {
+ Icon = "bank.png";
+ }
+ }
+
+ public class DetailPage1 : ContentPage
+ {
+ SidemenuPage _sideMenu;
+
+ public DetailPage1 (SidemenuPage menu)
+ {
+ _sideMenu = menu;
+ Title = "Detail";
+ var btns = new Button { Text = "Change Icon" };
+ btns.Clicked += (object sender, EventArgs e) => {
+ _sideMenu.ChangeIcon();
+ };
+ var btn = new Button { Text = "Sidemenu Opener" };
+ btn.SetBinding (Button.CommandProperty, new Binding ("OpenSideMenuCommand"));
+ Content = new StackLayout { Children = { btns, btn} };
+ }
+ }
+
+ [Preserve (AllMembers = true)]
+ public class MasterViewModel1 : INotifyPropertyChanged
+ {
+ public MasterDetailPage MasterPage;
+
+ public event PropertyChangedEventHandler PropertyChanged = delegate { };
+
+ protected void OnPropertyChanged ([CallerMemberName] string propertyName = null)
+ {
+ if (PropertyChanged != null) {
+ PropertyChanged (this, new PropertyChangedEventArgs (propertyName));
+ }
+ }
+
+ bool _isMenuOpen;
+
+ public bool IsMenuOpen {
+ get { return _isMenuOpen; }
+ private set {
+ if (_isMenuOpen != value) {
+ System.Diagnostics.Debug.WriteLine ("setting new sidemenu visibility flag to: " + value);
+ _isMenuOpen = value;
+ OnPropertyChanged ();
+ }
+ }
+ }
+
+ public ICommand OpenSideMenuCommand { get; private set; }
+
+ public MasterViewModel1 ()
+ {
+ IsMenuOpen = true;
+ OpenSideMenuCommand = new Command (OpenSideMenu);
+ }
+
+ void OpenSideMenu ()
+ {
+ IsMenuOpen = true;
+ MasterPage.IsPresented = IsMenuOpen;
+ }
+ }
+
+ #if UITEST
+ [Test]
+ public void Bugzilla31602Test ()
+ {
+ var appAs = RunningApp as iOSApp;
+ if (appAs != null && appAs.Device.IsTablet) {
+ RunningApp.Tap (q => q.Marked ("Sidemenu Opener"));
+ RunningApp.WaitForElement (q => q.Marked ("SideMenu"));
+ RunningApp.SetOrientationLandscape ();
+ RunningApp.WaitForElement (q => q.Marked ("SideMenu"));
+ RunningApp.SetOrientationPortrait ();
+ RunningApp.WaitForNoElement (q => q.Marked ("SideMenu"));
+ RunningApp.Tap (q => q.Marked ("Sidemenu Opener"));
+ RunningApp.WaitForElement (q => q.Marked ("SideMenu"));
+ }
+ }
+#endif
+ }
+}