Skip to content

Commit fd4c3b6

Browse files
authored
Merge branch 'main' into fnewberg/use-upload-sdk-version-action
2 parents 9c5aa68 + f4cb1a8 commit fd4c3b6

28 files changed

Lines changed: 224 additions & 711 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
plugins {
2+
id("com.android.application")
3+
id("io.embrace.swazzler")
4+
id("io.embrace.android.testplugin")
5+
}
6+
7+
repositories {
8+
google()
9+
mavenCentral()
10+
mavenLocal()
11+
}
12+
13+
integrationTest.configureAndroidProject(project)
14+
15+
embrace {
16+
autoAddEmbraceDependencies.set(true)
17+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-keep class com.example.app.Foo { *; }
2+
-keep class io.embrace.android.embracesdk.internal.config.instrumented.* { *; }
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest />
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"app_id": "abcde",
3+
"api_token": "12345123451234512345123451234512",
4+
"ndk_enabled": true
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.app;
2+
3+
public class Bar {
4+
public static String getBar() {
5+
return "bar";
6+
}
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example.app;
2+
3+
public class Foo {
4+
public static String getFoo() {
5+
return "foo";
6+
}
7+
}

embrace-gradle-plugin-integration-tests/src/main/java/io/embrace/android/gradle/integration/framework/SetupInterface.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ class SetupInterface(
4040
enqueueResponse(endpoint, response)
4141
}
4242

43+
fun SetupInterface.setupEmptyHandshakeResponse() {
44+
val json = serializeRequestBody(NdkUploadHandshakeResponse(null))
45+
enqueueResponse(EmbraceEndpoint.NDK_HANDSHAKE, MockResponse().setBody(json))
46+
}
47+
4348
fun SetupInterface.setupMapResponseWithEmptyValues(endpoint: EmbraceEndpoint) {
4449
val response = """
4550
{

embrace-gradle-plugin-integration-tests/src/test/java/io/embrace/android/gradle/integration/testcases/AndroidNdkTest.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ class AndroidNdkTest {
100100
)
101101
}
102102

103-
// When a 3rd party dependency has native libraries, but the project has no externalNativeBuild block, we don't send symbols (yet).
104103
@Test
105-
fun `don't send 3rd party native library symbols when the project has no native libraries`() {
104+
fun `send 3rd party native library symbols even when the project has no native libraries`() {
106105
rule.runTest(
107106
fixture = "android-3rd-party-symbols",
108107
task = "build",
@@ -116,8 +115,8 @@ class AndroidNdkTest {
116115
},
117116
assertions = {
118117
verifyBuildTelemetryRequestSent(defaultExpectedVariants)
119-
verifyNoHandshakes()
120-
verifyNoUploads()
118+
verifyHandshakes(defaultExpectedLibs, defaultExpectedArchs, defaultExpectedVariants)
119+
verifyUploads(defaultExpectedLibs, defaultExpectedArchs, defaultExpectedVariants)
121120
}
122121
)
123122
}

embrace-gradle-plugin-integration-tests/src/test/java/io/embrace/android/gradle/integration/testcases/ConfigInstrumentationTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ class ConfigInstrumentationTest {
5656
File(projectDir, "src/main/embrace-config.json").outputStream().buffered().use {
5757
ResourceReader.readResource("config-overrides.json").buffered().copyTo(it)
5858
}
59+
// TODO: why is libembrace-native uploaded in this fixture, but not in the rest?
60+
setupMockResponses(
61+
expectedLibs = listOf("libembrace-native.so"),
62+
expectedArchs = listOf("x86_64", "x86", "armeabi-v7a", "arm64-v8a"),
63+
expectedVariants = listOf("debug", "release")
64+
)
5965
},
6066
assertions = { projectDir ->
6167
verifyInstrumentedConfig(projectDir, "instrumented-config-overrides.json")

embrace-gradle-plugin-integration-tests/src/test/java/io/embrace/android/gradle/integration/testcases/ReactNativeAndroidTest.kt

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,43 @@ class ReactNativeAndroidTest {
4848
installNodeModules(projectDir)
4949
setupMockResponses(handshakeLibs, handshakeArchs, defaultExpectedVariants)
5050
},
51-
assertions = { projectDir ->
51+
assertions = {
5252
verifyBuildTelemetryRequestSent(defaultExpectedVariants)
5353
verifyHandshakes(defaultExpectedLibs, defaultExpectedArchs, defaultExpectedVariants)
5454
verifyUploads(handshakeLibs, handshakeArchs, defaultExpectedVariants)
55-
verifyAsmInjection(projectDir)
55+
}
56+
)
57+
}
58+
59+
@Test
60+
fun `react native asm injection test`() {
61+
rule.runTest(
62+
fixture = "react-native-android",
63+
androidProjectRoot = "android",
64+
task = "assembleRelease",
65+
setup = { projectDir ->
66+
setupEmptyHandshakeResponse()
67+
installNodeModules(projectDir)
68+
},
69+
assertions = { projectDir ->
70+
verifyAsmInjection(File(projectDir, "app"), "765FB008173DC25D016D112F67250241")
71+
}
72+
)
73+
}
74+
75+
@Test
76+
fun `react native project without bundle or sourcemap`() {
77+
rule.runTest(
78+
fixture = "not-react-native-android",
79+
androidProjectRoot = "android",
80+
additionalArgs = listOf("-Pandroid.useAndroidX=true"),
81+
task = "assembleRelease",
82+
setup = {
83+
setupEmptyHandshakeResponse()
84+
},
85+
assertions = { projectDir ->
86+
verifyNoUploads()
87+
verifyAsmInjection(projectDir, null)
5688
}
5789
)
5890
}
@@ -71,10 +103,10 @@ class ReactNativeAndroidTest {
71103
}
72104
}
73105

74-
private fun verifyAsmInjection(projectDir: File) {
106+
private fun verifyAsmInjection(buildDir: File, expectedBundleId: String?) {
75107
// Read and parse the smali file containing the injected symbols
76108
val smaliFile = SmaliConfigReader().readSmaliFiles(
77-
File(projectDir, "app"),
109+
buildDir,
78110
listOf("/io/embrace/android/embracesdk/internal/config/instrumented/ProjectConfigImpl")
79111
).first()
80112

@@ -84,6 +116,6 @@ class ReactNativeAndroidTest {
84116
listOf(SmaliMethod("getReactNativeBundleId()Ljava/lang/String;"))
85117
).methods.first()
86118

87-
assertEquals("765FB008173DC25D016D112F67250241", method.returnValue)
119+
assertEquals(expectedBundleId, method.returnValue)
88120
}
89121
}

0 commit comments

Comments
 (0)