Skip to content

Commit df9a957

Browse files
author
“Akshay
committed
Correction after github checks
1 parent 3e4dcd1 commit df9a957

File tree

3 files changed

+12
-21
lines changed

3 files changed

+12
-21
lines changed

iterableapi/src/main/java/com/iterable/iterableapi/IterableInAppFragmentHTMLNotification.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,14 +691,14 @@ int getVerticalLocation(Rect padding) {
691691
* Rounds an orientation value to the nearest 90-degree increment.
692692
* This is used to detect significant orientation changes (portrait/landscape).
693693
*
694-
* The calculation uses integer division: ((orientation + 45) / 90) * 90
695-
* This rounds to the nearest multiple of 90 by adding 45 before dividing.
694+
* The calculation rounds to the nearest multiple of 90 by adding 45 before dividing.
695+
* Uses floating point division to correctly handle negative numbers.
696696
*
697697
* @param orientation The orientation value in degrees (typically 0-359 from OrientationEventListener)
698698
* @return The orientation rounded to the nearest 90-degree increment (0, 90, 180, 270, or 360)
699699
*/
700700
static int roundToNearest90Degrees(int orientation) {
701-
return ((orientation + 45) / 90) * 90;
701+
return (int) (Math.round((orientation + 45.0) / 90.0) * 90);
702702
}
703703

704704
/**

iterableapi/src/test/java/com/iterable/iterableapi/IterableInAppHTMLNotificationTest.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@
2020
import static junit.framework.Assert.assertEquals;
2121
import static junit.framework.Assert.assertNotNull;
2222
import static junit.framework.Assert.assertTrue;
23-
import static org.mockito.ArgumentMatchers.any;
24-
import static org.mockito.Mockito.doCallRealMethod;
25-
import static org.mockito.Mockito.never;
26-
import static org.mockito.Mockito.spy;
27-
import static org.mockito.Mockito.times;
28-
import static org.mockito.Mockito.verify;
2923
import static org.robolectric.Shadows.shadowOf;
3024

3125
public class IterableInAppHTMLNotificationTest extends BaseTest {
@@ -146,7 +140,7 @@ public void testResizeValidation_HandlesGracefully() {
146140
public void testApplyWindowGravity_Center() {
147141
Rect padding = new Rect(0, -1, 0, -1); // Center padding
148142
IterableInAppFragmentHTMLNotification notification = IterableInAppFragmentHTMLNotification.createInstance(
149-
"<html><body>Test</body></html>", false, uri -> {}, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
143+
"<html><body>Test</body></html>", false, uri -> { }, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
150144

151145
// Verify gravity calculation for center padding
152146
assertEquals(Gravity.CENTER_VERTICAL, notification.getVerticalLocation(padding));
@@ -156,7 +150,7 @@ public void testApplyWindowGravity_Center() {
156150
public void testApplyWindowGravity_Top() {
157151
Rect padding = new Rect(0, 0, 0, -1); // Top padding
158152
IterableInAppFragmentHTMLNotification notification = IterableInAppFragmentHTMLNotification.createInstance(
159-
"<html><body>Test</body></html>", false, uri -> {}, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
153+
"<html><body>Test</body></html>", false, uri -> { }, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
160154

161155
assertEquals(Gravity.TOP, notification.getVerticalLocation(padding));
162156
}
@@ -165,7 +159,7 @@ public void testApplyWindowGravity_Top() {
165159
public void testApplyWindowGravity_Bottom() {
166160
Rect padding = new Rect(0, -1, 0, 0); // Bottom padding
167161
IterableInAppFragmentHTMLNotification notification = IterableInAppFragmentHTMLNotification.createInstance(
168-
"<html><body>Test</body></html>", false, uri -> {}, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
162+
"<html><body>Test</body></html>", false, uri -> { }, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
169163

170164
assertEquals(Gravity.BOTTOM, notification.getVerticalLocation(padding));
171165
}
@@ -174,8 +168,8 @@ public void testApplyWindowGravity_Bottom() {
174168
public void testApplyWindowGravity_HandlesNullWindow() {
175169
Rect padding = new Rect(0, 0, 0, -1);
176170
IterableInAppFragmentHTMLNotification notification = IterableInAppFragmentHTMLNotification.createInstance(
177-
"<html><body>Test</body></html>", false, uri -> {}, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
178-
171+
"<html><body>Test</body></html>", false, uri -> { }, IterableInAppLocation.IN_APP, "msg1", 0.0, padding, false, new IterableInAppMessage.InAppBgColor(null, 0.0f));
172+
179173
// Test that getVerticalLocation works correctly
180174
assertEquals(Gravity.TOP, notification.getVerticalLocation(padding));
181175
// applyWindowGravity is private but is called in onStart/onCreateDialog/onCreateView
@@ -300,7 +294,7 @@ public void testOrientationChange_PortraitToLandscape() throws Exception {
300294
// The test passes if no exceptions are thrown and the resize was triggered
301295
// We verify indirectly by ensuring the notification still exists and is in a valid state
302296
assertNotNull("Notification should still exist after orientation change", notification);
303-
297+
304298
// The resize should have been triggered (1500ms delay + 200ms debounce)
305299
// If runResizeScript wasn't called, we would have seen validation errors or exceptions
306300
// The fact that we get here without exceptions means the orientation change handling worked
@@ -326,18 +320,18 @@ public void testRoundToNearest90Degrees_StandardOrientations() {
326320
public void testRoundToNearest90Degrees_BoundaryValues() {
327321
// Values that round down to 0 (0-44)
328322
assertEquals(0, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(44));
329-
323+
330324
// Values that round up to 90 (45-134)
331325
assertEquals(90, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(45));
332326
assertEquals(90, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(89));
333327
assertEquals(90, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(90));
334328
assertEquals(90, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(134));
335-
329+
336330
// Values that round up to 180 (135-224)
337331
assertEquals(180, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(135));
338332
assertEquals(180, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(180));
339333
assertEquals(180, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(224));
340-
334+
341335
// Values that round up to 270 (225-314)
342336
assertEquals(270, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(225));
343337
assertEquals(270, IterableInAppFragmentHTMLNotification.roundToNearest90Degrees(270));

iterableapi/src/test/java/com/iterable/iterableapi/IterableWebChromeClientTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@
44

55
import org.junit.Before;
66
import org.junit.Test;
7-
import org.mockito.ArgumentCaptor;
87
import org.mockito.Mock;
98
import org.mockito.MockitoAnnotations;
109

11-
import static org.mockito.ArgumentMatchers.any;
1210
import static org.mockito.Mockito.mock;
1311
import static org.mockito.Mockito.never;
14-
import static org.mockito.Mockito.spy;
1512
import static org.mockito.Mockito.times;
1613
import static org.mockito.Mockito.verify;
1714

0 commit comments

Comments
 (0)