Skip to content

Commit a49128a

Browse files
committed
Port 'JcwGen-Tests' to .NET.
1 parent 0b1fb83 commit a49128a

7 files changed

Lines changed: 96 additions & 175 deletions

File tree

build-tools/automation/azure-pipelines.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,26 @@ stages:
204204
extraBuildArgs: -p:TestsFlavor=AotLlvm -p:EnableLLVM=true -p:AndroidEnableProfiledAot=false
205205
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Mono.Android.NET_Tests-Signed.aab
206206
artifactFolder: $(DotNetTargetFramework)-AotLlvm
207+
208+
- template: yaml-templates/apk-instrumentation.yaml
209+
parameters:
210+
configuration: $(XA.Build.Configuration)
211+
testName: Xamarin.Android.JcwGen_Tests
212+
project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
213+
testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests-$(XA.Build.Configuration).xml
214+
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk
215+
artifactFolder: $(DotNetTargetFramework)-Default
207216

217+
- template: yaml-templates/apk-instrumentation.yaml
218+
parameters:
219+
configuration: $(XA.Build.Configuration)
220+
testName: Xamarin.Android.JcwGen_Tests_FastDev
221+
project: tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.csproj
222+
testResultsFiles: TestResult-Xamarin.Android.JcwGen_Tests_FastDev-$(XA.Build.Configuration).xml
223+
artifactSource: bin/Test$(XA.Build.Configuration)/$(DotNetTargetFramework)-android/Xamarin.Android.JcwGen_Tests-Signed.apk
224+
artifactFolder: $(DotNetTargetFramework)-FastDev_Assemblies_Dexes
225+
extraBuildArgs: /p:AndroidFastDeploymentType=Assemblies:Dexes
226+
208227
- template: yaml-templates/run-nunit-tests.yaml
209228
parameters:
210229
testRunTitle: Xamarin.Android.Tools.Aidl-Tests - macOS

tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/BindingTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public void TestTimingCreateTimingIsCorrectType ()
2020
Assert.IsTrue (t is Com.Xamarin.Android.Timing);
2121
}
2222

23+
#if TODO_7794
2324
[Test]
2425
public void TestResourceId ()
2526
{
@@ -37,6 +38,7 @@ public void TestNativeLibDllImportInEmbeddedArchive ()
3738
{
3839
Assert.AreEqual (TestNativeLib.Binding.SampleFunction2 (), 0xf200);
3940
}
41+
#endif // TODO_7794
4042

4143
[Test]
4244
public void NamespaceTransforms ()
@@ -178,6 +180,9 @@ public void VirtualMethodBinding ()
178180
}
179181
}
180182

183+
#if TODO_7794
184+
// This test requires that https://github.com/xamarin/xamarin-android/issues/7794
185+
// be completed first, as it depends on Xamarin.Android.FixJavaAbstractMethod* projects.
181186
[Test]
182187
public void JavaAbstractMethodTest ()
183188
{
@@ -202,6 +207,7 @@ public void JavaAbstractMethodTest ()
202207
if (mi != null && mi.GetMethodBody ().LocalVariables.Count == 0)
203208
throw new Exception ("FixAbstractMethodStep broken, MethodWithRT added, while it should not be");
204209
}
210+
#endif // TODO_7794
205211

206212
// Context https://bugzilla.xamarin.com/show_bug.cgi?id=36036
207213
[Test]

tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<metadata>
2+
<!-- Change Bxc4288.useColors() method to take and return Android.Graphics.Color -->
3+
<attr
4+
path="/api/package[@name='com.xamarin.android']/class[@name='Bxc4288']/method[@name='useColors']"
5+
name="return"
6+
>Android.Graphics.Color</attr>
7+
<attr
8+
path="/api/package[@name='com.xamarin.android']/class[@name='Bxc4288']/method[@name='useColors']/parameter[1]"
9+
name="type"
10+
>Android.Graphics.Color</attr>
11+
12+
<!-- Interface method parameters names are lost -->
13+
<attr path="/api/package[@name='com.xamarin.android']/interface[@name='DataListener']/method[@name='onDataReceived']/parameter[1]" name="managedName">fromNode</attr>
14+
<attr path="/api/package[@name='com.xamarin.android']/interface[@name='DataListener']/method[@name='onDataReceived']/parameter[2]" name="managedName">fromChannel</attr>
15+
<attr path="/api/package[@name='com.xamarin.android']/interface[@name='DataListener']/method[@name='onDataReceived']/parameter[3]" name="managedName">payloadType</attr>
16+
<attr path="/api/package[@name='com.xamarin.android']/interface[@name='DataListener']/method[@name='onDataReceived']/parameter[4]" name="managedName">payload</attr>
17+
</metadata>
Lines changed: 54 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,75 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
33
<PropertyGroup>
4-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6-
<ProductVersion>10.0.0</ProductVersion>
7-
<SchemaVersion>2.0</SchemaVersion>
8-
<ProjectGuid>{9479B71F-19FE-48F9-AB3F-AE764D76038A}</ProjectGuid>
9-
<ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
10-
<OutputType>Library</OutputType>
4+
<TargetFramework>$(DotNetAndroidTargetFramework)</TargetFramework>
5+
<SupportedOSPlatformVersion>24</SupportedOSPlatformVersion>
6+
<OutputType>Exe</OutputType>
7+
<Nullable>enable</Nullable>
8+
<ImplicitUsings>enable</ImplicitUsings>
9+
<ApplicationId>Xamarin.Android.JcwGen_Tests</ApplicationId>
10+
<ApplicationVersion>1</ApplicationVersion>
11+
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
1112
<RootNamespace>Xamarin.Android.JcwGenTests</RootNamespace>
12-
<AndroidApplication>True</AndroidApplication>
13-
<AndroidResgenFile>Resources\Resource.designer.cs</AndroidResgenFile>
14-
<AndroidResgenClass>Resource</AndroidResgenClass>
15-
<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix>
16-
<MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
17-
<AssemblyName>Xamarin.Android.JcwGen-Tests</AssemblyName>
18-
<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>
19-
<AndroidSupportedAbis>armeabi-v7a;x86</AndroidSupportedAbis>
2013
</PropertyGroup>
14+
2115
<Import Project="..\..\..\Configuration.props" />
16+
2217
<PropertyGroup>
23-
<TargetFrameworkVersion>$(AndroidFrameworkVersion)</TargetFrameworkVersion>
18+
<OutputPath>..\..\..\bin\Test$(Configuration)</OutputPath>
2419
</PropertyGroup>
25-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
26-
<DebugSymbols>true</DebugSymbols>
27-
<Optimize>false</Optimize>
28-
<OutputPath>..\..\..\bin\TestDebug</OutputPath>
29-
<DefineConstants>DEBUG;</DefineConstants>
30-
<ErrorReport>prompt</ErrorReport>
31-
<WarningLevel>4</WarningLevel>
32-
<AndroidLinkMode>None</AndroidLinkMode>
33-
<ConsolePause>false</ConsolePause>
34-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
35-
</PropertyGroup>
36-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
37-
<Optimize>true</Optimize>
38-
<OutputPath>..\..\..\bin\TestRelease</OutputPath>
39-
<ErrorReport>prompt</ErrorReport>
40-
<WarningLevel>4</WarningLevel>
41-
<ConsolePause>false</ConsolePause>
42-
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
43-
</PropertyGroup>
44-
<ItemGroup>
45-
<Reference Include="System" />
46-
<Reference Include="System.Xml" />
47-
<Reference Include="System.Core" />
48-
<Reference Include="Mono.Android" />
49-
<Reference Include="Xamarin.Android.NUnitLite" />
50-
</ItemGroup>
20+
5121
<ItemGroup>
52-
<Compile Include="BindingTests.cs" />
53-
<Compile Include="KotlinUnsignedTypesTests.cs" />
54-
<Compile Include="DimBindingTests.cs" />
55-
<Compile Include="ExceptionTests.cs" />
56-
<Compile Include="MainActivity.cs" />
57-
<Compile Include="TestInstrumentation.cs" />
58-
<Compile Include="TimingTests.cs" />
59-
<Compile Include="TypeWithUnicodeCharacters.cs" />
60-
<Compile Include="Resources\Resource.designer.cs" />
61-
<Compile Include="Properties\AssemblyInfo.cs" />
22+
<AndroidJavaSource Include="../Xamarin.Android.McwGen-Tests/java/**/*.java" />
23+
<Compile Remove="TimingTests.cs" />
24+
<AndroidLibrary Include="../Xamarin.Android.McwGen-Tests/Jars/KotlinUnsignedTypes.jar" />
25+
<None Remove="Java\DefaultMethodsInterface.java" />
26+
<None Remove="Java\StaticMethodsInterface.java" />
6227
</ItemGroup>
28+
6329
<ItemGroup>
64-
<AndroidEnvironment Include="Environment.txt" />
30+
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="1.8.0.1" />
6531
</ItemGroup>
32+
6633
<ItemGroup>
67-
<None Include="Resources\AboutResources.txt" />
68-
<None Include="Assets\AboutAssets.txt" />
69-
<None Include="Properties\AndroidManifest.xml" />
34+
<ProjectReference Include="..\..\..\src\Xamarin.Android.NUnitLite\Xamarin.Android.NUnitLite.NET.csproj" />
7035
</ItemGroup>
36+
7137
<ItemGroup>
72-
<AndroidResource Include="Resources\drawable\Icon.png" />
38+
<AndroidNamespaceReplacement Include="xamarin.example" Replacement="Example" />
39+
<AndroidNamespaceReplacement Include="com.example" Replacement="Transformed.Namespace" />
7340
</ItemGroup>
74-
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
75-
<Import Project="Xamarin.Android.JcwGen-Tests.targets" />
41+
7642
<PropertyGroup>
77-
<BuildDependsOn>
78-
BuildNativeLibs;
79-
$(BuildDependsOn)
80-
</BuildDependsOn>
43+
<_PackageName>$(ApplicationId)</_PackageName>
8144
</PropertyGroup>
82-
<ItemGroup>
83-
<AndroidNativeLibrary Include="libs\arm64-v8a\libtiming.so" />
84-
<AndroidNativeLibrary Include="libs\armeabi-v7a\libtiming.so" />
85-
<AndroidNativeLibrary Include="libs\x86\libtiming.so" />
86-
<AndroidNativeLibrary Include="libs\x86_64\libtiming.so" />
87-
</ItemGroup>
88-
<PropertyGroup>
89-
<CleanDependsOn>
90-
$(CleanDependsOn);
91-
CleanLocal;
92-
</CleanDependsOn>
45+
46+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
47+
<EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
9348
</PropertyGroup>
49+
9450
<ItemGroup>
95-
<AndroidJavaLibrary Include="..\Xamarin.Android.FixJavaAbstractMethod-APIv2Binding\Jars\Cursor.jar">
96-
<Link>Jars\Cursor.jar</Link>
97-
</AndroidJavaLibrary>
51+
<TestApk Include="$(OutputPath)$(ApplicationId)-Signed.apk">
52+
<Package>$(ApplicationId)</Package>
53+
<TimingDefinitionsFilename>$(MSBuildThisFileDirectory)..\..\..\build-tools\scripts\TimingDefinitions.txt</TimingDefinitionsFilename>
54+
<TimingResultsFilename>$(MSBuildThisFileDirectory)..\..\..\TestResult-Xamarin.Android.JcwGen_Tests-times.csv</TimingResultsFilename>
55+
</TestApk>
9856
</ItemGroup>
57+
9958
<ItemGroup>
100-
<ProjectReference Include="..\Xamarin.Android.FixJavaAbstractMethod-APIv2Binding\Xamarin.Android.FixJavaAbstractMethod-APIv2Binding.csproj">
101-
<Project>{7B9D9F32-973F-49CF-A8F8-05BDFC75556C}</Project>
102-
<Name>Xamarin.Android.FixJavaAbstractMethod-APIv2Binding</Name>
103-
</ProjectReference>
104-
<ProjectReference Include="..\Xamarin.Android.FixJavaAbstractMethod-Library\Xamarin.Android.FixJavaAbstractMethod-Library.csproj">
105-
<Project>{B7476528-C166-40BF-931F-EAEB02247879}</Project>
106-
<Name>Xamarin.Android.FixJavaAbstractMethod-Library</Name>
107-
</ProjectReference>
108-
<ProjectReference Include="..\Xamarin.Android.LibraryProjectZip-LibBinding\Xamarin.Android.LibraryProjectZip-LibBinding.csproj">
109-
<Project>{9553ED9D-92EA-411B-ADFF-21C5608CCD16}</Project>
110-
<Name>Xamarin.Android.LibraryProjectZip-LibBinding</Name>
111-
</ProjectReference>
112-
<ProjectReference Include="..\Xamarin.Android.McwGen-Tests\Xamarin.Android.McwGen-Tests.csproj">
113-
<Project>{EF798EB3-D639-4E09-9DB0-233E67F727B0}</Project>
114-
<Name>Xamarin.Android.McwGen-Tests</Name>
115-
</ProjectReference>
59+
<TestApkInstrumentation Include="xamarin.android.jcwgentests.TestInstrumentation">
60+
<Package>$(ApplicationId)</Package>
61+
<ResultsPath>$(OutputPath)TestResult-Xamarin.Android.JcwGen_Tests.xml</ResultsPath>
62+
</TestApkInstrumentation>
63+
64+
<TestApkPermission Include="READ_EXTERNAL_STORAGE">
65+
<Package>$(ApplicationId)</Package>
66+
</TestApkPermission>
67+
68+
<TestApkPermission Include="WRITE_EXTERNAL_STORAGE">
69+
<Package>$(ApplicationId)</Package>
70+
</TestApkPermission>
11671
</ItemGroup>
117-
</Project>
72+
73+
<Import Project="..\..\..\build-tools\scripts\TestApks.targets" />
74+
75+
</Project>

tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.projitems

Lines changed: 0 additions & 29 deletions
This file was deleted.

tests/CodeGen-Binding/Xamarin.Android.JcwGen-Tests/Xamarin.Android.JcwGen-Tests.targets

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)