Skip to content

Commit 90c3933

Browse files
author
Ali Abdelfattah
authored
Merge branch 'release/10.11.0' into update/support-graphQL
2 parents 856208f + aa26286 commit 90c3933

File tree

113 files changed

+16663
-6085
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

113 files changed

+16663
-6085
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ workflows:
223223
context: cross-platform
224224
- test_module
225225
- test_sample
226-
# - test_android
226+
- test_android
227227
- test_ios
228228
- e2e_ios
229229
# - e2e_android
File renamed without changes.

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## master
22

33
* Adds GraphQL support for APM network traces with proper grouping
4+
* Adds APM.endAppLaunch API
5+
* Fixes an issue with iOS sourcemap upload that causes the build to fail
46

57
## 10.9.1 (2021-10-13)
68

Dangerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ if github.pr_body.length < 3 && git.lines_of_code > 10
88
end
99

1010
if !git.modified_files.include?("CHANGELOG.md") && !declared_trivial
11-
fail("Please include a CHANGELOG entry. \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-Flutter/blob/master/CHANGELOG.md).", sticky: false)
11+
warn("You have not included a CHANGELOG entry! \nYou can find it at [CHANGELOG.md](https://github.com/Instabug/Instabug-Flutter/blob/master/CHANGELOG.md).", sticky: false)
1212
end

InstabugSample/ios/InstabugSampleTests/InstabugAPMTests.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ - (void) testSetAppLaunchEnabled {
7777
OCMVerify([mock setAppLaunchEnabled:isEnabled]);
7878
}
7979

80+
- (void) testEndAppLaunch {
81+
id mock = OCMClassMock([IBGAPM class]);
82+
83+
OCMStub([mock endAppLaunch]);
84+
[self.instabugBridge endAppLaunch];
85+
OCMVerify([mock endAppLaunch]);
86+
}
87+
8088
- (void) testSetAutoUITraceEnabled {
8189
id mock = OCMClassMock([IBGAPM class]);
8290
BOOL isEnabled = YES;

InstabugSample/metro.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ module.exports = {
1414
},
1515
}),
1616
},
17+
maxWorkers: 2,
1718
};

__tests__/apm.spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ describe("APM Module", () => {
2121
const endExecutionTrace = sinon.spy(NativeModules.IBGAPM, "endExecutionTrace");
2222
const startUITrace = sinon.spy(NativeModules.IBGAPM, "startUITrace");
2323
const endUITrace = sinon.spy(NativeModules.IBGAPM, "endUITrace");
24+
const endAppLaunch = sinon.spy(NativeModules.IBGAPM, "endAppLaunch");
2425
const setNetworkLoggingEnabled = sinon.spy(NativeModules.Instabug, "setNetworkLoggingEnabled");
2526
const _ibgSleep = sinon.spy(NativeModules.IBGAPM, "ibgSleep");
2627

@@ -47,6 +48,12 @@ describe("APM Module", () => {
4748
expect(setNetworkLoggingEnabled.calledOnceWithExactly(true)).toBe(true);
4849
});
4950

51+
it("should call the native method endAppLaunch", () => {
52+
APM.endAppLaunch();
53+
54+
expect(endAppLaunch.calledOnceWithExactly()).toBe(true);
55+
});
56+
5057
it("should call the native method setAutoUITraceEnabled", () => {
5158
APM.setAutoUITraceEnabled(true);
5259

android/build.gradle

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,13 @@ android {
2929
dependencies {
3030
implementation 'com.android.support:multidex:1.0.3'
3131
implementation 'com.facebook.react:react-native:+'
32-
api('com.instabug.library:instabug:10.9.1') {
32+
api('com.instabug.library:instabug:10.11.0') {
3333
exclude group: 'com.android.support:appcompat-v7'
3434
}
35-
testImplementation 'org.mockito:mockito-core:1.10.19'
36-
testImplementation 'junit:junit:4.12'
37-
testImplementation 'org.powermock:powermock-api-mockito:1.6.6'
38-
testImplementation 'org.powermock:powermock-module-junit4-rule-agent:1.6.2'
39-
testImplementation 'org.powermock:powermock-module-junit4-rule:1.6.6'
40-
testImplementation 'org.powermock:powermock-module-junit4:1.6.6'
35+
testImplementation "org.mockito:mockito-inline:3.4.0"
36+
testImplementation "org.mockito:mockito-android:3.4.0"
37+
testImplementation 'junit:junit:4.13.2'
38+
4139
}
4240

4341

android/src/main/java/com/instabug/reactlibrary/RNInstabugAPMModule.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,23 @@ public void run() {
128128
});
129129
}
130130

131+
/**
132+
* Ends app launch
133+
*/
134+
@ReactMethod
135+
public void endAppLaunch() {
136+
MainThreadHandler.runOnMainThread(new Runnable() {
137+
@Override
138+
public void run() {
139+
try {
140+
APM.endAppLaunch();
141+
} catch (Exception e) {
142+
e.printStackTrace();
143+
}
144+
}
145+
});
146+
}
147+
131148
/**
132149
* Enables or disables auto UI tracing
133150
* @param isEnabled boolean indicating enabled or disabled.
Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,122 +1,127 @@
11
package com.instabug.reactlibrary;
2-
3-
import android.os.Handler;
42
import android.os.Looper;
5-
import android.os.SystemClock;
63

74
import com.facebook.react.bridge.Callback;
85
import com.instabug.apm.APM;
9-
import com.instabug.apm.model.ExecutionTrace;
106

11-
import com.facebook.react.bridge.Arguments;
12-
import com.instabug.reactlibrary.utils.InstabugUtil;
137
import com.instabug.reactlibrary.utils.MainThreadHandler;
148

15-
import org.json.JSONArray;
9+
import org.junit.After;
1610
import org.junit.Before;
1711
import org.junit.Test;
18-
import org.junit.runner.RunWith;
19-
import org.mockito.Matchers;
20-
import org.mockito.internal.verification.VerificationModeFactory;
12+
import org.mockito.MockedStatic;
2113
import org.mockito.invocation.InvocationOnMock;
2214
import org.mockito.stubbing.Answer;
23-
import org.powermock.api.mockito.PowerMockito;
24-
import org.powermock.core.classloader.annotations.PrepareForTest;
25-
import org.powermock.modules.junit4.PowerMockRunner;
2615

2716
import java.util.concurrent.Executors;
2817
import java.util.concurrent.ScheduledExecutorService;
2918

30-
import static org.mockito.Matchers.any;
31-
import static org.mockito.Matchers.anyLong;
32-
import static org.mockito.Matchers.eq;
19+
import static org.mockito.ArgumentMatchers.any;
20+
import static org.mockito.Mockito.doAnswer;
21+
import static org.mockito.Mockito.mock;
22+
import static org.mockito.Mockito.mockStatic;
23+
import static org.mockito.Mockito.times;
3324
import static org.mockito.Mockito.verify;
34-
import static org.powermock.api.mockito.PowerMockito.doAnswer;
35-
import static org.powermock.api.mockito.PowerMockito.mock;
36-
import static org.powermock.api.mockito.PowerMockito.when;
37-
38-
@RunWith(PowerMockRunner.class)
39-
@PrepareForTest({Looper.class, android.os.Handler.class, APM.class, ExecutionTrace.class, SystemClock.class, Runnable.class, RNInstabugAPMModule.class, Arguments.class, InstabugUtil.class, MainThreadHandler.class})
25+
import static org.mockito.Mockito.when;
4026

4127
public class RNInstabugAPMModuleTest {
4228

4329
private RNInstabugAPMModule apmModule = new RNInstabugAPMModule(null);
44-
4530
private final static ScheduledExecutorService mainThread = Executors.newSingleThreadScheduledExecutor();
4631

32+
// Mock Objects
33+
private MockedStatic<Looper> mockLooper;
34+
private MockedStatic <MainThreadHandler> mockMainThreadHandler;
35+
private MockedStatic <APM> mockAPM;
36+
4737
@Before
4838
public void mockMainThreadHandler() throws Exception {
49-
PowerMockito.mockStatic(Looper.class);
39+
// Mock static functions
40+
mockAPM = mockStatic(APM.class);
41+
mockLooper = mockStatic(Looper.class);
42+
mockMainThreadHandler = mockStatic(MainThreadHandler.class);
43+
44+
// Mock Looper class
5045
Looper mockMainThreadLooper = mock(Looper.class);
5146
when(Looper.getMainLooper()).thenReturn(mockMainThreadLooper);
52-
Handler mockMainThreadHandler = mock(Handler.class);
47+
48+
// Override runOnMainThread
5349
Answer<Boolean> handlerPostAnswer = new Answer<Boolean>() {
5450
@Override
5551
public Boolean answer(InvocationOnMock invocation) throws Throwable {
56-
invocation.getArgumentAt(0, Runnable.class).run();
52+
invocation.getArgument(0, Runnable.class).run();
5753
return true;
5854
}
5955
};
60-
doAnswer(handlerPostAnswer).when(mockMainThreadHandler).post(any(Runnable.class));
61-
doAnswer(handlerPostAnswer).when(mockMainThreadHandler).postDelayed(any(Runnable.class), anyLong());
62-
PowerMockito.whenNew(Handler.class).withArguments(mockMainThreadLooper).thenReturn(mockMainThreadHandler);
56+
doAnswer(handlerPostAnswer).when(MainThreadHandler.class);
57+
MainThreadHandler.runOnMainThread(any(Runnable.class));
58+
}
59+
@After
60+
public void tearDown() {
61+
// Remove static mocks
62+
mockLooper.close();
63+
mockMainThreadHandler.close();
64+
mockAPM.close();
6365
}
6466

6567
/********APM*********/
6668

6769
@Test
68-
public void givenFalse$setEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() {
69-
// given
70-
PowerMockito.mockStatic(APM.class);
70+
public void givenFalsesetEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() {
7171
// when
7272
apmModule.setEnabled(false);
7373
// then
74-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
74+
verify(APM.class, times(1));
7575
APM.setEnabled(false);
7676
}
7777

7878
@Test
79-
public void givenTrue$setEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() {
80-
// given
81-
PowerMockito.mockStatic(APM.class);
79+
public void givenTruesetEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() {
8280
// when
8381
apmModule.setEnabled(true);
8482
// then
85-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
83+
verify(APM.class, times(1));
8684
APM.setEnabled(true);
8785
}
8886

8987
@Test
9088
public void givenFalse$setAppLaunchEnabled_whenQuery_thenShouldCallNativeApiWithDisabled() {
91-
// given
92-
PowerMockito.mockStatic(APM.class);
89+
9390
// when
9491
apmModule.setAppLaunchEnabled(false);
9592
// then
96-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
93+
verify(APM.class, times(1));
9794
APM.setAppLaunchEnabled(false);
9895
}
9996

10097
@Test
10198
public void givenTrue$setAppLaunchEnabled_whenQuery_thenShouldCallNativeApiWithEnabled() {
102-
// given
103-
PowerMockito.mockStatic(APM.class);
99+
104100
// when
105101
apmModule.setAppLaunchEnabled(true);
106102
// then
107-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
103+
verify(APM.class, times(1));
108104
APM.setAppLaunchEnabled(true);
109105
}
110106

107+
@Test
108+
public void given$endAppLaunch_whenQuery_thenShouldCallNativeApiWithEnabled() {
109+
110+
// when
111+
apmModule.endAppLaunch();
112+
// then
113+
verify(APM.class, times(1));
114+
APM.endAppLaunch();
115+
}
116+
111117
@Test
112118
public void givenString$startExecutionTrace_whenQuery_thenShouldCallNativeApi() {
113-
// given
114-
PowerMockito.mockStatic(APM.class);
119+
115120
Callback callback = mock(Callback.class);
116121
// when
117122
apmModule.startExecutionTrace("trace", "1", callback);
118123
// then
119-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
124+
verify(APM.class, times(1));
120125
APM.startExecutionTrace("trace");
121126
verify(callback).invoke(any());
122127
}
@@ -151,24 +156,22 @@ public Boolean answer(InvocationOnMock invocation) throws Throwable {
151156

152157
@Test
153158
public void givenString$startUITrace_whenQuery_thenShouldCallNativeApiWithEnabled() {
154-
// given
155-
PowerMockito.mockStatic(APM.class);
159+
156160
// when
157161
apmModule.startUITrace("uiTrace");
158162
// then
159-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
163+
verify(APM.class, times(1));
160164
APM.startUITrace("uiTrace");
161165
}
162166

163167
@Test
164168
public void given$endUITrace_whenQuery_thenShouldCallNativeApiWithEnabled() {
165-
// given
166-
PowerMockito.mockStatic(APM.class);
169+
167170
// when
168171
apmModule.startUITrace("uiTrace");
169172
apmModule.endUITrace();
170173
// then
171-
PowerMockito.verifyStatic(VerificationModeFactory.times(1));
174+
verify(APM.class, times(1));
172175
APM.endUITrace();
173176
}
174177
}

0 commit comments

Comments
 (0)