Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Unified Diff: chrome/test/data/webui/print_preview.js

Issue 2849733002: Fix Print Preview failure state and add test (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/print_preview.js
diff --git a/chrome/test/data/webui/print_preview.js b/chrome/test/data/webui/print_preview.js
index 2743ce8ed98a97ae60ecaf0cfe1a9bf0ed4786c0..d14f9f222dd8973d2063b58b588f1ca1e2305ab6 100644
--- a/chrome/test/data/webui/print_preview.js
+++ b/chrome/test/data/webui/print_preview.js
@@ -151,6 +151,17 @@ PrintPreviewWebUITest.prototype = {
},
/**
+ * Dispatch the SETTINGS_INVALID event. This call is NOT async and will
+ * happen in the same thread.
+ */
+ invalidSettings: function() {
dpapad 2017/04/28 17:13:30 Nit: |invalidSettings| sounds more like a data var
rbpotter 2017/04/29 00:07:11 Done.
+ var invalidSettingsEvent =
+ new Event(print_preview.NativeLayer.EventType.SETTINGS_INVALID);
+ this.nativeLayer_.dispatchEvent(invalidSettingsEvent);
+ },
+
+
+ /**
* Even though animation duration and delay is set to zero, it is necessary to
* wait until the animation has finished.
*/
@@ -1356,3 +1367,57 @@ TEST_F('PrintPreviewWebUITest', 'TestInitIssuesOneRequest', function() {
0);
testDone();
});
+
+// Test that invalid settings errors disable the print preview and display
+// an error and that the preview dialog can be recovered by selecting a
+// new destination.
+TEST_F('PrintPreviewWebUITest', 'TestInvalidSettingsError', function() {
+ // Setup
+ this.setInitialSettings();
+ this.setLocalDestinations();
+ expectEquals('ready', printPreview.uiState_);
dpapad 2017/04/28 17:13:30 Is there a way to avoid referring to a private var
rbpotter 2017/04/29 00:07:11 Done.
+
+ // There will be an error message in the preview area since the plugin is
+ // not running. However, it should not be the invalid settings error.
+ var previewAreaEl = $('preview-area');
+ var customMessageEl =
+ previewAreaEl.getElementsByClassName('preview-area-custom-message')[0];
+ expectEquals(false, customMessageEl.hidden);
+ var expectedMessageStart = 'The selected printer is not available or not ' +
+ 'installed correctly.'
+ expectEquals(-1, customMessageEl.textContent.search(expectedMessageStart));
+
+ // Manually enable the print button to verify it is disabled.
+ var printHeader = $('print-header');
+ var printButton = printHeader.querySelector('button.print');
+ checkElementDisplayed(printButton, true);
+ printButton.disabled = false;
+ expectEquals(false, printButton.disabled);
+
+ // Report invalid settings error.
+ this.invalidSettings();
+
+ // Should be in an error state, print button disabled, invalid custom error
+ // message shown.
+ expectEquals('error', printPreview.uiState_);
+ expectEquals(false, customMessageEl.hidden);
+ expectEquals(true,
+ customMessageEl.textContent.search(expectedMessageStart) > -1);
+ expectEquals(true, printButton.disabled);
+
+ // Select a new destination
+ var barDestination;
+ var destinations = printPreview.destinationStore_.destinations();
+ for (var destination, i = 0; destination = destinations[i]; i++) {
+ if (destination.id == 'BarDevice') {
+ barDestination = destination;
+ break;
+ }
+ }
+ printPreview.destinationStore_.selectDestination(barDestination);
+
+ // Should now have recovered. Error message does not change and the button
+ // will not be re-enabled since the preview never actually loads.
+ expectEquals('ready', printPreview.uiState_);
+ testDone();
+});
« no previous file with comments | « chrome/browser/resources/print_preview/print_preview.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698