Commit 49ac1df1 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Fix destination dialog interactive test

This test was passing accidentally due to an issue with autofocus. The
print-preview-user-manager should be necessary to make the test pass.
Add it to the test.

Bug: 979603
Change-Id: I44065fdfcd28ad69b46373805f67f37c6a16799c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1704734
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#678954}
parent 8a7ad1e3
...@@ -165,9 +165,11 @@ ...@@ -165,9 +165,11 @@
<option value="">$i18n{addAccountTitle}</option> <option value="">$i18n{addAccountTitle}</option>
</select> </select>
</div> </div>
<!-- Note: Autofocus is not used below, as due to a Blink issue it is
not possible to test refocusing this element in tests if autofocus is
used. autofocus can be restored when this issue is resolved. -->
<print-preview-search-box id="searchBox" <print-preview-search-box id="searchBox"
label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}" label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}">
autofocus>
</print-preview-search-box> </print-preview-search-box>
</div> </div>
<div slot="body"> <div slot="body">
......
...@@ -287,6 +287,7 @@ Polymer({ ...@@ -287,6 +287,7 @@ Polymer({
show: function() { show: function() {
this.$.dialog.showModal(); this.$.dialog.showModal();
this.$.searchBox.focus();
this.loadingDestinations_ = this.destinationStore === undefined || this.loadingDestinations_ = this.destinationStore === undefined ||
this.destinationStore.isPrintDestinationSearchInProgress; this.destinationStore.isPrintDestinationSearchInProgress;
this.metrics_.record( this.metrics_.record(
......
...@@ -16,9 +16,6 @@ cr.define('destination_dialog_interactive_test', function() { ...@@ -16,9 +16,6 @@ cr.define('destination_dialog_interactive_test', function() {
/** @type {?PrintPreviewDestinationDialogElement} */ /** @type {?PrintPreviewDestinationDialogElement} */
let dialog = null; let dialog = null;
/** @type {?print_preview.DestinationStore} */
let destinationStore = null;
/** @type {?print_preview.NativeLayer} */ /** @type {?print_preview.NativeLayer} */
let nativeLayer = null; let nativeLayer = null;
...@@ -29,30 +26,41 @@ cr.define('destination_dialog_interactive_test', function() { ...@@ -29,30 +26,41 @@ cr.define('destination_dialog_interactive_test', function() {
/** @override */ /** @override */
setup(function() { setup(function() {
PolymerTest.clearBody();
// Create destinations. // Create destinations.
nativeLayer = new print_preview.NativeLayerStub(); nativeLayer = new print_preview.NativeLayerStub();
print_preview.NativeLayer.setInstance(nativeLayer); print_preview.NativeLayer.setInstance(nativeLayer);
destinationStore = print_preview_test_utils.createDestinationStore();
const localDestinations = []; const localDestinations = [];
const destinations = print_preview_test_utils.getDestinations( const destinations = print_preview_test_utils.getDestinations(
nativeLayer, localDestinations); nativeLayer, localDestinations);
const recentDestinations = const recentDestinations =
[print_preview.makeRecentDestination(destinations[4])]; [print_preview.makeRecentDestination(destinations[4])];
destinationStore.init(
false /* isInAppKioskMode */, 'FooDevice' /* printerName */,
'' /* serializedDefaultDestinationSelectionRulesStr */,
recentDestinations /* recentDestinations */);
nativeLayer.setLocalDestinations(localDestinations); nativeLayer.setLocalDestinations(localDestinations);
cloudPrintInterface = new print_preview.CloudPrintInterfaceStub();
// Set up dialog
dialog = document.createElement('print-preview-destination-dialog'); const model = document.createElement('print-preview-model');
dialog.activeUser = ''; document.body.appendChild(model);
dialog.users = [];
dialog.destinationStore = destinationStore; // Create destination settings, so that the user manager is created.
dialog.invitationStore = new print_preview.InvitationStore(); const destinationSettings =
dialog.recentDestinations = recentDestinations; document.createElement('print-preview-destination-settings');
document.body.appendChild(dialog); destinationSettings.settings = model.settings;
return nativeLayer.whenCalled('getPrinterCapabilities'); destinationSettings.state = print_preview.State.READY;
destinationSettings.disabled = false;
test_util.fakeDataBind(model, destinationSettings, 'settings');
document.body.appendChild(destinationSettings);
// Initialize
destinationSettings.cloudPrintInterface = cloudPrintInterface;
destinationSettings.init(
'FooDevice' /* printerName */,
'' /* serializedDefaultDestinationSelectionRulesStr */,
[] /* userAccounts */, true /* syncAvailable */);
return nativeLayer.whenCalled('getPrinterCapabilities').then(() => {
// Retrieve a reference to dialog
dialog = destinationSettings.$.destinationDialog.get();
});
}); });
// Tests that the search input text field is automatically focused when the // Tests that the search input text field is automatically focused when the
...@@ -61,7 +69,7 @@ cr.define('destination_dialog_interactive_test', function() { ...@@ -61,7 +69,7 @@ cr.define('destination_dialog_interactive_test', function() {
const searchInput = dialog.$.searchBox.getSearchInput(); const searchInput = dialog.$.searchBox.getSearchInput();
assertTrue(!!searchInput); assertTrue(!!searchInput);
const whenFocusDone = test_util.eventToPromise('focus', searchInput); const whenFocusDone = test_util.eventToPromise('focus', searchInput);
destinationStore.startLoadAllDestinations(); dialog.destinationStore.startLoadAllDestinations();
dialog.show(); dialog.show();
return whenFocusDone; return whenFocusDone;
}); });
...@@ -75,7 +83,7 @@ cr.define('destination_dialog_interactive_test', function() { ...@@ -75,7 +83,7 @@ cr.define('destination_dialog_interactive_test', function() {
const signInLink = dialog.$$('.sign-in'); const signInLink = dialog.$$('.sign-in');
assertTrue(!!signInLink); assertTrue(!!signInLink);
const whenFocusDone = test_util.eventToPromise('focus', searchInput); const whenFocusDone = test_util.eventToPromise('focus', searchInput);
destinationStore.startLoadAllDestinations(); dialog.destinationStore.startLoadAllDestinations();
dialog.show(); dialog.show();
return whenFocusDone return whenFocusDone
.then(() => { .then(() => {
...@@ -93,6 +101,10 @@ cr.define('destination_dialog_interactive_test', function() { ...@@ -93,6 +101,10 @@ cr.define('destination_dialog_interactive_test', function() {
test_util.eventToPromise('focus', searchInput); test_util.eventToPromise('focus', searchInput);
signInLink.click(); signInLink.click();
return whenSearchFocused; return whenSearchFocused;
})
.then(() => {
assertEquals('foo@chromium.org', dialog.activeUser);
assertEquals(1, dialog.users.length);
}); });
}); });
...@@ -102,7 +114,7 @@ cr.define('destination_dialog_interactive_test', function() { ...@@ -102,7 +114,7 @@ cr.define('destination_dialog_interactive_test', function() {
const searchInput = dialog.$.searchBox.getSearchInput(); const searchInput = dialog.$.searchBox.getSearchInput();
assertTrue(!!searchInput); assertTrue(!!searchInput);
const whenFocusDone = test_util.eventToPromise('focus', searchInput); const whenFocusDone = test_util.eventToPromise('focus', searchInput);
destinationStore.startLoadAllDestinations(); dialog.destinationStore.startLoadAllDestinations();
dialog.show(); dialog.show();
return whenFocusDone return whenFocusDone
.then(() => { .then(() => {
......
...@@ -113,15 +113,15 @@ var PrintPreviewDestinationDialogInteractiveTest = ...@@ -113,15 +113,15 @@ var PrintPreviewDestinationDialogInteractiveTest =
class extends PrintPreviewInteractiveUITest { class extends PrintPreviewInteractiveUITest {
/** @override */ /** @override */
get browsePreload() { get browsePreload() {
return 'chrome://print/ui/destination_dialog.html'; return 'chrome://print/ui/destination_settings.html';
} }
/** @override */ /** @override */
get extraLibraries() { get extraLibraries() {
return super.extraLibraries.concat([ return super.extraLibraries.concat([
'//chrome/test/data/webui/settings/test_util.js', '//chrome/test/data/webui/settings/test_util.js',
'//ui/webui/resources/js/web_ui_listener_behavior.js',
'../test_browser_proxy.js', '../test_browser_proxy.js',
'cloud_print_interface_stub.js',
'native_layer_stub.js', 'native_layer_stub.js',
'print_preview_test_utils.js', 'print_preview_test_utils.js',
'destination_dialog_interactive_test.js', 'destination_dialog_interactive_test.js',
......
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