Skip to content

Commit

Permalink
[One .NET] Add Microsoft.Android-Tests unit tests
Browse files Browse the repository at this point in the history
The following general test files and categories have been ignored:

	• Mono.Data.Sqlite/SqliteTests.cs
	• JnienvTest.CreateTypeWithExportedMethods
	• All System.Drawing/TypeConverterTest tests
	• NetworkInterfaces.DotNetInterfacesShouldEqualJavaInterfaces
	• AppDomainTest
	• TimeZoneTest.TestDaylightSavingsTime

The following tests have been ignored due missing
System.Security.Cryptography and/or networking support:

	• XmlReaderPullParserTest.ToLocalJniHandle
	• XmlReaderResourceParserTest.ToLocalJniHandle
	• System.Net/SslTest
	• System.Net/WebSocketTests
  • Loading branch information
pjcollins committed Nov 6, 2020
1 parent b864f93 commit 8b367fd
Show file tree
Hide file tree
Showing 28 changed files with 370 additions and 303 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ packages
TestResult.xml
TestResult-*.xml
TestResult-*.csv
tests/Runtime-Microsoft.Android.Sdk/nuget.config
.vs/
.vscode/
.gradle/
Expand Down
21 changes: 21 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,27 @@ stages:
artifactName: com.companyname.vsandroidapp-Signed.apk
artifactFolder: Default

- task: MSBuild@1
displayName: run Microsoft.Android_Tests
inputs:
solution: tests/Runtime-Microsoft.Android.Sdk/Microsoft.Android-Tests.csproj
configuration: $(ApkTestConfiguration)
msbuildArguments: /t:RunDotNetInstrumentation
continueOnError: true

- script: >
mkdir -p $(Build.ArtifactStagingDirectory)/OneDotNet &&
cp "$(System.DefaultWorkingDirectory)/bin/Test$(ApkTestConfiguration)/net5.0-android/Microsoft.Android_Tests-Signed.apk" "$(Build.ArtifactStagingDirectory)/OneDotNet"
displayName: copy apk/aab
continueOnError: true
- task: PublishTestResults@2
displayName: publish Microsoft.Android_Tests results
inputs:
testResultsFormat: NUnit
testResultsFiles: TestResult-Microsoft.Android_Tests-Release.xml
testRunTitle: Microsoft.Android_Tests

- task: MSBuild@1
displayName: shut down emulator
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ protected override async Task<bool> Execute (Context context)
var dotnetPreviewVersion = context.Properties.GetRequiredValue (KnownProperties.DotNetPreviewVersionFull);
var dotnetTestRuntimeVersion = Configurables.Defaults.DotNetTestRuntimeVersion;

// Delete any custom Microsoft.Android packs that may have been installed by test runs. Other ref/runtime packs will be ignored.
var packsPath = Path.Combine (dotnetPath, "packs");
if (Directory.Exists (packsPath)) {
foreach (var packToRemove in Directory.EnumerateDirectories (packsPath).Where (p => new DirectoryInfo (p).Name.Contains ("Android"))) {
Log.StatusLine ($"Removing Android pack: {packToRemove}");
Utilities.DeleteDirectory (packToRemove);
}
}

// Delete any unnecessary SDKs if they exist.
var sdkPath = Path.Combine (dotnetPath, "sdk");
if (Directory.Exists (sdkPath)) {
Expand Down
4 changes: 2 additions & 2 deletions src-ThirdParty/NUnitLite/Internal/TestExecutionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

using NUnit.Framework.Api;
#if !SILVERLIGHT && !NETCF
#if !SILVERLIGHT && !NETCF && !NET
using System.Runtime.Remoting.Messaging;
#endif

Expand All @@ -53,7 +53,7 @@ namespace NUnit.Framework.Internal
/// object on the top of the stack.
/// </summary>
public class TestExecutionContext
#if !SILVERLIGHT && !NETCF
#if !SILVERLIGHT && !NETCF && !NET
: ILogicalThreadAffinative
#endif
{
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Properties/AssemblyInfo.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ using System.Runtime.CompilerServices;
[assembly: InternalsVisibleTo("Java.Interop-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android-TestsMultiDex, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Mono.Android-TestsAppBundle, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
[assembly: InternalsVisibleTo("Microsoft.Android-Tests, PublicKey=0024000004800000940000000602000000240000525341310004000011000000438ac2a5acfbf16cbd2b2b47a62762f273df9cb2795ceccdf77d10bf508e69e7a362ea7a45455bbf3ac955e1f2e2814f144e5d817efc4c6502cc012df310783348304e3ae38573c6d658c234025821fda87a0be8a0d504df564e2c93b2b878925f42503e9d54dfef9f9586d9e6f38a305769587b1de01f6c0410328b2c9733db")]
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Android.RuntimeTests {
public class XmlReaderPullParserTest {

[Test]
[Category ("DotNetIgnore")] // Missing crypto / networking support.
public void ToLocalJniHandle ()
{
var p = Application.Context.Resources.GetXml (MyResource.Xml.XmlReaderResourceParser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Android.RuntimeTests {
public class XmlReaderResourceParserTest {

[Test]
[Category ("DotNetIgnore")] // Missing crypto / networking support.
public void ToLocalJniHandle ()
{
var p = Application.Context.Resources.GetXml (MyResource.Xml.XmlReaderResourceParser);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<Project>
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
<Import Project="..\..\..\..\Configuration.props" />

<PropertyGroup>
<TargetFramework>net5.0-android</TargetFramework>
<RootNamespace>Java.Interop_Tests</RootNamespace>
<AssemblyName>Java.Interop-Tests</AssemblyName>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\..\..\product.snk</AssemblyOriginatorKeyFile>
<DefineConstants>$(DefineConstants);NO_MARSHAL_MEMBER_BUILDER_SUPPORT</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Mono.Linq.Expressions" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<Compile Include="$(JavaInteropSourceDirectory)\tests\Java.Interop-Tests\**\*.cs" />
<Compile Remove="$(JavaInteropSourceDirectory)\tests\Java.Interop-Tests\Java.Interop\JavaVMFixture.cs" />
<Compile Remove="$(JavaInteropSourceDirectory)\tests\Java.Interop-Tests\Java.Interop\JniReferenceSafeHandleTest.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(XamarinAndroidSourcePath)src\Xamarin.Android.NUnitLite\Xamarin.Android.NUnitLite.NET.csproj" />
<ProjectReference Include="$(JavaInteropSourceDirectory)\src\Java.Interop.GenericMarshaler\Java.Interop.GenericMarshaler.csproj" />
</ItemGroup>

<!-- Import Microsoft.NET.Sdk targets before our targets so we can override build/clean behavior -->
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
<Import Project="Java.Interop-Tests.targets" />

<PropertyGroup>
<BuildDependsOn>
BuildTestJarFile;
_CopyTestJarFiles;
$(BuildDependsOn)
</BuildDependsOn>
</PropertyGroup>

<PropertyGroup>
<CleanDependsOn>
CleanTestJarFile;
$(CleanDependsOn);
CleanLocal;
</CleanDependsOn>
</PropertyGroup>

</Project>
3 changes: 3 additions & 0 deletions src/Mono.Android/Test/Java.Interop/JnienvTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public void SetField_PermitNullValues ()
}

[Test]
[Category ("DotNetIgnore")] // https://github.com/xamarin/xamarin-android/issues/5265
public void CreateTypeWithExportedMethods ()
{
using (var e = new ContainsExportedMethods ()) {
Expand Down Expand Up @@ -453,7 +454,9 @@ public ContainsExportedMethods ()
Constructed = true;
}

#if !NET // https://github.com/xamarin/xamarin-android/issues/5265
[Export]
#endif
public void Exported ()
{
Count++;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk" >

<PropertyGroup>
<TargetFramework>net5.0-android</TargetFramework>
<RootNamespace>Xamarin.Android.RuntimeTests</RootNamespace>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Mono.Android_Test.Library</RootNamespace>
<FileAlignment>512</FileAlignment>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>

<ItemGroup>
<AndroidAsset Include="..\LinkedAssets\linked_text2.txt">
<Link>Assets\linked_text2.txt</Link>
</AndroidAsset>
<AndroidAsset Include="..\LinkedAssets\folder.png">
<Link>Assets\LibAssetSubFolder\folder.png</Link>
</AndroidAsset>
</ItemGroup>

</Project>
1 change: 1 addition & 0 deletions src/Mono.Android/Test/System.Drawing/TypeConverterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
namespace System.Drawing {

[TestFixture]
[NUnit.Framework.Category ("DotNetIgnore")] // https://github.com/xamarin/xamarin-android/issues/5275
public class TypeConverterTest {

[Test]
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Test/System.Net/NetworkInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ bool HardwareAddressesAreEqual (byte[] one, byte[] two)
}

[Test, Category("NetworkInterfaces")]
[Category ("DotNetIgnore")] // https://github.com/dotnet/runtime/issues/35836
public void DotNetInterfacesShouldEqualJavaInterfaces ()
{
List <InterfaceInfo> dotnetInterfaces = GetInfos (MNetworkInterface.GetAllNetworkInterfaces ());
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Test/System.Net/SslTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace System.NetTests {

[TestFixture, Category ("InetAccess")]
[Category ("DotNetIgnore")] // Missing crypto / networking support.
public class SslTest
{
bool ShouldIgnoreException (WebException wex)
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Test/System.Net/WebSocketTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace System.NetTests
public class WebSocketTests
{
[Test, Category ("InetAccess")]
[Category ("DotNetIgnore")] // Missing crypto / networking support.
public void TestSocketConnection()
{
string testMessage = "This is a test!";
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Test/System/AppDomainTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class AppDomainTest {

[Test]
[Category ("HybridAotNotWorking")] // See https://github.com/xamarin/xamarin-android/issues/1536
[Category ("DotNetIgnore")] // System.PlatformNotSupportedException : Secondary AppDomains are not supported on this platform.
public void DateTime_Now_Works ()
{
new Boom().Bang();
Expand Down
1 change: 1 addition & 0 deletions src/Mono.Android/Test/System/TimeZoneTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Xamarin.Android.RuntimeTests
public class TimeZoneTest
{
[Test]
[Category ("DotNetIgnore")] // https://github.com/dotnet/runtime/issues/44358
public void TestDaylightSavingsTime ()
{
using (var jtz = Java.Util.TimeZone.Default) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ static Type GetInnerHandlerType (HttpClient httpClient)
}

[Test]
[Category ("DotNetIgnore")] // Missing crypto / networking support.
public void Sanity_Tls_1_2_Url_WithMonoClientHandlerFails ()
{
var tlsProvider = global::System.Environment.GetEnvironmentVariable ("XA_TLS_PROVIDER");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ public void GetByteArray_ServerError ()
#endif // TODO

[Test]
[Category ("DotNetIgnore")] // Missing crypto / networking support.
public void DisallowAutoRedirect ()
{
var listener = CreateListener (l => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ projects.
<_CreateAarInputs Include="@(AndroidAsset)" />
<_CreateAarInputs Include="@(_AndroidResourceDest)" />
<_CreateAarInputs Include="@(AndroidEnvironment)" />
<_CreateAarInputs Include="@(AndroidJavaLibrary)" />
<_CreateAarInputs Include="@(EmbeddedJar)" />
<_CreateAarInputs Include="@(EmbeddedNativeLibrary)" />
</ItemGroup>
Expand Down
22 changes: 0 additions & 22 deletions src/Xamarin.Android.NUnitLite/Properties/AssemblyInfo.cs

This file was deleted.

35 changes: 35 additions & 0 deletions src/Xamarin.Android.NUnitLite/Xamarin.Android.NUnitLite.NET.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk" >

<PropertyGroup>
<TargetFramework>net5.0-android</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Xamarin.Android.NUnitLite</RootNamespace>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\..\product.snk</AssemblyOriginatorKeyFile>
<AndroidApplication>false</AndroidApplication>
<NoStdLib>true</NoStdLib>
<!-- Disable XML doc warnings:
CS1570: XML comment has badly formed XML - 'Whitespace is not allowed at this location.'
CS1572: XML comment has a param tag for 'Bar', but there is no parameter by that name
CS1591: Missing XML comment for publicly visible type or member 'Foo'
-->
<NoWarn>1570;1572;1591</NoWarn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<Import Project="..\..\build-tools\scripts\MonoAndroidFramework.props" />

<PropertyGroup>
<DebugSymbols>true</DebugSymbols>
<Optimize>false</Optimize>
<OutputPath>..\..\bin\$(Configuration)\lib\xamarin.android\xbuild-frameworks\Microsoft.Android\</OutputPath>
<DefineConstants>$(DefineConstants);NUNITLITE;CLR_4_0;NET_4_5;__MOBILE__;MONOTOUCH</DefineConstants>
<DocumentationFile>$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
<GenerateDocumentation>True</GenerateDocumentation>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\..\src-ThirdParty\NUnitLite\**\*.cs" />
</ItemGroup>

</Project>
Loading

0 comments on commit 8b367fd

Please sign in to comment.