@@ -305,4 +305,82 @@ public void testOrientationChange_PortraitToLandscape() throws Exception {
305305 // If runResizeScript wasn't called, we would have seen validation errors or exceptions
306306 // The fact that we get here without exceptions means the orientation change handling worked
307307 }
308+
309+ // ===== Orientation Rounding Tests =====
310+
311+ @ Test
312+ public void testRoundToNearest90Degrees_Zero () {
313+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (0 ));
314+ }
315+
316+ @ Test
317+ public void testRoundToNearest90Degrees_StandardOrientations () {
318+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (0 ));
319+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (90 ));
320+ assertEquals (180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (180 ));
321+ assertEquals (270 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (270 ));
322+ assertEquals (360 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (360 ));
323+ }
324+
325+ @ Test
326+ public void testRoundToNearest90Degrees_BoundaryValues () {
327+ // Values that round down to 0 (0-44)
328+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (44 ));
329+
330+ // Values that round up to 90 (45-134)
331+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (45 ));
332+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (89 ));
333+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (90 ));
334+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (134 ));
335+
336+ // Values that round up to 180 (135-224)
337+ assertEquals (180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (135 ));
338+ assertEquals (180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (180 ));
339+ assertEquals (180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (224 ));
340+
341+ // Values that round up to 270 (225-314)
342+ assertEquals (270 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (225 ));
343+ assertEquals (270 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (270 ));
344+ assertEquals (270 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (314 ));
345+
346+ // Values that round up to 360 (315-359)
347+ assertEquals (360 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (315 ));
348+ assertEquals (360 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (359 ));
349+ }
350+
351+ @ Test
352+ public void testRoundToNearest90Degrees_NearZero () {
353+ // Test values very close to 0
354+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (1 ));
355+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-1 ));
356+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-44 ));
357+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-45 ));
358+ }
359+
360+ @ Test
361+ public void testRoundToNearest90Degrees_NegativeValues () {
362+ // Test negative values (though OrientationEventListener typically returns 0-359)
363+ // These test the integer division behavior with negative numbers
364+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-1 ));
365+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-45 ));
366+ assertEquals (-90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-46 ));
367+ assertEquals (-90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-90 ));
368+ assertEquals (-90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-134 ));
369+ assertEquals (-180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (-135 ));
370+ }
371+
372+ @ Test
373+ public void testRoundToNearest90Degrees_EdgeCases () {
374+ // Test edge cases around boundaries
375+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (0 ));
376+ assertEquals (0 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (44 ));
377+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (45 ));
378+ assertEquals (90 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (134 ));
379+ assertEquals (180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (135 ));
380+ assertEquals (180 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (224 ));
381+ assertEquals (270 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (225 ));
382+ assertEquals (270 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (314 ));
383+ assertEquals (360 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (315 ));
384+ assertEquals (360 , IterableInAppFragmentHTMLNotification .roundToNearest90Degrees (359 ));
385+ }
308386}
0 commit comments