### Question:
Aapt2RenamingConventions { @NonNull public static String compilationRename(@NonNull File f) throws Aapt2Exception { String fileName = f.getName(); File fileParent = f.getParentFile(); if (fileParent == null) { throw Aapt2Exception.create("Could not get parent of file '" + f.getAbsolutePath() + "'"); } String parentName = fileParent.getName(); int extIdx = fileName.lastIndexOf('.'); String ext = extIdx == -1 ? "" : fileName.substring(extIdx); fileName = extIdx == -1 ? fileName : fileName.substring(0, extIdx); if (parentName.startsWith("values") && ext.equals(".xml")) { ext = ".arsc"; } return parentName + "_" + fileName + ext + ".flat"; } private  Aapt2RenamingConventions(); @NonNull static String compilationRename(@NonNull File f);  }### Answer:
@Test public void testRenameDrawable() throws Exception { File drawables = temporaryFolder.newFolder("drawables"); File fooPng = new File(drawables, "foo.png"); String renamed = Aapt2RenamingConventions.compilationRename(fooPng); assertEquals("drawables_foo.png.flat", renamed); }
@Test public void testRenameQualifiedDrawable() throws Exception { File drawables = temporaryFolder.newFolder("drawables-xhdpi-v21"); File fooPng = new File(drawables, "foo.png"); String renamed = Aapt2RenamingConventions.compilationRename(fooPng); assertEquals("drawables-xhdpi-v21_foo.png.flat", renamed); }
@Test public void testRenameStrings() throws Exception { File values = temporaryFolder.newFolder("values"); File strings = new File(values, "strings.xml"); String renamed = Aapt2RenamingConventions.compilationRename(strings); assertEquals("values_strings.arsc.flat", renamed); }
@Test public void testRenameValues() throws Exception { File values = temporaryFolder.newFolder("values"); File strings = new File(values, "values.xml"); String renamed = Aapt2RenamingConventions.compilationRename(strings); assertEquals("values_values.arsc.flat", renamed); }