Commit 60f4f97a authored by yamaguchi's avatar yamaguchi Committed by Commit bot

Postpone automatic popup of cloud backup details until ready to backup.

BUG=669745
TEST=manual test as noted in the bug.
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:closure_compilation

Review-Url: https://codereview.chromium.org/2538413002
Cr-Commit-Position: refs/heads/master@{#436236}
parent f9262a06
...@@ -71,6 +71,13 @@ importer.ImportController = ...@@ -71,6 +71,13 @@ importer.ImportController =
*/ */
this.lastActivityState_ = importer.ActivityState.HIDDEN; this.lastActivityState_ = importer.ActivityState.HIDDEN;
/**
* Whether the window was opened by plugging a media device and user hadn't
* navigated to other directories.
* @private {boolean}
*/
this.isRightAfterPluggingMedia_ = false;
var listener = this.onScanEvent_.bind(this); var listener = this.onScanEvent_.bind(this);
this.scanner_.addObserver(listener); this.scanner_.addObserver(listener);
// Remove the observer when the foreground window is closed. // Remove the observer when the foreground window is closed.
...@@ -163,11 +170,7 @@ importer.ImportController.prototype.onVolumeUnmounted_ = function(volumeId) { ...@@ -163,11 +170,7 @@ importer.ImportController.prototype.onVolumeUnmounted_ = function(volumeId) {
* @private * @private
*/ */
importer.ImportController.prototype.onDirectoryChanged_ = function(event) { importer.ImportController.prototype.onDirectoryChanged_ = function(event) {
if (!event.previousDirEntry && this.isRightAfterPluggingMedia_ = !event.previousDirEntry;
event.newDirEntry &&
importer.isMediaDirectory(event.newDirEntry, this.environment_)) {
this.commandWidget_.setDetailsVisible(true);
}
this.scanManager_.reset(); this.scanManager_.reset();
if (this.isCurrentDirectoryScannable_()) { if (this.isCurrentDirectoryScannable_()) {
...@@ -390,6 +393,10 @@ importer.ImportController.prototype.checkState_ = function(opt_scan) { ...@@ -390,6 +393,10 @@ importer.ImportController.prototype.checkState_ = function(opt_scan) {
this.updateUi_( this.updateUi_(
importer.ActivityState.READY, // to import... importer.ActivityState.READY, // to import...
opt_scan); opt_scan);
if (this.isRightAfterPluggingMedia_) {
this.isRightAfterPluggingMedia_ = false;
this.commandWidget_.setDetailsVisible(true);
}
}.bind(this)) }.bind(this))
.catch(importer.getLogger().catcher('import-controller-check-state')); .catch(importer.getLogger().catcher('import-controller-check-state'));
}; };
......
...@@ -201,7 +201,7 @@ function testWindowClose_CancelsScan(callback) { ...@@ -201,7 +201,7 @@ function testWindowClose_CancelsScan(callback) {
reportPromise(promise, callback); reportPromise(promise, callback);
} }
function testDirectoryChange_DetailsPanelVisibility_InitialChangeDir() { function testDirectoryChange_DetailsPanelVisibility_InitialChangeDir(callback) {
var controller = createController( var controller = createController(
VolumeManagerCommon.VolumeType.MTP, VolumeManagerCommon.VolumeType.MTP,
'mtp-volume', 'mtp-volume',
...@@ -212,13 +212,32 @@ function testDirectoryChange_DetailsPanelVisibility_InitialChangeDir() { ...@@ -212,13 +212,32 @@ function testDirectoryChange_DetailsPanelVisibility_InitialChangeDir() {
], ],
'/DCIM'); '/DCIM');
var fileSystem = new MockFileSystem('testFs');
var event = new Event('directory-changed'); var event = new Event('directory-changed');
event.newDirEntry = new MockDirectoryEntry( event.newDirEntry = new MockDirectoryEntry(
new MockFileSystem('testFs'), fileSystem,
'/DCIM/'); '/DCIM/');
// ensure there is some content in the scan so the code that depends
// on this state doesn't croak which it finds it missing.
mediaScanner.fileEntries.push(
new MockFileEntry(fileSystem, '/DCIM/photos0/IMG00001.jpg', {size: 0}));
// Make controller enter a scanning state.
environment.directoryChangedListener(event); environment.directoryChangedListener(event);
assertTrue(widget.detailsVisible); assertFalse(widget.detailsVisible);
var promise = widget.updateResolver.promise.then(function() {
// "scanning..."
assertFalse(widget.detailsVisible);
widget.resetPromises();
mediaScanner.finalizeScans();
return widget.updateResolver.promise;
}).then(function() {
// "ready to update"
// Details should pop up.
assertTrue(widget.detailsVisible);
});
reportPromise(promise, callback);
} }
function testDirectoryChange_DetailsPanelVisibility_SubsequentChangeDir() { function testDirectoryChange_DetailsPanelVisibility_SubsequentChangeDir() {
......
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