Merge "Add # of active print jobs back to print setting summary"

This commit is contained in:
TreeHugger Robot
2017-05-27 01:25:44 +00:00
committed by Android (Google) Code Review
2 changed files with 80 additions and 30 deletions

View File

@@ -22,6 +22,8 @@ import static org.mockito.Mockito.when;
import android.app.Activity;
import android.content.res.Resources;
import android.print.PrintJob;
import android.print.PrintJobInfo;
import android.print.PrintManager;
import android.printservice.PrintServiceInfo;
@@ -34,9 +36,11 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.robolectric.annotation.Config;
import java.util.ArrayList;
import java.util.List;
@@ -62,6 +66,19 @@ public class PrintSettingsFragmentTest {
mPrintManager);
}
@Test
public void testSummary_hasActiveJob_shouldSetSummaryToNumberOfJobs() {
final List<PrintJob> printJobs = new ArrayList<>();
final PrintJob job = mock(PrintJob.class, Mockito.RETURNS_DEEP_STUBS);
printJobs.add(job);
when(job.getInfo().getState()).thenReturn(PrintJobInfo.STATE_STARTED);
when(mPrintManager.getPrintJobs()).thenReturn(printJobs);
mSummaryProvider.setListening(true);
verify(mRes).getQuantityString(R.plurals.print_jobs_summary, 1, 1);
}
@Test
public void testSummary_shouldSetSummaryToNumberOfPrintServices() {
final List<PrintServiceInfo> printServices = mock(List.class);
@@ -69,7 +86,7 @@ public class PrintSettingsFragmentTest {
when(printServices.size()).thenReturn(2);
// 2 services
when(mPrintManager.getPrintServices(PrintManager.ENABLED_SERVICES))
.thenReturn(printServices);
.thenReturn(printServices);
mSummaryProvider.setListening(true);