Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 13 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
54 changes: 28 additions & 26 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,42 +151,44 @@ define(function (require, exports, module) {
// in the modules since they would run in context of the unit test window,
// and would not have access to the app html/css.
brackets.test = {
PreferencesManager : PreferencesManager,
ProjectManager : ProjectManager,
CodeHintManager : CodeHintManager,
CodeInspection : CodeInspection,
CommandManager : CommandManager,
Commands : Commands,
CSSUtils : require("language/CSSUtils"),
DefaultDialogs : DefaultDialogs,
Dialogs : Dialogs,
DocumentCommandHandlers : DocumentCommandHandlers,
FileViewController : FileViewController,
DocumentManager : DocumentManager,
DOMAgent : require("LiveDevelopment/Agents/DOMAgent"),
DragAndDrop : DragAndDrop,
EditorManager : EditorManager,
Commands : Commands,
WorkingSetView : WorkingSetView,
PerfUtils : PerfUtils,
JSUtils : JSUtils,
CommandManager : CommandManager,
ExtensionLoader : ExtensionLoader,
ExtensionUtils : ExtensionUtils,
FileFilters : require("search/FileFilters"),
FileSyncManager : FileSyncManager,
FileSystem : FileSystem,
Menus : Menus,
FileViewController : FileViewController,
FindInFiles : require("search/FindInFiles"),
HTMLInstrumentation : require("language/HTMLInstrumentation"),
Inspector : require("LiveDevelopment/Inspector/Inspector"),
InstallExtensionDialog : require("extensibility/InstallExtensionDialog"),
JSUtils : JSUtils,
KeyBindingManager : KeyBindingManager,
CodeHintManager : CodeHintManager,
Dialogs : Dialogs,
DefaultDialogs : DefaultDialogs,
DragAndDrop : DragAndDrop,
CodeInspection : CodeInspection,
CSSUtils : require("language/CSSUtils"),
LanguageManager : LanguageManager,
LiveDevelopment : require("LiveDevelopment/LiveDevelopment"),
LiveDevServerManager : require("LiveDevelopment/LiveDevServerManager"),
DOMAgent : require("LiveDevelopment/Agents/DOMAgent"),
Inspector : require("LiveDevelopment/Inspector/Inspector"),
Menus : Menus,
MultiRangeInlineEditor : require("editor/MultiRangeInlineEditor").MultiRangeInlineEditor,
NativeApp : NativeApp,
ExtensionLoader : ExtensionLoader,
ExtensionUtils : ExtensionUtils,
UpdateNotification : require("utils/UpdateNotification"),
InstallExtensionDialog : require("extensibility/InstallExtensionDialog"),
PerfUtils : PerfUtils,
PreferencesManager : PreferencesManager,
ProjectManager : ProjectManager,
RemoteAgent : require("LiveDevelopment/Agents/RemoteAgent"),
HTMLInstrumentation : require("language/HTMLInstrumentation"),
MultiRangeInlineEditor : require("editor/MultiRangeInlineEditor").MultiRangeInlineEditor,
LanguageManager : LanguageManager,
FindInFiles : require("search/FindInFiles"),
FileFilters : require("search/FileFilters"),
ScrollTrackMarkers : require("search/ScrollTrackMarkers"),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that adding ScrollTrackMarkers was the only logical change here -- the rest was ordering alphabetically to make it easier to see what's in list.

UpdateNotification : require("utils/UpdateNotification"),
WorkingSetView : WorkingSetView,

doneLoading : false
};

Expand Down
3 changes: 2 additions & 1 deletion src/search/FindInFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,7 @@ define(function (require, exports, module) {
CommandManager.register(Strings.CMD_FIND_IN_FILES, Commands.EDIT_FIND_IN_FILES, _doFindInFiles);
CommandManager.register(Strings.CMD_FIND_IN_SUBTREE, Commands.EDIT_FIND_IN_SUBTREE, _doFindInSubtree);

// For unit testing - updated in _doSearch() when search complete
// For unit testing
exports._doFindInFiles = _doFindInFiles;
exports._searchResults = null;
});
18 changes: 13 additions & 5 deletions src/search/ScrollTrackMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,17 @@ define(function (require, exports, module) {
marks = marks.concat(posArray);
_renderMarks(posArray);
}


exports.clear = clear;
exports.setVisible = setVisible;
exports.addTickmarks = addTickmarks;

// Private helper for unit tests
function _getMarks() {
return marks;
}


// For unit tests
exports._getMarks = _getMarks;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: shouldn't we call it _getTickmarks since we have another one called addTickmarks below?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


exports.clear = clear;
exports.setVisible = setVisible;
exports.addTickmarks = addTickmarks;
});
74 changes: 71 additions & 3 deletions test/spec/FileFilters-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ define(function (require, exports, module) {
var testPath = SpecRunnerUtils.getTestPath("/spec/InlineEditorProviders-test-files"),
testWindow,
FileFilters,
FileSystem,
FindInFiles,
CommandManager,
$;
Expand All @@ -438,6 +439,7 @@ define(function (require, exports, module) {

// Load module instances from brackets.test
FileFilters = testWindow.brackets.test.FileFilters;
FileSystem = testWindow.brackets.test.FileSystem;
FindInFiles = testWindow.brackets.test.FindInFiles;
CommandManager = testWindow.brackets.test.CommandManager;
$ = testWindow.$;
Expand All @@ -448,22 +450,23 @@ define(function (require, exports, module) {

afterLast(function () {
testWindow = null;
FileSystem = null;
FileFilters = null;
FindInFiles = null;
CommandManager = null;
$ = null;
SpecRunnerUtils.closeTestWindow();
});

function openSearchBar() {
function openSearchBar(scope) {
// Make sure search bar from previous test has animated out fully
runs(function () {
waitsFor(function () {
return $(".modal-bar").length === 0;
}, "search bar close");
});
runs(function () {
waitsForDone(CommandManager.execute(Commands.EDIT_FIND_IN_FILES));
FindInFiles._doFindInFiles(scope);
});
}

Expand Down Expand Up @@ -506,11 +509,76 @@ define(function (require, exports, module) {
executeSearch("{1}");
});
runs(function () {
expect(FindInFiles._searchResults[testPath + "/test1.css"]).toBeFalsy(); // *.css should have been excluded this time
// *.css should have been excluded this time
expect(FindInFiles._searchResults[testPath + "/test1.css"]).toBeFalsy();
expect(FindInFiles._searchResults[testPath + "/test1.html"]).toBeTruthy();
});
});

it("should respect filter when searching folder", function () {
var dirEntry = FileSystem.getDirectoryForPath(testPath);
openSearchBar(dirEntry);
runs(function () {
setExcludeCSSFiles();
});
runs(function () {
executeSearch("{1}");
});
runs(function () {
// *.css should have been excluded this time
expect(FindInFiles._searchResults[testPath + "/test1.css"]).toBeFalsy();
expect(FindInFiles._searchResults[testPath + "/test1.html"]).toBeTruthy();
});
});

it("should ignore filter when searching a single file", function () {
var fileEntry = FileSystem.getFileForPath(testPath + "/test1.css");
openSearchBar(fileEntry);
runs(function () {
// Cannot explicitly set *.css filter in dialog because button is hidden
// (which is verified here), but filter persists from previous test
expect($(".filter-picker button").is(":visible")).toBeFalsy();
});
runs(function () {
executeSearch("{1}");
});
runs(function () {
// ignore *.css exclusion since we're explicitly searching this file
expect(FindInFiles._searchResults[testPath + "/test1.css"]).toBeTruthy();
});
});

it("should show error when filter excludes all files", function () {
openSearchBar();
runs(function () {
// Launch filter editor
$(".filter-picker button").click();

// Edit the filter & confirm changes
$(".modal.instance textarea").val("test1.*\n*.css");
SpecRunnerUtils.clickDialogButton(Dialogs.DIALOG_BTN_OK);
});
runs(function () {
executeSearch("{1}");
});
runs(function () {
var $modalBar = $(".modal-bar");

// Dialog still showing
expect($modalBar.length).toBe(1);

// Error message displayed
expect($modalBar.find("#find-group div.error").is(":visible")).toBeTruthy();

// Search panel not showing
expect($("#search-results").is(":visible")).toBeFalsy();

// Close search bar
var $searchField = $modalBar.find("#find-group input");
SpecRunnerUtils.simulateKeyEvent(KeyEvent.DOM_VK_ESCAPE, "keydown", $searchField[0]);
});
});

it("should respect filter when editing code", function () {
openSearchBar();
runs(function () {
Expand Down
3 changes: 3 additions & 0 deletions test/spec/FindReplace-test-files/bar.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bar.txt file

This file should *not* show up in certain searches
13 changes: 13 additions & 0 deletions test/spec/FindReplace-test-files/css/foo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* foo.css */
body {
margin: 0;
}
h1, footer {
padding: 2px auto;
}
ul.foo {
list-style: none;
}
.bar {
font-size: large;
}
22 changes: 22 additions & 0 deletions test/spec/FindReplace-test-files/foo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Foo</title>
<link rel="stylesheet" href="css/foo.css">
<script src="foo.js"></script>
</head>

<body>

<h1>Foo</h1>
<p>Intro to foo</p>
<ul class="foo">
<li>foo</li>
<li>bar</li>
<li>baz</li>
</ul>
<p class="bar">It's all about the bar</p>

</body>
</html>
13 changes: 13 additions & 0 deletions test/spec/FindReplace-test-files/foo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Test comment */
define(function (require, exports, module) {
var Foo = require("modules/Foo"),
Bar = require("modules/Bar"),
Baz = require("modules/Baz");

function callFoo() {

foo();

}

}
Loading