Commit 634f69c8 authored by yoshiki@chromium.org's avatar yoshiki@chromium.org

[Cleanup] Files.app: Remove 'this' from class methods. #2

In class method (not instance methods), we shouldn't use this because 'this' indicates not "instance" but "class" itself. 

BUG=175657
TEST=Files.app launches. 
TBR=mtomasz@chromium.org, haruki@chromium.org

Review URL: https://chromiumcodereview.appspot.com/12261004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182252 0039d316-1c4b-4281-b951-d872f2087c98
parent 182d98d7
...@@ -20,42 +20,42 @@ var playerTestAPI = { ...@@ -20,42 +20,42 @@ var playerTestAPI = {
* Respond with the path to the current media source. * Respond with the path to the current media source.
*/ */
getSrc: function() { getSrc: function() {
this.respond_(util.extractFilePath(this.getMedia_().src)); playerTestAPI.respond_(util.extractFilePath(playerTestAPI.getMedia_().src));
}, },
/** /**
* Respond with a boolean value, true if the media is playing. * Respond with a boolean value, true if the media is playing.
*/ */
isPlaying: function() { isPlaying: function() {
this.respond_(this.getControls_().isPlaying()); playerTestAPI.respond_(playerTestAPI.getControls_().isPlaying());
}, },
/** /**
* Play the media. * Play the media.
*/ */
play: function() { play: function() {
this.getControls_().play(); playerTestAPI.getControls_().play();
}, },
/** /**
* Pause the playback. * Pause the playback.
*/ */
pause: function() { pause: function() {
this.getControls_().pause(); playerTestAPI.getControls_().pause();
}, },
/** /**
* Respond with a number, duration of the media in seconds. * Respond with a number, duration of the media in seconds.
*/ */
getDuration: function() { getDuration: function() {
this.respond_(this.getMedia_().duration); playerTestAPI.respond_(playerTestAPI.getMedia_().duration);
}, },
/** /**
* Respond with a number, current media position in seconds. * Respond with a number, current media position in seconds.
*/ */
getCurrentTime: function() { getCurrentTime: function() {
this.respond_(this.getMedia_().currentTime); playerTestAPI.respond_(playerTestAPI.getMedia_().currentTime);
}, },
/** /**
...@@ -63,7 +63,7 @@ var playerTestAPI = { ...@@ -63,7 +63,7 @@ var playerTestAPI = {
* @param {number} time Media positions. * @param {number} time Media positions.
*/ */
seekTo: function(time) { seekTo: function(time) {
this.getMedia_().currentTime = time; playerTestAPI.getMedia_().currentTime = time;
}, },
/* Video player-specific methods. /* Video player-specific methods.
...@@ -88,7 +88,7 @@ var playerTestAPI = { ...@@ -88,7 +88,7 @@ var playerTestAPI = {
* Respond with a number, current volume [0..100]. * Respond with a number, current volume [0..100].
*/ */
getVolume: function() { getVolume: function() {
this.respond_(this.getMedia_().volume * 100); playerTestAPI.respond_(playerTestAPI.getMedia_().volume * 100);
}, },
/** /**
...@@ -96,30 +96,31 @@ var playerTestAPI = { ...@@ -96,30 +96,31 @@ var playerTestAPI = {
* @param {number} volume Volume [0..100]. * @param {number} volume Volume [0..100].
*/ */
setVolume: function(volume) { setVolume: function(volume) {
this.respond_(this.getControls_().onVolumeChange_(volume / 100)); playerTestAPI.respond_(
playerTestAPI.getControls_().onVolumeChange_(volume / 100));
}, },
/** /**
* Respond with a boolean, true if the volume is muted. * Respond with a boolean, true if the volume is muted.
*/ */
isMuted: function() { isMuted: function() {
this.respond_(this.getMedia_().volume == 0); playerTestAPI.respond_(playerTestAPI.getMedia_().volume == 0);
}, },
/** /**
* Mute the volume. No-op if already muted. * Mute the volume. No-op if already muted.
*/ */
mute: function() { mute: function() {
if (this.getMedia_().volume != 0) if (playerTestAPI.getMedia_().volume != 0)
this.getControls_().onSoundButtonClick_(); playerTestAPI.getControls_().onSoundButtonClick_();
}, },
/** /**
* Unmute the volume. No-op if not muted. * Unmute the volume. No-op if not muted.
*/ */
unmute: function() { unmute: function() {
if (this.getMedia_().volume == 0) if (playerTestAPI.getMedia_().volume == 0)
this.getControls_().onSoundButtonClick_(); playerTestAPI.getControls_().onSoundButtonClick_();
}, },
/* Audio player-specific methods. */ /* Audio player-specific methods. */
...@@ -141,14 +142,14 @@ var playerTestAPI = { ...@@ -141,14 +142,14 @@ var playerTestAPI = {
* Respond with a current track number, * Respond with a current track number,
*/ */
getTrackNumber: function() { getTrackNumber: function() {
this.respond_(AudioPlayer.instance.currentTrack_); playerTestAPI.respond_(AudioPlayer.instance.currentTrack_);
}, },
/** /**
* Play the next track. * Play the next track.
*/ */
forward: function() { forward: function() {
this.getControls_().onAdvanceClick_(true /* forward */); playerTestAPI.getControls_().onAdvanceClick_(true /* forward */);
}, },
/** /**
...@@ -156,7 +157,7 @@ var playerTestAPI = { ...@@ -156,7 +157,7 @@ var playerTestAPI = {
* or play the previous track otherwise. * or play the previous track otherwise.
*/ */
back: function() { back: function() {
this.getControls_().onAdvanceClick_(false /* back */); playerTestAPI.getControls_().onAdvanceClick_(false /* back */);
}, },
/* Utility methods */ /* Utility methods */
...@@ -174,7 +175,7 @@ var playerTestAPI = { ...@@ -174,7 +175,7 @@ var playerTestAPI = {
* @private * @private
*/ */
getMedia_: function() { getMedia_: function() {
return this.getControls_().getMedia(); return playerTestAPI.getControls_().getMedia();
}, },
/** /**
......
...@@ -22,53 +22,53 @@ var galleryTestAPI = { ...@@ -22,53 +22,53 @@ var galleryTestAPI = {
*/ */
load: function(path) { load: function(path) {
Gallery.openStandalone(path, null, function() { Gallery.openStandalone(path, null, function() {
this.waitFor_('loaded'); galleryTestAPI.waitFor_('loaded');
}.bind(this)); });
}, },
/** /**
* Responds with the selected file name. * Responds with the selected file name.
*/ */
getSelectedFileName: function() { getSelectedFileName: function() {
this.respond_(document.querySelector('.namebox').value); galleryTestAPI.respond_(document.querySelector('.namebox').value);
}, },
/** /**
* Toggles edit mode. * Toggles edit mode.
*/ */
clickEditToggle: function() { clickEditToggle: function() {
this.click('.edit'); galleryTestAPI.click('.edit');
setTimeout(this.respond_.bind(this, true), 0); setTimeout(galleryTestAPI.respond_.bind(null, true), 0);
}, },
/** /**
* Clicks arrow to select next image. * Clicks arrow to select next image.
*/ */
clickNextImageArrow: function() { clickNextImageArrow: function() {
this.click('.arrow.right'); galleryTestAPI.click('.arrow.right');
this.waitFor_('image-displayed'); galleryTestAPI.waitFor_('image-displayed');
}, },
/** /**
* Clicks arrow to select previous image. * Clicks arrow to select previous image.
*/ */
clickPreviousImageArrow: function() { clickPreviousImageArrow: function() {
this.click('.arrow.left'); galleryTestAPI.click('.arrow.left');
this.waitFor_('image-displayed'); galleryTestAPI.waitFor_('image-displayed');
}, },
/** /**
* Clicks last thumbnail in ribbon to select an image. * Clicks last thumbnail in ribbon to select an image.
*/ */
clickLastRibbonThumbnail: function() { clickLastRibbonThumbnail: function() {
this.clickRibbonThumbnail(true); galleryTestAPI.clickRibbonThumbnail(true);
}, },
/** /**
* Clicks first thumbnail in ribbon to select an image. * Clicks first thumbnail in ribbon to select an image.
*/ */
clickFirstRibbonThumbnail: function() { clickFirstRibbonThumbnail: function() {
this.clickRibbonThumbnail(false); galleryTestAPI.clickRibbonThumbnail(false);
}, },
/** /**
...@@ -80,54 +80,57 @@ var galleryTestAPI = { ...@@ -80,54 +80,57 @@ var galleryTestAPI = {
setTimeout(function() { setTimeout(function() {
var nodes = document.querySelectorAll('.ribbon > :not([vanishing])'); var nodes = document.querySelectorAll('.ribbon > :not([vanishing])');
if (nodes.length == 0) { if (nodes.length == 0) {
this.respond_(false); galleryTestAPI.respond_(false);
return; return;
} }
nodes[last ? nodes.length - 1 : 0].click(); nodes[last ? nodes.length - 1 : 0].click();
this.waitFor_('image-displayed'); galleryTestAPI.waitFor_('image-displayed');
}.bind(this), 0); }, 0);
}, },
/** /**
* Clicks 'rotate left' tool. * Clicks 'rotate left' tool.
*/ */
clickRotateLeft: function() { clickRotateLeft: function() {
this.editAndRespond_(this.click.bind(this, '.rotate_left')); galleryTestAPI.editAndRespond_(
galleryTestAPI.click.bind(null, '.rotate_left'));
}, },
/** /**
* Clicks 'rotate right' tool. * Clicks 'rotate right' tool.
*/ */
clickRotateRight: function() { clickRotateRight: function() {
this.editAndRespond_(this.click.bind(this, '.rotate_right')); galleryTestAPI.editAndRespond_(
galleryTestAPI.click.bind(null, '.rotate_right'));
}, },
/** /**
* Clicks 'undo' tool. * Clicks 'undo' tool.
*/ */
clickUndo: function() { clickUndo: function() {
this.editAndRespond_(this.click.bind(this, '.undo')); galleryTestAPI.editAndRespond_(galleryTestAPI.click.bind(null, '.undo'));
}, },
/** /**
* Clicks 'redo' tool. * Clicks 'redo' tool.
*/ */
clickRedo: function() { clickRedo: function() {
this.editAndRespond_(this.click.bind(this, '.redo')); galleryTestAPI.editAndRespond_(galleryTestAPI.click.bind(null, '.redo'));
}, },
/** /**
* Clicks 'autofix' tool. * Clicks 'autofix' tool.
*/ */
clickAutofix: function() { clickAutofix: function() {
this.editAndRespond_(this.click.bind(this, '.autofix')); galleryTestAPI.editAndRespond_(galleryTestAPI.click.bind(null, '.autofix'));
}, },
/** /**
* Responds whether autofix tool is available. * Responds whether autofix tool is available.
*/ */
isAutofixAvailable: function() { isAutofixAvailable: function() {
this.respond_(!document.querySelector('.autofix').hasAttribute('disabled')); galleryTestAPI.respond_(
!document.querySelector('.autofix').hasAttribute('disabled'));
}, },
/** /**
...@@ -147,19 +150,19 @@ var galleryTestAPI = { ...@@ -147,19 +150,19 @@ var galleryTestAPI = {
// TODO(dgozman): investigate why this is required sometimes. // TODO(dgozman): investigate why this is required sometimes.
setTimeout(function() { setTimeout(function() {
action(); action();
this.waitFor_('image-saved'); galleryTestAPI.waitFor_('image-saved');
}.bind(this), 0); }, 0);
}, },
/** /**
* Waits for event fired and then calls a function. * Waits for event fired and then calls a function.
* @param {string} event Event name. * @param {string} event Event name.
* @param {function=} opt_callback Callback. If not passed, * @param {function=} opt_callback Callback. If not passed,
* |this.respond_(true)| is called. * |galleryTestAPI.respond_(true)| is called.
* @private * @private
*/ */
waitFor_: function(event, opt_callback) { waitFor_: function(event, opt_callback) {
var callback = opt_callback || this.respond_.bind(this, true); var callback = opt_callback || galleryTestAPI.respond_.bind(null, true);
var listener = function() { var listener = function() {
Gallery.instance.removeEventListener(event, listener); Gallery.instance.removeEventListener(event, listener);
callback(); callback();
...@@ -174,8 +177,8 @@ var galleryTestAPI = { ...@@ -174,8 +177,8 @@ var galleryTestAPI = {
respond_: function(value) { respond_: function(value) {
if (window.domAutomationController) { if (window.domAutomationController) {
window.domAutomationController.send(value); window.domAutomationController.send(value);
} else if (this.respondCallback) { } else if (galleryTestAPI.respondCallback) {
this.respondCallback(value); galleryTestAPI.respondCallback(value);
} else { } else {
console.log('playerTestAPI response: ' + value); console.log('playerTestAPI response: ' + value);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment