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

Commit 02d02b9

Browse files
committed
Merge pull request #4313 from adobe/randy/unit-test-memory
Unit Test memory cleanup
2 parents 3e42743 + e582d9a commit 02d02b9

24 files changed

Lines changed: 279 additions & 47 deletions

src/extensions/default/JSLint/unittests.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ define(function (require, exports, module) {
5959
});
6060

6161
afterEach(function () {
62+
testWindow = null;
63+
$ = null;
64+
brackets = null;
65+
EditorManager = null;
6266
SpecRunnerUtils.closeTestWindow();
6367
});
6468

src/extensions/default/JavaScriptQuickEdit/unittests.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,12 @@ define(function (require, exports, module) {
189189
//waits(1000);
190190

191191
// revert files to original content with offset markup
192+
initInlineTest = null;
193+
testWindow = null;
194+
EditorManager = null;
195+
CommandManager = null;
196+
FileIndexManager = null;
197+
JSUtils = null;
192198
SpecRunnerUtils.closeTestWindow();
193199
});
194200

@@ -386,15 +392,20 @@ define(function (require, exports, module) {
386392
JSCodeHints = extensionRequire("main");
387393
}
388394

395+
beforeEach(function () {
396+
initInlineTest("test.html");
397+
initJSCodeHints();
398+
});
399+
400+
afterEach(function () {
401+
JSCodeHints = null;
402+
});
389403

390404
it("should see code hint lists in quick editor", function () {
391405
var start = {line: 13, ch: 11 },
392406
testPos = {line: 5, ch: 29},
393407
testEditor;
394408

395-
initInlineTest("test.html");
396-
initJSCodeHints();
397-
398409
runs(function () {
399410
var openQuickEditor = SpecRunnerUtils.toggleQuickEditAtOffset(EditorManager.getCurrentFullEditor(), start);
400411
waitsForDone(openQuickEditor, "Open quick editor");
@@ -416,9 +427,6 @@ define(function (require, exports, module) {
416427
jumpPos = {line: 3, ch: 6},
417428
testEditor;
418429

419-
initInlineTest("test.html");
420-
initJSCodeHints();
421-
422430
runs(function () {
423431
var openQuickEditor = SpecRunnerUtils.toggleQuickEditAtOffset(EditorManager.getCurrentFullEditor(), start);
424432
waitsForDone(openQuickEditor, "Open quick editor");
@@ -445,9 +453,6 @@ define(function (require, exports, module) {
445453
jumpPos = {line: 9, ch: 21},
446454
testEditor;
447455

448-
initInlineTest("test.html");
449-
initJSCodeHints();
450-
451456
runs(function () {
452457
var openQuickEditor = SpecRunnerUtils.toggleQuickEditAtOffset(EditorManager.getCurrentFullEditor(), start);
453458
waitsForDone(openQuickEditor, "Open quick editor");
@@ -480,6 +485,10 @@ define(function (require, exports, module) {
480485
});
481486

482487
afterEach(function () {
488+
testWindow = null;
489+
CommandManager = null;
490+
EditorManager = null;
491+
PerfUtils = null;
483492
SpecRunnerUtils.closeTestWindow();
484493
});
485494

src/extensions/default/QuickView/unittests.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -392,20 +392,27 @@ define(function (require, exports, module) {
392392
checkImagePathAtPos("img/Gradient.png", 154, 80); // url()
393393
checkImagePathAtPos("img/Gradient.png", 155, 80); // ""
394394
});
395+
});
396+
397+
it("Should show image preview for a data URI inside url()", function () {
398+
runs(function () {
399+
checkImageDataAtPos("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAABq0lEQVQoU11RPUgcURD+Zt/unnrcCf4QIugRMcS7a2xjmmArRlRIFRBFgrVtGgmBRFCwTBoLsQiBGMxiJ4iksLRSFEzQRC2EAwm5g727feP3LpyFy1tm5s33zcz7RnDvG4x0zFgMJRY/jiewhy/w8FKSJkyaTuG7Fumvi+ARbQiLpcMDvH/Qj1S6Bf6vI5SxKPUG4fGm5kMf6wr08MKHILCKldoZlk0OIeuHjNuDBBcNAqvvENTLwKii1ZFoF/7G2PQDpNo8dFUt1AcSGfymz42PVfI8ghxht1bHh9MpucCiegMFdJoUOtSD+MxLPtI5T/GaHWhg+NjRk3G5utPikwb5bjzhq40JSChs6Sx1eOYAojg/fCFv7yvnBLGCLPMqxS2dZrtXnDthhySuYebnpFw3ST2RtmUVIx5z1sIKdX9qgDcOTJAj7WsNa8eTUhrY0Gwqg2FldeZiduH5r9JHvqEDigzDS/4VJvYJfMh9VLmbNO9+s9hNg5D/qjkJ8I6uW0yFtkrwHydCg+AhVgsp/8Pnu00XI+0jYJ7gjANRiEsmQ3aNOXuJhG035i1QA6g+uONCrgAAAABJRU5ErkJggg==", 159, 26);
400+
});
395401

396402
// This must be in the last spec in the suite.
397403
runs(function () {
398404
this.after(function () {
405+
testWindow = null;
406+
brackets = null;
407+
CommandManager = null;
408+
Commands = null;
409+
EditorManager = null;
410+
extensionRequire = null;
411+
QuickView = null;
399412
SpecRunnerUtils.closeTestWindow();
400413
});
401414
});
402415
});
403-
404-
it("Should show image preview for a data URI inside url()", function () {
405-
runs(function () {
406-
checkImageDataAtPos("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAABq0lEQVQoU11RPUgcURD+Zt/unnrcCf4QIugRMcS7a2xjmmArRlRIFRBFgrVtGgmBRFCwTBoLsQiBGMxiJ4iksLRSFEzQRC2EAwm5g727feP3LpyFy1tm5s33zcz7RnDvG4x0zFgMJRY/jiewhy/w8FKSJkyaTuG7Fumvi+ARbQiLpcMDvH/Qj1S6Bf6vI5SxKPUG4fGm5kMf6wr08MKHILCKldoZlk0OIeuHjNuDBBcNAqvvENTLwKii1ZFoF/7G2PQDpNo8dFUt1AcSGfymz42PVfI8ghxht1bHh9MpucCiegMFdJoUOtSD+MxLPtI5T/GaHWhg+NjRk3G5utPikwb5bjzhq40JSChs6Sx1eOYAojg/fCFv7yvnBLGCLPMqxS2dZrtXnDthhySuYebnpFw3ST2RtmUVIx5z1sIKdX9qgDcOTJAj7WsNa8eTUhrY0Gwqg2FldeZiduH5r9JHvqEDigzDS/4VJvYJfMh9VLmbNO9+s9hNg5D/qjkJ8I6uW0yFtkrwHydCg+AhVgsp/8Pnu00XI+0jYJ7gjANRiEsmQ3aNOXuJhG035i1QA6g+uONCrgAAAABJRU5ErkJggg==", 159, 26);
407-
});
408-
});
409416
});
410417
});
411418
});

src/extensions/default/StaticServer/unittests.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,10 @@ define(function (require, exports, module) {
539539
});
540540

541541
afterEach(function () {
542+
brackets = null;
543+
ProjectManager = null;
544+
extensionRequire = null;
545+
StaticServer = null;
542546
SpecRunnerUtils.closeTestWindow();
543547
});
544548

test/perf/Performance-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ define(function (require, exports, module) {
8888
});
8989

9090
afterEach(function () {
91+
testWindow = null;
92+
CommandManager = null;
93+
Commands = null;
94+
DocumentCommandHandlers = null;
95+
DocumentManager = null;
96+
PerfUtils = null;
9197
SpecRunnerUtils.closeTestWindow();
9298
});
9399

test/spec/CSSUtils-test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,6 +1379,7 @@ define(function (require, exports, module) {
13791379
});
13801380
});
13811381
afterEach(function () {
1382+
CSSUtils = null;
13821383
SpecRunnerUtils.closeTestWindow();
13831384
});
13841385

@@ -1424,6 +1425,11 @@ define(function (require, exports, module) {
14241425
});
14251426

14261427
afterEach(function () {
1428+
brackets = null;
1429+
CSSUtils = null;
1430+
DocumentManager = null;
1431+
FileViewController = null;
1432+
ProjectManager = null;
14271433
SpecRunnerUtils.closeTestWindow();
14281434
});
14291435

@@ -1450,6 +1456,8 @@ define(function (require, exports, module) {
14501456
// Look for ".FIRSTGRADE"
14511457
CSSUtils.findMatchingRules(".FIRSTGRADE")
14521458
.done(function (result) { rules = result; });
1459+
1460+
doc = null;
14531461
});
14541462

14551463
waitsFor(function () { return rules !== null; }, "CSSUtils.findMatchingRules() timeout", 1000);
@@ -1484,6 +1492,8 @@ define(function (require, exports, module) {
14841492
// Look for the selector we just created
14851493
CSSUtils.findMatchingRules(".TESTSELECTOR")
14861494
.done(function (result) { rules = result; });
1495+
1496+
doc = null;
14871497
});
14881498

14891499
waitsFor(function () { return rules !== null; }, "CSSUtils.findMatchingRules() timeout", 1000);

test/spec/CodeHint-test.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ define(function (require, exports, module) {
8181
});
8282

8383
afterEach(function () {
84+
initCodeHintTest = null;
85+
testWindow = null;
86+
CodeHintManager = null;
87+
EditorManager = null;
88+
CommandManager = null;
89+
KeyBindingManager = null;
8490
SpecRunnerUtils.closeTestWindow();
8591
});
8692

@@ -213,12 +219,13 @@ define(function (require, exports, module) {
213219

214220
// and popup should auto-close
215221
expectNoHints();
222+
223+
editor = null;
216224
});
217225
});
218226

219227
it("should dismiss code hints menu with Esc key", function () {
220-
var editor,
221-
pos = {line: 3, ch: 1};
228+
var pos = {line: 3, ch: 1};
222229

223230
// minimal markup with an open '<' before IP
224231
// Note: line for pos is 0-based and editor lines numbers are 1-based
@@ -267,6 +274,8 @@ define(function (require, exports, module) {
267274

268275
// verify list is no longer open
269276
expectNoHints();
277+
278+
editor = null;
270279
});
271280
});
272281

@@ -308,8 +317,9 @@ define(function (require, exports, module) {
308317
// to move this expectNoHints() up after the click.
309318
expectNoHints();
310319
expect(editor.document.getText()).toEqual(text);
320+
321+
editor = null;
311322
});
312-
313323
});
314324
});
315325
});

test/spec/Document-test.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ define(function (require, exports, module) {
5757
});
5858

5959
afterEach(function () {
60+
testWindow = null;
61+
CommandManager = null;
62+
Commands = null;
63+
EditorManager = null;
64+
DocumentManager = null;
6065
SpecRunnerUtils.closeTestWindow();
6166
});
6267

@@ -118,8 +123,9 @@ define(function (require, exports, module) {
118123
expect(cssDoc._masterEditor).toBeFalsy();
119124
expect(testWindow.$(".CodeMirror").length).toBe(2); // HTML editor (working set) & JS editor (current)
120125
});
126+
127+
cssDoc = cssMasterEditor = null;
121128
});
122-
123129
});
124130
});
125131
});

test/spec/DocumentCommandHandlers-test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ define(function (require, exports, module) {
6262
});
6363

6464
afterEach(function () {
65+
testWindow = null;
66+
CommandManager = null;
67+
Commands = null;
68+
DocumentCommandHandlers = null;
69+
DocumentManager = null;
6570
SpecRunnerUtils.closeTestWindow();
6671
});
6772

test/spec/EditorCommandHandlers-test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ define(function (require, exports, module) {
138138
if ($dlg.length) {
139139
SpecRunnerUtils.clickDialogButton("dontsave");
140140
}
141+
$dlg = null;
141142
});
142143
}
143144

@@ -146,7 +147,10 @@ define(function (require, exports, module) {
146147
runs(function () {
147148
this.after(function () {
148149
SpecRunnerUtils.closeTestWindow();
149-
testWindow = null;
150+
testWindow = null;
151+
CommandManager = null;
152+
Commands = null;
153+
EditorManager = null;
150154
});
151155
});
152156
}

0 commit comments

Comments
 (0)