Commit fa1b1a37 authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview Componentization: Migrate InitIssuesOneRequest test

Migrate the test that verifies only one printer is fetched at startup,
even when there are multiple recent destinations.

Bug: 814860
Change-Id: Ia4da53b322b86191b64f5510cfa8260affe2e5f5
Reviewed-on: https://chromium-review.googlesource.com/1042541
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555987}
parent 44e2fc52
...@@ -6,7 +6,9 @@ cr.define('destination_select_test', function() { ...@@ -6,7 +6,9 @@ cr.define('destination_select_test', function() {
/** @enum {string} */ /** @enum {string} */
const TestNames = { const TestNames = {
SingleRecentDestination: 'single recent destination', SingleRecentDestination: 'single recent destination',
MultipleRecentDestinations: 'multiple recent destination', MultipleRecentDestinations: 'multiple recent destinations',
MultipleRecentDestinationsOneRequest:
'multiple recent destinations one request',
DefaultDestinationSelectionRules: 'default destination selection rules', DefaultDestinationSelectionRules: 'default destination selection rules',
SystemDefaultPrinterPolicy: 'system default printer policy', SystemDefaultPrinterPolicy: 'system default printer policy',
}; };
...@@ -81,11 +83,8 @@ cr.define('destination_select_test', function() { ...@@ -81,11 +83,8 @@ cr.define('destination_select_test', function() {
* destinations are marked as recent in the store. * destinations are marked as recent in the store.
*/ */
test(assert(TestNames.MultipleRecentDestinations), function() { test(assert(TestNames.MultipleRecentDestinations), function() {
const recentDestinations = []; const recentDestinations = destinations.slice(0, 3).map(
destinations.slice(0, 3).forEach(destination => { destination => print_preview.makeRecentDestination(destination));
recentDestinations.push(
print_preview.makeRecentDestination(destination));
});
initialSettings.serializedAppStateStr = JSON.stringify({ initialSettings.serializedAppStateStr = JSON.stringify({
version: 2, version: 2,
...@@ -110,10 +109,49 @@ cr.define('destination_select_test', function() { ...@@ -110,10 +109,49 @@ cr.define('destination_select_test', function() {
const match = reportedPrinters.find((reportedPrinter) => { const match = reportedPrinters.find((reportedPrinter) => {
return reportedPrinter.id == destination.id;}); return reportedPrinter.id == destination.id;});
assertFalse(typeof match === "undefined"); assertFalse(typeof match === "undefined");
if (index < 3) assertEquals(index < 3, match.isRecent);
assertTrue(match.isRecent); });
else });
assertFalse(match.isRecent); });
/**
* Tests that if the user has multiple valid recent destinations, this
* does not result in multiple calls to getPrinterCapabilities and the
* correct destination is selected for the preview request.
* For crbug.com/666595.
*/
test(assert(TestNames.MultipleRecentDestinationsOneRequest), function() {
const recentDestinations = destinations.slice(0, 3).map(
destination => print_preview.makeRecentDestination(destination));
initialSettings.serializedAppStateStr = JSON.stringify({
version: 2,
recentDestinations: recentDestinations,
});
return setInitialSettings().then(function(argsArray) {
// Should have loaded ID1 as the selected printer, since it was most
// recent.
assertEquals('ID1', argsArray[1].destinationId);
assertEquals(print_preview.PrinterType.LOCAL, argsArray[1].type);
assertEquals('ID1', page.destination_.id);
return nativeLayer.whenCalled('getPreview');
}).then(function(previewArgs) {
const ticket = JSON.parse(previewArgs.printTicket);
assertEquals(0, ticket.requestID);
assertEquals('ID1', ticket.deviceName);
// None of the other printers should have been loaded. Should only have
// ID1 and Save as PDF. They will be loaded when the dialog is opened
// and startLoadDestinations() is called.
const reportedPrinters = page.destinationStore_.destinations();
assertEquals(2, reportedPrinters.length);
destinations.forEach((destination, index) => {
if (destination.id == 'ID1')
return;
assertFalse(reportedPrinters.some(p => p.id == destination.id));
}); });
}); });
}); });
......
...@@ -459,6 +459,13 @@ TEST_F('PrintPreviewDestinationSelectTest', 'MultipleRecentDestinations', ...@@ -459,6 +459,13 @@ TEST_F('PrintPreviewDestinationSelectTest', 'MultipleRecentDestinations',
destination_select_test.TestNames.MultipleRecentDestinations); destination_select_test.TestNames.MultipleRecentDestinations);
}); });
TEST_F('PrintPreviewDestinationSelectTest',
'MultipleRecentDestinationsOneRequest',
function() {
this.runMochaTest(
destination_select_test.TestNames.MultipleRecentDestinationsOneRequest);
});
TEST_F('PrintPreviewDestinationSelectTest', 'DefaultDestinationSelectionRules', TEST_F('PrintPreviewDestinationSelectTest', 'DefaultDestinationSelectionRules',
function() { function() {
this.runMochaTest( this.runMochaTest(
......
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