public override IAsyncOperation Refresh () { AsyncOperation oper = new AsyncOperation (); System.Threading.ThreadPool.QueueUserWorkItem (delegate { lock (locker) { try { while (Status == TestStatus.Loading) { Monitor.Wait (locker); } if (RefreshRequired) { lastAssemblyTime = GetAssemblyTime (); UpdateTests (); OnCreateTests (); // Force loading while (Status == TestStatus.Loading) { Monitor.Wait (locker); } } oper.SetCompleted (true); } catch { oper.SetCompleted (false); } } }); return oper; }
// Forces the reloading of tests, if they have changed public virtual IAsyncOperation Refresh () { AsyncOperation op = new AsyncOperation (); op.SetCompleted (true); return op; }
internal IAsyncOperation RunTest (UnitTest test, IExecutionHandler context, bool buildOwnerObject, bool checkCurrentRunOperation) { string testName = test.FullName; if (buildOwnerObject) { IBuildTarget bt = test.OwnerObject as IBuildTarget; if (bt != null && bt.NeedsBuilding (IdeApp.Workspace.ActiveConfiguration)) { if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) { MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations (); IdeApp.ProjectOperations.CurrentRunOperation.WaitForCompleted (); } AsyncOperation retOper = new AsyncOperation (); IAsyncOperation op = IdeApp.ProjectOperations.Build (bt); retOper.TrackOperation (op, false); op.Completed += delegate { // The completed event of the build operation is run in the gui thread, // so we need a new thread, because refreshing must be async System.Threading.ThreadPool.QueueUserWorkItem (delegate { if (op.Success) { RefreshTests (); test = SearchTest (testName); if (test != null) { Gtk.Application.Invoke (delegate { // RunTest must run in the gui thread retOper.TrackOperation (RunTest (test, context, false), true); }); } else retOper.SetCompleted (false); } }); }; return retOper; } } if (checkCurrentRunOperation && !IdeApp.ProjectOperations.ConfirmExecutionOperation ()) return NullProcessAsyncOperation.Failure; Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>(); if (resultsPad == null) { resultsPad = IdeApp.Workbench.ShowPad (new TestResultsPad (), "MonoDevelop.NUnit.TestResultsPad", GettextCatalog.GetString ("Test results"), "Bottom", "md-solution"); } // Make the pad sticky while the tests are runnig, so the results pad is always visible (even if minimized) // That's required since when running in debug mode, the layout is automatically switched to debug. resultsPad.Sticky = true; resultsPad.BringToFront (); TestSession session = new TestSession (test, context, (TestResultsPad) resultsPad.Content); session.Completed += delegate { Gtk.Application.Invoke (delegate { resultsPad.Sticky = false; }); }; OnTestSessionStarting (new TestSessionEventArgs { Session = session, Test = test }); session.Start (); if (checkCurrentRunOperation) IdeApp.ProjectOperations.CurrentRunOperation = session; return session; }
public IAsyncOperation RunTest (UnitTest test, IExecutionHandler context, bool buildOwnerObject) { string testName = test.FullName; if (buildOwnerObject) { IBuildTarget bt = test.OwnerObject as IBuildTarget; if (bt != null && bt.NeedsBuilding (IdeApp.Workspace.ActiveConfiguration)) { if (!IdeApp.ProjectOperations.CurrentRunOperation.IsCompleted) { MonoDevelop.Ide.Commands.StopHandler.StopBuildOperations (); IdeApp.ProjectOperations.CurrentRunOperation.WaitForCompleted (); } AsyncOperation retOper = new AsyncOperation (); IAsyncOperation op = IdeApp.ProjectOperations.Build (bt); retOper.TrackOperation (op, false); op.Completed += delegate { // The completed event of the build operation is run in the gui thread, // so we need a new thread, because refreshing must be async System.Threading.ThreadPool.QueueUserWorkItem (delegate { if (op.Success) { RefreshTests (); test = SearchTest (testName); if (test != null) { Gtk.Application.Invoke (delegate { // RunTest must run in the gui thread retOper.TrackOperation (RunTest (test, context, false), true); }); } else retOper.SetCompleted (false); } }); }; return retOper; } } Pad resultsPad = IdeApp.Workbench.GetPad <TestResultsPad>(); if (resultsPad == null) { resultsPad = IdeApp.Workbench.ShowPad (new TestResultsPad (), "MonoDevelop.NUnit.TestResultsPad", GettextCatalog.GetString ("Test results"), "Bottom", "md-solution"); } resultsPad.BringToFront (); TestSession session = new TestSession (test, context, (TestResultsPad) resultsPad.Content); session.Start (); return session; }