Skip to content

feat: add screen loading manual & automatic approaches #477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 115 commits into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
59bccda
chore: deprecate execution traces APIs
abdelhamid-f-nasser Feb 21, 2024
ca3c399
feat: support app flows
abdelhamid-f-nasser Feb 21, 2024
9c09365
chore: reformat files
abdelhamid-f-nasser Feb 21, 2024
537038d
docs: update changelog.md
abdelhamid-f-nasser Feb 21, 2024
ea5a5a8
docs: update deprecation notice with APM prefix
abdelhamid-f-nasser Feb 21, 2024
1167181
chore(example): add network_security_config to support proxy
abdelhamid-f-nasser Jan 23, 2024
1080627
chore(example): add flutter_lints for dart analysis
abdelhamid-f-nasser Jan 23, 2024
0e65509
feat(example): add crash buttons
abdelhamid-f-nasser Feb 28, 2024
847f127
refactor(example): extract components to separate files
abdelhamid-f-nasser Mar 3, 2024
3061809
feat(example): introduce instabug_clipboard_icon_button
abdelhamid-f-nasser Mar 3, 2024
70a7d07
feat(example): introduce instabug_clipboard_input
abdelhamid-f-nasser Mar 3, 2024
0effd8d
build(example): add http package
abdelhamid-f-nasser Mar 3, 2024
a71e26a
feat(example): add APM network monitoring
abdelhamid-f-nasser Mar 3, 2024
7e03120
feat(example): add smallFontSize button constructor
abdelhamid-f-nasser Mar 3, 2024
c50db3d
feat(example): enhance instabug_text_field with customizable label style
abdelhamid-f-nasser Mar 3, 2024
e4a764b
feat(example): add traces widget
abdelhamid-f-nasser Mar 3, 2024
29df3aa
feat(example): add apm traces widget
abdelhamid-f-nasser Mar 3, 2024
f5a1696
WIP: adding app flows snapshot
abdelhamid-f-nasser Mar 3, 2024
d1687b0
refactor: change flow attribute value to nullable
abdelhamid-f-nasser Mar 5, 2024
f9751ca
Merge branch 'feat/support-app-flows' into feat/combo-support-app-flo…
abdelhamid-f-nasser Mar 5, 2024
bb02359
chore: update ios snapshot
abdelhamid-f-nasser Apr 14, 2024
1e6c5e5
Update CHANGELOG.md
abdelhamid-f-nasser Apr 21, 2024
6626393
Merge branch 'dev' of https://github.com/Instabug/Instabug-Flutter in…
abdelhamid-f-nasser Apr 21, 2024
5938b43
Update lib/src/modules/apm.dart
abdelhamid-f-nasser Apr 23, 2024
2ec2229
Merge branch 'feat/support-app-flows' into feat/support-manual-screen…
abdelhamid-f-nasser Apr 23, 2024
b43037f
Merge remote-tracking branch 'origin/feat/add-apm-buttons' into feat/…
abdelhamid-f-nasser Apr 23, 2024
88f5f98
feat: support screen loading monitoring
abdelhamid-f-nasser Apr 22, 2024
45f5f58
refactor(example): move apm and crashes to separate pages
abdelhamid-f-nasser Apr 22, 2024
3377e7a
fix(example): resolve infinite width for SessionReplayLink
abdelhamid-f-nasser Apr 24, 2024
22f269c
feat(example): add complex widget page
abdelhamid-f-nasser Apr 24, 2024
590511b
refactor: move screen loading files to utils
abdelhamid-f-nasser Apr 24, 2024
6bef49c
chore: change logs to debugPrint
abdelhamid-f-nasser Apr 24, 2024
ca927af
chore: expose instabug_capture_screen_loading.dart
abdelhamid-f-nasser Apr 25, 2024
98899f9
refactor: rearrange child argument to be the last parameter
abdelhamid-f-nasser Apr 25, 2024
348225c
chore: update debugging logs
abdelhamid-f-nasser Apr 25, 2024
edb0bfe
fix: resolve issues in Screen loading capturing
abdelhamid-f-nasser Apr 25, 2024
39bc3fc
refactor: allow passing keyboardType to InstabugTextField
abdelhamid-f-nasser Apr 25, 2024
ff37171
chore: apply review comments
abdelhamid-f-nasser Apr 29, 2024
a66ddfc
WIP: add ios snapshot
abdelhamid-f-nasser Apr 29, 2024
74b1294
fix: class members names
AndrewAminInstabug May 2, 2024
d637f09
Merge branches 'feat/support-manual-screen-loading' and 'feat/support…
abdelhamid-f-nasser May 4, 2024
ecc3e0b
chore: add checks for isBuilt and isEnabled
abdelhamid-f-nasser May 4, 2024
8823db8
chore: remove checks for isBuilt and isEnabled
abdelhamid-f-nasser May 5, 2024
6c9ebe8
chore: un-track generated files
abdelhamid-f-nasser May 5, 2024
ad9f8d6
chore: fix logger
abdelhamid-f-nasser May 5, 2024
11a9ee9
Merge branch 'master' into feat/add-crashes-buttons
a7medev May 7, 2024
3e5ee75
Merge branch 'feat/add-crashes-buttons' into feat/add-apm-buttons
a7medev May 7, 2024
1ff12ad
Merge branch 'feat/add-apm-buttons' into feat/support-manual-screen-l…
a7medev May 7, 2024
2074678
Merge branch 'feat/add-apm-buttons' into feat/combo-support-app-flows…
a7medev May 7, 2024
d2e30c9
Merge branch 'feat/combo-support-app-flows-with-apm-and-crashes-examp…
a7medev May 7, 2024
0f5d54a
chore: update pubspec
a7medev May 7, 2024
4cb5bd7
fix: resolve formatting issues
a7medev May 8, 2024
8ed1a52
chore: remove package:logging and put the severity values directly
a7medev May 8, 2024
797b3ea
refactor: use camel case for FlagsConfig enum and resolve analysis
a7medev May 8, 2024
5860669
feat: match ui trace screen and screen loading screen instead of equa…
a7medev May 8, 2024
f59a9fb
fix: ignore query parameters in route matcher
a7medev May 8, 2024
3f1c3cb
test: add unit tests for route matcher
a7medev May 8, 2024
10dd0c5
fix: skip is APM enabled check when starting a ui trace
a7medev May 8, 2024
859a898
refactor: use `InstabugLogger` instead of `debugPrint`
a7medev May 8, 2024
ac13eec
refactor: use `IBGDateTime` instead of `DateTime`
a7medev May 8, 2024
9f2862a
chore(ios): add logs when screen loading or APM are disabled
a7medev May 8, 2024
a347e85
fix: correctly calculate end timestamp in end screen loading api
a7medev May 8, 2024
b3cfce8
fix(android): access internal APM APIs without reflection
a7medev May 8, 2024
7bebebc
chore(android): set instabug platform in Android manifest
a7medev May 8, 2024
2388e0c
chore(ios): use negative duration fix snapshot
a7medev May 8, 2024
71f8d67
fix: endScreenLoading is not reported to native
AndrewAminInstabug May 9, 2024
2edc7b2
fix: wrong & missed log messages
AndrewAminInstabug May 13, 2024
bfefa6b
chore: commit generated files to snapshot
AndrewAminInstabug May 14, 2024
e998673
chore: generic log messages
AndrewAminInstabug May 14, 2024
beba1e4
chore: fix setScreenLoading mapping function for iOS.
AndrewAminInstabug May 15, 2024
eab1c07
chore: update instabug android snapshot from [13.0.1.5819387-SNAPSHOT…
AndrewAminInstabug May 15, 2024
6e5a854
fix: allow null for ScreenLoadingTrace in _reportScreenLoadingDropped…
abdelhamid-f-nasser May 19, 2024
ab43434
test: add unit tests for ScreenLoadingManager
abdelhamid-f-nasser May 19, 2024
5111fe7
chore: add exception handling for screen_loading_manager methods
AndrewAminInstabug May 20, 2024
7c08e5e
Revert "chore: commit generated files to snapshot"
AndrewAminInstabug May 20, 2024
448a0d9
Merge branch 'feat/support-manual-screen-loading' into feat/fix/suppo…
AndrewAminInstabug May 20, 2024
954a859
test: add unit tests for ScreenLoadingManager
abdelhamid-f-nasser May 19, 2024
1fdfd9e
chore: pull changes from feat/support-screen-loading and resolve conf…
AndrewAminInstabug May 20, 2024
e79ae86
Merge remote-tracking branch 'origin/feat/fix/support-manual-screen-l…
abdelhamid-f-nasser May 20, 2024
ed40cdf
test: add isBuilt disabled tests
abdelhamid-f-nasser May 20, 2024
363e4e9
chore: add automatic approach nav 1
AndrewAminInstabug May 22, 2024
7760240
feat: add SCL automatic approach for Navigator1,
AndrewAminInstabug May 23, 2024
3097fed
feat: sanitize the Screen name before reporting
AndrewAminInstabug May 23, 2024
e11f75e
Merge pull request #467 from Instabug/feat/support-manual-screen-load…
AndrewAminInstabug May 23, 2024
688020d
Merge branch 'feat/support-manual-screen-loading' into feat/support-a…
AndrewAminInstabug May 23, 2024
15418b0
feat: add unit test for navigator 1 wrapRoutes method
AndrewAminInstabug May 26, 2024
c9aab81
feat: add screen name sanitization unit tests and fix bug in its logic
AndrewAminInstabug May 26, 2024
3d60da7
fix: update example app to capture home page
AndrewAminInstabug May 27, 2024
70d4d66
feat: add isEndScreenLoading API
AndrewAminInstabug May 30, 2024
58b9aac
feat: add unit tests for isEndScreenLoading API
AndrewAminInstabug May 30, 2024
6098cde
fix: [endScreenLoading should End screen loading] unit test
AndrewAminInstabug May 30, 2024
13f45e9
fix: format screen_loading_manager_test.dart
AndrewAminInstabug May 30, 2024
51b3e26
fix: downgrade http package to pass test_flutter-2.10.5 ci job
AndrewAminInstabug Jun 1, 2024
9def9f7
fix: flutter failed tests , add: java jdk8 to circle ci machine
AndrewAminInstabug Jun 1, 2024
d2fc2c8
fix: java jdk8 in circle ci machine
AndrewAminInstabug Jun 1, 2024
eb401e0
Updated config.yml
AndrewAminInstabug Jun 1, 2024
bb57abe
fix: flutter 2.10.5 error
AndrewAminInstabug Jun 2, 2024
0d704ca
Updated config.yml
AndrewAminInstabug Jun 2, 2024
e44ffba
Updated config.yml
AndrewAminInstabug Jun 2, 2024
8493623
Merge pull request #469 from Instabug/feat/support-manual-screen-load…
AndrewAminInstabug Jun 3, 2024
5d55c8a
Merge remote-tracking branch 'origin/feat/support-manual-screen-loadi…
AndrewAminInstabug Jun 3, 2024
f51825d
chore: remove unused codes & format files
AndrewAminInstabug Jun 3, 2024
6881613
Merge remote-tracking branch 'origin/dev' into feat/support-manual-sc…
AndrewAminInstabug Jun 4, 2024
bf8a606
chore: revert changes in circle config.yml file, since they have been…
AndrewAminInstabug Jun 4, 2024
ad80239
Merge remote-tracking branch 'origin/feat/support-automatic-screen-lo…
AndrewAminInstabug Jun 9, 2024
f4ac87f
chore: run dart fix and flutter format
AndrewAminInstabug Jun 9, 2024
8eafcf2
Merge remote-tracking branch 'origin/dev' into feat/support-automatic…
AndrewAminInstabug Jun 9, 2024
5d7cda2
chore: pull ci changes from dev
AndrewAminInstabug Jun 9, 2024
0615009
fix: screen_loading_manager_test to pass flutter 2
AndrewAminInstabug Jun 9, 2024
3ac947f
Merge pull request #476 from Instabug/feat/support-automatic-screen-l…
AndrewAminInstabug Jun 9, 2024
e4fc848
fix: SessionReplayApiTest hashed test
AndrewAminInstabug Jun 11, 2024
fc101af
Merge remote-tracking branch 'origin/dev' into feat/screen-loading
AndrewAminInstabug Jul 7, 2024
0adc55e
chore: remove duplicate dependency in example pubspec
a7medev Jul 7, 2024
7043c29
chore(ios): remove ios snapshot
a7medev Jul 7, 2024
df6f5eb
test: skip change report types e2e test as it's flaky
a7medev Jul 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,4 @@ workflows:
- hold_release
filters:
branches:
only: master
only: master
7 changes: 7 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.instabug.flutter">

<application>
<meta-data
android:name="com.instabug.library.ibg_platform"
android:value="FLUTTER" />
</application>

</manifest>
75 changes: 75 additions & 0 deletions android/src/main/java/com/instabug/flutter/modules/ApmApi.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package com.instabug.flutter.modules;

import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.instabug.apm.APM;
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.util.Reflection;
import com.instabug.flutter.util.ThreadManager;

import io.flutter.plugin.common.BinaryMessenger;

import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -213,4 +221,71 @@ public void networkLogAndroid(@NonNull Map<String, Object> data) {
e.printStackTrace();
}
}


@Override
public void startCpUiTrace(@NonNull String screenName, @NonNull Long microTimeStamp, @NonNull Long traceId) {
try {
InternalAPM._startUiTraceCP(screenName, microTimeStamp, traceId);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void reportScreenLoadingCP(@NonNull Long startTimeStampMicro, @NonNull Long durationMicro, @NonNull Long uiTraceId) {
try {
InternalAPM._reportScreenLoadingCP(startTimeStampMicro, durationMicro, uiTraceId);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void endScreenLoadingCP(@NonNull Long timeStampMicro, @NonNull Long uiTraceId) {
try {
InternalAPM._endScreenLoadingCP(timeStampMicro, uiTraceId);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void isEndScreenLoadingEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
isScreenLoadingEnabled(result);
}

@Override
public void isEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
try {
// TODO: replace true with an actual implementation of APM.isEnabled once implemented
// in the Android SDK.
result.success(true);
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void isScreenLoadingEnabled(@NonNull ApmPigeon.Result<Boolean> result) {
try {
InternalAPM._isFeatureEnabledCP(APMFeature.SCREEN_LOADING, "InstabugCaptureScreenLoading", new FeatureAvailabilityCallback() {
@Override
public void invoke(boolean isFeatureAvailable) {
result.success(isFeatureAvailable);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}

@Override
public void setScreenLoadingEnabled(@NonNull Boolean isEnabled) {
try {
APM.setScreenLoadingEnabled(isEnabled);
} catch (Exception e) {
e.printStackTrace();
}
}
}
31 changes: 16 additions & 15 deletions android/src/main/java/com/instabug/flutter/modules/InstabugApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;

import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.generated.InstabugPigeon;
import com.instabug.flutter.util.ArgsRegistry;
import com.instabug.flutter.util.Reflection;
import com.instabug.flutter.util.ThreadManager;
import com.instabug.library.Feature;
import com.instabug.library.Instabug;
import com.instabug.library.InstabugColorTheme;
import com.instabug.library.InstabugCustomTextPlaceHolder;
import com.instabug.library.IssueType;
import com.instabug.library.Platform;
import com.instabug.library.ReproConfigurations;
import com.instabug.library.*;
import com.instabug.library.internal.module.InstabugLocale;
import com.instabug.library.invocation.InstabugInvocationEvent;
import com.instabug.library.model.NetworkLog;
import com.instabug.library.ui.onboarding.WelcomeMessage;

import io.flutter.FlutterInjector;
import io.flutter.embedding.engine.loader.FlutterLoader;
import io.flutter.plugin.common.BinaryMessenger;
import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

import java.io.File;
Expand All @@ -39,10 +34,6 @@
import java.util.Map;
import java.util.concurrent.Callable;

import io.flutter.FlutterInjector;
import io.flutter.plugin.common.BinaryMessenger;
import io.flutter.embedding.engine.loader.FlutterLoader;

public class InstabugApi implements InstabugPigeon.InstabugHostApi {
private final String TAG = InstabugApi.class.getName();
private final Context context;
Expand Down Expand Up @@ -85,6 +76,16 @@ public void setEnabled(@NonNull Boolean isEnabled) {
}
}

@NotNull
@Override
public Boolean isEnabled() {
return Instabug.isEnabled();
}

@NotNull
@Override
public Boolean isBuilt() { return Instabug.isBuilt(); }

@Override
public void init(@NonNull String token, @NonNull List<String> invocationEvents, @NonNull String debugLogsLevel) {
setCurrentPlatform();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package com.instabug.flutter.modules;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.instabug.flutter.generated.SessionReplayPigeon;
import com.instabug.library.OnSessionReplayLinkReady;
import com.instabug.library.sessionreplay.SessionReplay;

import io.flutter.plugin.common.BinaryMessenger;

public class SessionReplayApi implements SessionReplayPigeon.SessionReplayHostApi {
Expand Down
132 changes: 119 additions & 13 deletions android/src/test/java/com/instabug/flutter/ApmApiTest.java
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
package com.instabug.flutter;

import static com.instabug.flutter.util.GlobalMocks.reflected;
import static com.instabug.flutter.util.MockResult.makeResult;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import com.instabug.apm.APM;
import com.instabug.apm.InternalAPM;
import com.instabug.apm.configuration.cp.APMFeature;
import com.instabug.apm.configuration.cp.FeatureAvailabilityCallback;
import com.instabug.apm.model.ExecutionTrace;
import com.instabug.apm.networking.APMNetworkLogger;
import com.instabug.flutter.generated.ApmPigeon;
import com.instabug.flutter.modules.ApmApi;
import com.instabug.flutter.util.GlobalMocks;
import com.instabug.flutter.util.MockReflected;

import io.flutter.plugin.common.BinaryMessenger;

import org.json.JSONObject;
import org.junit.After;
import org.junit.Assert;
Expand All @@ -31,23 +24,32 @@
import java.util.HashMap;
import java.util.Map;

import io.flutter.plugin.common.BinaryMessenger;
import static com.instabug.flutter.util.GlobalMocks.reflected;
import static com.instabug.flutter.util.MockResult.makeResult;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;


public class ApmApiTest {

private final BinaryMessenger mMessenger = mock(BinaryMessenger.class);
private final ApmApi api = new ApmApi();
private MockedStatic<APM> mAPM;
private MockedStatic<InternalAPM> mInternalApmStatic;
private MockedStatic<ApmPigeon.ApmHostApi> mHostApi;

@Before
public void setUp() throws NoSuchMethodException {
mAPM = mockStatic(APM.class);
mInternalApmStatic = mockStatic(InternalAPM.class);
mHostApi = mockStatic(ApmPigeon.ApmHostApi.class);
GlobalMocks.setUp();
}

@After
public void cleanUp() {
mInternalApmStatic.close();
mAPM.close();
mHostApi.close();
GlobalMocks.close();
Expand Down Expand Up @@ -266,4 +268,108 @@ public void testNetworkLogAndroid() {
mAPMNetworkLogger.close();
mJSONObject.close();
}

@Test
public void testStartUiTraceCP() {
String screenName = "screen-name";
long microTimeStamp = System.currentTimeMillis() / 1000;
long traceId = System.currentTimeMillis();


api.startCpUiTrace(screenName, microTimeStamp, traceId);

mInternalApmStatic.verify(() -> InternalAPM._startUiTraceCP(screenName, microTimeStamp, traceId));
mInternalApmStatic.verifyNoMoreInteractions();
}

@Test
public void testReportScreenLoadingCP() {
long startTimeStampMicro = System.currentTimeMillis() / 1000;
long durationMicro = System.currentTimeMillis() / 1000;
long uiTraceId = System.currentTimeMillis();

api.reportScreenLoadingCP(startTimeStampMicro, durationMicro, uiTraceId);

mInternalApmStatic.verify(() -> InternalAPM._reportScreenLoadingCP(startTimeStampMicro, durationMicro, uiTraceId));
mInternalApmStatic.verifyNoMoreInteractions();
}

@Test
public void testEndScreenLoading() {
long timeStampMicro = System.currentTimeMillis() / 1000;
long uiTraceId = System.currentTimeMillis();

api.endScreenLoadingCP(timeStampMicro, uiTraceId);

mInternalApmStatic.verify(() -> InternalAPM._endScreenLoadingCP(timeStampMicro, uiTraceId));
mInternalApmStatic.verifyNoMoreInteractions();
}

@Test
public void testIsEnabled() {
boolean expected = true;
ApmPigeon.Result<Boolean> result = spy(makeResult((actual) -> assertEquals(expected, actual)));
mInternalApmStatic.when(() -> InternalAPM._isFeatureEnabledCP(eq(APMFeature.SCREEN_LOADING), any(), any(FeatureAvailabilityCallback.class))).thenAnswer(invocation -> {
FeatureAvailabilityCallback callback = invocation.getArgument(1);
callback.invoke(expected);
return null;
});

api.isEnabled(result);

verify(result).success(expected);
}

@Test
public void testIsScreenLoadingEnabled() {
boolean expected = true;
ApmPigeon.Result<Boolean> result = spy(makeResult((actual) -> assertEquals(expected, actual)));

mInternalApmStatic.when(() -> InternalAPM._isFeatureEnabledCP(any(), any(), any())).thenAnswer(
invocation -> {
FeatureAvailabilityCallback callback = (FeatureAvailabilityCallback) invocation.getArguments()[2];
callback.invoke(expected);
return null;
});


api.isScreenLoadingEnabled(result);

mInternalApmStatic.verify(() -> InternalAPM._isFeatureEnabledCP(any(), any(), any()));
mInternalApmStatic.verifyNoMoreInteractions();

verify(result).success(expected);
}

@Test
public void testIsEndScreenLoadingEnabled() {
boolean expected = true;
ApmPigeon.Result<Boolean> result = spy(makeResult((actual) -> assertEquals(expected, actual)));

mInternalApmStatic.when(() -> InternalAPM._isFeatureEnabledCP(any(), any(), any())).thenAnswer(
invocation -> {
FeatureAvailabilityCallback callback = (FeatureAvailabilityCallback) invocation.getArguments()[2];
callback.invoke(expected);
return null;
});


api.isEndScreenLoadingEnabled(result);

mInternalApmStatic.verify(() -> InternalAPM._isFeatureEnabledCP(any(), any(), any()));
mInternalApmStatic.verifyNoMoreInteractions();

verify(result).success(expected);

}


@Test
public void testSetScreenLoadingMonitoringEnabled() {
boolean isEnabled = false;

api.setScreenLoadingEnabled(isEnabled);

mAPM.verify(() -> APM.setScreenLoadingEnabled(isEnabled));
}
}
15 changes: 15 additions & 0 deletions android/src/test/java/com/instabug/flutter/InstabugApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.util.concurrent.Callable;

import io.flutter.plugin.common.BinaryMessenger;
import org.mockito.verification.VerificationMode;

public class InstabugApiTest {
private final Callable<Bitmap> screenshotProvider = () -> mock(Bitmap.class);
Expand Down Expand Up @@ -155,6 +156,20 @@ public void testSetEnabledGivenFalse() {
mInstabug.verify(Instabug::disable);
}

@Test
public void testIsEnabled() {
api.isEnabled();

mInstabug.verify(Instabug::isEnabled);
}

@Test
public void testIsBuilt() {
api.isBuilt();

mInstabug.verify(Instabug::isBuilt);
}

@Test
public void testShow() {
api.show();
Expand Down
Loading