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

Resizing the player window after testing has finished throws an unhandled exception #11

Open
Strilanc opened this issue Mar 29, 2012 · 0 comments

Comments

@Strilanc
Copy link

After the tests have completed successfully and the test runner has been removed from the stage so the project can run, resizing the flash player's window throws an exception:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at asunit.textui::TestRunner/resizeHandler()[as3\src\asunit\textui\TestRunner.as:84]

The code I'm using to run the tests:

    public function Main() {
        var testing:Task = AllTests.RunShowAsync(this.stage);
        testing.Await(function():void {
            if (!testing.IsFaulted()) init();
        });
    }

package UnitTests {
import asunit.framework.TestResult;
import asunit.framework.TestSuite;
import asunit.textui.TestRunner;
import Async.Task;
import Async.TaskSource;
import Async.TaskUtil;
import flash.display.Stage;
import flash.errors.IllegalOperationError;

public class AllTests extends TestSuite {
    private static var HACKY_LAST_INSTANCE:AllTests;
    public function AllTests() {
        super();

        addTest(new TestAsync());
        //... omitted ...

        HACKY_LAST_INSTANCE = this;
    }
    public static function RunShowAsync(stage : Stage) :Task {
        var r:TaskSource = new TaskSource();
        var testRunner:TestRunner = new TestRunner();
        stage.addChild(testRunner);
        var testResult:TestResult = testRunner.start(AllTests, null, TestRunner.SHOW_TRACE);
        var allTests:AllTests = HACKY_LAST_INSTANCE;

        var queryResultLooper:Function = function():void {
            if (!allTests.getIsComplete()) {
                TaskUtil.Delay(100).Await(queryResultLooper);
                return;
            }
            if (testResult.failureCount() > 0 || testResult.errorCount() > 0) {
                r.SetFault(new IllegalOperationError("Test Failures"));
            } else {
                r.SetResult(null);
                stage.removeChild(testRunner);      
            }
        }
        queryResultLooper();

        return r;
    }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant