File tree Expand file tree Collapse file tree 5 files changed +37
-2
lines changed
onesignal/src/main/java/com/onesignal
unittest/src/test/java/com Expand file tree Collapse file tree 5 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ public synchronized void complete(@Nullable final OSNotification notification) {
77
77
78
78
isComplete = true ;
79
79
80
- if (OSUtils . isRunningOnMainThread ()) {
80
+ if (isRunningOnMainThread ()) {
81
81
new Thread (new Runnable () {
82
82
@ Override
83
83
public void run () {
@@ -119,4 +119,8 @@ public String toString() {
119
119
", notification=" + notification +
120
120
'}' ;
121
121
}
122
+
123
+ static boolean isRunningOnMainThread () {
124
+ return OSUtils .isRunningOnMainThread ();
125
+ }
122
126
}
Original file line number Diff line number Diff line change @@ -986,6 +986,9 @@ public static void provideUserConsent(boolean consent) {
986
986
}
987
987
988
988
private static boolean reassignDelayedInitParams () {
989
+ if (initDone )
990
+ return false ;
991
+
989
992
String delayedAppId ;
990
993
Context delayedContext ;
991
994
if (delayedInitParams == null ) {
Original file line number Diff line number Diff line change
1
+ package com .onesignal ;
2
+
3
+ import org .robolectric .annotation .Implementation ;
4
+ import org .robolectric .annotation .Implements ;
5
+
6
+ @ Implements (OSNotificationReceivedEvent .class )
7
+ public class ShadowNotificationReceivedEvent {
8
+
9
+ private static boolean runningOnMainThreadCheck = false ;
10
+
11
+ @ Implementation
12
+ public static boolean isRunningOnMainThread () {
13
+ // Remove Main thread check and throw
14
+ runningOnMainThreadCheck = true ;
15
+ return false ;
16
+ }
17
+
18
+ public static boolean isRunningOnMainThreadCheckCalled () {
19
+ return runningOnMainThreadCheck ;
20
+ }
21
+
22
+ public static void resetStatics () {
23
+ runningOnMainThreadCheck = false ;
24
+ }
25
+ }
Original file line number Diff line number Diff line change 68
68
import com .onesignal .ShadowFCMBroadcastReceiver ;
69
69
import com .onesignal .ShadowGenerateNotification ;
70
70
import com .onesignal .ShadowNotificationManagerCompat ;
71
+ import com .onesignal .ShadowNotificationReceivedEvent ;
71
72
import com .onesignal .ShadowOSUtils ;
72
73
import com .onesignal .ShadowOSViewUtils ;
73
74
import com .onesignal .ShadowOSWebView ;
@@ -823,7 +824,7 @@ public void shouldUpdateNormalNotificationDisplayWhenReplacingANotification() th
823
824
}
824
825
825
826
@ Test
826
- @ Config (shadows = { ShadowGenerateNotification .class })
827
+ @ Config (shadows = { ShadowGenerateNotification .class , ShadowNotificationReceivedEvent . class })
827
828
public void shouldHandleBasicNotifications () throws Exception {
828
829
// Make sure the notification got posted and the content is correct.
829
830
Bundle bundle = getBaseNotifBundle ();
Original file line number Diff line number Diff line change 37
37
import com .onesignal .ShadowHMSFusedLocationProviderClient ;
38
38
import com .onesignal .ShadowHmsInstanceId ;
39
39
import com .onesignal .ShadowNotificationManagerCompat ;
40
+ import com .onesignal .ShadowNotificationReceivedEvent ;
40
41
import com .onesignal .ShadowOSUtils ;
41
42
import com .onesignal .ShadowOSWebView ;
42
43
import com .onesignal .ShadowOneSignalDbHelper ;
@@ -128,6 +129,7 @@ static void beforeTestInitAndCleanup() throws Exception {
128
129
ShadowOSUtils .resetStatics ();
129
130
ShadowTimeoutHandler .resetStatics ();
130
131
ShadowGenerateNotification .resetStatics ();
132
+ ShadowNotificationReceivedEvent .resetStatics ();
131
133
132
134
lastException = null ;
133
135
}
You can’t perform that action at this time.
0 commit comments