Search in sources :

Example 1 with Margins

use of android.print.PrintAttributes.Margins in project platform_frameworks_base by android.

the class IPrintManagerParametersTest method createMockCallbacks.

/**
     * Create mock print service callbacks.
     *
     * @return the callbacks
     */
private PrintServiceCallbacks createMockCallbacks() {
    return createMockPrintServiceCallbacks(new Answer<PrinterDiscoverySessionCallbacks>() {

        @Override
        public PrinterDiscoverySessionCallbacks answer(InvocationOnMock invocation) {
            return createMockPrinterDiscoverySessionCallbacks(new Answer<Void>() {

                @Override
                public Void answer(InvocationOnMock invocation) {
                    // Get the session.
                    StubbablePrinterDiscoverySession session = ((PrinterDiscoverySessionCallbacks) invocation.getMock()).getSession();
                    if (session.getPrinters().isEmpty()) {
                        final String PRINTER_NAME = "good printer";
                        List<PrinterInfo> printers = new ArrayList<>();
                        // Add the printer.
                        mGoodPrinterId = session.getService().generatePrinterId(PRINTER_NAME);
                        PrinterCapabilitiesInfo capabilities = new PrinterCapabilitiesInfo.Builder(mGoodPrinterId).setMinMargins(new Margins(200, 200, 200, 200)).addMediaSize(MediaSize.ISO_A4, true).addResolution(new Resolution("300x300", "300x300", 300, 300), true).setColorModes(PrintAttributes.COLOR_MODE_COLOR, PrintAttributes.COLOR_MODE_COLOR).build();
                        PrinterInfo printer = new PrinterInfo.Builder(mGoodPrinterId, PRINTER_NAME, PrinterInfo.STATUS_IDLE).setCapabilities(capabilities).build();
                        printers.add(printer);
                        session.addPrinters(printers);
                    }
                    onPrinterDiscoverySessionStartCalled();
                    return null;
                }
            }, null, null, null, null, null, null);
        }
    }, null, null);
}
Also used : ArrayList(java.util.ArrayList) PrinterDiscoverySessionCallbacks(android.print.mockservice.PrinterDiscoverySessionCallbacks) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Margins(android.print.PrintAttributes.Margins) StubbablePrinterDiscoverySession(android.print.mockservice.StubbablePrinterDiscoverySession) Resolution(android.print.PrintAttributes.Resolution)

Example 2 with Margins

use of android.print.PrintAttributes.Margins in project android_frameworks_base by DirtyUnicorns.

the class IPrintManagerParametersTest method createMockCallbacks.

/**
     * Create mock print service callbacks.
     *
     * @return the callbacks
     */
private PrintServiceCallbacks createMockCallbacks() {
    return createMockPrintServiceCallbacks(new Answer<PrinterDiscoverySessionCallbacks>() {

        @Override
        public PrinterDiscoverySessionCallbacks answer(InvocationOnMock invocation) {
            return createMockPrinterDiscoverySessionCallbacks(new Answer<Void>() {

                @Override
                public Void answer(InvocationOnMock invocation) {
                    // Get the session.
                    StubbablePrinterDiscoverySession session = ((PrinterDiscoverySessionCallbacks) invocation.getMock()).getSession();
                    if (session.getPrinters().isEmpty()) {
                        final String PRINTER_NAME = "good printer";
                        List<PrinterInfo> printers = new ArrayList<>();
                        // Add the printer.
                        mGoodPrinterId = session.getService().generatePrinterId(PRINTER_NAME);
                        PrinterCapabilitiesInfo capabilities = new PrinterCapabilitiesInfo.Builder(mGoodPrinterId).setMinMargins(new Margins(200, 200, 200, 200)).addMediaSize(MediaSize.ISO_A4, true).addResolution(new Resolution("300x300", "300x300", 300, 300), true).setColorModes(PrintAttributes.COLOR_MODE_COLOR, PrintAttributes.COLOR_MODE_COLOR).build();
                        PrinterInfo printer = new PrinterInfo.Builder(mGoodPrinterId, PRINTER_NAME, PrinterInfo.STATUS_IDLE).setCapabilities(capabilities).build();
                        printers.add(printer);
                        session.addPrinters(printers);
                    }
                    onPrinterDiscoverySessionStartCalled();
                    return null;
                }
            }, null, null, null, null, null, null);
        }
    }, null, null);
}
Also used : ArrayList(java.util.ArrayList) PrinterDiscoverySessionCallbacks(android.print.mockservice.PrinterDiscoverySessionCallbacks) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Margins(android.print.PrintAttributes.Margins) StubbablePrinterDiscoverySession(android.print.mockservice.StubbablePrinterDiscoverySession) Resolution(android.print.PrintAttributes.Resolution)

Example 3 with Margins

use of android.print.PrintAttributes.Margins in project android_frameworks_base by ResurrectionRemix.

the class IPrintManagerParametersTest method createMockCallbacks.

/**
     * Create mock print service callbacks.
     *
     * @return the callbacks
     */
private PrintServiceCallbacks createMockCallbacks() {
    return createMockPrintServiceCallbacks(new Answer<PrinterDiscoverySessionCallbacks>() {

        @Override
        public PrinterDiscoverySessionCallbacks answer(InvocationOnMock invocation) {
            return createMockPrinterDiscoverySessionCallbacks(new Answer<Void>() {

                @Override
                public Void answer(InvocationOnMock invocation) {
                    // Get the session.
                    StubbablePrinterDiscoverySession session = ((PrinterDiscoverySessionCallbacks) invocation.getMock()).getSession();
                    if (session.getPrinters().isEmpty()) {
                        final String PRINTER_NAME = "good printer";
                        List<PrinterInfo> printers = new ArrayList<>();
                        // Add the printer.
                        mGoodPrinterId = session.getService().generatePrinterId(PRINTER_NAME);
                        PrinterCapabilitiesInfo capabilities = new PrinterCapabilitiesInfo.Builder(mGoodPrinterId).setMinMargins(new Margins(200, 200, 200, 200)).addMediaSize(MediaSize.ISO_A4, true).addResolution(new Resolution("300x300", "300x300", 300, 300), true).setColorModes(PrintAttributes.COLOR_MODE_COLOR, PrintAttributes.COLOR_MODE_COLOR).build();
                        PrinterInfo printer = new PrinterInfo.Builder(mGoodPrinterId, PRINTER_NAME, PrinterInfo.STATUS_IDLE).setCapabilities(capabilities).build();
                        printers.add(printer);
                        session.addPrinters(printers);
                    }
                    onPrinterDiscoverySessionStartCalled();
                    return null;
                }
            }, null, null, null, null, null, null);
        }
    }, null, null);
}
Also used : ArrayList(java.util.ArrayList) PrinterDiscoverySessionCallbacks(android.print.mockservice.PrinterDiscoverySessionCallbacks) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Margins(android.print.PrintAttributes.Margins) StubbablePrinterDiscoverySession(android.print.mockservice.StubbablePrinterDiscoverySession) Resolution(android.print.PrintAttributes.Resolution)

Example 4 with Margins

use of android.print.PrintAttributes.Margins in project android_frameworks_base by AOSPA.

the class IPrintManagerParametersTest method createMockCallbacks.

/**
     * Create mock print service callbacks.
     *
     * @return the callbacks
     */
private PrintServiceCallbacks createMockCallbacks() {
    return createMockPrintServiceCallbacks(new Answer<PrinterDiscoverySessionCallbacks>() {

        @Override
        public PrinterDiscoverySessionCallbacks answer(InvocationOnMock invocation) {
            return createMockPrinterDiscoverySessionCallbacks(new Answer<Void>() {

                @Override
                public Void answer(InvocationOnMock invocation) {
                    // Get the session.
                    StubbablePrinterDiscoverySession session = ((PrinterDiscoverySessionCallbacks) invocation.getMock()).getSession();
                    if (session.getPrinters().isEmpty()) {
                        final String PRINTER_NAME = "good printer";
                        List<PrinterInfo> printers = new ArrayList<>();
                        // Add the printer.
                        mGoodPrinterId = session.getService().generatePrinterId(PRINTER_NAME);
                        PrinterCapabilitiesInfo capabilities = new PrinterCapabilitiesInfo.Builder(mGoodPrinterId).setMinMargins(new Margins(200, 200, 200, 200)).addMediaSize(MediaSize.ISO_A4, true).addResolution(new Resolution("300x300", "300x300", 300, 300), true).setColorModes(PrintAttributes.COLOR_MODE_COLOR, PrintAttributes.COLOR_MODE_COLOR).build();
                        PrinterInfo printer = new PrinterInfo.Builder(mGoodPrinterId, PRINTER_NAME, PrinterInfo.STATUS_IDLE).setCapabilities(capabilities).build();
                        printers.add(printer);
                        session.addPrinters(printers);
                    }
                    onPrinterDiscoverySessionStartCalled();
                    return null;
                }
            }, null, null, null, null, null, null);
        }
    }, null, null);
}
Also used : ArrayList(java.util.ArrayList) PrinterDiscoverySessionCallbacks(android.print.mockservice.PrinterDiscoverySessionCallbacks) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Margins(android.print.PrintAttributes.Margins) StubbablePrinterDiscoverySession(android.print.mockservice.StubbablePrinterDiscoverySession) Resolution(android.print.PrintAttributes.Resolution)

Example 5 with Margins

use of android.print.PrintAttributes.Margins in project android_frameworks_base by crdroidandroid.

the class IPrintManagerParametersTest method createMockCallbacks.

/**
     * Create mock print service callbacks.
     *
     * @return the callbacks
     */
private PrintServiceCallbacks createMockCallbacks() {
    return createMockPrintServiceCallbacks(new Answer<PrinterDiscoverySessionCallbacks>() {

        @Override
        public PrinterDiscoverySessionCallbacks answer(InvocationOnMock invocation) {
            return createMockPrinterDiscoverySessionCallbacks(new Answer<Void>() {

                @Override
                public Void answer(InvocationOnMock invocation) {
                    // Get the session.
                    StubbablePrinterDiscoverySession session = ((PrinterDiscoverySessionCallbacks) invocation.getMock()).getSession();
                    if (session.getPrinters().isEmpty()) {
                        final String PRINTER_NAME = "good printer";
                        List<PrinterInfo> printers = new ArrayList<>();
                        // Add the printer.
                        mGoodPrinterId = session.getService().generatePrinterId(PRINTER_NAME);
                        PrinterCapabilitiesInfo capabilities = new PrinterCapabilitiesInfo.Builder(mGoodPrinterId).setMinMargins(new Margins(200, 200, 200, 200)).addMediaSize(MediaSize.ISO_A4, true).addResolution(new Resolution("300x300", "300x300", 300, 300), true).setColorModes(PrintAttributes.COLOR_MODE_COLOR, PrintAttributes.COLOR_MODE_COLOR).build();
                        PrinterInfo printer = new PrinterInfo.Builder(mGoodPrinterId, PRINTER_NAME, PrinterInfo.STATUS_IDLE).setCapabilities(capabilities).build();
                        printers.add(printer);
                        session.addPrinters(printers);
                    }
                    onPrinterDiscoverySessionStartCalled();
                    return null;
                }
            }, null, null, null, null, null, null);
        }
    }, null, null);
}
Also used : ArrayList(java.util.ArrayList) PrinterDiscoverySessionCallbacks(android.print.mockservice.PrinterDiscoverySessionCallbacks) Answer(org.mockito.stubbing.Answer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Margins(android.print.PrintAttributes.Margins) StubbablePrinterDiscoverySession(android.print.mockservice.StubbablePrinterDiscoverySession) Resolution(android.print.PrintAttributes.Resolution)

Aggregations

Margins (android.print.PrintAttributes.Margins)5 Resolution (android.print.PrintAttributes.Resolution)5 PrinterDiscoverySessionCallbacks (android.print.mockservice.PrinterDiscoverySessionCallbacks)5 StubbablePrinterDiscoverySession (android.print.mockservice.StubbablePrinterDiscoverySession)5 ArrayList (java.util.ArrayList)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 Answer (org.mockito.stubbing.Answer)5