Skip to content

Commit

Permalink
Temporarily revert threading changes as it introduce regression for U…
Browse files Browse the repository at this point in the history
…I testing
  • Loading branch information
spouliot committed Nov 29, 2013
1 parent f67a579 commit 430b3da
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 55 deletions.
44 changes: 19 additions & 25 deletions NUnitLite/TouchRunner/TestCaseElement.cs
Expand Up @@ -20,7 +20,6 @@

using System;
using System.Reflection;
using System.Threading;
using MonoTouch.Dialog;
using MonoTouch.UIKit;

Expand All @@ -38,33 +37,28 @@ public TestCaseElement (TestMethod testCase, TouchRunner runner)
Caption = testCase.Name;
Value = "NotExecuted";
this.Tapped += delegate {
ThreadPool.QueueUserWorkItem (delegate {
if (!Runner.OpenWriter (Test.FullName))
return;
if (!Runner.OpenWriter (Test.FullName))
return;

var suite = (testCase.Parent as TestSuite);
var context = TestExecutionContext.CurrentContext;
context.TestObject = Reflect.Construct (testCase.Method.ReflectedType, null);
var suite = (testCase.Parent as TestSuite);
var context = TestExecutionContext.CurrentContext;
context.TestObject = Reflect.Construct (testCase.Method.ReflectedType, null);

suite.GetOneTimeSetUpCommand ().Execute (context);
Run ();
suite.GetOneTimeTearDownCommand ().Execute (context);
suite.GetOneTimeSetUpCommand ().Execute (context);
Run ();
suite.GetOneTimeTearDownCommand ().Execute (context);

Runner.CloseWriter ();

// display more details on (any) failure (but not when ignored)
if ((TestCase.RunState == RunState.Runnable) && !Result.IsSuccess ()) {
Runner.InvokeOnMainThread (() => {
var root = new RootElement ("Results") {
new Section () {
new TestResultElement (Result)
}
};
var dvc = new DialogViewController (root, true) { Autorotate = true };
runner.NavigationController.PushViewController (dvc, true);
});
}
});
Runner.CloseWriter ();
// display more details on (any) failure (but not when ignored)
if ((TestCase.RunState == RunState.Runnable) && !Result.IsSuccess ()) {
var root = new RootElement ("Results") {
new Section () {
new TestResultElement (Result)
}
};
var dvc = new DialogViewController (root, true) { Autorotate = true };
runner.NavigationController.PushViewController (dvc, true);
}
};
}

Expand Down
6 changes: 2 additions & 4 deletions NUnitLite/TouchRunner/TestElement.cs
Expand Up @@ -61,10 +61,8 @@ public void Update (TestResult result)
Update ();

if (GetContainerTableView () != null) {
Runner.InvokeOnMainThread (() => {
var root = GetImmediateRootElement ();
root.Reload (this, UITableViewRowAnimation.Fade);
});
var root = GetImmediateRootElement ();
root.Reload (this, UITableViewRowAnimation.Fade);
}
}

Expand Down
42 changes: 16 additions & 26 deletions NUnitLite/TouchRunner/TouchRunner.cs
Expand Up @@ -38,8 +38,7 @@

namespace MonoTouch.NUnit.UI {

[CLSCompliant (false)]
public class TouchRunner : NSObject, ITestListener {
public class TouchRunner : ITestListener {

UIWindow window;
int passed;
Expand Down Expand Up @@ -151,15 +150,14 @@ public UIViewController GetViewController ()

void Run ()
{
ThreadPool.QueueUserWorkItem (delegate {
if (!OpenWriter ("Run Everything"))
return;
try {
Run (suite);
} finally {
CloseWriter ();
}
});
if (!OpenWriter ("Run Everything"))
return;
try {
Run (suite);
}
finally {
CloseWriter ();
}
}

void Options ()
Expand Down Expand Up @@ -349,19 +347,11 @@ TestSuiteElement Setup (TestSuite suite)
if (section.Count > 1) {
Section options = new Section () {
new StringElement ("Run all", delegate () {
ThreadPool.QueueUserWorkItem (delegate {
if (!OpenWriter (suite.Name))
return;
try {
Run (suite);
}
finally {
CloseWriter ();
InvokeOnMainThread (() => {
suites_dvc [suite].Filter ();
});
}
});
if (OpenWriter (suite.Name)) {
Run (suite);
CloseWriter ();
suites_dvc [suite].Filter ();
}
})
};
root.Add (options);
Expand Down Expand Up @@ -393,11 +383,11 @@ public void TestFinished (ITestResult r)
if (ts != null) {
TestSuiteElement tse;
if (suite_elements.TryGetValue (ts, out tse))
BeginInvokeOnMainThread (() => tse.Update (result));
tse.Update (result);
} else {
TestMethod tc = result.Test as TestMethod;
if (tc != null)
BeginInvokeOnMainThread (() => case_elements [tc].Update (result));
case_elements [tc].Update (result);
}

if (result.Test is TestSuite) {
Expand Down

0 comments on commit 430b3da

Please sign in to comment.