Generalize PreviewPanelModel so that it stops to refer specific cloud-import CSS class.
BUG=438947 TEST=FileManagerJsTest.PreviewPanelModelTest Review URL: https://codereview.chromium.org/871563002 Cr-Commit-Position: refs/heads/master@{#312682}
This commit is contained in:
ui/file_manager/file_manager
@@ -23,9 +23,9 @@ function PreviewPanelModel(initialVisibilityType) {
|
||||
* @const
|
||||
* @private
|
||||
*/
|
||||
this.cloudImportCommands_ = Array.prototype.slice.call(
|
||||
document.querySelectorAll('command.cloud-import'));
|
||||
cr.ui.decorate('command.cloud-import', cr.ui.Command);
|
||||
this.autoVisibilityCommands_ = Array.prototype.slice.call(
|
||||
document.querySelectorAll('command.auto-visibility'));
|
||||
cr.ui.decorate('command.auto-visibility', cr.ui.Command);
|
||||
|
||||
/**
|
||||
* FileSelection to be displayed.
|
||||
@@ -42,8 +42,8 @@ function PreviewPanelModel(initialVisibilityType) {
|
||||
*/
|
||||
this.visible = false;
|
||||
|
||||
for (var i = 0; i < this.cloudImportCommands_.length; i++) {
|
||||
this.cloudImportCommands_[i].addEventListener(
|
||||
for (var i = 0; i < this.autoVisibilityCommands_.length; i++) {
|
||||
this.autoVisibilityCommands_[i].addEventListener(
|
||||
'hiddenChange', this.updateVisibility_.bind(this));
|
||||
}
|
||||
this.updateVisibility_();
|
||||
@@ -92,7 +92,7 @@ PreviewPanelModel.prototype.updateVisibility_ = function() {
|
||||
case PreviewPanelModel.VisibilityType.AUTO:
|
||||
newVisible =
|
||||
this.selection_.entries.length !== 0 ||
|
||||
this.cloudImportCommands_.some(function(command) {
|
||||
this.autoVisibilityCommands_.some(function(command) {
|
||||
return !command.hidden;
|
||||
});
|
||||
break;
|
||||
|
@@ -2,24 +2,22 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/**
|
||||
* Timeout in milliseconds to determine if the event is dispatched or not.
|
||||
* If the event is dispached in the timeout, the test regards the event is
|
||||
* dispatched, otherwise not. Otherwise it regards the event is not dispatched.
|
||||
*/
|
||||
var TIMEOUT_MS = 3000;
|
||||
|
||||
function testPreviewPanelModel(callback) {
|
||||
document.querySelector('body').innerHTML =
|
||||
'<command class="cloud-import" hidden></command>';
|
||||
var command = document.querySelector('command.cloud-import');
|
||||
'<command class="auto-visibility" hidden></command>';
|
||||
var command = document.querySelector('command.auto-visibility');
|
||||
var model = new PreviewPanelModel(PreviewPanelModel.VisibilityType.AUTO);
|
||||
|
||||
var testStep = function(step, changed) {
|
||||
var waitPromise = new Promise(function(fulfill) {
|
||||
model.addEventListener(
|
||||
PreviewPanelModel.EventType.CHANGE, fulfill.bind(null, true));
|
||||
setTimeout(fulfill.bind(null, false), TIMEOUT_MS);
|
||||
// The handler of hiddenChange event in PreviewPanelModel dispatches
|
||||
// PreviewPanelModel.EventType.CHANGE event synchronously. Thus if
|
||||
// the below hiddenChange handler is called ahead of the above change
|
||||
// handler, it means PreviewPanelModel.EventType.CHANGE was not
|
||||
// dispatched.
|
||||
command.addEventListener('hiddenChange', fulfill.bind(null, false));
|
||||
});
|
||||
|
||||
switch (step) {
|
||||
|
@@ -217,7 +217,7 @@
|
||||
shortcut="U+00BE" hide-shortcut-text><!-- Shortcut: '.' -->
|
||||
<!-- The visibility is refered by preview panel. Set hidden until
|
||||
visibility is obtained once. -->
|
||||
<command id="cloud-import" class="cloud-import"
|
||||
<command id="cloud-import" class="auto-visibility"
|
||||
i18n-values="label:CLOUD_IMPORT_BUTTON_LABEL" hidden>
|
||||
|
||||
<command id="zoom-in" shortcut="U+00BB-Ctrl">
|
||||
|
Reference in New Issue
Block a user