Commit 8c4b4833 authored by Jason Parks's avatar Jason Parks
Browse files

Fix the CTS print tests.

Only run these test if the device says it supports
printing. These test hang on wear devices otherwise.

Bug: 18463847
Change-Id: I967c92af3042795fa6a311ab607ace8c02777ec8
parent e6ad305e
......@@ -25,6 +25,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.pdf.PdfDocument;
......@@ -458,4 +459,8 @@ public abstract class BasePrintTest extends UiAutomatorTestCase {
}
}
}
protected boolean supportsPrinting() {
return getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_PRINTING);
}
}
......@@ -62,6 +62,10 @@ public class PageRangeAdjustmentTest extends BasePrintTest {
private static final String FIRST_PRINTER = "First printer";
public void testAllPagesWantedAndAllPagesWritten() throws Exception {
if (!supportsPrinting()) {
return;
}
// Create a callback for the target print service.
PrintServiceCallbacks firstServiceCallbacks = createMockPrintServiceCallbacks(
new Answer<PrinterDiscoverySessionCallbacks>() {
......@@ -161,6 +165,10 @@ public class PageRangeAdjustmentTest extends BasePrintTest {
}
public void testSomePagesWantedAndAllPagesWritten() throws Exception {
if (!supportsPrinting()) {
return;
}
// Create a callback for the target print service.
PrintServiceCallbacks firstServiceCallbacks = createMockPrintServiceCallbacks(
new Answer<PrinterDiscoverySessionCallbacks>() {
......@@ -269,6 +277,10 @@ public class PageRangeAdjustmentTest extends BasePrintTest {
}
public void testSomePagesWantedAndSomeMorePagesWritten() throws Exception {
if (!supportsPrinting()) {
return;
}
// Create a callback for the target print service.
PrintServiceCallbacks firstServiceCallbacks = createMockPrintServiceCallbacks(
new Answer<PrinterDiscoverySessionCallbacks>() {
......@@ -393,6 +405,10 @@ public class PageRangeAdjustmentTest extends BasePrintTest {
}
public void testSomePagesWantedAndNotWritten() throws Exception {
if (!supportsPrinting()) {
return;
}
// Create a callback for the target print service.
PrintServiceCallbacks firstServiceCallbacks = createMockPrintServiceCallbacks(
new Answer<PrinterDiscoverySessionCallbacks>() {
......@@ -481,6 +497,10 @@ public class PageRangeAdjustmentTest extends BasePrintTest {
}
public void testWantedPagesAlreadyWrittenForPreview() throws Exception {
if (!supportsPrinting()) {
return;
}
// Create a callback for the target print service.
PrintServiceCallbacks firstServiceCallbacks = createMockPrintServiceCallbacks(
new Answer<PrinterDiscoverySessionCallbacks>() {
......
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