@@ -0,0 +1,3682 @@
+package com.farmerbb.taskbar.util;%0A%0Aimport android.content.ComponentName;%0Aimport android.content.Context;%0Aimport android.content.Intent;%0Aimport android.content.IntentFilter;%0Aimport android.content.pm.ActivityInfo;%0Aimport android.content.pm.ApplicationInfo;%0Aimport android.content.pm.PackageInfo;%0Aimport android.content.pm.PackageManager;%0Aimport android.content.pm.ResolveInfo;%0Aimport android.os.Bundle;%0A%0Aimport androidx.test.core.app.ApplicationProvider;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.robolectric.RobolectricTestRunner;%0Aimport org.robolectric.Shadows;%0Aimport org.robolectric.shadows.ShadowPackageManager;%0A%0Aimport java.util.HashSet;%0Aimport java.util.List;%0Aimport java.util.Set;%0A%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertNotNull;%0Aimport static org.junit.Assert.assertNotSame;%0Aimport static org.junit.Assert.assertSame;%0A%0A@RunWith(RobolectricTestRunner.class)%0Apublic class IconPackManagerTest %7B%0A    private IconPackManager iconPackManager = IconPackManager.getInstance();%0A    private Context context;%0A%0A    @Before%0A    public void setUp() %7B%0A        context = ApplicationProvider.getApplicationContext();%0A    %7D%0A%0A    @Test%0A    public void testGetInstance() %7B%0A        assertNotNull(iconPackManager);%0A        for (int i = 1; i %3C= 20; i++) %7B%0A            assertEquals(iconPackManager, IconPackManager.getInstance());%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testGetAvailableIconPacks() throws PackageManager.NameNotFoundException %7B%0A        List%3CIconPack%3E iconPacks = iconPackManager.getAvailableIconPacks(context);%0A        assertEquals(0, iconPacks.size());%0A%0A        String testPackageName = %22com.test.package%22;%0A        PackageManager packageManager = context.getPackageManager();%0A        ShadowPackageManager shadowPackageManager = Shadows.shadowOf(packageManager);%0A        int testIconPackSize = 20;%0A        for (int i = 1; i %3C= testIconPackSize; i++) %7B%0A            ComponentName componentName =%0A                    new ComponentName(testPackageName + i, testPackageName + i);%0A            IntentFilter intentFilter = new IntentFilter(%22org.adw.launcher.THEMES%22);%0A            shadowPackageManager.addActivityIfNotPresent(componentName);%0A            shadowPackageManager.addIntentFilterForActivity(componentName, intentFilter);%0A            iconPacks = iconPackManager.getAvailableIconPacks(context);%0A        %7D%0A        assertEquals(testIconPackSize, iconPacks.size());%0A        Set%3CString%3E fetchedIconPackPackages = new HashSet%3C%3E();%0A        iconPacks.forEach(iconPack -%3E fetchedIconPackPackages.add(iconPack.getPackageName()));%0A        assertEquals(testIconPackSize, fetchedIconPackPackages.size());%0A        Set%3CString%3E expectedIconPackPackages = new HashSet%3C%3E();%0A        for (int i = 1; i %3C= testIconPackSize; i++) %7B%0A            expectedIconPackPackages.add(testPackageName + i);%0A            shadowPackageManager.removeActivity(%0A                    new ComponentName(testPackageName + i, testPackageName + i)%0A            );%0A        %7D%0A        assertEquals(expectedIconPackPackages, fetchedIconPackPackages);%0A    %7D%0A%0A    @Test%0A    public void testGetIconPack() %7B%0A        IconPack iconPack = iconPackManager.getIconPack(context.getPackageName());%0A        assertNotNull(iconPack);%0A        assertEquals(context.getPackageName(), iconPack.getPackageName());%0A        assertSame(iconPack, iconPackManager.getIconPack(context.getPackageName()));%0A        iconPackManager.nullify();%0A        IconPack newIconPack = iconPackManager.getIconPack(context.getPackageName());%0A        assertEquals(context.getPackageName(), newIconPack.getPackageName());%0A        assertNotSame(iconPack, newIconPack);%0A    %7D%0A%7D%0A

Add unit tests for IconPackManager