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

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

Issue 2788283002: Fix PrintPreviewDestinationSearchTest.Select (Closed)
Patch Set: comments addressed 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/ui/webui/print_preview/print_preview_ui.cc ('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_destination_search_test.js
diff --git a/chrome/test/data/webui/print_preview_destination_search_test.js b/chrome/test/data/webui/print_preview_destination_search_test.js
index e63db9d7c56e5214df5340d17e90c9fc5e3ab8d9..2155bd7820beb4ff844b9bbad2fb318f5ba96494 100644
--- a/chrome/test/data/webui/print_preview_destination_search_test.js
+++ b/chrome/test/data/webui/print_preview_destination_search_test.js
@@ -27,7 +27,7 @@ PrintPreviewDestinationSearchTest.prototype = {
extraLibraries: PolymerTest.getLibraries(ROOT_PATH),
};
-TEST_F('PrintPreviewDestinationSearchTest', 'DISABLED_Select', function() {
+TEST_F('PrintPreviewDestinationSearchTest', 'Select', function() {
var self = this;
suite('DestinationSearchTest', function() {
@@ -98,18 +98,55 @@ TEST_F('PrintPreviewDestinationSearchTest', 'DISABLED_Select', function() {
});
};
- function requestSetup(destId, nativeLayerMock, destinationSearch) {
+ function mockSetupCall(destId, nativeLayerMock) {
+ var resolver = new PromiseResolver();
+
+ if (cr.isChromeOS) {
+ nativeLayerMock.expects(once()).setupPrinter(destId).
+ will(returnValue(resolver.promise));
+
+ return resolver;
+ }
+
+ nativeLayerMock.expects(once()).startGetLocalDestinationCapabilities(
+ destId);
+ resolver.promise.then(
+ function(result) {
+ // Simulate the native layer dispatching capabilities.
+ var capsSetEvent =
+ new Event(print_preview.NativeLayer.EventType.CAPABILITIES_SET);
+ capsSetEvent.settingsInfo = result;
+ destinationStore_.onLocalDestinationCapabilitiesSet_(capsSetEvent);
+ }.bind(this),
+ function() {
+ var failEvent = new Event(
+ print_preview.NativeLayer.EventType.GET_CAPABILITIES_FAIL);
+ failEvent.destinationId = destId;
+ destinationStore_.onGetCapabilitiesFail_(failEvent);
+ }.bind(this));
+
+ return resolver;
+ };
+
+ function requestSetup(destId, destinationSearch) {
+ var origin = cr.isChromeOS ? print_preview.Destination.Origin.CROS :
+ print_preview.Destination.Origin.LOCAL;
+
var dest = new print_preview.Destination(destId,
print_preview.Destination.Type.LOCAL,
- print_preview.Destination.Origin.CROS,
+ origin,
"displayName",
print_preview.Destination.ConnectionStatus.ONLINE);
- var resolver = new PromiseResolver();
- nativeLayerMock.expects(once()).setupPrinter(destId).
- will(returnValue(resolver.promise));
- destinationSearch.handleOnDestinationSelect_(dest);
- return resolver;
+ // Add the destination to the list.
+ destinationSearch.localList_.updateDestinations([dest]);
+
+ // Select destination.
+ if (cr.isChromeOS) {
+ destinationSearch.handleConfigureDestination_(dest);
+ } else {
+ destinationSearch.handleOnDestinationSelect_(dest);
+ }
};
function resolveSetup(resolver, printerId, success, capabilities) {
@@ -145,19 +182,30 @@ TEST_F('PrintPreviewDestinationSearchTest', 'DISABLED_Select', function() {
});
test('ResolutionFails', function() {
+ if (!cr.isChromeOS) {
+ // Capabilities failure logs a console error for non-CrOS printers.
+ // TODO(crbug.com/708739): Handle this gracefully and activate test.
+ return;
+ }
+
var destId = "001122DEADBEEF";
- var resolver = requestSetup(destId, nativeLayer_, destinationSearch_);
+
+ var resolver = mockSetupCall(destId, nativeLayer_);
+ requestSetup(destId, destinationSearch_);
resolver.reject(destId);
});
test('ReceiveSuccessfulSetup', function() {
+
var destId = "00112233DEADBEEF";
- var resolver = requestSetup(destId, nativeLayer_, destinationSearch_);
- waiter = waitForEvent(
+ var waiter = waitForEvent(
destinationStore_,
print_preview.DestinationStore.EventType.DESTINATION_SELECT);
+ var resolver = mockSetupCall(destId, nativeLayer_);
+
+ requestSetup(destId, destinationSearch_);
resolveSetup(resolver, destId, true, getCaps());
// wait for event propogation to complete.
@@ -170,17 +218,21 @@ TEST_F('PrintPreviewDestinationSearchTest', 'DISABLED_Select', function() {
test('ReceiveFailedSetup', function() {
var destId = '00112233DEADBEEF';
- var resolver = requestSetup(destId, nativeLayer_, destinationSearch_);
- waiter = waitForEvent(
- destinationStore_,
- print_preview.DestinationStore.EventType.PRINTER_CONFIGURED);
+ var resolver = mockSetupCall(destId, nativeLayer_);
+ requestSetup(destId, destinationSearch_);
+ // Force resolution to fail.
resolveSetup(resolver, destId, false, null);
- return waiter.then(function() {
+ if (cr.isChromeOS) {
+ // Selection should not change on ChromeOS.
assertEquals(null, destinationStore_.selectedDestination);
- });
+ } else {
+ // Other code expects selection to be present so it still occurs
+ // for non-CrOS.
+ assertEquals(destId, destinationStore_.selectedDestination.id);
+ }
});
});
« no previous file with comments | « chrome/browser/ui/webui/print_preview/print_preview_ui.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698