Commit e611c41f authored by aurimas's avatar aurimas Committed by Commit bot

[Android] Move printing test to the correct package.

PrintingControllerTest was faking being in org.chromium.printing package.
Move to org.chromium.chrome.browser.printing package where it actually lives.

BUG=None

Review URL: https://codereview.chromium.org/618553002

Cr-Commit-Position: refs/heads/master@{#297346}
parent 34bf875f
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
package org.chromium.printing; package org.chromium.chrome.browser.printing;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.os.Build; import android.os.Build;
...@@ -18,9 +18,11 @@ import org.chromium.base.ApiCompatibilityUtils; ...@@ -18,9 +18,11 @@ import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.TestFileUtil; import org.chromium.base.test.util.TestFileUtil;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.chrome.browser.printing.TabPrinter;
import org.chromium.chrome.shell.ChromeShellTab; import org.chromium.chrome.shell.ChromeShellTab;
import org.chromium.chrome.shell.ChromeShellTestBase; import org.chromium.chrome.shell.ChromeShellTestBase;
import org.chromium.printing.PrintDocumentAdapterWrapper;
import org.chromium.printing.PrintManagerDelegate;
import org.chromium.printing.PrintingControllerImpl;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -92,9 +94,8 @@ public class PrintingControllerTest extends ChromeShellTestBase { ...@@ -92,9 +94,8 @@ public class PrintingControllerTest extends ChromeShellTestBase {
// Create a temporary file to save the PDF. // Create a temporary file to save the PDF.
final File cacheDir = getInstrumentation().getTargetContext().getCacheDir(); final File cacheDir = getInstrumentation().getTargetContext().getCacheDir();
final File tempFile = File.createTempFile(TEMP_FILE_NAME, TEMP_FILE_EXTENSION, cacheDir); final File tempFile = File.createTempFile(TEMP_FILE_NAME, TEMP_FILE_EXTENSION, cacheDir);
final ParcelFileDescriptor fileDescriptor = final ParcelFileDescriptor fileDescriptor = ParcelFileDescriptor.open(tempFile,
ParcelFileDescriptor.open(tempFile, (ParcelFileDescriptor.MODE_CREATE | (ParcelFileDescriptor.MODE_CREATE | ParcelFileDescriptor.MODE_READ_WRITE));
ParcelFileDescriptor.MODE_READ_WRITE));
PrintAttributes attributes = new PrintAttributes.Builder() PrintAttributes attributes = new PrintAttributes.Builder()
.setMediaSize(PrintAttributes.MediaSize.ISO_A4) .setMediaSize(PrintAttributes.MediaSize.ISO_A4)
...@@ -103,26 +104,22 @@ public class PrintingControllerTest extends ChromeShellTestBase { ...@@ -103,26 +104,22 @@ public class PrintingControllerTest extends ChromeShellTestBase {
.build(); .build();
// Use this to wait for PDF generation to complete, as it will happen asynchronously. // Use this to wait for PDF generation to complete, as it will happen asynchronously.
final FutureTask<Boolean> result = final FutureTask<Boolean> result = new FutureTask<Boolean>(new Callable<Boolean>() {
new FutureTask<Boolean>(new Callable<Boolean>() {
@Override
public Boolean call() {
return true;
}
});
callLayoutOnUiThread(
printingController,
null,
attributes,
new LayoutResultCallbackWrapperMock() {
// Called on UI thread
@Override @Override
public void onLayoutFinished(PrintDocumentInfo info, boolean changed) { public Boolean call() {
callWriteOnUiThread(printingController, fileDescriptor, result); return true;
} }
}); });
callLayoutOnUiThread(printingController, null, attributes,
new LayoutResultCallbackWrapperMock() {
// Called on UI thread
@Override
public void onLayoutFinished(PrintDocumentInfo info, boolean changed) {
callWriteOnUiThread(printingController, fileDescriptor, result);
}
});
FileInputStream in = null; FileInputStream in = null;
try { try {
// This blocks until the PDF is generated. // This blocks until the PDF is generated.
...@@ -169,8 +166,7 @@ public class PrintingControllerTest extends ChromeShellTestBase { ...@@ -169,8 +166,7 @@ public class PrintingControllerTest extends ChromeShellTestBase {
try { try {
final PrintManagerDelegate mockPrintManagerDelegate = new PrintManagerDelegate() { final PrintManagerDelegate mockPrintManagerDelegate = new PrintManagerDelegate() {
@Override @Override
public void print(String printJobName, public void print(String printJobName, PrintDocumentAdapter documentAdapter,
PrintDocumentAdapter documentAdapter,
PrintAttributes attributes) { PrintAttributes attributes) {
// Do nothing, as we will emulate the framework call sequence within the test. // Do nothing, as we will emulate the framework call sequence within the test.
} }
......
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