Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Followup updates to #4581 and #4598 #4629

Merged
merged 3 commits into from
Sep 4, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ define(function (require, exports, module) {
KeyBindingManager : KeyBindingManager,
CodeHintManager : CodeHintManager,
Dialogs : Dialogs,
DefaultDialogs : DefaultDialogs,
CSSUtils : require("language/CSSUtils"),
LiveDevelopment : require("LiveDevelopment/LiveDevelopment"),
LiveDevServerManager : require("LiveDevelopment/LiveDevServerManager"),
Expand Down
5 changes: 3 additions & 2 deletions src/widgets/Dialogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,12 @@ define(function (require, exports, module) {
* Immediately closes any dialog instances with the given class. The dialog callback for each instance will
* be called with the special buttonId DIALOG_CANCELED (note: callback is run asynchronously).
* @param {string} dlgClass The class name identifier for the dialog.
* @param {string=} buttonId The button id to use when closing the dialog. Defaults to DIALOG_CANCELED
*/
function cancelModalDialogIfOpen(dlgClass) {
function cancelModalDialogIfOpen(dlgClass, buttonId) {
$("." + dlgClass + ".instance").each(function () {
if ($(this).is(":visible")) { // Bootstrap breaks if try to hide dialog that's already hidden
_dismissDialog($(this), DIALOG_CANCELED);
_dismissDialog($(this), buttonId || DIALOG_CANCELED);
}
});
}
Expand Down
44 changes: 29 additions & 15 deletions test/spec/SpecRunnerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ define(function (require, exports, module) {
var promise = _testWindow.executeCommand(_testWindow.brackets.test.Commands.FILE_CLOSE_ALL);
waitsForDone(promise, "Close all open files in working set");

var $dlg = _testWindow.$(".modal.instance");
if ($dlg.length) {
clickDialogButton("dontsave");
}
_testWindow.brackets.test.Dialogs.cancelModalDialogIfOpen(
_testWindow.brackets.test.DefaultDialogs.DIALOG_ID_SAVE_CLOSE,
_testWindow.brackets.test.DefaultDialogs.DIALOG_BTN_DONTSAVE
);
});
};
});
Expand Down Expand Up @@ -1036,6 +1036,22 @@ define(function (require, exports, module) {
_addSuiteFunction("afterLast", func);
};

/**
* @private
* Returns an array with the parent suites of the current spec with the top most suite last
* @return {Array.<jasmine.Suite>}
*/
function _getParentSuites() {
var suite = jasmine.getEnv().currentSpec.suite,
suites = [];

while (suite) {
suites.push(suite);
suite = suite.parentSuite;
}
return suites;
}

/**
* @private
* Calls each function in the given array of functions
Expand All @@ -1049,30 +1065,29 @@ define(function (require, exports, module) {
}

/**
* Calls the before first functions for the parent suites of the current spec when is the first spec of each suite.
* Calls the before first functions for the parent suites of the current spec when is the first spec of the suite.
*/
function runBeforeFirst() {
var suite = jasmine.getEnv().currentSpec.suite;
var suites = _getParentSuites().reverse();

// Iterate throught all the parent suites of the current spec
while (suite) {
// Iterate through all the parent suites of the current spec
suites.forEach(function (suite) {
// If we have functions for this suite and it was never called, initialize the spec counter
if (_testSuites[suite.id] && _testSuites[suite.id].specCounter === null) {
_callFunctions(_testSuites[suite.id].beforeFirst);
_testSuites[suite.id].specCounter = countSpecs(suite);
}
suite = suite.parentSuite;
}
});
}

/**
* Calls the after last functions for the parent suites of the current spec when is the last spec of each suite.
* Calls the after last functions for the parent suites of the current spec when is the last spec of the suite.
*/
function runAfterLast() {
var suite = jasmine.getEnv().currentSpec.suite;
var suites = _getParentSuites();

// Iterate throught all the parent suites of the current spec
while (suite) {
suites.forEach(function (suite) {
// If we have functions for this suite, reduce the spec counter
if (_testSuites[suite.id] && _testSuites[suite.id].specCounter > 0) {
_testSuites[suite.id].specCounter--;
Expand All @@ -1083,8 +1098,7 @@ define(function (require, exports, module) {
delete _testSuites[suite.id];
}
}
suite = suite.parentSuite;
}
});
}


Expand Down