@@ -84,6 +84,57 @@ public void DotNetInstallAndRun (bool isRelease, bool xamarinForms, bool? publis
8484 Assert . IsTrue ( didLaunch , "Activity should have started." ) ;
8585 }
8686
87+ [ Test ]
88+ public void TypeAndMemberRemapping ( [ Values ( false , true ) ] bool isRelease )
89+ {
90+ AssertHasDevices ( ) ;
91+
92+ var proj = new XASdkProject ( ) {
93+ IsRelease = isRelease ,
94+ OtherBuildItems = {
95+ new AndroidItem . _AndroidRemapMembers ( "RemapActivity.xml" ) {
96+ Encoding = Encoding . UTF8 ,
97+ TextContent = ( ) => ResourceData . RemapActivityXml ,
98+ } ,
99+ new AndroidItem . AndroidJavaSource ( "RemapActivity.java" ) {
100+ Encoding = new UTF8Encoding ( encoderShouldEmitUTF8Identifier : false ) ,
101+ TextContent = ( ) => ResourceData . RemapActivityJava ,
102+ Metadata = {
103+ { "Bind" , "True" } ,
104+ } ,
105+ } ,
106+ } ,
107+ } ;
108+ proj . MainActivity = proj . DefaultMainActivity . Replace ( ": Activity" , ": global::Example.RemapActivity" ) ;
109+ proj . SetRuntimeIdentifier ( DeviceAbi ) ;
110+ var relativeProjDir = Path . Combine ( "temp" , TestName ) ;
111+ var fullProjDir = Path . Combine ( Root , relativeProjDir ) ;
112+ TestOutputDirectories [ TestContext . CurrentContext . Test . ID ] = fullProjDir ;
113+ var files = proj . Save ( ) ;
114+ proj . Populate ( relativeProjDir , files ) ;
115+ proj . CopyNuGetConfig ( relativeProjDir ) ;
116+ var dotnet = new DotNetCLI ( proj , Path . Combine ( fullProjDir , proj . ProjectFilePath ) ) ;
117+
118+ Assert . IsTrue ( dotnet . Build ( ) , "`dotnet build` should succeed" ) ;
119+ Assert . IsTrue ( dotnet . Run ( ) , "`dotnet run` should succeed" ) ;
120+
121+ bool didLaunch = WaitForActivityToStart ( proj . PackageName , "MainActivity" ,
122+ Path . Combine ( fullProjDir , "logcat.log" ) ) ;
123+ Assert . IsTrue ( didLaunch , "MainActivity should have launched!" ) ;
124+ var logcatOutput = File . ReadAllText ( Path . Combine ( fullProjDir , "logcat.log" ) ) ;
125+
126+ StringAssert . Contains (
127+ "RemapActivity.onMyCreate() invoked!" ,
128+ logcatOutput ,
129+ "Activity.onCreate() wasn't remapped to RemapActivity.onMyCreate()!"
130+ ) ;
131+ StringAssert . Contains (
132+ "ViewHelper.mySetOnClickListener() invoked!" ,
133+ logcatOutput ,
134+ "View.setOnClickListener() wasn't remapped to ViewHelper.mySetOnClickListener()!"
135+ ) ;
136+ }
137+
87138 [ Test ]
88139 [ Category ( "Debugger" ) , Category ( "Node-4" ) ]
89140 public void DotNetDebug ( )
@@ -157,57 +208,6 @@ public void DotNetDebug ()
157208 WaitFor ( 2000 ) ;
158209 Assert . IsTrue ( breakpointHit , "Should have a breakpoint" ) ;
159210 }
160-
161- [ Test ]
162- public void TypeAndMemberRemapping ( [ Values ( false , true ) ] bool isRelease )
163- {
164- AssertHasDevices ( ) ;
165-
166- var proj = new XASdkProject ( ) {
167- IsRelease = isRelease ,
168- OtherBuildItems = {
169- new AndroidItem . _AndroidRemapMembers ( "RemapActivity.xml" ) {
170- Encoding = Encoding . UTF8 ,
171- TextContent = ( ) => ResourceData . RemapActivityXml ,
172- } ,
173- new AndroidItem . AndroidJavaSource ( "RemapActivity.java" ) {
174- Encoding = new UTF8Encoding ( encoderShouldEmitUTF8Identifier : false ) ,
175- TextContent = ( ) => ResourceData . RemapActivityJava ,
176- Metadata = {
177- { "Bind" , "True" } ,
178- } ,
179- } ,
180- } ,
181- } ;
182- proj . MainActivity = proj . DefaultMainActivity . Replace ( ": Activity" , ": global::Example.RemapActivity" ) ;
183- proj . SetRuntimeIdentifier ( DeviceAbi ) ;
184- var relativeProjDir = Path . Combine ( "temp" , TestName ) ;
185- var fullProjDir = Path . Combine ( Root , relativeProjDir ) ;
186- TestOutputDirectories [ TestContext . CurrentContext . Test . ID ] = fullProjDir ;
187- var files = proj . Save ( ) ;
188- proj . Populate ( relativeProjDir , files ) ;
189- proj . CopyNuGetConfig ( relativeProjDir ) ;
190- var dotnet = new DotNetCLI ( proj , Path . Combine ( fullProjDir , proj . ProjectFilePath ) ) ;
191-
192- Assert . IsTrue ( dotnet . Build ( ) , "`dotnet build` should succeed" ) ;
193- Assert . IsTrue ( dotnet . Run ( ) , "`dotnet run` should succeed" ) ;
194-
195- bool didLaunch = WaitForActivityToStart ( proj . PackageName , "MainActivity" ,
196- Path . Combine ( fullProjDir , "logcat.log" ) ) ;
197- Assert . IsTrue ( didLaunch , "MainActivity should have launched!" ) ;
198- var logcatOutput = File . ReadAllText ( Path . Combine ( fullProjDir , "logcat.log" ) ) ;
199-
200- StringAssert . Contains (
201- "RemapActivity.onMyCreate() invoked!" ,
202- logcatOutput ,
203- "Activity.onCreate() wasn't remapped to RemapActivity.onMyCreate()!"
204- ) ;
205- StringAssert . Contains (
206- "ViewHelper.mySetOnClickListener() invoked!" ,
207- logcatOutput ,
208- "View.setOnClickListener() wasn't remapped to ViewHelper.mySetOnClickListener()!"
209- ) ;
210- }
211211 }
212212}
213213#endif
0 commit comments