2016-05-26 16:06:52 +03:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
|
|
|
|
|
using WatchKit;
|
|
|
|
|
using Foundation;
|
|
|
|
|
|
|
|
|
|
using NUnit.Framework.Internal.Filters;
|
|
|
|
|
using MonoTouch.NUnit.UI;
|
|
|
|
|
|
|
|
|
|
namespace monotouchtestWatchKitExtension
|
|
|
|
|
{
|
|
|
|
|
[Register ("InterfaceController")]
|
|
|
|
|
public partial class InterfaceController : WKInterfaceController
|
|
|
|
|
{
|
|
|
|
|
WatchOSRunner runner;
|
2016-05-31 20:06:35 +03:00
|
|
|
|
bool running;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
|
|
|
|
|
[Action ("runTests:")]
|
|
|
|
|
partial void RunTests (NSObject obj);
|
|
|
|
|
|
|
|
|
|
[Outlet ("lblStatus")]
|
|
|
|
|
WatchKit.WKInterfaceLabel lblStatus { get; set; }
|
|
|
|
|
|
|
|
|
|
[Outlet ("lblSuccess")]
|
|
|
|
|
WatchKit.WKInterfaceLabel lblSuccess { get; set; }
|
|
|
|
|
|
|
|
|
|
[Outlet ("lblFailed")]
|
|
|
|
|
WatchKit.WKInterfaceLabel lblFailed { get; set; }
|
|
|
|
|
|
|
|
|
|
[Outlet ("lblIgnored")]
|
|
|
|
|
WatchKit.WKInterfaceLabel lblIgnored { get; set; }
|
|
|
|
|
|
|
|
|
|
[Outlet ("lblInconclusive")]
|
|
|
|
|
WatchKit.WKInterfaceLabel lblInconclusive { get; set; }
|
|
|
|
|
|
|
|
|
|
[Outlet ("cmdRun")]
|
|
|
|
|
WatchKit.WKInterfaceButton cmdRun { get; set; }
|
|
|
|
|
|
2016-06-02 13:19:51 +03:00
|
|
|
|
static InterfaceController ()
|
|
|
|
|
{
|
|
|
|
|
ObjCRuntime.Runtime.MarshalManagedException += (object sender, ObjCRuntime.MarshalManagedExceptionEventArgs args) =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine ("Managed exception: {0}", args.Exception);
|
|
|
|
|
};
|
|
|
|
|
ObjCRuntime.Runtime.MarshalObjectiveCException += (object sender, ObjCRuntime.MarshalObjectiveCExceptionEventArgs args) =>
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine ("Objective-C exception: {0}", args.Exception);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-26 16:06:52 +03:00
|
|
|
|
public InterfaceController (IntPtr handle) : base (handle)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Awake (NSObject context)
|
|
|
|
|
{
|
|
|
|
|
base.Awake (context);
|
|
|
|
|
|
|
|
|
|
BeginInvokeOnMainThread (LoadTests);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void LoadTests ()
|
|
|
|
|
{
|
|
|
|
|
runner = new WatchOSRunner ();
|
|
|
|
|
runner.Filter = new NotFilter (new CategoryExpression ("MobileNotWorking,NotOnMac,NotWorking,ValueAdd,CAS,InetAccess,NotWorkingInterpreter").Filter);
|
|
|
|
|
runner.Add (GetType ().Assembly);
|
|
|
|
|
ThreadPool.QueueUserWorkItem ((v) =>
|
|
|
|
|
{
|
|
|
|
|
runner.LoadSync ();
|
|
|
|
|
BeginInvokeOnMainThread (() =>
|
|
|
|
|
{
|
|
|
|
|
lblStatus.SetText (string.Format ("{0} tests", runner.TestCount));
|
|
|
|
|
RenderResults ();
|
|
|
|
|
cmdRun.SetEnabled (true);
|
|
|
|
|
cmdRun.SetHidden (false);
|
|
|
|
|
|
|
|
|
|
runner.AutoRun ();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunTests ()
|
|
|
|
|
{
|
2016-05-31 20:06:35 +03:00
|
|
|
|
if (running) {
|
|
|
|
|
Console.WriteLine ("Already running");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
running = true;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
cmdRun.SetEnabled (false);
|
|
|
|
|
lblStatus.SetText ("Running");
|
|
|
|
|
BeginInvokeOnMainThread (() => {
|
|
|
|
|
runner.Run ();
|
|
|
|
|
|
2016-05-31 20:16:01 +03:00
|
|
|
|
cmdRun.SetEnabled (true);
|
|
|
|
|
lblStatus.SetText ("Done");
|
2016-05-26 16:06:52 +03:00
|
|
|
|
BeginInvokeOnMainThread (RenderResults);
|
2016-05-31 20:06:35 +03:00
|
|
|
|
running = false;
|
2016-05-26 16:06:52 +03:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RenderResults ()
|
|
|
|
|
{
|
|
|
|
|
lblSuccess.SetText (string.Format ("Passed: {0}/{1} {2}%", runner.PassedCount, runner.TestCount, 100 * runner.PassedCount / runner.TestCount));
|
|
|
|
|
lblFailed.SetText (string.Format ("Failed: {0}/{1} {2}%", runner.FailedCount, runner.TestCount, 100 * runner.FailedCount / runner.TestCount));
|
|
|
|
|
lblIgnored.SetText (string.Format ("Ignored: {0}/{1} {2}%", runner.IgnoredCount, runner.TestCount, 100 * runner.IgnoredCount / runner.TestCount));
|
|
|
|
|
lblInconclusive.SetText (string.Format ("Inconclusive: {0}/{1} {2}%", runner.InconclusiveCount, runner.TestCount, 100 * runner.InconclusiveCount / runner.TestCount));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
partial void RunTests (NSObject obj)
|
|
|
|
|
{
|
|
|
|
|
RunTests ();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|