|
1 | 1 | using System;
|
| 2 | +using System.Collections.Generic; |
| 3 | +using System.IO; |
2 | 4 | using System.Linq;
|
| 5 | +using System.Xml; |
3 | 6 | using NUnit.Framework;
|
4 | 7 |
|
5 | 8 | namespace Xamarin.Android.Tools.ApiXmlAdjuster.Tests
|
@@ -65,6 +68,35 @@ public void ResolveGenericArguments ()
|
65 | 68 | para.ResolvedType.ToString (),
|
66 | 69 | "referenced type is not correctly resolved");
|
67 | 70 | }
|
| 71 | + |
| 72 | + [Test] |
| 73 | + public void IntentServiceHack () |
| 74 | + { |
| 75 | + // https://github.com/xamarin/java.interop/issues/717 |
| 76 | + var api = JavaApiTestHelper.GetLoadedApi (); |
| 77 | + |
| 78 | + // Create "mono.android.app" package |
| 79 | + var mono_android_app = new JavaPackage (api) { Name = "mono.android.app", JniName = "mono/android/app", Types = new List<JavaType> () }; |
| 80 | + api.Packages.Add (mono_android_app); |
| 81 | + |
| 82 | + // Remove "android.app.IntentService" type |
| 83 | + var android_app = api.Packages.Single (p => p.Name == "android.app"); |
| 84 | + var intent_service = android_app.Types.Single (t => t.Name == "IntentService"); |
| 85 | + android_app.Types.Remove (intent_service); |
| 86 | + |
| 87 | + // Create new "mono.android.app.IntentService" type |
| 88 | + var new_intent_service = new JavaClass (mono_android_app) { |
| 89 | + Name = intent_service.Name, |
| 90 | + }; |
| 91 | + |
| 92 | + mono_android_app.Types.Add (new_intent_service); |
| 93 | + |
| 94 | + api.Resolve (); |
| 95 | + |
| 96 | + // Ensure we can resolve the type by either name |
| 97 | + Assert.AreSame (new_intent_service, api.FindNonGenericType ("android.app.IntentService")); |
| 98 | + Assert.AreSame (new_intent_service, api.FindNonGenericType ("mono.android.app.IntentService")); |
| 99 | + } |
68 | 100 | }
|
69 | 101 | }
|
70 | 102 |
|
0 commit comments