Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(774)

Unified Diff: chrome/browser/resources/file_manager/background/js/test_util.js

Issue 145813010: Files.app: add test for multi-profile desktop movement menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + review fix Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/file_manager/background/js/test_util.js
diff --git a/chrome/browser/resources/file_manager/background/js/test_util.js b/chrome/browser/resources/file_manager/background/js/test_util.js
index b122d5c1f5bcf2c3d44ec0b7a970ac27b14d0893..075bb3fe09641a0df0540e7c4e1c2169196b2e32 100644
--- a/chrome/browser/resources/file_manager/background/js/test_util.js
+++ b/chrome/browser/resources/file_manager/background/js/test_util.js
@@ -817,6 +817,52 @@ test.util.sync.visitDesktop = function(contentWindow, profileId) {
};
/**
+ * Waits for the 'move to profileId' menu to appear (if waitAppear = true) or
+ * to disappear (if waitAppear = false).
+ *
+ * @param {Window} contentWindow Window to be tested.
+ * @param {string} profileId Destination profile's ID.
+ * @param {boolean} waitAppear Flag for specifying the mode to wait.
+ * @param {function()} callback Callback for notifying the event.
+ */
+test.util.async.waitForVisitDesktopMenu = function(
+ contentWindow, profileId, waitAppear, callback) {
+ test.util.repeatUntilTrue_(function() {
+ var list = contentWindow.document.querySelectorAll('.visit-desktop');
+ for (var i = 0; i < list.length; ++i) {
+ if (list[i].label.indexOf(profileId) != -1) { // found
+ if (waitAppear)
+ callback();
+ return waitAppear;
+ }
+ }
+ if (!waitAppear)
+ callback();
+ return !waitAppear;
+ });
+};
+
+/**
+ * Runs the 'Move to profileId' menu.
+ *
+ * @param {Window} contentWindow Window to be tested.
+ * @param {string} profileId Destination profile's ID.
+ * @return {boolean} True if the menu is found and run.
+ */
+test.util.sync.runVisitDesktopMenu = function(contentWindow, profileId) {
+ var list = contentWindow.document.querySelectorAll('.visit-desktop');
+ for (var i = 0; i < list.length; ++i) {
+ if (list[i].label.indexOf(profileId) != -1) {
+ var activateEvent = contentWindow.document.createEvent('Event');
+ activateEvent.initEvent('activate');
+ list[i].dispatchEvent(activateEvent);
+ return true;
+ }
+ }
+ return false;
+};
+
+/**
* Registers message listener, which runs test utility functions.
*/
test.util.registerRemoteTestUtils = function() {

Powered by Google App Engine
This is Rietveld 408576698