/* * Helper functions for Tree_dnd.html and Tree_dnd_multiParent.html tests */ define([ "doh/runner", "dojo/robotx", "dojo/_base/array", "dojo/dnd/autoscroll", "dojo/dom", "dojo/dom-geometry", "dojo/query", "dojo/_base/window", "dijit/tests/helpers" ], function(doh, robot, array, autoscroll, dom, domGeom, query, win, helpers){ var exports = { setup: function setup(){ doh.register("setup screen", function(){ // Hide boilerplate text so it's easier to drag on small screen query("h1,h2,p", robot.doc).style("display", "none"); // Disable auto-scrolling because otherwise the viewport scrolls as robot.mouseMoveAt() // moves the mouse, literally making the the drop target a moving target // (and mouseMoveAt() doesn't take this possibility into account). autoscroll.autoScrollNodes = function(){}; // Scroll viewport to (try to) make sure that both tree and drag-source // are simultaneously in view. var scroll = domGeom.position(dom.byId("1001", robot.doc)).y; win.body(robot.doc).parentNode.scrollTop = scroll; // works on FF win.body(robot.doc).scrollTop = scroll; // works on safari }); // Wait for trees to load doh.register("wait for load", { name: "wait for load", timeout: 10000, runTest: helpers.waitForLoad }); doh.register("setup vars", function(){ registry = robot.window.require("dijit/registry"); }); }, findTreeNode: function findTreeNode(/*String*/ treeId, /*String*/ label){ // summary: // Find the TreeNode with the specified label in the given tree. // Assumes that there's only one TreeNode w/that label (i.e. it // breaks if certain items have multiple parents and appear in the // tree multiple times) var nodes = query(".dijitTreeLabel", dom.byId(treeId, robot.doc)); for(var i=0; i