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