WebpSuggester implements BundleEntrySuggester, ProjectTreeSuggester { @Override public ImmutableList<Suggestion> processProjectEntry(GradleContext context, FileData fileData) { return processFileEntry(context, fileData); } WebpSuggester(); @VisibleForTesting  WebpSuggester(WebpConverter webpConverter); @Override ImmutableList<Suggestion> processBundleZipEntry(BundleContext context, FileData fileData); @Override ImmutableList<Suggestion> processProjectEntry(GradleContext context, FileData fileData);  }
@Test public void losslessReducibleDrawing_supportedApiLevel_reducesSize() throws Exception { FakeWebpConverter fakeConverter = new FakeWebpConverter(); WebpSuggester webpSuggester = new WebpSuggester(fakeConverter); int webpSize = (int) (DRAWING_FILE_SIZE - WebpSuggester.SIZE_REDUCTION_THRESHOLD_BYTES - 100); byte[] webpBytes = new byte[webpSize]; fakeConverter.setFakeData(webpBytes); SystemFileData systemFileData = new SystemFileData(getTestDataFile(PNG_DRAWING), Paths.get("drawing.png")); List<Suggestion> suggestions = webpSuggester.processProjectEntry( GradleContext.create(MIN_SDK_VERSION_SUPPORTING_LOSSLESS_WEBP, false), systemFileData); assertThat(suggestions) .containsExactly( Suggestion.create( Suggestion.IssueType.WEBP, Suggestion.Category.WEBP, Payload.newBuilder() .setWebpData( WebpData.newBuilder() .setFile(FileEntryData.newBuilder().setFilePath("drawing.png"))) .build(), "Convert drawing.png to webp with lossless encoding", 200L, new WebpAutoFix(systemFileData.getSystemPath()))); }