-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Bugzilla34632.cs
107 lines (96 loc) · 2.65 KB
/
Bugzilla34632.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
using Xamarin.UITest.iOS;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Bugzilla)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Bugzilla, 34632, "Can't change IsPresented when setting SplitOnLandscape ")]
public class Bugzilla34632 : TestMasterDetailPage
{
protected override void Init()
{
if (Device.RuntimePlatform == Device.UWP)
MasterBehavior = MasterBehavior.Split;
else
MasterBehavior = MasterBehavior.SplitOnLandscape;
Master = new ContentPage
{
Title = "Main Page",
Content = new Button
{
Text = "Master",
AutomationId = "btnMaster",
Command = new Command(() =>
{
//If we're in potrait toggle hide the menu on click
if (Width < Height || Device.Idiom == TargetIdiom.Phone)
{
IsPresented = false;
}
})
}
};
Detail = new NavigationPage(new ModalRotationIssue());
NavigationPage.SetHasBackButton(Detail, false);
}
[Preserve(AllMembers = true)]
public class ModalRotationIssue : ContentPage
{
public ModalRotationIssue()
{
var btn = new Button { Text = "Open Modal", AutomationId = "btnModal" };
btn.Clicked += OnButtonClicked;
Content = btn;
}
async void OnButtonClicked(object sender, EventArgs e)
{
var testButton = new Button { Text = "Rotate Before Clicking", AutomationId = "btnDismissModal" };
testButton.Clicked += (async (snd, args) => await Navigation.PopModalAsync());
var testModal = new ContentPage()
{
Content = testButton
};
await Navigation.PushModalAsync(testModal);
}
}
#if UITEST && __IOS__
[Test]
public void Bugzilla34632Test()
{
if (RunningApp.IsTablet())
{
RunningApp.SetOrientationPortrait();
RunningApp.Tap(q => q.Marked("btnModal"));
RunningApp.SetOrientationLandscape();
RunningApp.Tap(q => q.Marked("btnDismissModal"));
RunningApp.Tap(q => q.Marked("btnModal"));
RunningApp.SetOrientationPortrait();
RunningApp.Tap(q => q.Marked("btnDismissModal"));
RunningApp.Tap("Main Page");
RunningApp.Tap(q => q.Marked("btnMaster"));
RunningApp.WaitForNoElement("btnMaster");
}
else
{
// Wait for the test to finish loading before exiting otherwise
// the next UI test might start running while this is still loading
RunningApp.WaitForElement(q => q.Marked("btnModal"));
}
}
[TearDown]
public override void TearDown()
{
RunningApp.SetOrientationPortrait();
base.TearDown();
}
#endif
}
}