-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Issue2740.cs
81 lines (72 loc) · 2.04 KB
/
Issue2740.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
using System;
using System.Collections.Generic;
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
#if UITEST
[NUnit.Framework.Category(Core.UITests.UITestCategories.Github5000)]
#endif
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 2740, "System.NotSupportedException: Unable to activate instance of type Xamarin.Forms.Platform.Android.PageContainer from native handle", PlatformAffected.Android)]
public class Issue2740 : TestMasterDetailPage // or TestMasterDetailPage, etc ...
{
protected override void Init()
{
var page = new AddressListView();
// Initialize ui here instead of ctor
Master = new ContentPage
{
Content = new Label
{
Text = "Click a item on the left then the toolbar item switch"
},
Title = "2740"
};
Detail = new NavigationPage(page);
}
public partial class AddressListView : ContentPage
{
public AddressListView()
{
var listview = new ListView();
listview.ItemsSource = new List<string> { "1", "2" };
listview.ItemTapped += OnItemTapped;
Content = listview;
Title = "Unit List";
}
public async void OnItemTapped(object sender, ItemTappedEventArgs e)
{
var p = new UnitViolationView();
await Navigation.PushAsync(p);
}
}
public partial class UnitViolationView : ContentPage
{
public UnitViolationView()
{
ToolbarItems.Add(new ToolbarItem("Switch", null, MapAddressSwitch) { AutomationId = "Switch" });
}
async void MapAddressSwitch()
{
await Navigation.PopAsync(false);
(Application.Current.MainPage as MasterDetailPage).Detail = new NavigationPage(new AddressListView());
}
}
#if UITEST
[Test]
public void Issue2740Test()
{
RunningApp.WaitForElement(q => q.Marked("1"));
RunningApp.Tap(q => q.Marked("1"));
RunningApp.WaitForElement(q => q.Marked("Switch"));
RunningApp.Tap(q => q.Marked("Switch"));
RunningApp.WaitForElement(q => q.Marked("1"));
}
#endif
}
}