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

Side by Side Diff: chrome/browser/resources/file_manager/js/mock_chrome.js

Issue 10832096: Make FileCopyManager work on harness. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/file_manager/js/metrics.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 function MockEventSource() { 5 function MockEventSource() {
6 this.listeners_ = []; 6 this.listeners_ = [];
7 } 7 }
8 8
9 /** 9 /**
10 * Add a listener. 10 * Add a listener.
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 /** 690 /**
691 * @param {string} path Extension-relative path. 691 * @param {string} path Extension-relative path.
692 * @return {string} Usable url. 692 * @return {string} Usable url.
693 */ 693 */
694 getURL: function(path) { 694 getURL: function(path) {
695 if (path.indexOf('external/') == 0) { 695 if (path.indexOf('external/') == 0) {
696 // Trick the volume manager asking for the external file system. 696 // Trick the volume manager asking for the external file system.
697 return path.replace('external/', 'file:///persistent/'); 697 return path.replace('external/', 'file:///persistent/');
698 } 698 }
699 return path || document.location.href; 699 return path || document.location.href;
700 },
701
702 getBackgroundPage: function() {
703 return window;
704 },
705
706 getViews: function() {
707 return [window];
700 } 708 }
701 }; 709 };
702 710
703 /** 711 /**
704 * Mock object for |chrome.test|. 712 * Mock object for |chrome.test|.
705 */ 713 */
706 chrome.test = { 714 chrome.test = {
707 verbose: false, 715 verbose: false,
708 716
709 sendMessage: function(msg) { 717 sendMessage: function(msg) {
710 if (chrome.test.verbose) 718 if (chrome.test.verbose)
711 console.log('chrome.test.sendMessage: ' + msg); 719 console.log('chrome.test.sendMessage: ' + msg);
712 } 720 }
713 }; 721 };
714 722
715 /** 723 /**
716 * Mock object for |chrome.fileBrowserHandler|. 724 * Mock object for |chrome.fileBrowserHandler|.
717 */ 725 */
718 chrome.fileBrowserHandler = { 726 chrome.fileBrowserHandler = {
719 onExecute: new MockEventSource() 727 onExecute: new MockEventSource()
720 }; 728 };
721 729
722 /** 730 /**
731 * Mock object for |chrome.runtime|.
732 */
733 chrome.runtime = {
734 getBackgroundPage: function(callback) {
735 setTimeout(function() {callback(window);}, 0);
736 }
737 };
738
739 /**
723 * Mock object for |chrome.tabs|. 740 * Mock object for |chrome.tabs|.
724 */ 741 */
725 chrome.tabs = { 742 chrome.tabs = {
726 create: function(createOptions) { 743 create: function(createOptions) {
727 window.open(createOptions.url); 744 window.open(createOptions.url);
728 }, 745 },
729 remove: function(id) { 746 remove: function(id) {
730 console.log('tabs.remove(' + id + ')'); 747 console.log('tabs.remove(' + id + ')');
731 }, 748 },
732 getCurrent: function(callback) { 749 getCurrent: function(callback) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
784 801
785 setWindowHeight: function(height) { 802 setWindowHeight: function(height) {
786 this.popup_.style.height = height + 'px'; 803 this.popup_.style.height = height + 'px';
787 }, 804 },
788 805
789 closeWindow: function() { 806 closeWindow: function() {
790 this.popup_.parentNode.removeChild(this.popup_); 807 this.popup_.parentNode.removeChild(this.popup_);
791 this.popup_ = null; 808 this.popup_ = null;
792 } 809 }
793 }; 810 };
794
795 /**
796 * TODO(olege): Remove once a Chrome with this interface available is released.
797 */
798 var v8Intl = (function() {
799
800 var v8Intl = {};
801
802 /**
803 * Constructs v8Intl.DateTimeFormat object given optional locales and options
804 * parameters.
805 *
806 * @constructor
807 * @param {Array?} locales Unused in the mock.
808 * @param {Object} options Unused in the mock.
809 */
810 v8Intl.DateTimeFormat = function(locales, options) {
811 return {
812 format: function(dateValue) {
813 return dateValue.toString();
814 }
815 };
816 };
817
818 /**
819 * @constructor
820 * @param {Array?} locales Unused in the mock.
821 * @param {Object} options Unused in the mock.
822 */
823 v8Intl.Collator = function(locales, options) {
824 return {
825 compare: function(a, b) {
826 if (a > b) return 1;
827 if (a < b) return -1;
828 return 0;
829 }
830 };
831 };
832
833 return v8Intl;
834 }());
OLDNEW
« no previous file with comments | « chrome/browser/resources/file_manager/js/metrics.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698