Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Improve Live Dev test reliability #3134

Merged
merged 6 commits into from

2 participants

@redmunds
Collaborator

LiveDevelopment status getting set to STATUS_ACTIVE happens after the Inspector becomes connected, so this is a better event to wait for. This removes the need to blindly wait an extra second just to be safe.

Also, this will detect the case that LiveDevelopment stays in the "Initializing..." state.

@gruehle Signed up to code review

@gruehle gruehle was assigned
@gruehle
Owner

Looks good, and definitely improves the tests. Thanks!

@gruehle gruehle merged commit 604b27f into master
@gruehle gruehle deleted the randy/live-dev-ut branch
@gruehle gruehle referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
3  src/LiveDevelopment/LiveDevelopment.js
@@ -776,6 +776,9 @@ define(function LiveDevelopment(require, exports, module) {
// Register user defined server provider
var userServerProvider = new UserServerProvider();
LiveDevServerManager.registerProvider(userServerProvider, 99);
+
+ // Initialize exports.status
+ _setStatus(STATUS_INACTIVE);
}
function _setServerProvider(serverProvider) {
View
59 test/spec/LiveDevelopment-test.js
@@ -39,7 +39,6 @@ define(function (require, exports, module) {
LiveDevelopment,
LiveDevServerManager,
DOMAgent,
- Inspector,
DocumentManager,
ProjectManager;
@@ -69,21 +68,22 @@ define(function (require, exports, module) {
var localText,
browserText;
- //verify we aren't currently connected
- expect(Inspector.connected()).toBeFalsy();
+ //verify live dev isn't currently active
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_INACTIVE);
runs(function () {
waitsForDone(SpecRunnerUtils.openProjectFiles([htmlFile]), "SpecRunnerUtils.openProjectFiles");
});
- //start the connection
+ //start live dev
runs(function () {
LiveDevelopment.open();
});
- waitsFor(function () { return Inspector.connected(); }, "Waiting for browser", 10000);
// Wait for the file and its stylesheets to fully load (and be communicated back).
- waits(1000);
+ waitsFor(function () {
+ return (LiveDevelopment.status === LiveDevelopment.STATUS_ACTIVE);
+ }, "Waiting for browser to become active", 10000);
runs(function () {
waitsForDone(SpecRunnerUtils.openProjectFiles([cssFile]), "SpecRunnerUtils.openProjectFiles");
@@ -116,7 +116,7 @@ define(function (require, exports, module) {
expect(fixSpaces(browserText)).toBe(fixSpaces(localText));
var doc = DocumentManager.getOpenDocumentForPath(testPath + "/" + htmlFile);
- //expect(isOpenInBrowser(doc, LiveDevelopment.agents)).toBeTruthy();
+ expect(isOpenInBrowser(doc, LiveDevelopment.agents)).toBeTruthy();
});
}
@@ -133,7 +133,6 @@ define(function (require, exports, module) {
LiveDevelopment = testWindow.brackets.test.LiveDevelopment;
LiveDevServerManager = testWindow.brackets.test.LiveDevServerManager;
DOMAgent = testWindow.brackets.test.DOMAgent;
- Inspector = testWindow.brackets.test.Inspector;
DocumentManager = testWindow.brackets.test.DocumentManager;
CommandManager = testWindow.brackets.test.CommandManager;
Commands = testWindow.brackets.test.Commands;
@@ -150,56 +149,60 @@ define(function (require, exports, module) {
LiveDevelopment.close();
});
- waitsFor(function () { return !Inspector.connected(); }, "Waiting to close inspector", 10000);
+ waitsFor(function () {
+ return (LiveDevelopment.status === LiveDevelopment.STATUS_INACTIVE);
+ }, "Waiting for browser to become inactive", 10000);
SpecRunnerUtils.closeTestWindow();
});
it("should establish a browser connection for an opened html file", function () {
- //verify we aren't currently connected
- expect(Inspector.connected()).toBeFalsy();
+ //verify live dev isn't currently active
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_INACTIVE);
//open a file
runs(function () {
waitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.html"]), "SpecRunnerUtils.openProjectFiles");
});
- //start the connection
+ //start live dev
runs(function () {
LiveDevelopment.open();
});
- waitsFor(function () { return Inspector.connected(); }, "Waiting for browser", 10000);
+ waitsFor(function () {
+ return (LiveDevelopment.status === LiveDevelopment.STATUS_ACTIVE);
+ }, "Waiting for browser to become active", 10000);
runs(function () {
- expect(Inspector.connected()).toBeTruthy();
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_ACTIVE);
var doc = DocumentManager.getOpenDocumentForPath(testPath + "/simple1.html");
- //expect(isOpenInBrowser(doc, LiveDevelopment.agents)).toBeTruthy();
+ expect(isOpenInBrowser(doc, LiveDevelopment.agents)).toBeTruthy();
});
- // Let things settle down before trying to close the connection.
+ // Let things settle down before trying to stop live dev.
waits(1000);
});
it("should should not start a browser connection for an opened css file", function () {
- //verify we aren't currently connected
- expect(Inspector.connected()).toBeFalsy();
+ //verify live dev isn't currently active
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_INACTIVE);
//open a file
runs(function () {
waitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.css"]), "SpecRunnerUtils.openProjectFiles");
});
- //start the connection
+ //start live dev
runs(function () {
LiveDevelopment.open();
});
- //we just need to wait an arbitrary time since we can't check for the connection to be true
+ //need to wait an arbitrary time since we can't check for live dev to be active
waits(1000);
runs(function () {
- expect(Inspector.connected()).toBeFalsy();
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_INACTIVE);
var doc = DocumentManager.getOpenDocumentForPath(testPath + "/simple1.css");
expect(isOpenInBrowser(doc, LiveDevelopment.agents)).toBeFalsy();
@@ -218,8 +221,8 @@ define(function (require, exports, module) {
var localText,
browserText;
- //verify we aren't currently connected
- expect(Inspector.connected()).toBeFalsy();
+ //verify live dev isn't currently active
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_INACTIVE);
var cssOpened = false;
runs(function () {
@@ -242,7 +245,7 @@ define(function (require, exports, module) {
waitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.css", "simple1.html"]), "SpecRunnerUtils.openProjectFiles");
});
- //start the connection
+ //start live dev
var liveDoc;
runs(function () {
LiveDevelopment.open();
@@ -275,8 +278,8 @@ define(function (require, exports, module) {
browserHtmlText,
htmlDoc;
- // verify we aren't currently connected
- expect(Inspector.connected()).toBeFalsy();
+ //verify live dev isn't currently active
+ expect(LiveDevelopment.status).toBe(LiveDevelopment.STATUS_INACTIVE);
var cssOpened = false;
runs(function () {
@@ -299,7 +302,7 @@ define(function (require, exports, module) {
waitsForDone(SpecRunnerUtils.openProjectFiles(["simple1.html"]), "SpecRunnerUtils.openProjectFiles");
});
- // Modify some text in test file before starting live connection
+ // Modify some text in test file before starting live dev
runs(function () {
htmlDoc = DocumentManager.getCurrentDocument();
origHtmlText = htmlDoc.getText();
@@ -307,7 +310,7 @@ define(function (require, exports, module) {
htmlDoc.setText(updatedHtmlText);
});
- // start the connection
+ // start live dev
var liveDoc, liveHtmlDoc;
runs(function () {
waitsForDone(LiveDevelopment.open(), "LiveDevelopment.open()", 2000);
Something went wrong with that request. Please try again.