Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup functional tests / Structure them like libraries tests #46810

Merged
merged 20 commits into from
Jan 15, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Made iOS work w/ right pinvokes defined
  • Loading branch information
Steve Pfister committed Jan 11, 2021
commit 78c888a2119a9603fcc0c646435998174b9a2bb1
40 changes: 6 additions & 34 deletions src/tests/FunctionalTests/iOS/Simulator/AOT/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,21 @@
using System.Threading.Tasks;
using System.Runtime.InteropServices;

// it's not part of the BCL but runtime needs it for native-to-managed callbacks in AOT
// To be replaced with NativeCallableAttribute
public class MonoPInvokeCallbackAttribute : Attribute
{
public MonoPInvokeCallbackAttribute(Type delegateType) { }
}

public static class Program
{
// Defined in main.m
// to be wired once https://github.com/dotnet/xharness/pull/46 is merged
MaximLipnin marked this conversation as resolved.
Show resolved Hide resolved
[DllImport("__Internal")]
private extern static void ios_set_text(string value);
public extern static void mono_ios_append_output (string value);

[DllImport("__Internal")]
private extern static void ios_register_button_click(Action action);

private static Action buttonClickHandler = null;

private static int counter = 0;

// Called by native code, see main.m
[MonoPInvokeCallback(typeof(Action))]
private static void OnButtonClick()
{
ios_set_text("OnButtonClick! #" + counter++);
}

public extern static void mono_ios_set_summary (string value);

public static async Task<int> Main(string[] args)
{
// Register a managed callback (will be called by UIButton, see main.m)
// Also, keep the handler alive so GC won't collect it.
ios_register_button_click(buttonClickHandler = OnButtonClick);

const string msg = "Hello World!\n.NET 5.0";
for (int i = 0; i < msg.Length; i++)
{
// a kind of an animation
ios_set_text(msg.Substring(0, i + 1));
await Task.Delay(100);
}

mono_ios_set_summary($"Starting functional test");
Console.WriteLine("Done!");
await Task.Delay(5000);

return 42;
}
}
40 changes: 6 additions & 34 deletions src/tests/FunctionalTests/iOS/Simulator/Interpreter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,21 @@
using System.Threading.Tasks;
using System.Runtime.InteropServices;

// it's not part of the BCL but runtime needs it for native-to-managed callbacks in AOT
// To be replaced with NativeCallableAttribute
public class MonoPInvokeCallbackAttribute : Attribute
{
public MonoPInvokeCallbackAttribute(Type delegateType) { }
}

public static class Program
{
// Defined in main.m
// to be wired once https://github.com/dotnet/xharness/pull/46 is merged
MaximLipnin marked this conversation as resolved.
Show resolved Hide resolved
[DllImport("__Internal")]
private extern static void ios_set_text(string value);
public extern static void mono_ios_append_output (string value);

[DllImport("__Internal")]
private extern static void ios_register_button_click(Action action);

private static Action buttonClickHandler = null;

private static int counter = 0;

// Called by native code, see main.m
[MonoPInvokeCallback(typeof(Action))]
private static void OnButtonClick()
{
ios_set_text("OnButtonClick! #" + counter++);
}

public extern static void mono_ios_set_summary (string value);

public static async Task<int> Main(string[] args)
{
// Register a managed callback (will be called by UIButton, see main.m)
// Also, keep the handler alive so GC won't collect it.
ios_register_button_click(buttonClickHandler = OnButtonClick);

const string msg = "Hello World!\n.NET 5.0";
for (int i = 0; i < msg.Length; i++)
{
// a kind of an animation
ios_set_text(msg.Substring(0, i + 1));
await Task.Delay(100);
}

mono_ios_set_summary($"Starting functional test");
Console.WriteLine("Done!");
await Task.Delay(5000);

return 42;
}
}