Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Namespace for test related things. | 6 * Namespace for test related things. |
| 7 */ | 7 */ |
| 8 var test = test || {}; | 8 var test = test || {}; |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 810 * @param {Window} contentWindow Window to be tested. | 810 * @param {Window} contentWindow Window to be tested. |
| 811 * @param {string} profileId Destination profile's ID. | 811 * @param {string} profileId Destination profile's ID. |
| 812 * @return {boolean} Always return true. | 812 * @return {boolean} Always return true. |
| 813 */ | 813 */ |
| 814 test.util.sync.visitDesktop = function(contentWindow, profileId) { | 814 test.util.sync.visitDesktop = function(contentWindow, profileId) { |
| 815 contentWindow.chrome.fileBrowserPrivate.visitDesktop(profileId); | 815 contentWindow.chrome.fileBrowserPrivate.visitDesktop(profileId); |
| 816 return true; | 816 return true; |
| 817 }; | 817 }; |
| 818 | 818 |
| 819 /** | 819 /** |
| 820 * Waits for the "move to profileId" menu appears (if waitAppear = true) or | |
|
hirono
2014/02/13 04:53:24
nit: Make the quotations consist with the comment
kinaba
2014/02/13 05:34:33
Done.
| |
| 821 * disappears (if waitAppear = false). | |
| 822 * | |
| 823 * @param {Window} contentWindow Window to be tested. | |
| 824 * @param {string} profileId Destination profile's ID. | |
| 825 * @param {boolean} waitAppear Flag for specifying the mode to wait. | |
| 826 * @param {function()} callback Callback for notifying the event. | |
| 827 */ | |
| 828 test.util.async.waitForVisitDesktopMenu = function( | |
| 829 contentWindow, profileId, waitAppear, callback) { | |
| 830 test.util.repeatUntilTrue_(function() { | |
| 831 var list = contentWindow.document.querySelectorAll('.visit-desktop'); | |
| 832 for (var i = 0; i < list.length; ++i) { | |
| 833 if (list[i].label.indexOf(profileId) != -1) { // found | |
| 834 if (waitAppear) | |
| 835 callback(); | |
| 836 return waitAppear; | |
| 837 } | |
| 838 } | |
| 839 if (!waitAppear) | |
| 840 callback(); | |
| 841 return !waitAppear; | |
| 842 }); | |
| 843 }; | |
| 844 | |
| 845 /** | |
| 846 * Runs the 'Move to profileId' menu. | |
| 847 * | |
| 848 * @param {Window} contentWindow Window to be tested. | |
| 849 * @param {string} profileId Destination profile's ID. | |
| 850 * @return {boolean} True if the menu is found and run. | |
| 851 */ | |
| 852 test.util.sync.runVisitDesktopMenu = function(contentWindow, profileId) { | |
| 853 var list = contentWindow.document.querySelectorAll('.visit-desktop'); | |
| 854 for (var i = 0; i < list.length; ++i) { | |
| 855 if (list[i].label.indexOf(profileId) != -1) { | |
| 856 var activateEvent = contentWindow.document.createEvent('Event'); | |
| 857 activateEvent.initEvent('activate'); | |
| 858 list[i].dispatchEvent(activateEvent); | |
| 859 return true; | |
| 860 } | |
| 861 } | |
| 862 return false; | |
| 863 }; | |
| 864 | |
| 865 /** | |
| 820 * Registers message listener, which runs test utility functions. | 866 * Registers message listener, which runs test utility functions. |
| 821 */ | 867 */ |
| 822 test.util.registerRemoteTestUtils = function() { | 868 test.util.registerRemoteTestUtils = function() { |
| 823 // Register the message listener. | 869 // Register the message listener. |
| 824 var onMessage = chrome.runtime ? chrome.runtime.onMessageExternal : | 870 var onMessage = chrome.runtime ? chrome.runtime.onMessageExternal : |
| 825 chrome.extension.onMessageExternal; | 871 chrome.extension.onMessageExternal; |
| 826 // Return true for asynchronous functions and false for synchronous. | 872 // Return true for asynchronous functions and false for synchronous. |
| 827 onMessage.addListener(function(request, sender, sendResponse) { | 873 onMessage.addListener(function(request, sender, sendResponse) { |
| 828 // Check the sender. | 874 // Check the sender. |
| 829 if (sender.id != test.util.TESTING_EXTENSION_ID) { | 875 if (sender.id != test.util.TESTING_EXTENSION_ID) { |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 860 return false; | 906 return false; |
| 861 } else { | 907 } else { |
| 862 console.error('Invalid function name.'); | 908 console.error('Invalid function name.'); |
| 863 return false; | 909 return false; |
| 864 } | 910 } |
| 865 }); | 911 }); |
| 866 }; | 912 }; |
| 867 | 913 |
| 868 // Register the test utils. | 914 // Register the test utils. |
| 869 test.util.registerRemoteTestUtils(); | 915 test.util.registerRemoteTestUtils(); |
| OLD | NEW |