-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release 0.2.0
- Loading branch information
Showing
45 changed files
with
1,001 additions
and
168 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
2 changes: 1 addition & 1 deletion
2
caliper-annotation-processor/src/test/resources/field-kt.caliper.json
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"proxiedMethods":[],"proxiedFields":[{"className":"android/provider/Settings$Secure","fieldName":"SERIAL","opcode":178,"replacedClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInKtForFieldReplacement_CaliperWrapper","replacedMethodName":"getString"}],"proxiedClasses":[]} | ||
{"proxiedMethods":[],"proxiedFields":[{"targetClassName":"android/provider/Settings$Secure","targetFieldName":"SERIAL","targetOpcode":178,"newClassName":"me/xx2bab/caliper/test/ProxyWrittenInKtForFieldReplacement","newMethodName":"getString","wrapperClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInKtForFieldReplacement_CaliperWrapper","wrapperMethodName":"getString"}],"proxiedClasses":[]} |
2 changes: 1 addition & 1 deletion
2
caliper-annotation-processor/src/test/resources/field.caliper.json
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"proxiedMethods":[],"proxiedFields":[{"className":"android/provider/Settings$Secure","fieldName":"SERIAL","opcode":178,"replacedClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInJavaForFieldReplacement_CaliperWrapper","replacedMethodName":"getString"}],"proxiedClasses":[]} | ||
{"proxiedMethods":[],"proxiedFields":[{"targetClassName":"android/provider/Settings$Secure","targetFieldName":"SERIAL","targetOpcode":178,"newClassName":"me/xx2bab/caliper/test/ProxyWrittenInJavaForFieldReplacement","newMethodName":"getString","wrapperClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInJavaForFieldReplacement_CaliperWrapper","wrapperMethodName":"getString"}],"proxiedClasses":[]} |
2 changes: 1 addition & 1 deletion
2
caliper-annotation-processor/src/test/resources/method-kt.caliper.json
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"proxiedMethods":[{"className":"android/provider/Settings$Secure","methodName":"getString","opcode":184,"replacedClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInKtForMethodReplacement_CaliperWrapper","replacedMethodName":"getString"}],"proxiedFields":[],"proxiedClasses":[]} | ||
{"proxiedMethods":[{"targetClassName":"android/provider/Settings$Secure","targetMethodName":"getString","targetOpcode":184,"newClassName":"me/xx2bab/caliper/test/ProxyWrittenInKtForMethodReplacement","newMethodName":"getString","wrapperClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInKtForMethodReplacement_CaliperWrapper","wrapperMethodName":"getString"}],"proxiedFields":[],"proxiedClasses":[]} |
2 changes: 1 addition & 1 deletion
2
caliper-annotation-processor/src/test/resources/method.caliper.json
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"proxiedMethods":[{"className":"android/provider/Settings$Secure","methodName":"getString","opcode":184,"replacedClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInJavaForMethodReplacement_CaliperWrapper","replacedMethodName":"getString"}],"proxiedFields":[],"proxiedClasses":[]} | ||
{"proxiedMethods":[{"targetClassName":"android/provider/Settings$Secure","targetMethodName":"getString","targetOpcode":184,"newClassName":"me/xx2bab/caliper/test/ProxyWrittenInJavaForMethodReplacement","newMethodName":"getString","wrapperClassName":"me/xx2bab/caliper/runtime/wrapper/ProxyWrittenInJavaForMethodReplacement_CaliperWrapper","wrapperMethodName":"getString"}],"proxiedFields":[],"proxiedClasses":[]} |
1 change: 1 addition & 0 deletions
1
caliper-annotation-processor/src/test/resources/thread-kt.caliper.json
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 @@ | ||
{"proxiedMethods":[],"proxiedFields":[],"proxiedClasses":[{"targetClassName":"java/lang/Thread","newClassName":"me/xx2bab/caliper/test/ThreadClassProxyWrittenInKotlin"}]} |
2 changes: 1 addition & 1 deletion
2
caliper-annotation-processor/src/test/resources/thread.caliper.json
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 |
---|---|---|
@@ -1 +1 @@ | ||
{"proxiedMethods":[],"proxiedFields":[],"proxiedClasses":[{"className":"java.lang.Thread","replacedClassName":"me/xx2bab/caliper/test/ThreadClassProxyWrittenInJava"}]} | ||
{"proxiedMethods":[],"proxiedFields":[],"proxiedClasses":[{"targetClassName":"java/lang/Thread","newClassName":"me/xx2bab/caliper/test/ThreadClassProxyWrittenInJava"}]} |
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
17 changes: 17 additions & 0 deletions
17
...-metadata/local-res-jar/src/main/java/me/xx2bab/caliper/sample/customproxy/CustomProxy.kt
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,17 @@ | ||
package me.xx2bab.caliper.sample.customproxy | ||
|
||
import me.xx2bab.caliper.anno.ASMOpcodes | ||
import me.xx2bab.caliper.anno.CaliperMethodProxy | ||
import me.xx2bab.caliper.sample.library.LibrarySampleClass | ||
|
||
object CustomProxy { | ||
|
||
@CaliperMethodProxy( | ||
className = "me/xx2bab/caliper/sample/library/LibrarySampleClass", | ||
methodName = "commonMethodReturnsString", | ||
opcode = ASMOpcodes.INVOKEVIRTUAL | ||
) | ||
@JvmStatic | ||
fun commonMethodReturnsString(lib: LibrarySampleClass) = "CustomProxy" | ||
|
||
} |
Binary file added
BIN
+6.13 KB
caliper-gradle-plugin/src/fixtures/gen-metadata/remote-class-jar/classes.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion
2
...bab/caliper/gradle/core/ASMManipulator.kt → ...e/xx2bab/caliper/gradle/ASMManipulator.kt
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
3 changes: 1 addition & 2 deletions
3
...me/xx2bab/caliper/CaliperExtensionTest.kt → ...ab/caliper/gradle/CaliperExtensionTest.kt
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
99 changes: 99 additions & 0 deletions
99
...c/integrationTest/kotlin/me/xx2bab/caliper/gradle/core/CaliperProxyConfigCollectorTest.kt
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,99 @@ | ||
package me.xx2bab.caliper.gradle.core | ||
|
||
import io.mockk.spyk | ||
import me.xx2bab.caliper.anno.ASMOpcodes | ||
import me.xx2bab.caliper.common.ProxiedMethod | ||
import org.hamcrest.MatcherAssert.assertThat | ||
import org.hamcrest.Matchers.containsInAnyOrder | ||
import org.hamcrest.Matchers.`is` | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
|
||
class CaliperProxyConfigCollectorTest { | ||
|
||
private val kLogger = spyk( | ||
object : KLogger { | ||
override fun lifecycle(message: String) {} | ||
override fun info(message: String) {} | ||
override fun warn(message: String) {} | ||
override fun error(message: String) {} | ||
override fun debug(message: String) {} | ||
}) | ||
|
||
@Test | ||
fun `doCollect() aggregates metadata from local project successfully`() { | ||
val config = CaliperProxyConfigCollector(kLogger) | ||
val localResJar = File( | ||
"src/fixtures/gen-metadata/local-res-jar" + | ||
"/build/intermediates/library_java_res/debug/res.jar" | ||
) | ||
val result = config.doCollect(setOf(localResJar)) | ||
assertThat(result.proxiedMethods.size, `is`(1)) | ||
assertThat(result.proxiedMethods.first().targetMethodName, `is`("commonMethodReturnsString")) | ||
assertThat( | ||
result.proxiedMethods.first().targetClassName, | ||
`is`("me/xx2bab/caliper/sample/library/LibrarySampleClass") | ||
) | ||
assertThat(result.proxiedMethods.first().targetOpcode, `is`(ASMOpcodes.INVOKEVIRTUAL)) | ||
assertThat( | ||
result.proxiedMethods.first().wrapperMethodName, | ||
`is`("commonMethodReturnsString") | ||
) | ||
assertThat( | ||
result.proxiedMethods.first().wrapperClassName, | ||
`is`("me/xx2bab/caliper/runtime/wrapper/CustomProxy_CaliperWrapper") | ||
) | ||
} | ||
|
||
@Test | ||
fun `doCollect() aggregates metadata from remote artifact successfully`() { | ||
val config = CaliperProxyConfigCollector(kLogger) | ||
val remoteClassJar = File( | ||
"src/fixtures/gen-metadata/remote-class-jar" + | ||
"/classes.jar" | ||
) | ||
val result = config.doCollect(setOf(remoteClassJar)) | ||
|
||
assertThat(result.proxiedMethods.size, `is`(3)) | ||
assertThat(result.proxiedMethods, containsInAnyOrder( | ||
ProxiedMethod( | ||
"android/os/Build", | ||
"getSerial", | ||
ASMOpcodes.INVOKESTATIC, | ||
"me/xx2bab/caliper/privacy/AndroidOSBuildProxy", | ||
"getSerial", | ||
"me/xx2bab/caliper/runtime/wrapper/AndroidOSBuildProxy_CaliperWrapper", | ||
"getSerial" | ||
), | ||
ProxiedMethod( | ||
"android/provider/Settings\$Secure", | ||
"getString", | ||
ASMOpcodes.INVOKESTATIC, | ||
"me/xx2bab/caliper/privacy/SettingsSecureProxy", | ||
"getString", | ||
"me/xx2bab/caliper/runtime/wrapper/SettingsSecureProxy_CaliperWrapper", | ||
"getString" | ||
), | ||
ProxiedMethod( | ||
"android/app/Activity", | ||
"requestPermissions", | ||
ASMOpcodes.INVOKEVIRTUAL, | ||
"me/xx2bab/caliper/privacy/ActivityProxy", | ||
"requestPermissions", | ||
"me/xx2bab/caliper/runtime/wrapper/ActivityProxy_CaliperWrapper", | ||
"requestPermissions" | ||
) | ||
)) | ||
|
||
assertThat(result.proxiedFields.size, `is`(1)) | ||
assertThat(result.proxiedFields.first().targetFieldName, `is`("SERIAL")) | ||
assertThat(result.proxiedFields.first().targetClassName, `is`("android/os/Build")) | ||
assertThat(result.proxiedFields.first().targetOpcode, `is`(ASMOpcodes.GETSTATIC)) | ||
assertThat(result.proxiedFields.first().wrapperMethodName, `is`("getSerialField")) | ||
assertThat( | ||
result.proxiedFields.first().wrapperClassName, | ||
`is`("me/xx2bab/caliper/runtime/wrapper/AndroidOSBuildProxy_CaliperWrapper") | ||
) | ||
} | ||
|
||
} |
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
Oops, something went wrong.