package com.farmerbb.taskbar.helper;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

@RunWith(RobolectricTestRunner.class)
public class LauncherHelperTest {
    private LauncherHelper launcherHelper = LauncherHelper.getInstance();

    @Test
    public void testGetInstance() {
        assertNotNull(launcherHelper);
        for (int i = 1; i <= 20; i++) {
            assertEquals(launcherHelper, LauncherHelper.getInstance());
        }
    }

    @Test
    public void testIsHomeScreen() {
        assertFalse(launcherHelper.isOnHomeScreen());
        launcherHelper.setOnPrimaryHomeScreen(true);
        assertTrue(launcherHelper.isOnHomeScreen());
        launcherHelper.setOnPrimaryHomeScreen(false);
        launcherHelper.setOnSecondaryHomeScreen(true, 1);
        assertTrue(launcherHelper.isOnHomeScreen());
        launcherHelper.setOnSecondaryHomeScreen(false, 1);
        assertEquals(-1, launcherHelper.getSecondaryDisplayId());
    }

    @Test
    public void testIsOnSecondaryHomeScreen() {
        assertFalse(launcherHelper.isOnSecondaryHomeScreen());
        launcherHelper.setOnPrimaryHomeScreen(true);
        assertFalse(launcherHelper.isOnSecondaryHomeScreen());
        launcherHelper.setOnSecondaryHomeScreen(true, 1);
        assertTrue(launcherHelper.isOnSecondaryHomeScreen());
        launcherHelper.setOnPrimaryHomeScreen(false);
        assertTrue(launcherHelper.isOnSecondaryHomeScreen());
        launcherHelper.setOnSecondaryHomeScreen(false, 1);
    }
}

@@ -42,428 +42,1533 @@
 ort 
-org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.robolectric.RobolectricTestRunner;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0A%0A@RunWith(RobolectricTestRunner.class)%0Apublic class LauncherHelperTest %7B%0A    private LauncherHelper launcherHelper = LauncherHelper.getInstance();
+android.content.Context;%0A%0Aimport androidx.test.core.app.ApplicationProvider;%0A%0Aimport com.farmerbb.taskbar.mockito.IntAnswer;%0Aimport com.farmerbb.taskbar.util.U;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Rule;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.powermock.api.mockito.PowerMockito;%0Aimport org.powermock.core.classloader.annotations.PowerMockIgnore;%0Aimport org.powermock.core.classloader.annotations.PrepareForTest;%0Aimport org.powermock.modules.junit4.rule.PowerMockRule;%0Aimport org.robolectric.RobolectricTestRunner;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertFalse;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertTrue;%0Aimport static org.powermock.api.mockito.PowerMockito.when;%0A%0A@RunWith(RobolectricTestRunner.class)%0A@PowerMockIgnore(%7B%22org.mockito.*%22, %22org.robolectric.*%22, %22android.*%22, %22androidx.*%22%7D)%0A@PrepareForTest(U.class)%0Apublic class LauncherHelperTest %7B%0A%0A    @Rule%0A    public PowerMockRule rule = new PowerMockRule();%0A%0A    private LauncherHelper launcherHelper;%0A    private Context context;%0A    private IntAnswer getExternalDisplayIdAnswer;%0A%0A    @Before%0A    public void setUp() %7B%0A        launcherHelper = LauncherHelper.getInstance();%0A        context = ApplicationProvider.getApplicationContext();%0A        assertNotNull(context);%0A%0A        PowerMockito.spy(U.class);%0A        getExternalDisplayIdAnswer = new IntAnswer();%0A        when(U.getExternalDisplayID(context)).thenAnswer(getExternalDisplayIdAnswer);%0A    %7D
 %0A%0A  
@@ -1868,32 +1868,39 @@
 .isOnHomeScreen(
+context
 ));%0A        laun
@@ -1981,32 +1981,39 @@
 .isOnHomeScreen(
+context
 ));%0A        laun
@@ -2104,32 +2104,140 @@
 creen(true, 1);%0A
+        assertFalse(launcherHelper.isOnHomeScreen(context));%0A        getExternalDisplayIdAnswer.answer = 1;%0A
         assertTr
@@ -2261,32 +2261,39 @@
 .isOnHomeScreen(
+context
 ));%0A        laun
@@ -2521,32 +2521,39 @@
 ndaryHomeScreen(
+context
 ));%0A        laun
@@ -2644,32 +2644,39 @@
 ndaryHomeScreen(
+context
 ));%0A        laun
@@ -2713,32 +2713,149 @@
 creen(true, 1);%0A
+        assertFalse(launcherHelper.isOnSecondaryHomeScreen(context));%0A        getExternalDisplayIdAnswer.answer = 1;%0A
         assertTr
@@ -2888,32 +2888,39 @@
 ndaryHomeScreen(
+context
 ));%0A        laun
@@ -3019,16 +3019,23 @@
 eScreen(
+context
 ));%0A    

Fix tests