mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 04:15:43 +00:00
Bug 1241732
- split browser_projecteditor_rename_file in 2 tests; r=bgrins
--HG-- rename : devtools/client/projecteditor/test/browser_projecteditor_rename_file.js => devtools/client/projecteditor/test/browser_projecteditor_rename_file_01.js
This commit is contained in:
parent
4032e5c5d0
commit
04d7ec73f0
@ -13,7 +13,8 @@ support-files =
|
||||
skip-if = true # Bug 1173950
|
||||
[browser_projecteditor_delete_file.js]
|
||||
skip-if = e10s # Frequent failures in e10s - Bug 1020027
|
||||
[browser_projecteditor_rename_file.js]
|
||||
[browser_projecteditor_rename_file_01.js]
|
||||
[browser_projecteditor_rename_file_02.js]
|
||||
[browser_projecteditor_editing_01.js]
|
||||
[browser_projecteditor_editors_image.js]
|
||||
[browser_projecteditor_external_change.js]
|
||||
|
@ -1,82 +0,0 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test file rename functionality
|
||||
|
||||
add_task(function*() {
|
||||
let projecteditor = yield addProjectEditorTabForTempDirectory();
|
||||
ok(true, "ProjectEditor has loaded");
|
||||
|
||||
let root = [...projecteditor.project.allStores()][0].root;
|
||||
is(root.path, TEMP_PATH, "The root store is set to the correct temp path.");
|
||||
for (let child of root.children) {
|
||||
yield renameWithContextMenu(projecteditor,
|
||||
projecteditor.projectTree.getViewContainer(child),
|
||||
".renamed");
|
||||
}
|
||||
});
|
||||
|
||||
add_task(function*() {
|
||||
let projecteditor = yield addProjectEditorTabForTempDirectory();
|
||||
ok(true, "ProjectEditor has loaded");
|
||||
|
||||
let root = [...projecteditor.project.allStores()][0].root;
|
||||
is(root.path, TEMP_PATH, "The root store is set to the correct temp path.");
|
||||
|
||||
let childrenList = new Array();
|
||||
for (let child of root.children) {
|
||||
yield renameWithContextMenu(projecteditor,
|
||||
projecteditor.projectTree.getViewContainer(child),
|
||||
".ren\u0061\u0308med");
|
||||
childrenList.push(child.basename + ".ren\u0061\u0308med");
|
||||
}
|
||||
for (let child of root.children) {
|
||||
is (childrenList.indexOf(child.basename) == -1, false,
|
||||
"Failed to update tree with non-ascii character");
|
||||
}
|
||||
});
|
||||
|
||||
function openContextMenuOn(node) {
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
node,
|
||||
{button: 2, type: "contextmenu"},
|
||||
node.ownerDocument.defaultView
|
||||
);
|
||||
}
|
||||
|
||||
function renameWithContextMenu(projecteditor, container, newName) {
|
||||
let defer = promise.defer();
|
||||
let popup = projecteditor.contextMenuPopup;
|
||||
let resource = container.resource;
|
||||
info ("Going to attempt renaming for: " + resource.path);
|
||||
|
||||
onPopupShow(popup).then(function () {
|
||||
let renameCommand = popup.querySelector("[command=cmd-rename]");
|
||||
ok (renameCommand, "Rename command exists in popup");
|
||||
is (renameCommand.getAttribute("hidden"), "", "Rename command is visible");
|
||||
is (renameCommand.getAttribute("disabled"), "", "Rename command is enabled");
|
||||
|
||||
projecteditor.project.on("refresh-complete", function refreshComplete() {
|
||||
projecteditor.project.off("refresh-complete", refreshComplete);
|
||||
OS.File.stat(resource.path + newName).then(() => {
|
||||
ok (true, "File is renamed");
|
||||
defer.resolve();
|
||||
}, (ex) => {
|
||||
ok (false, "Failed to rename file");
|
||||
defer.resolve();
|
||||
});
|
||||
});
|
||||
|
||||
renameCommand.click();
|
||||
popup.hidePopup();
|
||||
let input = container.elt.childNodes[0].childNodes[1];
|
||||
input.value = resource.basename + newName;
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, projecteditor.window);
|
||||
});
|
||||
|
||||
openContextMenuOn(container.label);
|
||||
return defer.promise;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test file rename functionality
|
||||
|
||||
add_task(function*() {
|
||||
let projecteditor = yield addProjectEditorTabForTempDirectory();
|
||||
ok(true, "ProjectEditor has loaded");
|
||||
|
||||
let root = [...projecteditor.project.allStores()][0].root;
|
||||
is(root.path, TEMP_PATH, "The root store is set to the correct temp path.");
|
||||
for (let child of root.children) {
|
||||
yield renameWithContextMenu(projecteditor,
|
||||
projecteditor.projectTree.getViewContainer(child), ".renamed");
|
||||
}
|
||||
});
|
@ -0,0 +1,26 @@
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Test file rename functionality with non ascii characters
|
||||
|
||||
add_task(function*() {
|
||||
let projecteditor = yield addProjectEditorTabForTempDirectory();
|
||||
ok(true, "ProjectEditor has loaded");
|
||||
|
||||
let root = [...projecteditor.project.allStores()][0].root;
|
||||
is(root.path, TEMP_PATH, "The root store is set to the correct temp path.");
|
||||
|
||||
let childrenList = [];
|
||||
for (let child of root.children) {
|
||||
yield renameWithContextMenu(projecteditor,
|
||||
projecteditor.projectTree.getViewContainer(child), ".ren\u0061\u0308med");
|
||||
childrenList.push(child.basename + ".ren\u0061\u0308med");
|
||||
}
|
||||
for (let child of root.children) {
|
||||
is(childrenList.indexOf(child.basename) == -1, false,
|
||||
"Failed to update tree with non-ascii character");
|
||||
}
|
||||
});
|
@ -284,6 +284,46 @@ function* getFileData(file) {
|
||||
return def.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rename the resource of the provided container using the context menu.
|
||||
*
|
||||
* @param {ProjectEditor} projecteditor the current project editor instance
|
||||
* @param {Shell} container for the resource to rename
|
||||
* @param {String} newName the name to use for renaming the resource
|
||||
* @return {Promise} a promise that resolves when the resource has been renamed
|
||||
*/
|
||||
var renameWithContextMenu = Task.async(function* (projecteditor,
|
||||
container, newName) {
|
||||
let popup = projecteditor.contextMenuPopup;
|
||||
let resource = container.resource;
|
||||
info("Going to attempt renaming for: " + resource.path);
|
||||
|
||||
let waitForPopupShow = onPopupShow(popup);
|
||||
openContextMenu(container.label);
|
||||
yield waitForPopupShow;
|
||||
|
||||
let renameCommand = popup.querySelector("[command=cmd-rename]");
|
||||
ok(renameCommand, "Rename command exists in popup");
|
||||
is(renameCommand.getAttribute("hidden"), "", "Rename command is visible");
|
||||
is(renameCommand.getAttribute("disabled"), "", "Rename command is enabled");
|
||||
|
||||
renameCommand.click();
|
||||
popup.hidePopup();
|
||||
let input = container.elt.childNodes[0].childNodes[1];
|
||||
input.value = resource.basename + newName;
|
||||
|
||||
let waitForProjectRefresh = onceProjectRefreshed(projecteditor);
|
||||
EventUtils.synthesizeKey("VK_RETURN", {}, projecteditor.window);
|
||||
yield waitForProjectRefresh;
|
||||
|
||||
try {
|
||||
yield OS.File.stat(resource.path + newName);
|
||||
ok(true, "File is renamed");
|
||||
} catch (e) {
|
||||
ok(false, "Failed to rename file");
|
||||
}
|
||||
});
|
||||
|
||||
function onceEditorCreated(projecteditor) {
|
||||
let def = promise.defer();
|
||||
projecteditor.once("onEditorCreated", (editor) => {
|
||||
@ -316,6 +356,15 @@ function onceEditorSave(projecteditor) {
|
||||
return def.promise;
|
||||
}
|
||||
|
||||
function onceProjectRefreshed(projecteditor) {
|
||||
return new Promise(resolve => {
|
||||
projecteditor.project.on("refresh-complete", function refreshComplete() {
|
||||
projecteditor.project.off("refresh-complete", refreshComplete);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function onPopupShow(menu) {
|
||||
let defer = promise.defer();
|
||||
menu.addEventListener("popupshown", function onpopupshown() {
|
||||
@ -333,3 +382,11 @@ function onPopupHidden(menu) {
|
||||
});
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
function openContextMenu(node) {
|
||||
EventUtils.synthesizeMouseAtCenter(
|
||||
node,
|
||||
{button: 2, type: "contextmenu"},
|
||||
node.ownerDocument.defaultView
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user