-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
218 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
jadx-core/src/test/java/jadx/core/utils/TestGetBetterClassName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package jadx.core.utils; | ||
|
||
import org.assertj.core.api.AbstractStringAssert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static jadx.core.utils.BetterName.getBetterClassName; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class TestGetBetterClassName { | ||
|
||
@Test | ||
public void testGoodNamesVsGeneratedAliases() { | ||
assertThatBetterClassName("AppCompatButton", "C2404e2").isEqualTo("AppCompatButton"); | ||
assertThatBetterClassName("ContextThemeWrapper", "C2106b1").isEqualTo("ContextThemeWrapper"); | ||
assertThatBetterClassName("ListPopupWindow", "C2344a3").isEqualTo("ListPopupWindow"); | ||
} | ||
|
||
@Test | ||
public void testShortGoodNamesVsGeneratedAliases() { | ||
assertThatBetterClassName("Room", "C2937kh").isEqualTo("Room"); | ||
assertThatBetterClassName("Fade", "C1428qi").isEqualTo("Fade"); | ||
assertThatBetterClassName("Scene", "C4063yi").isEqualTo("Scene"); | ||
} | ||
|
||
@Test | ||
public void testGoodNamesVsGeneratedAliasesWithPrefix() { | ||
assertThatBetterClassName("AppCompatActivity", "ActivityC2646h0").isEqualTo("AppCompatActivity"); | ||
assertThatBetterClassName("PagerAdapter", "AbstractC3038lk").isEqualTo("PagerAdapter"); | ||
assertThatBetterClassName("Lazy", "InterfaceC6434a").isEqualTo("Lazy"); | ||
assertThatBetterClassName("MembersInjector", "InterfaceC6435b").isEqualTo("MembersInjector"); | ||
assertThatBetterClassName("Subscriber", "InterfaceC6439c").isEqualTo("Subscriber"); | ||
} | ||
|
||
@Test | ||
public void testGoodNamesWithDigitsVsGeneratedAliases() { | ||
assertThatBetterClassName("ISO8061Formatter", "C1121uq4").isEqualTo("ISO8061Formatter"); | ||
assertThatBetterClassName("Jdk9Platform", "C1189rn6").isEqualTo("Jdk9Platform"); | ||
assertThatBetterClassName("WrappedDrawableApi14", "C2847i9").isEqualTo("WrappedDrawableApi14"); | ||
assertThatBetterClassName("WrappedDrawableApi21", "C2888j9").isEqualTo("WrappedDrawableApi21"); | ||
} | ||
|
||
@Test | ||
public void testShortNamesVsLongNames() { | ||
assertThatBetterClassName("az", "Observer").isEqualTo("Observer"); | ||
assertThatBetterClassName("bb", "RenderEvent").isEqualTo("RenderEvent"); | ||
assertThatBetterClassName("aaaa", "FontUtils").isEqualTo("FontUtils"); | ||
} | ||
|
||
/** | ||
* Tests {@link BetterName#getBetterClassName(String, String)} on equally good names. | ||
* In this case, according to the documentation, the method should return the first argument. | ||
* | ||
* @see BetterName#getBetterClassName(String, String) | ||
*/ | ||
@Test | ||
public void testEquallyGoodNames() { | ||
assertThatBetterClassName("AAAA", "BBBB").isEqualTo("AAAA"); | ||
assertThatBetterClassName("BBBB", "AAAA").isEqualTo("BBBB"); | ||
|
||
assertThatBetterClassName("XYXYXY", "YZYZYZ").isEqualTo("XYXYXY"); | ||
assertThatBetterClassName("YZYZYZ", "XYXYXY").isEqualTo("YZYZYZ"); | ||
} | ||
|
||
private AbstractStringAssert<?> assertThatBetterClassName(String firstName, String secondName) { | ||
return assertThat(getBetterClassName(firstName, secondName)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
jadx-core/src/test/java/jadx/core/utils/TestGetBetterResourceName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package jadx.core.utils; | ||
|
||
import org.assertj.core.api.AbstractStringAssert; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static jadx.core.utils.BetterName.getBetterResourceName; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class TestGetBetterResourceName { | ||
|
||
@Test | ||
public void testGoodNamesVsSyntheticNames() { | ||
assertThatBetterResourceName("color_main", "t0").isEqualTo("color_main"); | ||
assertThatBetterResourceName("done", "oOo0oO0o").isEqualTo("done"); | ||
} | ||
|
||
/** | ||
* Tests {@link BetterName#getBetterResourceName(String, String)} on equally good names. | ||
* In this case, according to the documentation, the method should return the first argument. | ||
* | ||
* @see BetterName#getBetterResourceName(String, String) | ||
*/ | ||
@Test | ||
public void testEquallyGoodNames() { | ||
assertThatBetterResourceName("AAAA", "BBBB").isEqualTo("AAAA"); | ||
assertThatBetterResourceName("BBBB", "AAAA").isEqualTo("BBBB"); | ||
|
||
assertThatBetterResourceName("Theme.AppCompat.Light", "Theme_AppCompat_Light") | ||
.isEqualTo("Theme.AppCompat.Light"); | ||
assertThatBetterResourceName("Theme_AppCompat_Light", "Theme.AppCompat.Light") | ||
.isEqualTo("Theme_AppCompat_Light"); | ||
} | ||
|
||
private AbstractStringAssert<?> assertThatBetterResourceName(String firstName, String secondName) { | ||
return assertThat(getBetterResourceName(firstName, secondName)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters