Merges Injector
Welcome to the new world boys.
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||
import org.junit.Test;
|
||||
|
||||
public class RuneLiteModuleTest
|
||||
{
|
||||
@Test
|
||||
public void testConfigure()
|
||||
{
|
||||
Guice.createInjector(new RuneLiteModule(ClientUpdateCheckMode.AUTO, true));
|
||||
}
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.config;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.io.IOException;
|
||||
import java.time.Instant;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.account.AccountSession;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ConfigManagerTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
EventBus eventBus;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ScheduledExecutorService executor;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
RuneLiteConfig runeliteConfig;
|
||||
|
||||
@Inject
|
||||
ConfigManager manager;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfig() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
|
||||
manager.setConfiguration("test", "key", "moo");
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
Assert.assertEquals("moo", conf.key());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfigDefault() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
Assert.assertEquals("default", conf.key());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetConfig() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
conf.key("new value");
|
||||
|
||||
Assert.assertEquals("new value", conf.key());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetConfigDescriptor() throws IOException
|
||||
{
|
||||
AccountSession accountSession = new AccountSession(UUID.randomUUID(), Instant.now());
|
||||
accountSession.setUsername("test");
|
||||
|
||||
TestConfig conf = manager.getConfig(TestConfig.class);
|
||||
ConfigDescriptor descriptor = manager.getConfigDescriptor(conf);
|
||||
Assert.assertEquals(1, descriptor.getItems().size());
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.config;
|
||||
|
||||
@ConfigGroup("test")
|
||||
public interface TestConfig
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "key",
|
||||
name = "Key Name",
|
||||
description = "value"
|
||||
)
|
||||
default String key()
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "key",
|
||||
name = "Key Name",
|
||||
description = "value"
|
||||
)
|
||||
void key(String key);
|
||||
}
|
||||
@@ -1,350 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Ron Young <https://github.com/raiyni>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.game;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import static net.runelite.api.ItemID.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ItemVariationMappingTest
|
||||
{
|
||||
private static final Map<Integer, Integer> ITEMS_MAP = new LinkedHashMap<Integer, Integer>()
|
||||
{{
|
||||
put(_12_ANCHOVY_PIZZA, ANCHOVY_PIZZA);
|
||||
put(_12_MEAT_PIZZA, MEAT_PIZZA);
|
||||
put(_12_PINEAPPLE_PIZZA, PINEAPPLE_PIZZA);
|
||||
put(_12_PLAIN_PIZZA, PLAIN_PIZZA);
|
||||
put(ADAMANT_PLATELEGS_T, ADAMANT_PLATELEGS);
|
||||
put(ADAMANT_PLATESKIRT_T, ADAMANT_PLATESKIRT);
|
||||
put(AGILITY_CAPET, AGILITY_CAPE);
|
||||
put(AGILITY_MIX1, AGILITY_MIX2);
|
||||
put(AGILITY_MIX2, AGILITY_MIX2);
|
||||
put(AHRIMS_ROBETOP_100, AHRIMS_ROBETOP);
|
||||
put(AHRIMS_ROBETOP_25, AHRIMS_ROBETOP);
|
||||
put(AHRIMS_ROBETOP_50, AHRIMS_ROBETOP);
|
||||
put(AHRIMS_ROBETOP_75, AHRIMS_ROBETOP);
|
||||
put(AHRIMS_STAFF_0, AHRIMS_STAFF);
|
||||
put(AMULET_OF_GLORY5, AMULET_OF_GLORY);
|
||||
put(AMULET_OF_GLORY6, AMULET_OF_GLORY);
|
||||
put(AMULET_OF_MAGIC_T, AMULET_OF_MAGIC);
|
||||
put(ANCIENT_PAGE_1, ANCIENT_PAGE);
|
||||
put(ANCIENT_PAGE_2, ANCIENT_PAGE);
|
||||
put(ANTIDOTE2, ANTIDOTE_UNF);
|
||||
put(ANTIDOTE3, ANTIDOTE_UNF);
|
||||
put(ANTIDOTE4, ANTIDOTE_UNF);
|
||||
put(ANTIDOTE1_5958, ANTIDOTE_UNF);
|
||||
put(ANTIDOTE2_5956, ANTIDOTE_UNF);
|
||||
put(APPLES2, APPLES1);
|
||||
put(APPLES3, APPLES1);
|
||||
put(APPLES4, APPLES1);
|
||||
put(APPLES5, APPLES1);
|
||||
put(ARCHERS_RING_I, ARCHERS_RING);
|
||||
put(ASGARNIAN_ALEM4, ASGARNIAN_ALE);
|
||||
put(ATTACK_CAPET, ATTACK_CAPE);
|
||||
put(ATTACK_MIX1, ATTACK_MIX2);
|
||||
put(ATTACK_MIX2, ATTACK_MIX2);
|
||||
put(ATTACK_POTION1, ATTACK_POTION3);
|
||||
put(BANANAS2, BANANAS1);
|
||||
put(BANANAS3, BANANAS1);
|
||||
put(BANANAS4, BANANAS1);
|
||||
put(BANANAS5, BANANAS1);
|
||||
put(BANDOS_PAGE_1, BANDOS_PAGE_1);
|
||||
put(BLACK_KITESHIELD_T, BLACK_KITESHIELD);
|
||||
put(BLACK_MASK_1, BLACK_MASK_10);
|
||||
put(BLACK_MASK_2, BLACK_MASK_10);
|
||||
put(BLACK_MASK_3, BLACK_MASK_10);
|
||||
put(BLACK_MASK_4, BLACK_MASK_10);
|
||||
put(BLUE_SKIRT_T, BLUE_SKIRT);
|
||||
put(BLUE_WIZARD_HAT_T, BLUE_WIZARD_HAT);
|
||||
put(BLUE_WIZARD_ROBE_T, BLUE_WIZARD_ROBE);
|
||||
put(BOOK_PAGE_1, BOOK_PAGE_1);
|
||||
put(BOOK_PAGE_2, BOOK_PAGE_1);
|
||||
put(BROODOO_SHIELD_9, BROODOO_SHIELD_10);
|
||||
put(BROWN_SPICE_1, BROWN_SPICE_4);
|
||||
put(BROWN_SPICE_2, BROWN_SPICE_4);
|
||||
put(BROWN_SPICE_3, BROWN_SPICE_4);
|
||||
put(BROWN_SPICE_4, BROWN_SPICE_4);
|
||||
put(CASKET_ELITE, CASKET);
|
||||
put(CASKET_HARD, CASKET);
|
||||
put(CASKET_MEDIUM, CASKET);
|
||||
put(CASTLE_SKETCH_1, CASTLE_SKETCH_1);
|
||||
put(CASTLE_SKETCH_2, CASTLE_SKETCH_1);
|
||||
put(CHEFS_DELIGHTM2, CHEFS_DELIGHT);
|
||||
put(CHEFS_DELIGHTM3, CHEFS_DELIGHT);
|
||||
put(CHEFS_DELIGHTM4, CHEFS_DELIGHT);
|
||||
put(CIDER1, CIDER);
|
||||
put(CIDER2, CIDER);
|
||||
put(CLUE_NEST_ELITE, CLUE_NEST_EASY);
|
||||
put(CLUE_NEST_HARD, CLUE_NEST_EASY);
|
||||
put(CLUE_NEST_MEDIUM, CLUE_NEST_EASY);
|
||||
put(CLUE_SCROLL_EASY, CLUE_SCROLL);
|
||||
put(CLUE_SCROLL_ELITE, CLUE_SCROLL);
|
||||
put(COMMORB_V2, COMMORB_V2);
|
||||
put(COMPOST_POTION1, COMPOST_POTION4);
|
||||
put(COMPOST_POTION2, COMPOST_POTION4);
|
||||
put(COMPOST_POTION3, COMPOST_POTION4);
|
||||
put(COMPOST_POTION4, COMPOST_POTION4);
|
||||
put(CRYSTAL_BOW_510_I, NEW_CRYSTAL_BOW);
|
||||
put(CRYSTAL_BOW_510, NEW_CRYSTAL_BOW);
|
||||
put(CRYSTAL_BOW_610_I, NEW_CRYSTAL_BOW);
|
||||
put(CRYSTAL_BOW_610, NEW_CRYSTAL_BOW);
|
||||
put(CRYSTAL_BOW_710_I, NEW_CRYSTAL_BOW);
|
||||
put(CRYSTAL_HALBERD_510_I, NEW_CRYSTAL_HALBERD_FULL_I);
|
||||
put(CRYSTAL_HALBERD_510, NEW_CRYSTAL_HALBERD_FULL_I);
|
||||
put(CRYSTAL_HALBERD_610_I, NEW_CRYSTAL_HALBERD_FULL_I);
|
||||
put(CRYSTAL_HALBERD_610, NEW_CRYSTAL_HALBERD_FULL_I);
|
||||
put(CRYSTAL_HALBERD_710_I, NEW_CRYSTAL_HALBERD_FULL_I);
|
||||
put(CRYSTAL_SHIELD_510_I, NEW_CRYSTAL_SHIELD);
|
||||
put(CRYSTAL_SHIELD_510, NEW_CRYSTAL_SHIELD);
|
||||
put(CRYSTAL_SHIELD_610_I, NEW_CRYSTAL_SHIELD);
|
||||
put(CRYSTAL_SHIELD_610, NEW_CRYSTAL_SHIELD);
|
||||
put(CRYSTAL_SHIELD_710_I, NEW_CRYSTAL_SHIELD);
|
||||
put(DEFENCE_POTION2, DEFENCE_POTION3);
|
||||
put(DEFENCE_POTION3, DEFENCE_POTION3);
|
||||
put(DEFENCE_POTION4, DEFENCE_POTION3);
|
||||
put(DESERT_AMULET_1, DESERT_AMULET);
|
||||
put(DESERT_AMULET_2, DESERT_AMULET);
|
||||
put(DHAROKS_PLATEBODY_50, DHAROKS_PLATEBODY);
|
||||
put(DHAROKS_PLATEBODY_75, DHAROKS_PLATEBODY);
|
||||
put(DHAROKS_PLATELEGS_0, DHAROKS_PLATELEGS);
|
||||
put(DHAROKS_PLATELEGS_100, DHAROKS_PLATELEGS);
|
||||
put(DHAROKS_PLATELEGS_25, DHAROKS_PLATELEGS);
|
||||
put(DRAGON_BITTERM3, DRAGON_BITTER);
|
||||
put(DRAGON_BITTERM4, DRAGON_BITTER);
|
||||
put(DRAGON_DEFENDER_T, DRAGON_DEFENDER);
|
||||
put(DRAGONSTONE_BOLTS, DRAGONSTONE_BOLTS_E);
|
||||
put(DRAGONSTONE_DRAGON_BOLTS, DRAGONSTONE_DRAGON_BOLTS_E);
|
||||
put(ENCHANTED_LYRE2, ENCHANTED_LYRE);
|
||||
put(ENCHANTED_LYRE3, ENCHANTED_LYRE);
|
||||
put(ENCHANTED_LYRE4, ENCHANTED_LYRE);
|
||||
put(ENCHANTED_LYRE5, ENCHANTED_LYRE);
|
||||
put(ENERGY_MIX1, ENERGY_MIX2);
|
||||
put(EXTENDED_SUPER_ANTIFIRE_MIX1, EXTENDED_SUPER_ANTIFIRE_MIX2);
|
||||
put(EXTENDED_SUPER_ANTIFIRE_MIX2, EXTENDED_SUPER_ANTIFIRE_MIX2);
|
||||
put(EXTENDED_SUPER_ANTIFIRE1, EXTENDED_SUPER_ANTIFIRE4);
|
||||
put(EXTENDED_SUPER_ANTIFIRE2, EXTENDED_SUPER_ANTIFIRE4);
|
||||
put(EXTENDED_SUPER_ANTIFIRE3, EXTENDED_SUPER_ANTIFIRE4);
|
||||
put(FRAGMENT_1, FRAGMENT_1);
|
||||
put(FRAGMENT_2, FRAGMENT_1);
|
||||
put(FRAGMENT_3, FRAGMENT_1);
|
||||
put(FREMENNIK_SEA_BOOTS_1, FREMENNIK_SEA_BOOTS);
|
||||
put(FREMENNIK_SEA_BOOTS_2, FREMENNIK_SEA_BOOTS);
|
||||
put(GAMES_NECKLACE3, GAMES_NECKLACE8);
|
||||
put(GAMES_NECKLACE4, GAMES_NECKLACE8);
|
||||
put(GAMES_NECKLACE5, GAMES_NECKLACE8);
|
||||
put(GAMES_NECKLACE6, GAMES_NECKLACE8);
|
||||
put(GAMES_NECKLACE7, GAMES_NECKLACE8);
|
||||
put(GREENMANS_ALE4, GREENMANS_ALE);
|
||||
put(GREENMANS_ALEM1, GREENMANS_ALE);
|
||||
put(GREENMANS_ALEM2, GREENMANS_ALE);
|
||||
put(GREENMANS_ALEM3, GREENMANS_ALE);
|
||||
put(GREENMANS_ALEM4, GREENMANS_ALE);
|
||||
put(GUTHANS_PLATEBODY_75, GUTHANS_PLATEBODY);
|
||||
put(GUTHANS_WARSPEAR_0, GUTHANS_WARSPEAR);
|
||||
put(GUTHANS_WARSPEAR_100, GUTHANS_WARSPEAR);
|
||||
put(GUTHANS_WARSPEAR_25, GUTHANS_WARSPEAR);
|
||||
put(GUTHANS_WARSPEAR_50, GUTHANS_WARSPEAR);
|
||||
put(HALF_A_GARDEN_PIE, PART_GARDEN_PIE);
|
||||
put(HALF_A_MEAT_PIE, MEAT_PIE);
|
||||
put(MUSHROOM_PIE, HALF_A_MUSHROOM_PIE);
|
||||
put(HALF_A_REDBERRY_PIE, REDBERRY_PIE);
|
||||
put(HALF_A_ROCK, ROCK);
|
||||
put(HUNTING_MIX1, HUNTING_MIX2);
|
||||
put(HUNTING_MIX2, HUNTING_MIX2);
|
||||
put(IMPINABOX1, IMPINABOX2);
|
||||
put(IMPINABOX2, IMPINABOX2);
|
||||
put(IRON_FULL_HELM_T, IRON_FULL_HELM);
|
||||
put(KARILS_COIF_100, KARILS_COIF);
|
||||
put(KARILS_COIF_25, KARILS_COIF);
|
||||
put(KARILS_COIF_50, KARILS_COIF);
|
||||
put(KARILS_COIF_75, KARILS_COIF);
|
||||
put(KARILS_CROSSBOW_0, KARILS_CROSSBOW);
|
||||
put(KEY_MEDIUM, KEY);
|
||||
put(KODAI_POTION_1, KODAI_POTION_1);
|
||||
put(KODAI_POTION_2, KODAI_POTION_1);
|
||||
put(KODAI_POTION_3, KODAI_POTION_1);
|
||||
put(KODAI_POTION_4, KODAI_POTION_1);
|
||||
put(MAGIC_POTION1, MAGIC_POTION4);
|
||||
put(MAGIC_POTION2, MAGIC_POTION4);
|
||||
put(MAGIC_POTION3, MAGIC_POTION4);
|
||||
put(MAGIC_POTION4, MAGIC_POTION4);
|
||||
put(MAGIC_SHORTBOW_I, MAGIC_SHORTBOW_U);
|
||||
put(MITHRIL_FULL_HELM_T, MITHRIL_FULL_HELM);
|
||||
put(MITHRIL_KITESHIELD_T, MITHRIL_KITESHIELD);
|
||||
put(MITHRIL_PLATEBODY_T, MITHRIL_PLATEBODY);
|
||||
put(MITHRIL_PLATELEGS_T, MITHRIL_PLATELEGS);
|
||||
put(MITHRIL_PLATESKIRT_T, MITHRIL_PLATESKIRT);
|
||||
put(NECKLACE_OF_PASSAGE1, NECKLACE_OF_PASSAGE5);
|
||||
put(NECKLACE_OF_PASSAGE2, NECKLACE_OF_PASSAGE5);
|
||||
put(NECKLACE_OF_PASSAGE3, NECKLACE_OF_PASSAGE5);
|
||||
put(NECKLACE_OF_PASSAGE4, NECKLACE_OF_PASSAGE5);
|
||||
put(NECKLACE_OF_PASSAGE5, NECKLACE_OF_PASSAGE5);
|
||||
put(OLIVE_OIL4, OLIVE_OIL4);
|
||||
put(ONIONS1, ONIONS1);
|
||||
put(ONIONS2, ONIONS1);
|
||||
put(ONIONS3, ONIONS1);
|
||||
put(ONIONS4, ONIONS1);
|
||||
put(ORANGES3, ORANGES1);
|
||||
put(ORANGES4, ORANGES1);
|
||||
put(ORANGES5, ORANGES1);
|
||||
put(OVERLOAD_1, OVERLOAD_4);
|
||||
put(OVERLOAD_2, OVERLOAD_4);
|
||||
put(PHARAOHS_SCEPTRE_3, PHARAOHS_SCEPTRE_3);
|
||||
put(PHARAOHS_SCEPTRE_4, PHARAOHS_SCEPTRE_3);
|
||||
put(PHARAOHS_SCEPTRE_5, PHARAOHS_SCEPTRE_3);
|
||||
put(PHARAOHS_SCEPTRE_6, PHARAOHS_SCEPTRE_3);
|
||||
put(PHARAOHS_SCEPTRE_7, PHARAOHS_SCEPTRE_3);
|
||||
put(PRAEL_BAT_1, PRAEL_BAT_1);
|
||||
put(PRAYER_CAPET, PRAYER_CAPE);
|
||||
put(PRAYER_ENHANCE_1_20965, PRAYER_ENHANCE_1);
|
||||
put(PRAYER_ENHANCE_2_20966, PRAYER_ENHANCE_1);
|
||||
put(PRAYER_ENHANCE_3_20967, PRAYER_ENHANCE_1);
|
||||
put(RANGING_MIX1, RANGING_MIX2);
|
||||
put(RANGING_MIX2, RANGING_MIX2);
|
||||
put(RANGING_POTION1, RANGING_POTION3);
|
||||
put(RANGING_POTION2, RANGING_POTION3);
|
||||
put(RANGING_POTION3, RANGING_POTION3);
|
||||
put(RED_DHIDE_BODY_T, RED_DHIDE_BODY);
|
||||
put(RED_DHIDE_CHAPS_T, RED_DHIDE_CHAPS);
|
||||
put(RED_SLAYER_HELMET_I, SLAYER_HELMET);
|
||||
put(RED_SPICE_1, RED_SPICE_4);
|
||||
put(RED_SPICE_2, RED_SPICE_4);
|
||||
put(RESTORE_MIX1, RESTORE_MIX2);
|
||||
put(RESTORE_MIX2, RESTORE_MIX2);
|
||||
put(RESTORE_POTION1, RESTORE_POTION3);
|
||||
put(RESTORE_POTION2, RESTORE_POTION3);
|
||||
put(RESTORE_POTION3, RESTORE_POTION3);
|
||||
put(RING_OF_DUELING5, RING_OF_DUELING8);
|
||||
put(RING_OF_DUELING6, RING_OF_DUELING8);
|
||||
put(RING_OF_DUELING7, RING_OF_DUELING8);
|
||||
put(RING_OF_DUELING8, RING_OF_DUELING8);
|
||||
put(RING_OF_RETURNING1, RING_OF_RETURNING5);
|
||||
put(ROD_OF_IVANDIS_4, ROD_OF_IVANDIS_10);
|
||||
put(ROD_OF_IVANDIS_5, ROD_OF_IVANDIS_10);
|
||||
put(ROD_OF_IVANDIS_6, ROD_OF_IVANDIS_10);
|
||||
put(ROD_OF_IVANDIS_7, ROD_OF_IVANDIS_10);
|
||||
put(ROD_OF_IVANDIS_8, ROD_OF_IVANDIS_10);
|
||||
put(SACRED_OIL3, SACRED_OIL4);
|
||||
put(SACRED_OIL4, SACRED_OIL4);
|
||||
put(SALVE_AMULET_E, SALVE_AMULET);
|
||||
put(SALVE_AMULETI, SALVE_AMULET);
|
||||
put(SANDSTONE_1KG, SANDSTONE_1KG);
|
||||
put(SARADOMIN_PAGE_4, SARADOMIN_PAGE_1);
|
||||
put(SEERS_RING_I, SEERS_RING);
|
||||
put(SHAYZIEN_BOOTS_1, SHAYZIEN_BOOTS_1);
|
||||
put(SHAYZIEN_BOOTS_2, SHAYZIEN_BOOTS_1);
|
||||
put(SHAYZIEN_BOOTS_3, SHAYZIEN_BOOTS_1);
|
||||
put(SHAYZIEN_HELM_4, SHAYZIEN_HELM_1);
|
||||
put(SHAYZIEN_HELM_5, SHAYZIEN_HELM_1);
|
||||
put(SHAYZIEN_PLATEBODY_1, SHAYZIEN_PLATEBODY_1);
|
||||
put(SHAYZIEN_PLATEBODY_2, SHAYZIEN_PLATEBODY_1);
|
||||
put(SHAYZIEN_PLATEBODY_3, SHAYZIEN_PLATEBODY_1);
|
||||
put(SHAYZIEN_SUPPLY_GREAVES_4, SHAYZIEN_SUPPLY_GREAVES_1);
|
||||
put(SHAYZIEN_SUPPLY_GREAVES_5, SHAYZIEN_SUPPLY_GREAVES_1);
|
||||
put(SHAYZIEN_SUPPLY_HELM_1, SHAYZIEN_SUPPLY_HELM_1);
|
||||
put(SHAYZIEN_SUPPLY_HELM_2, SHAYZIEN_SUPPLY_HELM_1);
|
||||
put(SHAYZIEN_SUPPLY_HELM_3, SHAYZIEN_SUPPLY_HELM_1);
|
||||
put(SHEEP_BONES_4, SHEEP_BONES_1);
|
||||
put(SINHAZA_SHROUD_TIER_1, SINHAZA_SHROUD_TIER_1);
|
||||
put(SINHAZA_SHROUD_TIER_2, SINHAZA_SHROUD_TIER_1);
|
||||
put(SINHAZA_SHROUD_TIER_3, SINHAZA_SHROUD_TIER_1);
|
||||
put(SINHAZA_SHROUD_TIER_4, SINHAZA_SHROUD_TIER_1);
|
||||
put(SLAYER_RING_6, SLAYER_RING_8);
|
||||
put(SLAYER_RING_7, SLAYER_RING_8);
|
||||
put(SLAYER_RING_8, SLAYER_RING_8);
|
||||
put(SLAYER_RING_ETERNAL, SLAYER_RING_8);
|
||||
put(SLAYERS_RESPITE1, SLAYERS_RESPITE);
|
||||
put(STAMINA_POTION4, STAMINA_POTION4);
|
||||
put(STASH_UNITS_EASY, STASH_UNITS_EASY);
|
||||
put(STASH_UNITS_ELITE, STASH_UNITS_EASY);
|
||||
put(STASH_UNITS_HARD, STASH_UNITS_EASY);
|
||||
put(STASH_UNITS_MASTER, STASH_UNITS_EASY);
|
||||
put(STRENGTH_POTION1, STRENGTH_POTION4);
|
||||
put(STRENGTH_POTION2, STRENGTH_POTION4);
|
||||
put(STRENGTH_POTION3, STRENGTH_POTION4);
|
||||
put(STRENGTH_POTION4, STRENGTH_POTION4);
|
||||
put(STUDDED_BODY_T, STUDDED_BODY);
|
||||
put(SUPER_DEF_MIX1, SUPER_DEF_MIX2);
|
||||
put(SUPER_DEF_MIX2, SUPER_DEF_MIX2);
|
||||
put(SUPER_DEFENCE1, SUPER_DEFENCE3);
|
||||
put(SUPER_DEFENCE2, SUPER_DEFENCE3);
|
||||
put(SUPER_DEFENCE3, SUPER_DEFENCE3);
|
||||
put(SUPER_RESTORE_MIX1, SUPER_RESTORE_MIX2);
|
||||
put(SUPER_RESTORE_MIX2, SUPER_RESTORE_MIX2);
|
||||
put(SUPER_RESTORE1, SUPER_RESTORE4);
|
||||
put(SUPER_RESTORE2, SUPER_RESTORE4);
|
||||
put(SUPER_RESTORE3, SUPER_RESTORE4);
|
||||
put(TEAK_SHELVES_2, TEAK_SHELVES_1);
|
||||
put(TELEPORT_CRYSTAL_1, TELEPORT_CRYSTAL_4);
|
||||
put(TELEPORT_CRYSTAL_2, TELEPORT_CRYSTAL_4);
|
||||
put(TELEPORT_CRYSTAL_3, TELEPORT_CRYSTAL_4);
|
||||
put(TELEPORT_CRYSTAL_4, TELEPORT_CRYSTAL_4);
|
||||
put(TOPAZ_BOLTS, TOPAZ_BOLTS_E);
|
||||
put(TOPAZ_DRAGON_BOLTS, TOPAZ_DRAGON_BOLTS_E);
|
||||
put(TORAGS_HAMMERS_0, TORAGS_HAMMERS);
|
||||
put(TORAGS_HAMMERS_100, TORAGS_HAMMERS);
|
||||
put(TORAGS_HAMMERS_25, TORAGS_HAMMERS);
|
||||
put(TORAGS_PLATELEGS_50, TORAGS_PLATELEGS);
|
||||
put(TORAGS_PLATELEGS_75, TORAGS_PLATELEGS);
|
||||
put(TREASONOUS_RING_I, TREASONOUS_RING);
|
||||
put(TRIDENT_OF_THE_SEAS_E, TRIDENT_OF_THE_SEAS_FULL);
|
||||
put(TRIDENT_OF_THE_SWAMP_E, TRIDENT_OF_THE_SWAMP);
|
||||
put(VERACS_BRASSARD_50, VERACS_BRASSARD);
|
||||
put(VERACS_BRASSARD_75, VERACS_BRASSARD);
|
||||
put(VERACS_FLAIL_0, VERACS_FLAIL);
|
||||
put(VERACS_FLAIL_100, VERACS_FLAIL);
|
||||
put(VERACS_FLAIL_25, VERACS_FLAIL);
|
||||
put(VOID_SEAL1, VOID_SEAL8);
|
||||
put(VOID_SEAL2, VOID_SEAL8);
|
||||
put(VOID_SEAL3, VOID_SEAL8);
|
||||
put(VOID_SEAL4, VOID_SEAL8);
|
||||
put(VOID_SEAL5, VOID_SEAL8);
|
||||
put(WATERSKIN3, WATERSKIN4);
|
||||
put(WATERSKIN4, WATERSKIN4);
|
||||
put(WESTERN_BANNER_1, WESTERN_BANNER);
|
||||
put(WESTERN_BANNER_2, WESTERN_BANNER);
|
||||
put(WESTERN_BANNER_3, WESTERN_BANNER);
|
||||
put(YELLOW_SPICE_2, YELLOW_SPICE_4);
|
||||
put(YELLOW_SPICE_3, YELLOW_SPICE_4);
|
||||
put(YELLOW_SPICE_4, YELLOW_SPICE_4);
|
||||
put(ZAMORAK_BREW1, ZAMORAK_BREW3);
|
||||
put(ZAMORAK_BREW2, ZAMORAK_BREW3);
|
||||
}};
|
||||
|
||||
@Test
|
||||
public void testMappedNames()
|
||||
{
|
||||
ITEMS_MAP.forEach((key, value) ->
|
||||
{
|
||||
assertEquals(value, (Integer) ItemVariationMapping.map(key));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins;
|
||||
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import com.google.common.reflect.ClassPath.ClassInfo;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.grapher.graphviz.GraphvizGrapher;
|
||||
import com.google.inject.grapher.graphviz.GraphvizModule;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import com.google.inject.util.Modules;
|
||||
import java.applet.Applet;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.RuneLiteModule;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import net.runelite.client.rs.ClientUpdateCheckMode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class PluginManagerTest
|
||||
{
|
||||
private static final String PLUGIN_PACKAGE = "net.runelite.client.plugins";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
public Applet applet;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
public Client client;
|
||||
|
||||
private Set<Class> pluginClasses;
|
||||
private Set<Class> configClasses;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
{
|
||||
Injector injector = Guice.createInjector(Modules
|
||||
.override(new RuneLiteModule(ClientUpdateCheckMode.AUTO, true))
|
||||
.with(BoundFieldModule.of(this)));
|
||||
|
||||
RuneLite.setInjector(injector);
|
||||
|
||||
// Find plugins and configs we expect to have
|
||||
pluginClasses = new HashSet<>();
|
||||
configClasses = new HashSet<>();
|
||||
Set<ClassInfo> classes = ClassPath.from(getClass().getClassLoader()).getTopLevelClassesRecursive(PLUGIN_PACKAGE);
|
||||
for (ClassInfo classInfo : classes)
|
||||
{
|
||||
Class<?> clazz = classInfo.load();
|
||||
PluginDescriptor pluginDescriptor = clazz.getAnnotation(PluginDescriptor.class);
|
||||
if (pluginDescriptor != null)
|
||||
{
|
||||
pluginClasses.add(clazz);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Config.class.isAssignableFrom(clazz))
|
||||
{
|
||||
configClasses.add(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadPlugins() throws Exception
|
||||
{
|
||||
PluginManager pluginManager = new PluginManager(false, null, null, null, null, null);
|
||||
pluginManager.setOutdated(true);
|
||||
pluginManager.loadCorePlugins();
|
||||
Collection<Plugin> plugins = pluginManager.getPlugins();
|
||||
long expected = pluginClasses.stream()
|
||||
.map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(PluginDescriptor::loadWhenOutdated)
|
||||
.count();
|
||||
assertEquals(expected, plugins.size());
|
||||
|
||||
pluginManager = new PluginManager(false, null, null, null, null, null);
|
||||
pluginManager.loadCorePlugins();
|
||||
plugins = pluginManager.getPlugins();
|
||||
|
||||
// Check that the plugins register with the eventbus without errors
|
||||
EventBus eventBus = new EventBus();
|
||||
plugins.forEach(eventBus::register);
|
||||
|
||||
expected = pluginClasses.stream()
|
||||
.map(cl -> (PluginDescriptor) cl.getAnnotation(PluginDescriptor.class))
|
||||
.filter(Objects::nonNull)
|
||||
.filter(pd -> !pd.developerPlugin())
|
||||
.count();
|
||||
assertEquals(expected, plugins.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dumpGraph() throws Exception
|
||||
{
|
||||
List<Module> modules = new ArrayList<>();
|
||||
modules.add(new GraphvizModule());
|
||||
modules.add(new RuneLiteModule(ClientUpdateCheckMode.AUTO, true));
|
||||
|
||||
PluginManager pluginManager = new PluginManager(true, null, null, null, null, null);
|
||||
pluginManager.loadCorePlugins();
|
||||
for (Plugin p : pluginManager.getPlugins())
|
||||
{
|
||||
modules.add(p);
|
||||
}
|
||||
|
||||
File file = folder.newFile();
|
||||
try (PrintWriter out = new PrintWriter(file, "UTF-8"))
|
||||
{
|
||||
Injector injector = Guice.createInjector(modules);
|
||||
GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class);
|
||||
grapher.setOut(out);
|
||||
grapher.setRankdir("TB");
|
||||
grapher.graph(injector);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ensureNoDuplicateConfigKeyNames()
|
||||
{
|
||||
for (final Class clazz : configClasses)
|
||||
{
|
||||
final Set<String> configKeyNames = new HashSet<>();
|
||||
|
||||
for (final Method method : clazz.getMethods())
|
||||
{
|
||||
if (!method.isDefault())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final ConfigItem annotation = method.getAnnotation(ConfigItem.class);
|
||||
|
||||
if (annotation == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String configKeyName = annotation.keyName();
|
||||
|
||||
if (configKeyNames.contains(configKeyName))
|
||||
{
|
||||
throw new IllegalArgumentException("keyName " + configKeyName + " is duplicated in " + clazz);
|
||||
}
|
||||
|
||||
configKeyNames.add(configKeyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.attackstyles;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.Set;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class AttackStylesPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
AttackStylesConfig attackConfig;
|
||||
|
||||
@Inject
|
||||
AttackStylesPlugin attackPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that red text is displayed when attacking with a style that gains experience
|
||||
* in one of the unwanted skills.
|
||||
*/
|
||||
@Test
|
||||
public void testWarning()
|
||||
{
|
||||
ConfigChanged warnForAttackEvent = new ConfigChanged();
|
||||
warnForAttackEvent.setGroup("attackIndicator");
|
||||
warnForAttackEvent.setKey("warnForAttack");
|
||||
warnForAttackEvent.setNewValue("true");
|
||||
attackPlugin.onConfigChanged(warnForAttackEvent);
|
||||
|
||||
// Verify there is a warned skill
|
||||
Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();
|
||||
assertTrue(warnedSkills.contains(Skill.ATTACK));
|
||||
|
||||
// Set mock client to attack in style that gives attack xp
|
||||
when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.ACCURATE.ordinal());
|
||||
|
||||
// verify that earning xp in a warned skill will display red text on the widget
|
||||
attackPlugin.onVarbitChanged(new VarbitChanged());
|
||||
assertTrue(attackPlugin.isWarnedSkillSelected());
|
||||
|
||||
// Switch to attack style that doesn't give attack xp
|
||||
when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(AttackStyle.AGGRESSIVE.ordinal());
|
||||
|
||||
// Verify the widget will now display white text
|
||||
attackPlugin.onVarbitChanged(new VarbitChanged());
|
||||
warnedSkills = attackPlugin.getWarnedSkills();
|
||||
assertTrue(warnedSkills.contains(Skill.ATTACK));
|
||||
assertFalse(attackPlugin.isWarnedSkillSelected());
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that attack style widgets are hidden when filtered with the AttackStylesPlugin.
|
||||
*/
|
||||
@Test
|
||||
public void testHiddenWidget()
|
||||
{
|
||||
ConfigChanged warnForAttackEvent = new ConfigChanged();
|
||||
warnForAttackEvent.setGroup("attackIndicator");
|
||||
warnForAttackEvent.setKey("warnForAttack");
|
||||
warnForAttackEvent.setNewValue("true");
|
||||
attackPlugin.onConfigChanged(warnForAttackEvent);
|
||||
|
||||
// Set up mock widgets for atk and str attack styles
|
||||
Widget atkWidget = mock(Widget.class);
|
||||
Widget strWidget = mock(Widget.class);
|
||||
when(client.getWidget(WidgetInfo.COMBAT_STYLE_ONE)).thenReturn(atkWidget);
|
||||
when(client.getWidget(WidgetInfo.COMBAT_STYLE_TWO)).thenReturn(strWidget);
|
||||
// Set widgets to return their hidden value in widgetsToHide when isHidden() is called
|
||||
when(atkWidget.isHidden()).thenAnswer(x -> isAtkHidden());
|
||||
when(strWidget.isHidden()).thenAnswer(x -> isStrHidden());
|
||||
|
||||
// equip type_4 weapon type on player
|
||||
when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(WeaponType.TYPE_4.ordinal());
|
||||
attackPlugin.onVarbitChanged(new VarbitChanged());
|
||||
|
||||
// Verify there is a warned skill
|
||||
Set<Skill> warnedSkills = attackPlugin.getWarnedSkills();
|
||||
assertTrue(warnedSkills.contains(Skill.ATTACK));
|
||||
|
||||
// Enable hiding widgets
|
||||
ConfigChanged hideWidgetEvent = new ConfigChanged();
|
||||
hideWidgetEvent.setGroup("attackIndicator");
|
||||
hideWidgetEvent.setKey("removeWarnedStyles");
|
||||
hideWidgetEvent.setNewValue("true");
|
||||
attackPlugin.onConfigChanged(hideWidgetEvent);
|
||||
when(attackConfig.removeWarnedStyles()).thenReturn(true);
|
||||
|
||||
// verify that the accurate attack style widget is hidden
|
||||
assertTrue(atkWidget.isHidden());
|
||||
|
||||
// add another warned skill
|
||||
ConfigChanged warnForStrengthEvent = new ConfigChanged();
|
||||
warnForStrengthEvent.setGroup("attackIndicator");
|
||||
warnForStrengthEvent.setKey("warnForStrength");
|
||||
warnForStrengthEvent.setNewValue("true");
|
||||
attackPlugin.onConfigChanged(warnForStrengthEvent);
|
||||
|
||||
// verify that the aggressive attack style widget is now hidden
|
||||
assertTrue(strWidget.isHidden());
|
||||
|
||||
// disable hiding attack style widgets
|
||||
hideWidgetEvent.setGroup("attackIndicator");
|
||||
hideWidgetEvent.setKey("removeWarnedStyles");
|
||||
hideWidgetEvent.setNewValue("false");
|
||||
attackPlugin.onConfigChanged(hideWidgetEvent);
|
||||
when(attackConfig.removeWarnedStyles()).thenReturn(false);
|
||||
|
||||
// verify that the aggressive and accurate attack style widgets are no longer hidden
|
||||
assertFalse(attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4,
|
||||
WidgetInfo.COMBAT_STYLE_ONE));
|
||||
assertFalse(attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4,
|
||||
WidgetInfo.COMBAT_STYLE_THREE));
|
||||
}
|
||||
|
||||
private boolean isAtkHidden()
|
||||
{
|
||||
if (attackPlugin.getHiddenWidgets().size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4, WidgetInfo.COMBAT_STYLE_ONE);
|
||||
}
|
||||
|
||||
private boolean isStrHidden()
|
||||
{
|
||||
if (attackPlugin.getHiddenWidgets().size() == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return attackPlugin.getHiddenWidgets().get(WeaponType.TYPE_4, WidgetInfo.COMBAT_STYLE_TWO);
|
||||
}
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.bank;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class BankCalculationTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private BankConfig bankConfig;
|
||||
|
||||
@Inject
|
||||
private BankCalculation bankCalculation;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculate()
|
||||
{
|
||||
when(bankConfig.showHA())
|
||||
.thenReturn(true);
|
||||
|
||||
Item coins = mock(Item.class);
|
||||
when(coins.getId())
|
||||
.thenReturn(ItemID.COINS_995);
|
||||
when(coins.getQuantity())
|
||||
.thenReturn(Integer.MAX_VALUE);
|
||||
|
||||
Item whip = mock(Item.class);
|
||||
when(whip.getId())
|
||||
.thenReturn(ItemID.ABYSSAL_WHIP);
|
||||
when(whip.getQuantity())
|
||||
.thenReturn(1_000_000_000);
|
||||
|
||||
Item[] items = ImmutableList.of(
|
||||
coins,
|
||||
whip
|
||||
).toArray(new Item[0]);
|
||||
|
||||
ItemContainer bankContainer = mock(ItemContainer.class);
|
||||
when(bankContainer.getItems())
|
||||
.thenReturn(items);
|
||||
|
||||
when(client.getItemContainer(InventoryID.BANK))
|
||||
.thenReturn(bankContainer);
|
||||
|
||||
ItemComposition whipComp = mock(ItemComposition.class);
|
||||
when(whipComp.getId())
|
||||
.thenReturn(ItemID.ABYSSAL_WHIP);
|
||||
when(whipComp.getPrice())
|
||||
.thenReturn(7); // 7 * .6 = 4, 4 * 1m overflows
|
||||
when(itemManager.getItemComposition(ItemID.ABYSSAL_WHIP))
|
||||
.thenReturn(whipComp);
|
||||
|
||||
bankCalculation.calculate();
|
||||
|
||||
long value = bankCalculation.getHaPrice();
|
||||
assertTrue(value == Integer.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
@@ -1,92 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.cerberus;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CerberusPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Inject
|
||||
CerberusPlugin cerberusPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnGameTick()
|
||||
{
|
||||
List<NPC> ghosts = cerberusPlugin.getGhosts();
|
||||
ghosts.addAll(Arrays.asList(
|
||||
mockNpc(new LocalPoint(0, 0)),
|
||||
mockNpc(new LocalPoint(1, 0)),
|
||||
mockNpc(new LocalPoint(0, 5)),
|
||||
mockNpc(new LocalPoint(2, 0)),
|
||||
mockNpc(new LocalPoint(2, 5)),
|
||||
mockNpc(new LocalPoint(1, 5))
|
||||
));
|
||||
cerberusPlugin.onGameTick(new GameTick());
|
||||
|
||||
// Expected sort is by lowest y first, then by lowest x
|
||||
assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0));
|
||||
assertEquals(ghosts.get(1).getLocalLocation(), new LocalPoint(1, 0));
|
||||
assertEquals(ghosts.get(2).getLocalLocation(), new LocalPoint(2, 0));
|
||||
|
||||
assertEquals(ghosts.get(3).getLocalLocation(), new LocalPoint(0, 5));
|
||||
assertEquals(ghosts.get(4).getLocalLocation(), new LocalPoint(1, 5));
|
||||
assertEquals(ghosts.get(5).getLocalLocation(), new LocalPoint(2, 5));
|
||||
}
|
||||
|
||||
private static NPC mockNpc(LocalPoint localPoint)
|
||||
{
|
||||
NPC npc = mock(NPC.class);
|
||||
when(npc.getLocalLocation()).thenReturn(localPoint);
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.chatcommands;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import static net.runelite.api.ChatMessageType.GAMEMESSAGE;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.client.config.ChatColorConfig;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ChatCommandsPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ConfigManager configManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatColorConfig chatColorConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatCommandsConfig chatCommandsConfig;
|
||||
|
||||
@Inject
|
||||
ChatCommandsPlugin chatCommandsPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCorporealBeastKill()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your Corporeal Beast kill count is: <col=ff0000>4</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(configManager).setConfiguration("killcount.adam", "corporeal beast", 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTheatreOfBlood()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your completed Theatre of Blood count is: <col=ff0000>73</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(configManager).setConfiguration("killcount.adam", "theatre of blood", 73);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWintertodt()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your subdued Wintertodt count is: <col=ff0000>4</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(configManager).setConfiguration("killcount.adam", "wintertodt", 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKreearra()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your Kree'arra kill count is: <col=ff0000>4</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(configManager).setConfiguration("killcount.adam", "kree'arra", 4);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBarrows()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your Barrows chest count is: <col=ff0000>277</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(configManager).setConfiguration("killcount.adam", "barrows chests", 277);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHerbiboar()
|
||||
{
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", "Your herbiboar harvest count is: <col=ff0000>4091</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(configManager).setConfiguration("killcount.adam", "herbiboar", 4091);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersonalBest()
|
||||
{
|
||||
final String FIGHT_DURATION = "Fight duration: <col=ff0000>2:06</col>. Personal best: 1:19.";
|
||||
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
// This sets lastBoss
|
||||
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Kree'arra kill count is: <col=ff0000>4</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", FIGHT_DURATION, null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("kree'arra"), eq(79));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPersonalBestNoTrailingPeriod()
|
||||
{
|
||||
final String FIGHT_DURATION = "Fight duration: <col=ff0000>0:59</col>. Personal best: 0:55";
|
||||
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
// This sets lastBoss
|
||||
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Zulrah kill count is: <col=ff0000>4</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", FIGHT_DURATION, null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("zulrah"), eq(55));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewPersonalBest()
|
||||
{
|
||||
final String NEW_PB = "Fight duration: <col=ff0000>3:01</col> (new personal best).";
|
||||
|
||||
when(client.getUsername()).thenReturn("Adam");
|
||||
|
||||
// This sets lastBoss
|
||||
ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Your Kree'arra kill count is: <col=ff0000>4</col>.", null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
chatMessage = new ChatMessage(null, GAMEMESSAGE, "", NEW_PB, null, 0);
|
||||
chatCommandsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(configManager).setConfiguration(eq("personalbest.adam"), eq("kree'arra"), eq(181));
|
||||
}
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* Copyright (c) 2019, osrs-music-map <osrs-music-map@users.noreply.github.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.chatfilter;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.Player;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ChatFilterPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ChatFilterConfig chatFilterConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Player localPlayer;
|
||||
|
||||
@Inject
|
||||
private ChatFilterPlugin chatFilterPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
|
||||
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_WORDS);
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("");
|
||||
when(chatFilterConfig.filteredRegex()).thenReturn("");
|
||||
when(client.getLocalPlayer()).thenReturn(localPlayer);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCensorWords()
|
||||
{
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("hat");
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
assertEquals("w***s up", chatFilterPlugin.censorMessage("whats up"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCensorRegex()
|
||||
{
|
||||
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE);
|
||||
when(chatFilterConfig.filteredRegex()).thenReturn("5[0-9]x2\n(");
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
assertNull(chatFilterPlugin.censorMessage("55X2 Dicing | Trusted Ranks | Huge Pay Outs!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBrokenRegex()
|
||||
{
|
||||
when(chatFilterConfig.filteredRegex()).thenReturn("Test\n)\n73");
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
assertEquals("** isn't funny", chatFilterPlugin.censorMessage("73 isn't funny"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCaseSensitivity()
|
||||
{
|
||||
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.CENSOR_MESSAGE);
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("ReGeX!!!");
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
assertEquals("Hey, everyone, I just tried to say something very silly!",
|
||||
chatFilterPlugin.censorMessage("I love regex!!!!!!!!"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNonPrintableCharacters()
|
||||
{
|
||||
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE);
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("test");
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
assertNull(chatFilterPlugin.censorMessage("te\u008Cst"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromFriendIsFiltered()
|
||||
{
|
||||
when(client.isFriended("Iron Mammal", false)).thenReturn(true);
|
||||
when(chatFilterConfig.filterFriends()).thenReturn(true);
|
||||
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromFriendIsNotFiltered()
|
||||
{
|
||||
when(client.isFriended("Iron Mammal", false)).thenReturn(true);
|
||||
when(chatFilterConfig.filterFriends()).thenReturn(false);
|
||||
assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("Iron Mammal"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromClanIsFiltered()
|
||||
{
|
||||
when(client.isClanMember("B0aty")).thenReturn(true);
|
||||
when(chatFilterConfig.filterClan()).thenReturn(true);
|
||||
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("B0aty"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromClanIsNotFiltered()
|
||||
{
|
||||
when(client.isClanMember("B0aty")).thenReturn(true);
|
||||
when(chatFilterConfig.filterClan()).thenReturn(false);
|
||||
assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("B0aty"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromSelfIsNotFiltered()
|
||||
{
|
||||
when(localPlayer.getName()).thenReturn("Swampletics");
|
||||
assertFalse(chatFilterPlugin.shouldFilterPlayerMessage("Swampletics"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromNonFriendNonClanIsFiltered()
|
||||
{
|
||||
when(client.isFriended("Woox", false)).thenReturn(false);
|
||||
when(client.isClanMember("Woox")).thenReturn(false);
|
||||
assertTrue(chatFilterPlugin.shouldFilterPlayerMessage("Woox"));
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.chatnotifications;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.util.Text;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ChatNotificationsPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ChatNotificationsConfig config;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ChatMessageManager chatMessageManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Notifier notifier;
|
||||
|
||||
@Inject
|
||||
private ChatNotificationsPlugin chatNotificationsPlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onChatMessage()
|
||||
{
|
||||
when(config.highlightWordsString()).thenReturn("Deathbeam, Deathbeam OSRS , test");
|
||||
|
||||
MessageNode messageNode = mock(MessageNode.class);
|
||||
when(messageNode.getValue()).thenReturn("Deathbeam, Deathbeam OSRS");
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage();
|
||||
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||
chatMessage.setMessageNode(messageNode);
|
||||
|
||||
chatNotificationsPlugin.startUp(); // load highlight config
|
||||
chatNotificationsPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(messageNode).setValue("<colHIGHLIGHT>Deathbeam<colNORMAL>, <colHIGHLIGHT>Deathbeam<colNORMAL> OSRS");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void highlightListTest()
|
||||
{
|
||||
when(config.highlightWordsString()).thenReturn("this,is, a , test, ");
|
||||
final List<String> higlights = Text.fromCSV(config.highlightWordsString());
|
||||
assertEquals(4, higlights.size());
|
||||
|
||||
final Iterator<String> iterator = higlights.iterator();
|
||||
assertEquals("this", iterator.next());
|
||||
assertEquals("is", iterator.next());
|
||||
assertEquals("a", iterator.next());
|
||||
assertEquals("test", iterator.next());
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.cluescrolls.clues;
|
||||
|
||||
import net.runelite.api.coords.WorldPoint;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CoordinateClueTest
|
||||
{
|
||||
@Test
|
||||
public void testDuplicateCoordinates()
|
||||
{
|
||||
// If this doesn't throw then the clues map doesn't have duplicate keys
|
||||
new CoordinateClue("test", new WorldPoint(0, 0, 0));
|
||||
}
|
||||
}
|
||||
@@ -1,396 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Brett Middle <https://github.com/bmiddle>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.combatlevel;
|
||||
|
||||
import net.runelite.api.Experience;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class CombatLevelPluginTest
|
||||
{
|
||||
@Test
|
||||
public void testNewPlayer()
|
||||
{
|
||||
int attackLevel = 1;
|
||||
int strengthLevel = 1;
|
||||
int defenceLevel = 1;
|
||||
int hitpointsLevel = 10;
|
||||
int magicLevel = 1;
|
||||
int rangeLevel = 1;
|
||||
int prayerLevel = 1;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int rangeNeed = Experience.getNextCombatLevelRange(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int magicNeed = Experience.getNextCombatLevelMagic(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(3, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(2, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(3, hpDefNeed);
|
||||
|
||||
// test ranged
|
||||
assertEquals(2, rangeNeed);
|
||||
|
||||
// test magic
|
||||
assertEquals(2, magicNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(5, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAll10()
|
||||
{
|
||||
int attackLevel = 10;
|
||||
int strengthLevel = 10;
|
||||
int defenceLevel = 10;
|
||||
int hitpointsLevel = 10;
|
||||
int magicLevel = 10;
|
||||
int rangeLevel = 10;
|
||||
int prayerLevel = 10;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int rangeNeed = Experience.getNextCombatLevelRange(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int magicNeed = Experience.getNextCombatLevelMagic(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(12, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(1, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(1, hpDefNeed);
|
||||
|
||||
// test ranged
|
||||
assertEquals(4, rangeNeed);
|
||||
|
||||
// test magic
|
||||
assertEquals(4, magicNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(2, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlayerBmid()
|
||||
{
|
||||
// snapshot of current stats 2018-10-2
|
||||
int attackLevel = 65;
|
||||
int strengthLevel = 70;
|
||||
int defenceLevel = 60;
|
||||
int hitpointsLevel = 71;
|
||||
int magicLevel = 73;
|
||||
int rangeLevel = 75;
|
||||
int prayerLevel = 56;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int rangeNeed = Experience.getNextCombatLevelRange(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int magicNeed = Experience.getNextCombatLevelMagic(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(83, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(2, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(2, hpDefNeed);
|
||||
|
||||
// test ranged
|
||||
assertEquals(17, rangeNeed);
|
||||
|
||||
// test magic
|
||||
assertEquals(19, magicNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(4, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlayerRunelite()
|
||||
{
|
||||
// snapshot of current stats 2018-10-2
|
||||
int attackLevel = 43;
|
||||
int strengthLevel = 36;
|
||||
int defenceLevel = 1;
|
||||
int hitpointsLevel = 42;
|
||||
int magicLevel = 64;
|
||||
int rangeLevel = 51;
|
||||
int prayerLevel = 15;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int rangeNeed = Experience.getNextCombatLevelRange(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int magicNeed = Experience.getNextCombatLevelMagic(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(43, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(18, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(2, hpDefNeed);
|
||||
|
||||
// test ranged
|
||||
assertEquals(14, rangeNeed);
|
||||
|
||||
// test magic
|
||||
assertEquals(1, magicNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(3, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPlayerZezima()
|
||||
{
|
||||
// snapshot of current stats 2018-10-3
|
||||
// Zezima cannot earn a combat level from ranged/magic anymore, so it won't show as the result is too high
|
||||
int attackLevel = 74;
|
||||
int strengthLevel = 74;
|
||||
int defenceLevel = 72;
|
||||
int hitpointsLevel = 72;
|
||||
int magicLevel = 60;
|
||||
int rangeLevel = 44;
|
||||
int prayerLevel = 52;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(90, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(2, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(2, hpDefNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(4, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrayerLevelsNeeded()
|
||||
{
|
||||
int attackLevel = 99;
|
||||
int strengthLevel = 99;
|
||||
int defenceLevel = 99;
|
||||
int hitpointsLevel = 99;
|
||||
int magicLevel = 99;
|
||||
int rangeLevel = 99;
|
||||
int prayerLevel = 89;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(124, combatLevel);
|
||||
|
||||
// test prayer
|
||||
assertEquals(1, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEvenPrayerLevelsNeededWhenNearNextCombatLevel()
|
||||
{
|
||||
int attackLevel = 74;
|
||||
int strengthLevel = 75;
|
||||
int defenceLevel = 72;
|
||||
int hitpointsLevel = 72;
|
||||
int magicLevel = 60;
|
||||
int rangeLevel = 44;
|
||||
int prayerLevel = 52;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(90, combatLevel);
|
||||
|
||||
// test prayer
|
||||
assertEquals(2, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOddPrayerLevelsNeededWhenNearNextCombatLevel()
|
||||
{
|
||||
int attackLevel = 74;
|
||||
int strengthLevel = 75;
|
||||
int defenceLevel = 72;
|
||||
int hitpointsLevel = 72;
|
||||
int magicLevel = 60;
|
||||
int rangeLevel = 44;
|
||||
int prayerLevel = 53;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(90, combatLevel);
|
||||
|
||||
// test prayer
|
||||
assertEquals(1, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNextMagicLevelBarelyReachesNextCombatLevel()
|
||||
{
|
||||
int attackLevel = 40;
|
||||
int strengthLevel = 44;
|
||||
int defenceLevel = 46;
|
||||
int hitpointsLevel = 39;
|
||||
int magicLevel = 57;
|
||||
int rangeLevel = 40;
|
||||
int prayerLevel = 29;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int rangeNeed = Experience.getNextCombatLevelRange(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int magicNeed = Experience.getNextCombatLevelMagic(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(52, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(3, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(3, hpDefNeed);
|
||||
|
||||
// test ranged
|
||||
assertEquals(18, rangeNeed);
|
||||
|
||||
// test magic
|
||||
assertEquals(1, magicNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(5, prayerNeed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRangeMagicLevelsNeeded()
|
||||
{
|
||||
int attackLevel = 60;
|
||||
int strengthLevel = 69;
|
||||
int defenceLevel = 1;
|
||||
int hitpointsLevel = 78;
|
||||
int magicLevel = 85;
|
||||
int rangeLevel = 85;
|
||||
int prayerLevel = 52;
|
||||
|
||||
int combatLevel = Experience.getCombatLevel(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int meleeNeed = Experience.getNextCombatLevelMelee(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int hpDefNeed = Experience.getNextCombatLevelHpDef(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int rangeNeed = Experience.getNextCombatLevelRange(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int magicNeed = Experience.getNextCombatLevelMagic(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
int prayerNeed = Experience.getNextCombatLevelPrayer(attackLevel, strengthLevel, defenceLevel, hitpointsLevel,
|
||||
magicLevel, rangeLevel, prayerLevel);
|
||||
|
||||
// test combat level
|
||||
assertEquals(68, combatLevel);
|
||||
|
||||
// test attack/strength
|
||||
assertEquals(3, meleeNeed);
|
||||
|
||||
// test defence/hitpoints
|
||||
assertEquals(4, hpDefNeed);
|
||||
|
||||
// test ranged
|
||||
assertEquals(3, rangeNeed);
|
||||
|
||||
// test magic
|
||||
assertEquals(3, magicNeed);
|
||||
|
||||
// test prayer
|
||||
assertEquals(8, prayerNeed);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.cooking;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GraphicID;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GraphicChanged;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.any;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CookingPluginTest
|
||||
{
|
||||
private static final String[] COOKING_MESSAGES = {
|
||||
"You successfully cook a shark.",
|
||||
"You successfully cook an anglerfish.",
|
||||
"You manage to cook a tuna.",
|
||||
"You cook the karambwan. It looks delicious.",
|
||||
"You roast a lobster.",
|
||||
"You cook a bass.",
|
||||
"You successfully bake a tasty garden pie."
|
||||
};
|
||||
|
||||
@Inject
|
||||
CookingPlugin cookingPlugin;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
InfoBoxManager infoBoxManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ItemManager itemManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
CookingConfig config;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
CookingOverlay cookingOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnChatMessage()
|
||||
{
|
||||
for (String message : COOKING_MESSAGES)
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", message, "", 0);
|
||||
cookingPlugin.onChatMessage(chatMessage);
|
||||
}
|
||||
|
||||
CookingSession cookingSession = cookingPlugin.getSession();
|
||||
assertNotNull(cookingSession);
|
||||
assertEquals(COOKING_MESSAGES.length, cookingSession.getCookAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnGraphicChanged()
|
||||
{
|
||||
Player player = mock(Player.class);
|
||||
when(player.getGraphic()).thenReturn(GraphicID.WINE_MAKE);
|
||||
|
||||
when(config.fermentTimer()).thenReturn(true);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
GraphicChanged graphicChanged = new GraphicChanged();
|
||||
graphicChanged.setActor(player);
|
||||
cookingPlugin.onGraphicChanged(graphicChanged);
|
||||
|
||||
verify(infoBoxManager).addInfoBox(any(FermentTimer.class));
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.examine;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.MenuOptionClicked;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.http.api.examine.ExamineClient;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ExaminePluginTest
|
||||
{
|
||||
@Inject
|
||||
ExaminePlugin examinePlugin;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ExamineClient examineClient;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatMessageManager chatMessageManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ItemManager itemManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItem()
|
||||
{
|
||||
when(client.getWidget(anyInt(), anyInt())).thenReturn(mock(Widget.class));
|
||||
|
||||
MenuOptionClicked menuOptionClicked = new MenuOptionClicked();
|
||||
menuOptionClicked.setMenuOption("Examine");
|
||||
menuOptionClicked.setMenuAction(MenuAction.EXAMINE_ITEM);
|
||||
menuOptionClicked.setId(ItemID.ABYSSAL_WHIP);
|
||||
examinePlugin.onMenuOptionClicked(menuOptionClicked);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.ITEM_EXAMINE, "", "A weapon from the abyss.", "", 0);
|
||||
examinePlugin.onChatMessage(chatMessage);
|
||||
|
||||
// This passes due to not mocking the ItemComposition for the whip
|
||||
verify(examineClient).submitItem(anyInt(), anyString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLargeStacks()
|
||||
{
|
||||
when(client.getWidget(anyInt(), anyInt())).thenReturn(mock(Widget.class));
|
||||
|
||||
MenuOptionClicked menuOptionClicked = new MenuOptionClicked();
|
||||
menuOptionClicked.setMenuOption("Examine");
|
||||
menuOptionClicked.setMenuAction(MenuAction.EXAMINE_ITEM);
|
||||
menuOptionClicked.setId(ItemID.ABYSSAL_WHIP);
|
||||
examinePlugin.onMenuOptionClicked(menuOptionClicked);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.ITEM_EXAMINE, "", "100000 x Abyssal whip", "", 0);
|
||||
examinePlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(examineClient, never()).submitItem(anyInt(), anyString());
|
||||
}
|
||||
}
|
||||
@@ -1,199 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.gpu;
|
||||
|
||||
import com.jogamp.nativewindow.AbstractGraphicsConfiguration;
|
||||
import com.jogamp.nativewindow.NativeWindowFactory;
|
||||
import com.jogamp.nativewindow.awt.AWTGraphicsConfiguration;
|
||||
import com.jogamp.nativewindow.awt.JAWTWindow;
|
||||
import com.jogamp.opengl.GL4;
|
||||
import com.jogamp.opengl.GLCapabilities;
|
||||
import com.jogamp.opengl.GLContext;
|
||||
import com.jogamp.opengl.GLDrawable;
|
||||
import com.jogamp.opengl.GLDrawableFactory;
|
||||
import com.jogamp.opengl.GLProfile;
|
||||
import java.awt.Canvas;
|
||||
import java.util.function.Function;
|
||||
import javax.swing.JFrame;
|
||||
import static net.runelite.client.plugins.gpu.GLUtil.inputStreamToString;
|
||||
import net.runelite.client.plugins.gpu.template.Template;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ShaderTest
|
||||
{
|
||||
private static final String VERTEX_SHADER = "" +
|
||||
"void main() {" +
|
||||
" gl_Position = vec4(1.0, 1.0, 1.0, 1.0);" +
|
||||
"}";
|
||||
private GL4 gl;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Canvas canvas = new Canvas();
|
||||
JFrame frame = new JFrame();
|
||||
frame.setSize(100, 100);
|
||||
frame.add(canvas);
|
||||
frame.setVisible(true);
|
||||
|
||||
GLProfile glProfile = GLProfile.getMaxFixedFunc(true);
|
||||
|
||||
GLCapabilities glCaps = new GLCapabilities(glProfile);
|
||||
AbstractGraphicsConfiguration config = AWTGraphicsConfiguration.create(canvas.getGraphicsConfiguration(),
|
||||
glCaps, glCaps);
|
||||
|
||||
JAWTWindow jawtWindow = (JAWTWindow) NativeWindowFactory.getNativeWindow(canvas, config);
|
||||
|
||||
GLDrawableFactory glDrawableFactory = GLDrawableFactory.getFactory(glProfile);
|
||||
|
||||
GLDrawable glDrawable = glDrawableFactory.createGLDrawable(jawtWindow);
|
||||
glDrawable.setRealized(true);
|
||||
|
||||
|
||||
GLContext glContext = glDrawable.createContext(null);
|
||||
int res = glContext.makeCurrent();
|
||||
if (res == GLContext.CONTEXT_NOT_CURRENT)
|
||||
{
|
||||
fail("error making context current");
|
||||
}
|
||||
|
||||
gl = glContext.getGL().getGL4();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testUnordered() throws ShaderException
|
||||
{
|
||||
int glComputeProgram = gl.glCreateProgram();
|
||||
int glComputeShader = gl.glCreateShader(gl.GL_COMPUTE_SHADER);
|
||||
try
|
||||
{
|
||||
Function<String, String> func = (s) -> inputStreamToString(getClass().getResourceAsStream(s));
|
||||
Template template = new Template(func);
|
||||
String source = template.process(func.apply("comp_unordered.glsl"));
|
||||
|
||||
int line = 0;
|
||||
for (String str : source.split("\\n"))
|
||||
{
|
||||
System.out.println(++line + " " + str);
|
||||
}
|
||||
|
||||
GLUtil.loadComputeShader(gl, glComputeProgram, glComputeShader, source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
gl.glDeleteShader(glComputeShader);
|
||||
gl.glDeleteProgram(glComputeProgram);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testSmall() throws ShaderException
|
||||
{
|
||||
int glComputeProgram = gl.glCreateProgram();
|
||||
int glComputeShader = gl.glCreateShader(gl.GL_COMPUTE_SHADER);
|
||||
try
|
||||
{
|
||||
Function<String, String> func = (s) -> inputStreamToString(getClass().getResourceAsStream(s));
|
||||
Template template = new Template(func);
|
||||
String source = template.process(func.apply("comp_small.glsl"));
|
||||
|
||||
int line = 0;
|
||||
for (String str : source.split("\\n"))
|
||||
{
|
||||
System.out.println(++line + " " + str);
|
||||
}
|
||||
|
||||
GLUtil.loadComputeShader(gl, glComputeProgram, glComputeShader, source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
gl.glDeleteShader(glComputeShader);
|
||||
gl.glDeleteProgram(glComputeProgram);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testComp() throws ShaderException
|
||||
{
|
||||
int glComputeProgram = gl.glCreateProgram();
|
||||
int glComputeShader = gl.glCreateShader(gl.GL_COMPUTE_SHADER);
|
||||
try
|
||||
{
|
||||
Function<String, String> func = (s) -> inputStreamToString(getClass().getResourceAsStream(s));
|
||||
Template template = new Template(func);
|
||||
String source = template.process(func.apply("comp.glsl"));
|
||||
|
||||
int line = 0;
|
||||
for (String str : source.split("\\n"))
|
||||
{
|
||||
System.out.println(++line + " " + str);
|
||||
}
|
||||
|
||||
GLUtil.loadComputeShader(gl, glComputeProgram, glComputeShader, source);
|
||||
}
|
||||
finally
|
||||
{
|
||||
gl.glDeleteShader(glComputeShader);
|
||||
gl.glDeleteProgram(glComputeProgram);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testGeom() throws ShaderException
|
||||
{
|
||||
int glComputeProgram = gl.glCreateProgram();
|
||||
int glVertexShader = gl.glCreateShader(gl.GL_VERTEX_SHADER);
|
||||
int glGeometryShader = gl.glCreateShader(gl.GL_GEOMETRY_SHADER);
|
||||
int glFragmentShader = gl.glCreateShader(gl.GL_FRAGMENT_SHADER);
|
||||
try
|
||||
{
|
||||
Function<String, String> func = (s) -> inputStreamToString(getClass().getResourceAsStream(s));
|
||||
Template template = new Template(func);
|
||||
String source = template.process(func.apply("geom.glsl"));
|
||||
|
||||
int line = 0;
|
||||
for (String str : source.split("\\n"))
|
||||
{
|
||||
System.out.println(++line + " " + str);
|
||||
}
|
||||
|
||||
GLUtil.loadShaders(gl, glComputeProgram, glVertexShader, glGeometryShader, glFragmentShader, VERTEX_SHADER, source, "");
|
||||
}
|
||||
finally
|
||||
{
|
||||
gl.glDeleteShader(glVertexShader);
|
||||
gl.glDeleteShader(glGeometryShader);
|
||||
gl.glDeleteShader(glFragmentShader);
|
||||
gl.glDeleteProgram(glComputeProgram);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.gpu.template;
|
||||
|
||||
import java.util.function.Function;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TemplateTest
|
||||
{
|
||||
private static final String FILE1 = "" +
|
||||
"test1\n" +
|
||||
"#include file2\n" +
|
||||
"test3\n";
|
||||
|
||||
private static final String FILE2 = "" +
|
||||
"test4\n" +
|
||||
"test5\n";
|
||||
|
||||
private static final String RESULT = "" +
|
||||
"test1\n" +
|
||||
"test4\n" +
|
||||
"test5\n" +
|
||||
"test3\n";
|
||||
|
||||
@Test
|
||||
public void testProcess()
|
||||
{
|
||||
Function<String, String> func = (String resource) ->
|
||||
{
|
||||
switch (resource)
|
||||
{
|
||||
case "file2":
|
||||
return FILE2;
|
||||
default:
|
||||
throw new RuntimeException("unknown resource");
|
||||
}
|
||||
};
|
||||
String out = new Template(func).process(FILE1);
|
||||
assertEquals(RESULT, out);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, SomeoneWithAnInternetConnection
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.grandexchange;
|
||||
|
||||
import net.runelite.api.GrandExchangeOffer;
|
||||
import net.runelite.api.GrandExchangeOfferState;
|
||||
import net.runelite.api.ItemComposition;
|
||||
import net.runelite.client.game.AsyncBufferedImage;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class GrandExchangeOfferSlotTest
|
||||
{
|
||||
@Mock
|
||||
private GrandExchangeOffer offer;
|
||||
|
||||
@Test
|
||||
public void testUpdateOffer()
|
||||
{
|
||||
when(offer.getState()).thenReturn(GrandExchangeOfferState.CANCELLED_BUY);
|
||||
|
||||
GrandExchangeOfferSlot offerSlot = new GrandExchangeOfferSlot();
|
||||
offerSlot.updateOffer(mock(ItemComposition.class), mock(AsyncBufferedImage.class), offer);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.grounditems;
|
||||
|
||||
import java.util.Arrays;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WildcardMatchLoaderTest
|
||||
{
|
||||
@Test
|
||||
public void testLoad()
|
||||
{
|
||||
WildcardMatchLoader loader = new WildcardMatchLoader(Arrays.asList("rune*", "Abyssal whip"));
|
||||
assertTrue(loader.load("rune pouch"));
|
||||
assertTrue(loader.load("Rune pouch"));
|
||||
assertFalse(loader.load("Adamant dagger"));
|
||||
assertTrue(loader.load("Runeite Ore"));
|
||||
assertTrue(loader.load("Abyssal whip"));
|
||||
assertFalse(loader.load("Abyssal dagger"));
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.hiscore;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class HiscorePanelTest
|
||||
{
|
||||
@Test
|
||||
public void testConstructor()
|
||||
{
|
||||
new HiscorePanel(new HiscoreConfig()
|
||||
{
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.idlenotifier;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.EnumSet;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Hitsplat;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.NPCComposition;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.HitsplatApplied;
|
||||
import net.runelite.api.events.InteractingChanged;
|
||||
import net.runelite.client.Notifier;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import static org.mockito.Matchers.any;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class IdleNotifierPluginTest
|
||||
{
|
||||
private static final String PLAYER_NAME = "Deathbeam";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private IdleNotifierConfig config;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Notifier notifier;
|
||||
|
||||
@Inject
|
||||
private IdleNotifierPlugin plugin;
|
||||
|
||||
@Mock
|
||||
private NPC monster;
|
||||
|
||||
@Mock
|
||||
private NPC randomEvent;
|
||||
|
||||
@Mock
|
||||
private Player player;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
|
||||
// Mock monster
|
||||
final String[] monsterActions = new String[] { "Attack", "Examine" };
|
||||
final NPCComposition monsterComp = mock(NPCComposition.class);
|
||||
when(monsterComp.getActions()).thenReturn(monsterActions);
|
||||
when(monster.getComposition()).thenReturn(monsterComp);
|
||||
|
||||
// Mock random event
|
||||
final String[] randomEventActions = new String[] { "Talk-to", "Dismiss", "Examine" };
|
||||
final NPCComposition randomEventComp = mock(NPCComposition.class);
|
||||
when(randomEventComp.getActions()).thenReturn(randomEventActions);
|
||||
when(randomEvent.getComposition()).thenReturn(randomEventComp);
|
||||
|
||||
// Mock player
|
||||
when(player.getName()).thenReturn(PLAYER_NAME);
|
||||
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
|
||||
when(client.getLocalPlayer()).thenReturn(player);
|
||||
|
||||
// Mock config
|
||||
when(config.logoutIdle()).thenReturn(true);
|
||||
when(config.animationIdle()).thenReturn(true);
|
||||
when(config.interactionIdle()).thenReturn(true);
|
||||
when(config.getIdleNotificationDelay()).thenReturn(0);
|
||||
when(config.getHitpointsThreshold()).thenReturn(42);
|
||||
when(config.getPrayerThreshold()).thenReturn(42);
|
||||
|
||||
// Mock client
|
||||
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
|
||||
when(client.getKeyboardIdleTicks()).thenReturn(42);
|
||||
when(client.getMouseLastPressedMillis()).thenReturn(System.currentTimeMillis() - 100_000L);
|
||||
when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAnimationIdle()
|
||||
{
|
||||
when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE);
|
||||
AnimationChanged animationChanged = new AnimationChanged();
|
||||
animationChanged.setActor(player);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier).notify("[" + PLAYER_NAME + "] is now idle!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAnimationReset()
|
||||
{
|
||||
when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE);
|
||||
AnimationChanged animationChanged = new AnimationChanged();
|
||||
animationChanged.setActor(player);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
when(player.getAnimation()).thenReturn(AnimationID.LOOKING_INTO);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier, times(0)).notify(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkAnimationLogout()
|
||||
{
|
||||
when(player.getAnimation()).thenReturn(AnimationID.WOODCUTTING_BRONZE);
|
||||
AnimationChanged animationChanged = new AnimationChanged();
|
||||
animationChanged.setActor(player);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
|
||||
// Logout
|
||||
when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN);
|
||||
GameStateChanged gameStateChanged = new GameStateChanged();
|
||||
gameStateChanged.setGameState(GameState.LOGIN_SCREEN);
|
||||
plugin.onGameStateChanged(gameStateChanged);
|
||||
|
||||
// Log back in
|
||||
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
|
||||
gameStateChanged.setGameState(GameState.LOGGED_IN);
|
||||
plugin.onGameStateChanged(gameStateChanged);
|
||||
|
||||
// Tick
|
||||
when(player.getAnimation()).thenReturn(AnimationID.IDLE);
|
||||
plugin.onAnimationChanged(animationChanged);
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier, times(0)).notify(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkCombatIdle()
|
||||
{
|
||||
when(player.getInteracting()).thenReturn(monster);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, monster));
|
||||
plugin.onGameTick(new GameTick());
|
||||
when(player.getInteracting()).thenReturn(null);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, null));
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier).notify("[" + PLAYER_NAME + "] is now out of combat!");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkCombatReset()
|
||||
{
|
||||
when(player.getInteracting()).thenReturn(monster);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, monster));
|
||||
plugin.onGameTick(new GameTick());
|
||||
when(player.getInteracting()).thenReturn(randomEvent);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, randomEvent));
|
||||
plugin.onGameTick(new GameTick());
|
||||
when(player.getInteracting()).thenReturn(null);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, null));
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier, times(0)).notify(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkCombatLogout()
|
||||
{
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, monster));
|
||||
when(player.getInteracting()).thenReturn(monster);
|
||||
plugin.onGameTick(new GameTick());
|
||||
|
||||
// Logout
|
||||
when(client.getGameState()).thenReturn(GameState.LOGIN_SCREEN);
|
||||
GameStateChanged gameStateChanged = new GameStateChanged();
|
||||
gameStateChanged.setGameState(GameState.LOGIN_SCREEN);
|
||||
plugin.onGameStateChanged(gameStateChanged);
|
||||
|
||||
// Log back in
|
||||
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
|
||||
gameStateChanged.setGameState(GameState.LOGGED_IN);
|
||||
plugin.onGameStateChanged(gameStateChanged);
|
||||
|
||||
// Tick
|
||||
when(player.getInteracting()).thenReturn(null);
|
||||
plugin.onInteractingChanged(new InteractingChanged(player, null));
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier, times(0)).notify(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkCombatLogoutIdle()
|
||||
{
|
||||
// Player is idle
|
||||
when(client.getMouseIdleTicks()).thenReturn(80_000);
|
||||
|
||||
// But player is being damaged (is in combat)
|
||||
final HitsplatApplied hitsplatApplied = new HitsplatApplied();
|
||||
hitsplatApplied.setActor(player);
|
||||
hitsplatApplied.setHitsplat(new Hitsplat(Hitsplat.HitsplatType.DAMAGE, 0, 0));
|
||||
plugin.onHitsplatApplied(hitsplatApplied);
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier, times(0)).notify(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doubleNotifyOnMouseReset()
|
||||
{
|
||||
// Player is idle, but in combat so the idle packet is getting set repeatedly
|
||||
// make sure we are not notifying
|
||||
|
||||
when(client.getKeyboardIdleTicks()).thenReturn(80_000);
|
||||
when(client.getMouseIdleTicks()).thenReturn(14_500);
|
||||
|
||||
plugin.onGameTick(new GameTick());
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier, times(1)).notify(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpecRegen()
|
||||
{
|
||||
when(config.getSpecEnergyThreshold()).thenReturn(50);
|
||||
|
||||
when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(400); // 40%
|
||||
plugin.onGameTick(new GameTick()); // once to set lastSpecEnergy to 400
|
||||
verify(notifier, never()).notify(any());
|
||||
|
||||
when(client.getVar(Matchers.eq(VarPlayer.SPECIAL_ATTACK_PERCENT))).thenReturn(500); // 50%
|
||||
plugin.onGameTick(new GameTick());
|
||||
verify(notifier).notify(Matchers.eq("[" + PLAYER_NAME + "] has restored spec energy!"));
|
||||
}
|
||||
}
|
||||
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.itemcharges;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ItemChargePluginTest
|
||||
{
|
||||
private static final String CHECK = "Your dodgy necklace has 10 charges left.";
|
||||
private static final String PROTECT = "Your dodgy necklace protects you. It has 9 charges left.";
|
||||
private static final String PROTECT_1 = "Your dodgy necklace protects you. <col=ff0000>It has 1 charge left.</col>";
|
||||
private static final String BREAK = "Your dodgy necklace protects you. <col=ff0000>It then crumbles to dust.</col>";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private RuneLiteConfig runeLiteConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private OverlayManager overlayManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Notifier notifier;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ItemChargeConfig config;
|
||||
|
||||
@Inject
|
||||
private ItemChargePlugin itemChargePlugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOnChatMessage()
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", CHECK, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).dodgyNecklace(eq(10));
|
||||
reset(config);
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).dodgyNecklace(eq(9));
|
||||
reset(config);
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", PROTECT_1, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).dodgyNecklace(eq(1));
|
||||
reset(config);
|
||||
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", BREAK, "", 0);
|
||||
itemChargePlugin.onChatMessage(chatMessage);
|
||||
verify(config).dodgyNecklace(eq(10));
|
||||
reset(config);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.itemstats;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class ItemStatChangesTest
|
||||
{
|
||||
@Test
|
||||
public void testInit()
|
||||
{
|
||||
new ItemStatChanges();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Bartvollebregt <https://github.com/Bartvollebregt>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.maxhit.calculators;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.plugins.maxhit.calculators.testconfig.MagicMaxHitConfig;
|
||||
import net.runelite.client.plugins.maxhit.calculators.testconfig.MaxHitConfig;
|
||||
import net.runelite.client.plugins.maxhit.calculators.testconfig.MeleeMaxHitConfig;
|
||||
import net.runelite.client.plugins.maxhit.calculators.testconfig.RangeMaxHitConfig;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MaxHitCalculatorTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
protected Client client;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void calculate()
|
||||
{
|
||||
testMaxHitConfig(MeleeMaxHitConfig.values());
|
||||
testMaxHitConfig(RangeMaxHitConfig.values());
|
||||
testMaxHitConfig(MagicMaxHitConfig.values());
|
||||
}
|
||||
|
||||
private void testMaxHitConfig(MaxHitConfig[] maxHitConfigs)
|
||||
{
|
||||
for (MaxHitConfig maxHitConfig : maxHitConfigs)
|
||||
{
|
||||
maxHitConfig.test(client);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,243 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Bartvollebregt <https://github.com/Bartvollebregt>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.maxhit.calculators.testconfig;
|
||||
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.client.plugins.maxhit.calculators.MagicMaxHitCalculator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public enum MagicMaxHitConfig implements MaxHitConfig
|
||||
{
|
||||
|
||||
TRIDENT_SLAYER(new int[] {75, 83, 99}, 0, new Item[]
|
||||
{
|
||||
mockItem(ItemID.SLAYER_HELMET_I),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.OCCULT_NECKLACE),
|
||||
mockItem(ItemID.TRIDENT_OF_THE_SEAS),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, new int[] {25, 27, 34}),
|
||||
|
||||
TRIDENT_OF_SEAS(new int[] {75, 83, 99}, 0, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_GLORY),
|
||||
mockItem(ItemID.TRIDENT_OF_THE_SEAS),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, new int[] {20, 22, 28}),
|
||||
|
||||
TRIDENT_OF_SWAMP(new int[] {75, 83, 99}, 0, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_GLORY),
|
||||
mockItem(ItemID.TRIDENT_OF_THE_SWAMP),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, new int[] {23, 25, 31}),
|
||||
|
||||
MAGIC_DART(new int[] {75, 83, 99}, 18, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_GLORY),
|
||||
mockItem(ItemID.SLAYERS_STAFF),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, new int[] {17, 18, 19}),
|
||||
|
||||
|
||||
FIRE_BOLT(75, 8, new Item[]
|
||||
{
|
||||
mockItem(ItemID.SLAYER_HELMET_I),
|
||||
mockItem(ItemID.IMBUED_SARADOMIN_CAPE),
|
||||
mockItem(ItemID.OCCULT_NECKLACE),
|
||||
mockItem(ItemID.STAFF_OF_THE_DEAD),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.TOME_OF_FIRE),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.CHAOS_GAUNTLETS),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, 31),
|
||||
|
||||
|
||||
WIND_BLAST(75, 9, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_GLORY),
|
||||
mockItem(ItemID.STAFF_OF_AIR),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, 13),
|
||||
|
||||
|
||||
EARTH_WAVE(75, 15, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.OCCULT_NECKLACE),
|
||||
mockItem(ItemID.STAFF_OF_EARTH),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.TOME_OF_FIRE),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, 20),
|
||||
|
||||
FLAMES_OF_ZAMORAK(75, 20, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_GLORY),
|
||||
mockItem(ItemID.STAFF_OF_THE_DEAD),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, 23),
|
||||
|
||||
SARADOMIN_STRIKE(75, 52, new Item[]
|
||||
{
|
||||
mockItem(ItemID.MYSTIC_HAT),
|
||||
mockItem(ItemID.SARADOMIN_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_GLORY),
|
||||
mockItem(ItemID.STAFF_OF_LIGHT),
|
||||
mockItem(ItemID.MYSTIC_ROBE_TOP),
|
||||
mockItem(ItemID.BROODOO_SHIELD),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_ROBE_BOTTOM),
|
||||
null,
|
||||
mockItem(ItemID.MYSTIC_GLOVES),
|
||||
mockItem(ItemID.WIZARD_BOOTS),
|
||||
mockItem(ItemID.RING_OF_WEALTH)
|
||||
}, 23),
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
private final int[] magicLevels;
|
||||
private final int spellId;
|
||||
private final Item[] equipedItems;
|
||||
private final int[] expectedMaxHits;
|
||||
|
||||
MagicMaxHitConfig(int magicLevel, int spellId, Item[] equipedItems, int expectedMaxHit)
|
||||
{
|
||||
this.magicLevels = new int[] {magicLevel};
|
||||
this.spellId = spellId;
|
||||
this.equipedItems = equipedItems;
|
||||
this.expectedMaxHits = new int[] {expectedMaxHit};
|
||||
}
|
||||
|
||||
MagicMaxHitConfig(int[] magicLevels, int spellId, Item[] equipedItems, int[] expectedMaxHits)
|
||||
{
|
||||
this.magicLevels = magicLevels;
|
||||
this.spellId = spellId;
|
||||
this.equipedItems = equipedItems;
|
||||
this.expectedMaxHits = expectedMaxHits;
|
||||
}
|
||||
|
||||
|
||||
private static Item mockItem(int itemId)
|
||||
{
|
||||
Item item = mock(Item.class);
|
||||
when(item.getId()).thenReturn(itemId);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void test(Client client)
|
||||
{
|
||||
int[] magicLevels = this.magicLevels;
|
||||
for (int i = 0, magicLevelsLength = magicLevels.length; i < magicLevelsLength; i++)
|
||||
{
|
||||
int magicLevel = magicLevels[i];
|
||||
int expectedMaxHit = this.expectedMaxHits[i];
|
||||
|
||||
// Mock equipment container
|
||||
ItemContainer equipmentContainer = mock(ItemContainer.class);
|
||||
when(equipmentContainer.getItems())
|
||||
.thenReturn(this.equipedItems);
|
||||
when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentContainer);
|
||||
|
||||
// Mock Varbits
|
||||
when(client.getBoostedSkillLevel(Skill.MAGIC)).thenReturn(magicLevel);
|
||||
when(client.getVar(Varbits.AUTO_CAST_SPELL)).thenReturn(this.spellId);
|
||||
|
||||
// Test
|
||||
MagicMaxHitCalculator maxHitCalculator = new MagicMaxHitCalculator(client, this.equipedItems);
|
||||
assertEquals(this.toString(), expectedMaxHit, maxHitCalculator.getMaxHit(), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Bartvollebregt <https://github.com/Bartvollebregt>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.maxhit.calculators.testconfig;
|
||||
|
||||
import net.runelite.api.Client;
|
||||
|
||||
public interface MaxHitConfig
|
||||
{
|
||||
void test(Client client);
|
||||
}
|
||||
@@ -1,217 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Bartvollebregt <https://github.com/Bartvollebregt>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.maxhit.calculators.testconfig;
|
||||
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.maxhit.attackstyle.WeaponType;
|
||||
import net.runelite.client.plugins.maxhit.calculators.MeleeMaxHitCalculator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public enum MeleeMaxHitConfig implements MaxHitConfig
|
||||
{
|
||||
|
||||
DRAGON_SCIMITAR(new int[] {75, 83, 99}, 66, WeaponType.TYPE_9, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.IRON_FULL_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.DRAGON_SCIMITAR),
|
||||
mockItem(ItemID.IRON_PLATEBODY),
|
||||
mockItem(ItemID.IRON_KITESHIELD),
|
||||
null,
|
||||
mockItem(ItemID.IRON_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {17, 19, 22}),
|
||||
|
||||
DRAGON_SCIMITAR_DEFENDER(new int[] {75, 83, 99}, 76, WeaponType.TYPE_9, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.IRON_FULL_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.DRAGON_SCIMITAR),
|
||||
mockItem(ItemID.IRON_PLATEBODY),
|
||||
mockItem(ItemID.DRAGON_DEFENDER),
|
||||
null,
|
||||
mockItem(ItemID.IRON_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {19, 21, 24}),
|
||||
|
||||
DRAGON_SCIMITAR_COMPLETE(new int[] {75, 83, 99}, 108, WeaponType.TYPE_9, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.SLAYER_HELMET),
|
||||
mockItem(ItemID.FIRE_CAPE),
|
||||
mockItem(ItemID.AMULET_OF_FURY),
|
||||
mockItem(ItemID.DRAGON_SCIMITAR),
|
||||
mockItem(ItemID.FIGHTER_TORSO),
|
||||
mockItem(ItemID.DRAGON_DEFENDER),
|
||||
null,
|
||||
mockItem(ItemID.IRON_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.BARROWS_GLOVES),
|
||||
mockItem(ItemID.DRAGON_BOOTS),
|
||||
mockItem(ItemID.BERSERKER_RING)
|
||||
}, new int[] {26, 29, 35}),
|
||||
|
||||
OBSIDIAN_SET(new int[] {75, 83, 99}, 61, WeaponType.TYPE_17, 2, new Item[]
|
||||
{
|
||||
mockItem(ItemID.OBSIDIAN_HELMET),
|
||||
mockItem(ItemID.OBSIDIAN_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.TOKTZXILAK),
|
||||
mockItem(ItemID.OBSIDIAN_PLATEBODY),
|
||||
mockItem(ItemID.TOKTZKETXIL),
|
||||
null,
|
||||
mockItem(ItemID.OBSIDIAN_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {18, 19, 23}),
|
||||
|
||||
DHAROK_SET(new int[] {75, 75, 75, 83, 83, 83, 99, 99, 99}, 105, WeaponType.TYPE_1, 1,
|
||||
new int[][] {{99, 99}, {1, 99}, {32, 75}, {99, 99}, {1, 99}, {32, 75}, {99, 99}, {1, 99}, {32, 75}},
|
||||
new Item[]
|
||||
{
|
||||
mockItem(ItemID.DHAROKS_HELM_100),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.DHAROKS_GREATAXE_100),
|
||||
mockItem(ItemID.DHAROKS_PLATEBODY_100),
|
||||
null,
|
||||
null,
|
||||
mockItem(ItemID.DHAROKS_PLATELEGS_100),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {23, 45, 30, 25, 49, 33, 29, 57, 38}),
|
||||
|
||||
VOID_SET(new int[] {75, 83, 99}, 66, WeaponType.TYPE_9, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.VOID_MELEE_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.DRAGON_SCIMITAR),
|
||||
mockItem(ItemID.VOID_KNIGHT_TOP),
|
||||
mockItem(ItemID.IRON_KITESHIELD),
|
||||
null,
|
||||
mockItem(ItemID.VOID_KNIGHT_ROBE),
|
||||
null,
|
||||
mockItem(ItemID.VOID_KNIGHT_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {19, 21, 25}),
|
||||
;
|
||||
|
||||
|
||||
private final int[] strengthLevels;
|
||||
private final WeaponType weaponType;
|
||||
private final int attackStyleId;
|
||||
private final Item[] equipedItems;
|
||||
private final int[] expectedMaxHits;
|
||||
private final int[][] hitpoints;
|
||||
private final int meleeEquipmentStrength;
|
||||
|
||||
MeleeMaxHitConfig(int[] strengthLevels, int meleeEquipmentStrength, WeaponType weaponType, int attackStyleId, int[][] hitpoints, Item[] equipedItems, int[] expectedMaxHits)
|
||||
{
|
||||
this.strengthLevels = strengthLevels;
|
||||
this.meleeEquipmentStrength = meleeEquipmentStrength;
|
||||
this.weaponType = weaponType;
|
||||
this.attackStyleId = attackStyleId;
|
||||
this.hitpoints = hitpoints;
|
||||
this.equipedItems = equipedItems;
|
||||
this.expectedMaxHits = expectedMaxHits;
|
||||
}
|
||||
|
||||
MeleeMaxHitConfig(int[] strengthLevels, int meleeEquipmentStrength, WeaponType weaponType, int attackStyleId, Item[] equipedItems, int[] expectedMaxHits)
|
||||
{
|
||||
this.strengthLevels = strengthLevels;
|
||||
this.hitpoints = new int[strengthLevels.length][2];
|
||||
this.meleeEquipmentStrength = meleeEquipmentStrength;
|
||||
this.weaponType = weaponType;
|
||||
this.attackStyleId = attackStyleId;
|
||||
this.equipedItems = equipedItems;
|
||||
this.expectedMaxHits = expectedMaxHits;
|
||||
}
|
||||
|
||||
|
||||
private static Item mockItem(int itemId)
|
||||
{
|
||||
Item item = mock(Item.class);
|
||||
when(item.getId()).thenReturn(itemId);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void test(Client client)
|
||||
{
|
||||
int[] strengthLevels = this.strengthLevels;
|
||||
for (int i = 0, strengthLevelsLength = strengthLevels.length; i < strengthLevelsLength; i++)
|
||||
{
|
||||
int strengthLevel = strengthLevels[i];
|
||||
int[] hitpoints = this.hitpoints[i];
|
||||
int expectedMaxHit = this.expectedMaxHits[i];
|
||||
|
||||
// Mock equipment container
|
||||
ItemContainer equipmentContainer = mock(ItemContainer.class);
|
||||
when(equipmentContainer.getItems())
|
||||
.thenReturn(this.equipedItems);
|
||||
when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentContainer);
|
||||
|
||||
// Mock equipment strength
|
||||
Widget equipmentWidget = mock(Widget.class);
|
||||
when(client.getWidget(WidgetInfo.EQUIPMENT_MELEE_STRENGTH)).thenReturn(equipmentWidget);
|
||||
when(equipmentWidget.getText()).thenReturn("Melee strength: " + this.meleeEquipmentStrength);
|
||||
|
||||
// Mock Varbits
|
||||
when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(this.weaponType.ordinal());
|
||||
when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(this.attackStyleId);
|
||||
|
||||
// Mock strength
|
||||
when(client.getBoostedSkillLevel(Skill.STRENGTH)).thenReturn(strengthLevel);
|
||||
|
||||
// Mock hitpoints
|
||||
when(client.getBoostedSkillLevel(Skill.HITPOINTS)).thenReturn(hitpoints[0]);
|
||||
when(client.getRealSkillLevel(Skill.HITPOINTS)).thenReturn(hitpoints[1]);
|
||||
|
||||
// Test
|
||||
MeleeMaxHitCalculator maxHitCalculator = new MeleeMaxHitCalculator(client, this.equipedItems);
|
||||
assertEquals(this.toString(), expectedMaxHit, maxHitCalculator.getMaxHit(), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Bartvollebregt <https://github.com/Bartvollebregt>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.maxhit.calculators.testconfig;
|
||||
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.maxhit.attackstyle.WeaponType;
|
||||
import net.runelite.client.plugins.maxhit.calculators.RangeMaxHitCalculator;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public enum RangeMaxHitConfig implements MaxHitConfig
|
||||
{
|
||||
|
||||
MAGIC_SHORTBOW(new int[] {75, 83, 99}, 49, WeaponType.TYPE_3, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.IRON_FULL_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.MAGIC_SHORTBOW),
|
||||
mockItem(ItemID.IRON_PLATEBODY),
|
||||
null,
|
||||
null,
|
||||
mockItem(ItemID.IRON_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING),
|
||||
mockItem(ItemID.RUNE_ARROW)
|
||||
}, new int[] {15, 16, 19}),
|
||||
|
||||
RUNE_CROSSBOW(new int[] {75, 83, 99}, 115, WeaponType.TYPE_5, 0, new Item[]
|
||||
{
|
||||
mockItem(ItemID.IRON_FULL_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.RUNE_CROSSBOW),
|
||||
mockItem(ItemID.IRON_PLATEBODY),
|
||||
null,
|
||||
null,
|
||||
mockItem(ItemID.IRON_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING),
|
||||
mockItem(ItemID.RUNITE_BOLTS)
|
||||
}, new int[] {24, 26, 31}),
|
||||
|
||||
BLOwPIPE(new int[] {75, 83, 99}, 50, WeaponType.TYPE_19, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.IRON_FULL_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.TOXIC_BLOWPIPE),
|
||||
mockItem(ItemID.IRON_PLATEBODY),
|
||||
null,
|
||||
null,
|
||||
mockItem(ItemID.IRON_PLATELEGS),
|
||||
null,
|
||||
mockItem(ItemID.LEATHER_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {15, 16, 19}),
|
||||
|
||||
VOID_SET(new int[] {75, 83, 99}, 115, WeaponType.TYPE_5, 1, new Item[]
|
||||
{
|
||||
mockItem(ItemID.VOID_RANGER_HELM),
|
||||
mockItem(ItemID.BLACK_CAPE),
|
||||
mockItem(ItemID.GOLD_NECKLACE),
|
||||
mockItem(ItemID.RUNE_CROSSBOW),
|
||||
mockItem(ItemID.VOID_KNIGHT_TOP),
|
||||
mockItem(ItemID.IRON_KITESHIELD),
|
||||
null,
|
||||
mockItem(ItemID.VOID_KNIGHT_ROBE),
|
||||
null,
|
||||
mockItem(ItemID.VOID_KNIGHT_GLOVES),
|
||||
mockItem(ItemID.LEATHER_BOOTS),
|
||||
mockItem(ItemID.GOLD_RING)
|
||||
}, new int[] {26, 28, 33}),
|
||||
|
||||
;
|
||||
|
||||
private final int[] rangeLevels;
|
||||
private final WeaponType weaponType;
|
||||
private final int attackStyleId;
|
||||
private final Item[] equipedItems;
|
||||
private final int[] expectedMaxHits;
|
||||
private final int ammoEquipmentStrength;
|
||||
|
||||
RangeMaxHitConfig(int[] rangeLevels, int ammoEquipmentStrength, WeaponType weaponType, int attackStyleId, Item[] equipedItems, int[] expectedMaxHits)
|
||||
{
|
||||
this.rangeLevels = rangeLevels;
|
||||
this.ammoEquipmentStrength = ammoEquipmentStrength;
|
||||
this.weaponType = weaponType;
|
||||
this.attackStyleId = attackStyleId;
|
||||
this.equipedItems = equipedItems;
|
||||
this.expectedMaxHits = expectedMaxHits;
|
||||
}
|
||||
|
||||
|
||||
private static Item mockItem(int itemId)
|
||||
{
|
||||
Item item = mock(Item.class);
|
||||
when(item.getId()).thenReturn(itemId);
|
||||
return item;
|
||||
}
|
||||
|
||||
public void test(Client client)
|
||||
{
|
||||
int[] rangeLevels = this.rangeLevels;
|
||||
for (int i = 0, rangeLevelsLength = rangeLevels.length; i < rangeLevelsLength; i++)
|
||||
{
|
||||
int rangeLevel = rangeLevels[i];
|
||||
int expectedMaxHit = this.expectedMaxHits[i];
|
||||
|
||||
// Mock equipment container
|
||||
ItemContainer equipmentContainer = mock(ItemContainer.class);
|
||||
when(equipmentContainer.getItems())
|
||||
.thenReturn(this.equipedItems);
|
||||
when(client.getItemContainer(InventoryID.EQUIPMENT)).thenReturn(equipmentContainer);
|
||||
|
||||
// Mock equipment strength
|
||||
Widget equipmentWidget = mock(Widget.class);
|
||||
when(client.getWidget(WidgetInfo.EQUIPMENT_RANGED_STRENGTH)).thenReturn(equipmentWidget);
|
||||
when(equipmentWidget.getText()).thenReturn("Ranged strength: " + this.ammoEquipmentStrength);
|
||||
|
||||
// Mock Varbits
|
||||
when(client.getVar(Varbits.EQUIPPED_WEAPON_TYPE)).thenReturn(this.weaponType.ordinal());
|
||||
when(client.getVar(VarPlayer.ATTACK_STYLE)).thenReturn(this.attackStyleId);
|
||||
|
||||
// Mock strength
|
||||
when(client.getBoostedSkillLevel(Skill.RANGED)).thenReturn(rangeLevel);
|
||||
|
||||
// Test
|
||||
RangeMaxHitCalculator maxHitCalculator = new RangeMaxHitCalculator(client, this.equipedItems);
|
||||
assertEquals(this.toString(), expectedMaxHit, maxHitCalculator.getMaxHit(), 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.motherlode;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class MotherlodePluginTest
|
||||
{
|
||||
@Inject
|
||||
private MotherlodePlugin motherlodePlugin;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
MotherlodeSession motherlodeSession;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private MotherlodeConfig motherlodeConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private MotherlodeGemOverlay motherlodeGemOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private MotherlodeOreOverlay motherlodeOreOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private MotherlodeRocksOverlay motherlodeRocksOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private MotherlodeSackOverlay motherlodeSackOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ScheduledExecutorService scheduledExecutorService;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
|
||||
when(client.getGameState()).thenReturn(GameState.LOGGED_IN);
|
||||
when(client.getMapRegions()).thenReturn(new int[]{14679});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOreCounter()
|
||||
{
|
||||
// set inMlm
|
||||
GameStateChanged gameStateChanged = new GameStateChanged();
|
||||
gameStateChanged.setGameState(GameState.LOGGED_IN);
|
||||
motherlodePlugin.onGameStateChanged(gameStateChanged);
|
||||
|
||||
// Initial sack count
|
||||
when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(42);
|
||||
motherlodePlugin.onVarbitChanged(new VarbitChanged());
|
||||
|
||||
// Create before inventory
|
||||
ItemContainer inventory = mock(ItemContainer.class);
|
||||
Item[] items = new Item[]{
|
||||
mockItem(ItemID.RUNITE_ORE, 1),
|
||||
mockItem(ItemID.GOLDEN_NUGGET, 4),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
|
||||
};
|
||||
when(inventory.getItems())
|
||||
.thenReturn(items);
|
||||
when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory);
|
||||
|
||||
// Withdraw 20
|
||||
when(client.getVar(Varbits.SACK_NUMBER)).thenReturn(22);
|
||||
motherlodePlugin.onVarbitChanged(new VarbitChanged());
|
||||
|
||||
inventory = mock(ItemContainer.class);
|
||||
// +1 rune, +4 nugget, +2 coal, +1 addy
|
||||
items = new Item[]{
|
||||
mockItem(ItemID.RUNITE_ORE, 1),
|
||||
mockItem(ItemID.RUNITE_ORE, 1),
|
||||
mockItem(ItemID.GOLDEN_NUGGET, 8),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.COAL, 1),
|
||||
mockItem(ItemID.ADAMANTITE_ORE, 1),
|
||||
|
||||
};
|
||||
when(inventory.getItems())
|
||||
.thenReturn(items);
|
||||
when(client.getItemContainer(InventoryID.INVENTORY)).thenReturn(inventory);
|
||||
|
||||
// Trigger comparison
|
||||
motherlodePlugin.onItemContainerChanged(new ItemContainerChanged(inventory));
|
||||
|
||||
verify(motherlodeSession).updateOreFound(ItemID.RUNITE_ORE, 1);
|
||||
verify(motherlodeSession).updateOreFound(ItemID.GOLDEN_NUGGET, 4);
|
||||
verify(motherlodeSession).updateOreFound(ItemID.COAL, 2);
|
||||
verify(motherlodeSession).updateOreFound(ItemID.ADAMANTITE_ORE, 1);
|
||||
verifyNoMoreInteractions(motherlodeSession);
|
||||
}
|
||||
|
||||
private static Item mockItem(int itemId, int quantity)
|
||||
{
|
||||
Item item = mock(Item.class);
|
||||
when(item.getId()).thenReturn(itemId);
|
||||
when(item.getQuantity()).thenReturn(quantity);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.npchighlight;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class NpcIndicatorsPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ScheduledExecutorService executorService;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private NpcIndicatorsConfig npcIndicatorsConfig;
|
||||
|
||||
@Inject
|
||||
private NpcIndicatorsPlugin npcIndicatorsPlugin;
|
||||
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getHighlights()
|
||||
{
|
||||
when(npcIndicatorsConfig.getNpcToHighlight()).thenReturn("goblin, , zulrah , *wyvern, ,");
|
||||
final List<String> highlightedNpcs = npcIndicatorsPlugin.getHighlights();
|
||||
assertEquals("Length of parsed NPCs is incorrect", 3, highlightedNpcs.size());
|
||||
|
||||
final Iterator<String> iterator = highlightedNpcs.iterator();
|
||||
assertEquals("goblin", iterator.next());
|
||||
assertEquals("zulrah", iterator.next());
|
||||
assertEquals("*wyvern", iterator.next());
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Lotto <https://github.com/devLotto>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.puzzlesolver;
|
||||
|
||||
import net.runelite.client.plugins.puzzlesolver.solver.PuzzleSolver;
|
||||
import net.runelite.client.plugins.puzzlesolver.solver.PuzzleState;
|
||||
import net.runelite.client.plugins.puzzlesolver.solver.heuristics.ManhattanDistance;
|
||||
import net.runelite.client.plugins.puzzlesolver.solver.pathfinding.IDAStar;
|
||||
import net.runelite.client.plugins.puzzlesolver.solver.pathfinding.IDAStarMM;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class PuzzleSolverTest
|
||||
{
|
||||
private static final PuzzleState[] START_STATES =
|
||||
{
|
||||
new PuzzleState(new int[]{0, 11, 1, 3, 4, 5, 12, 2, 7, 9, 6, 20, 18, 16, 8, 15, 22, 10, 14, 13, 21, -1, 17, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 2, 7, 3, 4, 10, 5, 12, 1, 9, 6, 17, 8, 14, 19, -1, 16, 21, 11, 13, 15, 20, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 1, 11, 3, 4, 12, 2, 7, 13, 9, 5, 21, 15, 17, 14, -1, 10, 6, 8, 19, 16, 20, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 3, 4, 10, 5, 6, 9, 14, 15, -1, 7, 13, 17, 21, 11, 20, 23, 8, 16, 22, 12, 19, 18}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 3, 4, 5, 6, 8, 22, 18, 10, -1, 7, 17, 9, 20, 11, 12, 21, 14, 16, 15, 23, 13, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 3, 4, 5, 6, 8, 12, 9, 16, 11, 17, 7, 14, 10, 20, -1, 22, 13, 15, 18, 21, 23, 19}),
|
||||
new PuzzleState(new int[]{1, 6, 16, 8, 4, 0, 7, 11, 2, 9, 5, 21, 18, 3, 14, 10, 20, -1, 13, 22, 15, 23, 12, 17, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 4, 8, 6, 16, 11, 7, 3, 5, -1, 12, 14, 9, 15, 10, 17, 13, 18, 20, 21, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 2, 9, 14, 6, 5, 7, 11, 3, 4, 15, 10, 1, 12, 18, 16, 17, -1, 8, 13, 20, 21, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 3, 4, 11, 5, 12, 7, 8, 10, 6, 15, 13, 9, 16, 21, -1, 17, 14, 20, 22, 23, 18, 19}),
|
||||
new PuzzleState(new int[]{5, 0, 1, 2, 4, 10, 6, 3, 8, 9, 12, 13, 7, 14, 19, 15, 11, 16, 17, -1, 20, 21, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 3, 4, 5, 8, -1, 2, 9, 16, 11, 12, 7, 14, 10, 15, 17, 13, 19, 20, 21, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 2, 4, 11, 15, 8, 3, 14, 5, 7, 9, 12, 18, 16, 10, 17, 23, 13, 20, 21, 22, -1, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 7, 2, 4, 5, 3, 12, 8, 9, 15, 6, 18, -1, 13, 11, 10, 22, 17, 23, 16, 21, 20, 19, 14}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 7, 3, 5, 11, 6, 14, 4, 10, -1, 16, 12, 9, 15, 17, 18, 8, 19, 20, 21, 13, 22, 23}),
|
||||
new PuzzleState(new int[]{2, 10, 5, 3, 4, -1, 0, 1, 8, 9, 15, 11, 7, 13, 23, 17, 6, 20, 14, 19, 16, 12, 18, 21, 22}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 8, 9, 5, 6, 7, 3, 4, 10, -1, 14, 23, 18, 21, 11, 16, 12, 19, 15, 20, 17, 13, 22}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 3, 4, 11, 2, 13, 9, 12, 5, 16, 7, 18, 8, 20, 15, -1, 14, 19, 21, 10, 22, 23, 17}),
|
||||
new PuzzleState(new int[]{12, 1, 2, 3, 4, 0, 7, 6, 8, 9, 5, 10, 22, 13, 19, 15, 11, 21, 14, 17, 20, 16, 18, -1, 23}),
|
||||
new PuzzleState(new int[]{0, 2, 11, 3, 4, 5, 1, 6, 8, 9, 15, 10, 13, 14, 19, 7, 12, -1, 17, 18, 20, 21, 16, 22, 23}),
|
||||
new PuzzleState(new int[]{5, 0, 4, 2, 9, 10, 7, 3, 19, 8, 6, 1, 18, -1, 14, 15, 11, 16, 12, 13, 20, 21, 17, 22, 23}),
|
||||
new PuzzleState(new int[]{0, 3, 2, 7, 4, 6, 10, 1, 8, 9, 15, 5, 12, 18, 13, -1, 20, 11, 22, 14, 16, 21, 23, 17, 19}),
|
||||
new PuzzleState(new int[]{1, 2, 4, -1, 9, 0, 5, 7, 3, 14, 10, 6, 8, 13, 19, 15, 11, 18, 12, 22, 20, 16, 21, 23, 17}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 4, 9, 5, 11, -1, 7, 14, 10, 17, 6, 13, 8, 15, 16, 20, 3, 18, 22, 21, 12, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 8, 2, 4, 5, 11, 17, 3, 9, 6, 16, 7, 12, 18, 15, 21, -1, 14, 13, 20, 22, 10, 23, 19}),
|
||||
new PuzzleState(new int[]{5, 0, 2, 3, 4, 1, 8, 6, 7, 9, 11, 12, 16, 13, 14, -1, 22, 20, 17, 19, 21, 10, 15, 18, 23}),
|
||||
new PuzzleState(new int[]{0, -1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 16, 11, 13, 14, 10, 15, 19, 22, 23, 20, 21, 17, 12, 18}),
|
||||
new PuzzleState(new int[]{0, 2, 7, -1, 4, 6, 1, 9, 3, 14, 5, 12, 8, 13, 19, 15, 16, 10, 22, 23, 20, 11, 18, 21, 17}),
|
||||
new PuzzleState(new int[]{7, 5, 13, 1, 12, 0, 2, 4, 3, 9, 10, 6, 8, 17, 14, 15, 11, 16, 18, -1, 20, 21, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{5, 0, 3, 8, 4, 10, 6, -1, 7, 9, 11, 1, 12, 2, 19, 15, 16, 17, 14, 13, 20, 21, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{5, 2, 3, 7, 4, 0, 6, 14, 9, 19, 1, 11, 22, 17, 12, 10, 15, -1, 13, 8, 20, 16, 21, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 1, 3, 4, 9, 5, 6, 2, 7, 14, 10, 13, 17, -1, 8, 15, 11, 16, 12, 18, 20, 21, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 3, 11, 7, 4, 5, 2, 6, 12, 8, 10, 1, 17, -1, 9, 15, 16, 23, 13, 14, 20, 21, 18, 22, 19}),
|
||||
new PuzzleState(new int[]{1, 5, 8, 2, 4, -1, 0, 7, 3, 9, 11, 22, 15, 12, 14, 6, 10, 18, 16, 19, 20, 21, 17, 13, 23}),
|
||||
new PuzzleState(new int[]{7, 12, 11, 4, 9, -1, 0, 8, 10, 2, 6, 1, 16, 3, 14, 5, 15, 17, 13, 19, 20, 21, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{11, 3, 2, 12, 4, 6, 0, 7, 13, 8, 1, 5, 17, 16, 9, -1, 10, 15, 18, 14, 20, 21, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 3, 4, 5, 11, 2, 10, 9, 15, 12, 8, 14, 19, 16, 21, -1, 7, 13, 20, 22, 17, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 3, 4, 6, 10, 7, 8, 9, 5, 16, 11, 14, 17, 20, 13, 18, 12, 22, 21, 15, 23, -1, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 4, 8, 5, 6, 7, 3, -1, 10, 16, 18, 17, 9, 15, 12, 11, 14, 13, 20, 21, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 11, 6, 1, 4, 5, 21, 8, 2, 9, 10, 3, 16, -1, 14, 15, 12, 17, 13, 19, 20, 22, 7, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 2, 4, 11, 10, 3, 13, 9, 5, 7, 8, -1, 23, 15, 16, 22, 18, 14, 20, 21, 12, 17, 19}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 2, 3, 10, 11, 12, 5, 18, 15, 7, 4, -1, 14, 21, 17, 13, 8, 9, 16, 20, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 3, 11, 4, 6, 10, 14, 2, 8, 5, -1, 12, 7, 9, 15, 16, 18, 13, 19, 20, 21, 22, 17, 23}),
|
||||
new PuzzleState(new int[]{1, 5, 2, 3, 4, -1, 0, 7, 14, 8, 11, 6, 13, 9, 23, 10, 12, 15, 19, 17, 20, 21, 16, 22, 18}),
|
||||
};
|
||||
|
||||
private static final PuzzleState[] START_STATES_MM =
|
||||
{
|
||||
new PuzzleState(new int[]{0, 5, 1, 3, 4, 15, 2, 8, 10, 9, 22, 16, 11, 6, 14, 7, 21, 23, 12, 18, 20, -1, 17, 13, 19}),
|
||||
new PuzzleState(new int[]{0, 12, 8, 13, 4, 3, 16, 2, 1, 9, 21, 5, 6, 10, 14, 7, 17, 20, 18, -1, 15, 11, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{1, 3, 7, 9, 8, 13, 17, 2, 4, 6, 15, 5, 22, 12, 14, 11, 0, 10, 21, -1, 20, 18, 16, 23, 19}),
|
||||
new PuzzleState(new int[]{5, 2, 16, 14, 4, 3, 0, 8, 9, 11, 15, 6, 17, 19, 7, 1, 10, -1, 23, 18, 20, 12, 21, 13, 22}),
|
||||
new PuzzleState(new int[]{0, 6, 1, 4, 13, 10, 2, 16, 7, 3, 20, -1, 8, 14, 9, 21, 5, 18, 11, 19, 17, 15, 12, 22, 23}),
|
||||
new PuzzleState(new int[]{5, 0, 1, 4, 8, 10, 6, 7, 12, 3, 17, 16, 21, 2, 9, 18, 20, 13, 14, 19, 11, -1, 23, 15, 22}),
|
||||
new PuzzleState(new int[]{1, 9, 2, 13, 17, 5, 7, 8, 3, 22, 6, -1, 16, 12, 4, 15, 18, 0, 23, 14, 10, 21, 11, 20, 19}),
|
||||
new PuzzleState(new int[]{1, 2, 11, 13, 4, 21, 7, 3, 6, 9, 0, 8, 10, 19, 14, 20, 12, 16, 23, -1, 5, 17, 15, 22, 18}),
|
||||
new PuzzleState(new int[]{2, 0, 1, 4, 13, 6, 7, 3, 8, 9, 22, 15, 10, 14, 18, 5, 12, -1, 17, 21, 20, 11, 23, 16, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 8, 3, 6, 12, 22, 9, 7, 11, 21, 13, 4, 14, 5, 10, -1, 18, 19, 20, 15, 16, 23, 17}),
|
||||
new PuzzleState(new int[]{1, 2, 3, 4, 8, 0, 6, 15, 14, 18, 16, 17, 20, -1, 9, 10, 12, 22, 11, 13, 21, 7, 5, 19, 23}),
|
||||
new PuzzleState(new int[]{0, 5, 2, 4, 9, 7, 15, 20, 12, 13, 6, -1, 22, 1, 8, 10, 11, 23, 14, 3, 21, 16, 17, 19, 18}),
|
||||
new PuzzleState(new int[]{0, 1, 9, 6, 13, 5, 18, -1, 4, 2, 15, 12, 3, 17, 7, 16, 10, 8, 23, 14, 20, 21, 19, 11, 22}),
|
||||
new PuzzleState(new int[]{11, 5, 12, 3, 4, 15, 8, 0, 7, 1, 6, -1, 19, 2, 9, 16, 10, 13, 17, 23, 20, 21, 22, 14, 18}),
|
||||
new PuzzleState(new int[]{10, 0, 1, 3, 4, 18, 5, 6, 12, 9, 7, 11, 8, -1, 22, 15, 23, 14, 19, 13, 20, 2, 17, 16, 21}),
|
||||
new PuzzleState(new int[]{19, -1, 6, 2, 4, 0, 21, 10, 3, 9, 1, 15, 17, 8, 14, 11, 13, 22, 7, 18, 16, 12, 5, 23, 20}),
|
||||
new PuzzleState(new int[]{11, 6, 3, 4, 9, 1, 10, 16, 2, 7, 5, 0, 13, -1, 12, 21, 8, 18, 17, 14, 15, 20, 22, 23, 19}),
|
||||
new PuzzleState(new int[]{0, 1, 5, 3, 4, -1, 6, 2, 15, 10, 7, 8, 23, 16, 13, 22, 11, 9, 12, 14, 20, 21, 18, 17, 19}),
|
||||
new PuzzleState(new int[]{10, 0, 1, -1, 2, 6, 5, 4, 13, 9, 16, 17, 12, 8, 19, 20, 15, 7, 21, 11, 22, 18, 14, 23, 3}),
|
||||
new PuzzleState(new int[]{1, 0, 5, 3, 9, 20, 15, 7, 2, 14, 6, 4, 12, -1, 8, 13, 18, 10, 23, 11, 21, 16, 17, 19, 22}),
|
||||
new PuzzleState(new int[]{0, 7, 6, 3, 4, 15, 1, 2, 8, 18, 11, 5, 13, -1, 22, 17, 16, 23, 14, 9, 20, 10, 12, 19, 21}),
|
||||
new PuzzleState(new int[]{5, 7, 0, 2, 9, 10, 1, 11, 3, 4, 16, 22, 8, 14, 17, 15, 20, 12, 13, 6, 21, 23, 19, -1, 18}),
|
||||
new PuzzleState(new int[]{3, 0, 1, 5, 4, 11, 6, 2, 16, 9, 15, 10, 7, 12, 13, 21, 19, -1, 22, 8, 20, 17, 14, 18, 23}),
|
||||
new PuzzleState(new int[]{6, 0, 3, 2, 4, 5, 1, 8, 13, 12, 15, 14, 10, 7, 9, -1, 22, 11, 19, 23, 16, 20, 17, 21, 18}),
|
||||
new PuzzleState(new int[]{11, 5, 6, 8, 9, 0, 21, 16, 4, 3, 17, 18, 2, 7, 1, 15, 10, -1, 22, 14, 20, 19, 13, 12, 23}),
|
||||
new PuzzleState(new int[]{2, 18, 3, 11, 4, -1, 5, 6, 12, 1, 10, 20, 0, 7, 9, 21, 15, 14, 23, 19, 16, 22, 13, 8, 17}),
|
||||
new PuzzleState(new int[]{0, 6, 8, 3, 1, 5, 2, 12, 9, 13, 16, 14, 19, 7, 18, 10, 11, -1, 4, 15, 20, 17, 23, 21, 22}),
|
||||
new PuzzleState(new int[]{1, 16, 10, 4, 3, 0, 15, 2, 9, -1, 8, 5, 23, 12, 6, 21, 18, 14, 13, 11, 20, 22, 7, 19, 17}),
|
||||
new PuzzleState(new int[]{1, 7, 6, 3, 4, 0, 2, 14, 5, 22, 18, 21, 16, 9, 13, 10, 20, -1, 8, 17, 15, 23, 11, 19, 12}),
|
||||
new PuzzleState(new int[]{5, 0, 1, 7, 9, 11, 8, 4, 2, 14, 15, 17, 18, -1, 3, 20, 10, 12, 22, 19, 16, 6, 13, 21, 23}),
|
||||
new PuzzleState(new int[]{5, 0, 6, 14, 7, 13, 15, 1, 3, 10, 20, 9, 17, 4, 2, 11, 12, 8, 19, -1, 21, 16, 22, 18, 23}),
|
||||
new PuzzleState(new int[]{12, 7, 8, 4, 9, 6, 11, 15, 2, 1, 5, -1, 13, 16, 3, 17, 0, 10, 18, 14, 20, 22, 21, 19, 23}),
|
||||
new PuzzleState(new int[]{15, 1, 2, 3, 14, -1, 20, 9, 4, 19, 0, 6, 7, 16, 13, 10, 5, 12, 17, 18, 22, 11, 21, 23, 8}),
|
||||
new PuzzleState(new int[]{0, 1, 17, -1, 14, 6, 4, 2, 3, 16, 10, 18, 13, 19, 9, 7, 5, 8, 21, 22, 11, 20, 15, 12, 23}),
|
||||
new PuzzleState(new int[]{5, 11, 9, 0, 3, 8, 14, -1, 6, 4, 1, 13, 7, 2, 19, 10, 21, 18, 23, 17, 15, 20, 12, 16, 22}),
|
||||
new PuzzleState(new int[]{2, 0, 14, -1, 4, 18, 1, 10, 12, 13, 5, 9, 11, 22, 7, 15, 8, 17, 19, 3, 20, 21, 6, 16, 23}),
|
||||
new PuzzleState(new int[]{0, 1, 13, 9, 2, 6, 8, 22, 3, 4, 12, 16, 10, 7, 19, -1, 5, 11, 14, 17, 15, 20, 21, 18, 23}),
|
||||
new PuzzleState(new int[]{0, 13, 17, 8, 3, 5, 1, 12, 14, 4, 10, -1, 6, 7, 9, 15, 23, 2, 16, 19, 20, 11, 21, 22, 18}),
|
||||
new PuzzleState(new int[]{5, 10, 7, 2, 9, 15, 0, -1, 1, 3, 18, 4, 17, 12, 14, 21, 11, 6, 8, 23, 20, 16, 22, 19, 13}),
|
||||
new PuzzleState(new int[]{0, 3, 1, 2, 4, 10, 5, 7, 8, 9, 11, 6, 21, 13, 12, 20, 17, -1, 14, 19, 22, 18, 15, 16, 23}),
|
||||
new PuzzleState(new int[]{0, 2, 7, 11, 13, 3, 14, 1, 4, 9, 5, -1, 12, 8, 18, 20, 10, 15, 22, 23, 17, 16, 6, 21, 19}),
|
||||
new PuzzleState(new int[]{0, 16, 3, 22, 7, 11, 6, -1, 9, 4, 2, 1, 13, 12, 18, 5, 10, 8, 19, 14, 15, 20, 17, 23, 21}),
|
||||
new PuzzleState(new int[]{0, 13, 5, 12, 3, 2, 10, 4, 6, 8, 1, 21, 19, 14, 9, 17, 23, 22, 16, 11, 15, 7, 20, -1, 18}),
|
||||
new PuzzleState(new int[]{14, 5, 6, 12, 4, 10, 20, 1, 0, 23, 2, 16, 13, 19, 3, 15, 22, -1, 9, 8, 11, 7, 18, 17, 21}),
|
||||
new PuzzleState(new int[]{0, 1, 2, 4, 7, 5, 11, -1, 18, 8, 16, 10, 12, 13, 3, 17, 6, 21, 23, 9, 15, 20, 22, 14, 19}),
|
||||
new PuzzleState(new int[]{1, 6, 7, 3, 4, 5, 17, 0, 22, 12, 10, 15, 8, -1, 14, 11, 13, 16, 18, 19, 20, 2, 21, 9, 23}),
|
||||
};
|
||||
|
||||
private static final int[] FINISHED_STATE = new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, -1};
|
||||
|
||||
@Test
|
||||
public void testSolverMM()
|
||||
{
|
||||
for (PuzzleState state : START_STATES_MM)
|
||||
{
|
||||
PuzzleSolver solver = new PuzzleSolver(new IDAStarMM(new ManhattanDistance()), state);
|
||||
solver.run();
|
||||
|
||||
assertTrue(solver.hasSolution());
|
||||
assertFalse(solver.hasFailed());
|
||||
assertTrue(solver.getStep(solver.getStepCount() - 1).hasPieces(FINISHED_STATE));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSolver()
|
||||
{
|
||||
for (PuzzleState state : START_STATES)
|
||||
{
|
||||
PuzzleSolver solver = new PuzzleSolver(new IDAStar(new ManhattanDistance()), state);
|
||||
solver.run();
|
||||
|
||||
assertTrue(solver.hasSolution());
|
||||
assertFalse(solver.hasFailed());
|
||||
assertTrue(solver.getStep(solver.getStepCount() - 1).hasPieces(FINISHED_STATE));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.puzzlesolver.lightbox;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class LightboxSolverTest
|
||||
{
|
||||
private static final int[] INITIAL = new int[]{
|
||||
1, 0, 1, 0, 0,
|
||||
0, 1, 0, 1, 0,
|
||||
0, 1, 1, 1, 0,
|
||||
0, 1, 0, 1, 0,
|
||||
1, 0, 1, 0, 1
|
||||
};
|
||||
|
||||
private static final int[] A = new int[]{
|
||||
0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 1,
|
||||
0, 1, 0, 1, 0,
|
||||
0, 0, 0, 1, 0,
|
||||
0, 0, 0, 0, 1
|
||||
};
|
||||
|
||||
private static final int[] B = new int[]{
|
||||
0, 1, 0, 0, 0,
|
||||
1, 0, 0, 0, 1,
|
||||
0, 0, 0, 1, 0,
|
||||
1, 1, 0, 1, 0,
|
||||
0, 0, 0, 1, 1,
|
||||
};
|
||||
|
||||
private static final int[] C = new int[]{
|
||||
0, 1, 0, 0, 0,
|
||||
1, 0, 0, 0, 1,
|
||||
1, 1, 0, 0, 0,
|
||||
0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 1,
|
||||
};
|
||||
|
||||
private static final int[] D = new int[]{
|
||||
1, 1, 0, 0, 0,
|
||||
1, 0, 1, 0, 1,
|
||||
1, 1, 0, 1, 1,
|
||||
0, 1, 1, 0, 0,
|
||||
1, 0, 0, 1, 1,
|
||||
};
|
||||
|
||||
private static final int[] E = new int[]{
|
||||
1, 0, 0, 1, 0,
|
||||
1, 1, 1, 0, 1,
|
||||
1, 1, 0, 1, 0,
|
||||
0, 0, 1, 0, 0,
|
||||
1, 0, 0, 1, 1,
|
||||
};
|
||||
|
||||
private static final int[] F = new int[]{
|
||||
1, 0, 0, 1, 0,
|
||||
1, 0, 0, 0, 1,
|
||||
1, 0, 1, 1, 0,
|
||||
0, 0, 1, 0, 0,
|
||||
1, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
private static final int[] G = new int[]{
|
||||
1, 0, 0, 1, 1,
|
||||
1, 1, 1, 0, 0,
|
||||
0, 1, 1, 1, 0,
|
||||
0, 0, 0, 0, 1,
|
||||
1, 1, 0, 0, 0,
|
||||
};
|
||||
|
||||
private static final int[] H = new int[]{
|
||||
1, 0, 1, 1, 1,
|
||||
1, 1, 1, 0, 0,
|
||||
0, 1, 1, 1, 0,
|
||||
1, 1, 0, 0, 1,
|
||||
1, 0, 0, 1, 0
|
||||
};
|
||||
|
||||
private static LightboxState fromArray(int[] array)
|
||||
{
|
||||
LightboxState s = new LightboxState();
|
||||
|
||||
assert array.length == 25;
|
||||
for (int i = 0; i < array.length; ++i)
|
||||
{
|
||||
s.setState(i / 5, i % 5, array[i] != 0);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test()
|
||||
{
|
||||
LightboxSolver solver = new LightboxSolver();
|
||||
|
||||
solver.setInitial(fromArray(INITIAL));
|
||||
solver.setSwitchChange(Combination.A, fromArray(A));
|
||||
solver.setSwitchChange(Combination.B, fromArray(B));
|
||||
solver.setSwitchChange(Combination.C, fromArray(C));
|
||||
solver.setSwitchChange(Combination.D, fromArray(D));
|
||||
solver.setSwitchChange(Combination.E, fromArray(E));
|
||||
solver.setSwitchChange(Combination.F, fromArray(F));
|
||||
solver.setSwitchChange(Combination.G, fromArray(G));
|
||||
solver.setSwitchChange(Combination.H, fromArray(H));
|
||||
|
||||
LightboxSolution solution = solver.solve();
|
||||
|
||||
LightboxSolution expected = new LightboxSolution();
|
||||
expected.flip(Combination.A);
|
||||
expected.flip(Combination.B);
|
||||
expected.flip(Combination.D);
|
||||
expected.flip(Combination.E);
|
||||
expected.flip(Combination.F);
|
||||
expected.flip(Combination.G);
|
||||
|
||||
assertEquals(expected, solution);
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.reorderprayers;
|
||||
|
||||
import net.runelite.api.Prayer;
|
||||
import static net.runelite.api.Prayer.*;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ReorderPrayersPluginTest
|
||||
{
|
||||
private static final Prayer[] PRAYER_ORDER = new Prayer[]{
|
||||
THICK_SKIN,
|
||||
BURST_OF_STRENGTH,
|
||||
CLARITY_OF_THOUGHT,
|
||||
SHARP_EYE,
|
||||
MYSTIC_WILL,
|
||||
ROCK_SKIN,
|
||||
SUPERHUMAN_STRENGTH,
|
||||
IMPROVED_REFLEXES,
|
||||
RAPID_RESTORE,
|
||||
RAPID_HEAL,
|
||||
PROTECT_ITEM,
|
||||
HAWK_EYE,
|
||||
MYSTIC_LORE,
|
||||
STEEL_SKIN,
|
||||
ULTIMATE_STRENGTH,
|
||||
INCREDIBLE_REFLEXES,
|
||||
PROTECT_FROM_MAGIC,
|
||||
PROTECT_FROM_MISSILES,
|
||||
PROTECT_FROM_MELEE,
|
||||
EAGLE_EYE,
|
||||
MYSTIC_MIGHT,
|
||||
RETRIBUTION,
|
||||
REDEMPTION,
|
||||
SMITE,
|
||||
CHIVALRY,
|
||||
PIETY,
|
||||
PRESERVE,
|
||||
RIGOUR,
|
||||
AUGURY
|
||||
};
|
||||
|
||||
@Test
|
||||
public void testPrayerOrder()
|
||||
{
|
||||
// the reorder prayers plugin depends on the Prayer enum order
|
||||
assertArrayEquals(Prayer.values(), PRAYER_ORDER);
|
||||
}
|
||||
}
|
||||
@@ -1,256 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.screenshot;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.function.Consumer;
|
||||
import javax.inject.Inject;
|
||||
import static net.runelite.api.ChatMessageType.GAMEMESSAGE;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.WidgetLoaded;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import static net.runelite.api.widgets.WidgetID.DIALOG_SPRITE_GROUP_ID;
|
||||
import static net.runelite.api.widgets.WidgetID.LEVEL_UP_GROUP_ID;
|
||||
import static net.runelite.api.widgets.WidgetInfo.DIALOG_SPRITE_TEXT;
|
||||
import static net.runelite.api.widgets.WidgetInfo.LEVEL_UP_LEVEL;
|
||||
import static net.runelite.api.widgets.WidgetInfo.PACK;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.DrawManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Matchers;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class ScreenshotPluginTest
|
||||
{
|
||||
private static final String CLUE_SCROLL = "<col=3300ff>You have completed 28 medium Treasure Trails</col>";
|
||||
private static final String BARROWS_CHEST = "Your Barrows chest count is <col=ff0000>310</col>";
|
||||
private static final String CHAMBERS_OF_XERIC_CHEST = "Your completed Chambers of Xeric count is: <col=ff0000>489</col>.";
|
||||
private static final String THEATRE_OF_BLOOD_CHEST = "Your completed Theatre of Blood count is: <col=ff0000>73</col>.";
|
||||
private static final String VALUABLE_DROP = "<col=ef1020>Valuable drop: 6 x Bronze arrow (42 coins)</col>";
|
||||
private static final String UNTRADEABLE_DROP = "<col=ef1020>Untradeable drop: Rusty sword";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ScreenshotPlugin screenshotPlugin;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ScreenshotConfig screenshotConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Notifier notifier;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ClientUI clientUi;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
DrawManager drawManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
RuneLiteConfig config;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ScheduledExecutorService service;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
when(screenshotConfig.screenshotRewards()).thenReturn(true);
|
||||
when(screenshotConfig.screenshotLevels()).thenReturn(true);
|
||||
when(screenshotConfig.screenshotValuableDrop()).thenReturn(true);
|
||||
when(screenshotConfig.screenshotUntradeableDrop()).thenReturn(true);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClueScroll()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Seth", CLUE_SCROLL, null, 0);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("medium", screenshotPlugin.getClueType());
|
||||
assertEquals(28, screenshotPlugin.getClueNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBarrowsChest()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Seth", BARROWS_CHEST, null, 0);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(310, screenshotPlugin.getBarrowsNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChambersOfXericChest()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Seth", CHAMBERS_OF_XERIC_CHEST, null, 0);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(489, screenshotPlugin.getChambersOfXericNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTheatreOfBloodChest()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Magic fTail", THEATRE_OF_BLOOD_CHEST, null, 0);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(73, screenshotPlugin.gettheatreOfBloodNumber());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testValuableDrop()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", VALUABLE_DROP, null, 0);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUntradeableDrop()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", UNTRADEABLE_DROP, null, 0);
|
||||
screenshotPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHitpointsLevel99()
|
||||
{
|
||||
Widget widget = mock(Widget.class);
|
||||
when(widget.getId()).thenReturn(PACK(LEVEL_UP_GROUP_ID, 0));
|
||||
|
||||
Widget levelChild = mock(Widget.class);
|
||||
when(client.getWidget(Matchers.eq(LEVEL_UP_LEVEL))).thenReturn(levelChild);
|
||||
|
||||
when(levelChild.getText()).thenReturn("Your Hitpoints are now 99.");
|
||||
|
||||
assertEquals("Hitpoints(99)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL));
|
||||
|
||||
WidgetLoaded event = new WidgetLoaded();
|
||||
event.setGroupId(LEVEL_UP_GROUP_ID);
|
||||
screenshotPlugin.onWidgetLoaded(event);
|
||||
|
||||
GameTick tick = new GameTick();
|
||||
screenshotPlugin.onGameTick(tick);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFiremakingLevel9()
|
||||
{
|
||||
Widget widget = mock(Widget.class);
|
||||
when(widget.getId()).thenReturn(PACK(LEVEL_UP_GROUP_ID, 0));
|
||||
|
||||
Widget levelChild = mock(Widget.class);
|
||||
when(client.getWidget(Matchers.eq(LEVEL_UP_LEVEL))).thenReturn(levelChild);
|
||||
|
||||
when(levelChild.getText()).thenReturn("Your Firemaking level is now 9.");
|
||||
|
||||
assertEquals("Firemaking(9)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL));
|
||||
|
||||
WidgetLoaded event = new WidgetLoaded();
|
||||
event.setGroupId(LEVEL_UP_GROUP_ID);
|
||||
screenshotPlugin.onWidgetLoaded(event);
|
||||
|
||||
GameTick tick = new GameTick();
|
||||
screenshotPlugin.onGameTick(tick);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAttackLevel70()
|
||||
{
|
||||
Widget widget = mock(Widget.class);
|
||||
when(widget.getId()).thenReturn(PACK(LEVEL_UP_GROUP_ID, 0));
|
||||
|
||||
Widget levelChild = mock(Widget.class);
|
||||
when(client.getWidget(Matchers.eq(LEVEL_UP_LEVEL))).thenReturn(levelChild);
|
||||
|
||||
when(levelChild.getText()).thenReturn("Your Attack level is now 70.");
|
||||
|
||||
assertEquals("Attack(70)", screenshotPlugin.parseLevelUpWidget(LEVEL_UP_LEVEL));
|
||||
|
||||
WidgetLoaded event = new WidgetLoaded();
|
||||
event.setGroupId(LEVEL_UP_GROUP_ID);
|
||||
screenshotPlugin.onWidgetLoaded(event);
|
||||
|
||||
GameTick tick = new GameTick();
|
||||
screenshotPlugin.onGameTick(tick);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHunterLevel2()
|
||||
{
|
||||
Widget widget = mock(Widget.class);
|
||||
when(widget.getId()).thenReturn(PACK(DIALOG_SPRITE_GROUP_ID, 0));
|
||||
|
||||
Widget levelChild = mock(Widget.class);
|
||||
when(client.getWidget(Matchers.eq(DIALOG_SPRITE_TEXT))).thenReturn(levelChild);
|
||||
|
||||
when(levelChild.getText()).thenReturn("<col=000080>Congratulations, you've just advanced a Hunter level.<col=000000><br><br>Your Hunter level is now 2.");
|
||||
|
||||
assertEquals("Hunter(2)", screenshotPlugin.parseLevelUpWidget(DIALOG_SPRITE_TEXT));
|
||||
|
||||
WidgetLoaded event = new WidgetLoaded();
|
||||
event.setGroupId(DIALOG_SPRITE_GROUP_ID);
|
||||
screenshotPlugin.onWidgetLoaded(event);
|
||||
|
||||
GameTick tick = new GameTick();
|
||||
screenshotPlugin.onGameTick(tick);
|
||||
|
||||
verify(drawManager).requestNextFrameListener(Matchers.any(Consumer.class));
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.skybox;
|
||||
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.io.CharSource;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import javax.imageio.ImageIO;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
@Slf4j
|
||||
public class SkyboxTest
|
||||
{
|
||||
@Test
|
||||
public void testLoadSimple() throws IOException
|
||||
{
|
||||
Skybox skybox = new Skybox(CharSource.wrap("bounds 0 0 100 100 #00F // R 0 0 100 100\r\nr 99 99").openStream(), "simple");
|
||||
Assert.assertEquals(0, skybox.getColorForPoint(0, 0, 0, 0, 0, 1, null));
|
||||
int x = (99 * 64) + 32;
|
||||
int y = (99 * 64) + 32;
|
||||
Assert.assertEquals(0x0000FF, skybox.getColorForPoint(x, y, x, y, 0, 1, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLoadActual() throws IOException
|
||||
{
|
||||
long start = System.nanoTime();
|
||||
Skybox skybox = new Skybox(SkyboxPlugin.class.getResourceAsStream("skybox.txt"), "skybox.txt");
|
||||
log.info("Parse took {}ms", (System.nanoTime() - start) / 1_000_000);
|
||||
|
||||
String skyboxFile = System.getProperty("skyboxExport");
|
||||
if (!Strings.isNullOrEmpty(skyboxFile))
|
||||
{
|
||||
start = System.nanoTime();
|
||||
BufferedImage img = skybox.render(1f, 0, 0, null);
|
||||
long time = System.nanoTime() - start;
|
||||
log.info("Map render took {}ms", time / 1_000_000);
|
||||
log.info("Single render takes ~{}ns/frame", time / (img.getWidth() * img.getHeight()));
|
||||
ImageIO.write(img, "png", new File(skyboxFile));
|
||||
}
|
||||
|
||||
Assert.assertNotEquals(skybox.getColorForPoint(3232, 3232, 3232, 3232, 0, .9, null), 0); // Lumbridge will never be black
|
||||
}
|
||||
}
|
||||
@@ -1,451 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.slayer;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import static net.runelite.api.ChatMessageType.GAMEMESSAGE;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.MessageNode;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.Notifier;
|
||||
import net.runelite.client.chat.ChatCommandManager;
|
||||
import net.runelite.client.chat.ChatMessageManager;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.http.api.chat.ChatClient;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SlayerPluginTest
|
||||
{
|
||||
private static final String TASK_NEW = "Your new task is to kill 231 Suqahs.";
|
||||
private static final String TASK_NEW_KONAR = "You are to bring balance to 147 Wyrms in the Karuulm Slayer Dungeon.";
|
||||
private static final String TASK_NEW_KONAR_2 = "You are to bring balance to 142 Hellhounds in Witchhaven Dungeon.";
|
||||
private static final String TASK_NEW_KONAR_3 = "You are to bring balance to 135 Trolls south of Mount Quidamortem.";
|
||||
private static final String TASK_NEW_FIRST = "We'll start you off hunting goblins, you'll need to kill 17 of them.";
|
||||
private static final String TASK_NEW_NPC_CONTACT = "Excellent, you're doing great. Your new task is to kill<br>211 Suqahs.";
|
||||
private static final String TASK_NEW_FROM_PARTNER = "You have received a new Slayer assignment from breaklulz: Dust Devils (377)";
|
||||
private static final String TASK_CHECKSLAYERGEM = "You're assigned to kill Suqahs; only 211 more to go.";
|
||||
private static final String TASK_CHECKSLAYERGEM_WILDERNESS = "You're assigned to kill Suqahs in the Wilderness; only 211 more to go.";
|
||||
private static final String TASK_CHECKSLAYERGEM_KONAR = "You're assigned to kill Blue dragons in the Ogre Enclave; only 122 more to go.";
|
||||
|
||||
private static final String TASK_BOSS_NEW = "Excellent. You're now assigned to kill Vet'ion 3 times.<br>Your reward point tally is 914.";
|
||||
private static final String TASK_BOSS_NEW_THE = "Excellent. You're now assigned to kill the Chaos <br>Elemental 3 times. Your reward point tally is 914.";
|
||||
|
||||
private static final String TASK_EXISTING = "You're still hunting suqahs; you have 222 to go. Come<br>back when you've finished your task.";
|
||||
|
||||
private static final String REWARD_POINTS = "Reward points: 17,566";
|
||||
|
||||
private static final String TASK_ONE = "You've completed one task; return to a Slayer master.";
|
||||
private static final String TASK_COMPLETE_NO_POINTS = "<col=ef1020>You've completed 3 tasks; return to a Slayer master.</col>";
|
||||
private static final String TASK_POINTS = "You've completed 9 tasks and received 0 points, giving you a total of 18,000; return to a Slayer master.";
|
||||
private static final String TASK_LARGE_STREAK = "You've completed 2,465 tasks and received 15 points, giving you a total of 17,566,000; return to a Slayer master.";
|
||||
|
||||
private static final String TASK_COMPLETE = "You need something new to hunt.";
|
||||
private static final String TASK_CANCELED = "Your task has been cancelled.";
|
||||
|
||||
private static final String SUPERIOR_MESSAGE = "A superior foe has appeared...";
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SlayerConfig slayerConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SlayerOverlay overlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
InfoBoxManager infoBoxManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ItemManager itemManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
Notifier notifier;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatMessageManager chatMessageManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatCommandManager chatCommandManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ScheduledExecutorService executor;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
ChatClient chatClient;
|
||||
|
||||
@Inject
|
||||
SlayerPlugin slayerPlugin;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SlayerTaskPanel panel;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(231, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewKonarTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Wyrms", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(147, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Karuulm Slayer Dungeon", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewKonarTask2()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_2);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Hellhounds", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(142, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Witchhaven Dungeon", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewKonarTask3()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_KONAR_3);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Trolls", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(135, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Mount Quidamortem", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFirstTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_FIRST);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("goblins", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(17, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNewNpcContactTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_NEW_NPC_CONTACT);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBossTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Vet'ion", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(914, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBossTaskThe()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_BOSS_NEW_THE);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("Chaos Elemental", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(3, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(914, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartnerTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_NEW_FROM_PARTNER, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("Dust Devils", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(377, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckSlayerGem()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_CHECKSLAYERGEM, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckSlayerGemWildernessTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_CHECKSLAYERGEM_WILDERNESS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
assertEquals("Suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(211, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Wilderness", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckSlayerGemKonarTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "", TASK_CHECKSLAYERGEM_KONAR, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("Blue dragons", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(122, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals("Ogre Enclave", slayerPlugin.getCurrentTask().getTaskLocation());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExistingTask()
|
||||
{
|
||||
Widget npcDialog = mock(Widget.class);
|
||||
when(npcDialog.getText()).thenReturn(TASK_EXISTING);
|
||||
when(client.getWidget(WidgetInfo.DIALOG_NPC_TEXT)).thenReturn(npcDialog);
|
||||
slayerPlugin.onGameTick(new GameTick());
|
||||
|
||||
assertEquals("suqahs", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(222, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneTask()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_ONE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(1, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoPoints()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE_NO_POINTS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals(3, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPoints()
|
||||
{
|
||||
when(client.getVar(Varbits.SLAYER_REWARD_POINTS)).thenReturn(18_000);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_POINTS, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
VarbitChanged varbitChanged = new VarbitChanged();
|
||||
slayerPlugin.onVarbitChanged(varbitChanged);
|
||||
|
||||
assertEquals(9, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(18_000, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLargeStreak()
|
||||
{
|
||||
when(client.getVar(Varbits.SLAYER_REWARD_POINTS)).thenReturn(17_566_000);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_LARGE_STREAK, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
VarbitChanged varbitChanged = new VarbitChanged();
|
||||
slayerPlugin.onVarbitChanged(varbitChanged);
|
||||
|
||||
assertEquals(2465, slayerPlugin.getStreak());
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
assertEquals(17_566_000, slayerPlugin.getPoints());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testComplete()
|
||||
{
|
||||
slayerPlugin.getCurrentTask().setTaskName("cows");
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_COMPLETE, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCancelled()
|
||||
{
|
||||
slayerPlugin.getCurrentTask().setTaskName("cows");
|
||||
slayerPlugin.getCurrentTask().setAmount(42);
|
||||
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Perterter", TASK_CANCELED, null, 0);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
|
||||
assertEquals("", slayerPlugin.getCurrentTask().getTaskName());
|
||||
assertEquals(0, slayerPlugin.getCurrentTask().getAmount());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperiorNotification()
|
||||
{
|
||||
ChatMessage chatMessageEvent = new ChatMessage(null, GAMEMESSAGE, "Superior", SUPERIOR_MESSAGE, null, 0);
|
||||
|
||||
when(slayerConfig.showSuperiorNotification()).thenReturn(true);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
verify(notifier).notify(SUPERIOR_MESSAGE);
|
||||
|
||||
when(slayerConfig.showSuperiorNotification()).thenReturn(false);
|
||||
slayerPlugin.onChatMessage(chatMessageEvent);
|
||||
verifyNoMoreInteractions(notifier);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskLookup() throws IOException
|
||||
{
|
||||
net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task();
|
||||
task.setTask("task");
|
||||
task.setLocation("loc");
|
||||
task.setAmount(42);
|
||||
task.setInitialAmount(42);
|
||||
|
||||
when(slayerConfig.taskCommand()).thenReturn(true);
|
||||
when(chatClient.getTask(anyString())).thenReturn(task);
|
||||
|
||||
ChatMessage setMessage = new ChatMessage();
|
||||
setMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||
setMessage.setName("Adam");
|
||||
setMessage.setMessageNode(mock(MessageNode.class));
|
||||
|
||||
slayerPlugin.taskLookup(setMessage, "!task");
|
||||
|
||||
verify(chatMessageManager).update(any(MessageNode.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTaskLookupInvalid() throws IOException
|
||||
{
|
||||
net.runelite.http.api.chat.Task task = new net.runelite.http.api.chat.Task();
|
||||
task.setTask("task<");
|
||||
task.setLocation("loc");
|
||||
task.setAmount(42);
|
||||
task.setInitialAmount(42);
|
||||
|
||||
when(slayerConfig.taskCommand()).thenReturn(true);
|
||||
when(chatClient.getTask(anyString())).thenReturn(task);
|
||||
|
||||
ChatMessage chatMessage = new ChatMessage();
|
||||
chatMessage.setType(ChatMessageType.PUBLICCHAT);
|
||||
chatMessage.setName("Adam");
|
||||
chatMessage.setMessageNode(mock(MessageNode.class));
|
||||
|
||||
slayerPlugin.taskLookup(chatMessage, "!task");
|
||||
|
||||
verify(chatMessageManager, never()).update(any(MessageNode.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuperiorsLowercase()
|
||||
{
|
||||
for (String name : SlayerPlugin.SUPERIOR_SLAYER_MONSTERS)
|
||||
{
|
||||
assertEquals(name, name.toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Stephen <stepzhu@umich.edu>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.smelting;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.client.ui.overlay.OverlayManager;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SmeltingPluginTest
|
||||
{
|
||||
private static final String SMELT_CANNONBALL = "You remove the cannonballs from the mould";
|
||||
private static final String SMELT_BAR = "You retrieve a bar of steel.";
|
||||
|
||||
@Inject
|
||||
SmeltingPlugin smeltingPlugin;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SmeltingConfig config;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
SmeltingOverlay smeltingOverlay;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
OverlayManager overlayManager;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCannonballs()
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", SMELT_CANNONBALL, "", 0);
|
||||
smeltingPlugin.onChatMessage(chatMessage);
|
||||
|
||||
SmeltingSession smeltingSession = smeltingPlugin.getSession();
|
||||
assertNotNull(smeltingSession);
|
||||
assertEquals(4, smeltingSession.getCannonBallsSmelted());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBars()
|
||||
{
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", SMELT_BAR, "", 0);
|
||||
smeltingPlugin.onChatMessage(chatMessage);
|
||||
|
||||
SmeltingSession smeltingSession = smeltingPlugin.getSession();
|
||||
assertNotNull(smeltingSession);
|
||||
assertEquals(1, smeltingSession.getBarsSmelted());
|
||||
}
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.timestamp;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.util.TimeZone;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TimestampPluginTest
|
||||
{
|
||||
@Mock
|
||||
@Bind
|
||||
Client client;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
TimestampConfig config;
|
||||
|
||||
@Inject
|
||||
TimestampPlugin plugin;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGenerateTimestamp()
|
||||
{
|
||||
when(config.timestampFormat()).thenReturn("[yyyy:MM:dd:HH:hh:mm:ss]");
|
||||
|
||||
ConfigChanged configChanged = new ConfigChanged();
|
||||
configChanged.setGroup("timestamp");
|
||||
configChanged.setKey("format");
|
||||
configChanged.setNewValue("true");
|
||||
plugin.onConfigChanged(configChanged);
|
||||
|
||||
int testInput = 1554667116;
|
||||
String testOutput = "[2019:04:07:15:03:58:36]";
|
||||
TimeZone timeZone = TimeZone.getTimeZone("America/New_York");
|
||||
plugin.getFormatter().setTimeZone(timeZone);
|
||||
assertTrue(plugin.generateTimestamp(testInput, timeZone.toZoneId()).equals(testOutput));
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jamy C <https://github.com/jamyc>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.timetracking.clocks;
|
||||
|
||||
import java.time.format.DateTimeParseException;
|
||||
import org.junit.Test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
public class ClockPanelTest
|
||||
{
|
||||
@Test
|
||||
public void properColonSeparatedTimeStringShouldReturnCorrectSeconds()
|
||||
{
|
||||
assertEquals(5, ClockPanel.stringToSeconds("5"));
|
||||
assertEquals(50, ClockPanel.stringToSeconds("50"));
|
||||
assertEquals(120, ClockPanel.stringToSeconds("2:00"));
|
||||
assertEquals(120, ClockPanel.stringToSeconds("0:120"));
|
||||
assertEquals(120, ClockPanel.stringToSeconds("0:0:120"));
|
||||
assertEquals(1200, ClockPanel.stringToSeconds("20:00"));
|
||||
|
||||
assertEquals(50, ClockPanel.stringToSeconds("00:00:50"));
|
||||
assertEquals(121, ClockPanel.stringToSeconds("00:02:01"));
|
||||
assertEquals(3660, ClockPanel.stringToSeconds("01:01:00"));
|
||||
assertEquals(9000, ClockPanel.stringToSeconds("2:30:00"));
|
||||
assertEquals(9033, ClockPanel.stringToSeconds("02:30:33"));
|
||||
assertEquals(82800, ClockPanel.stringToSeconds("23:00:00"));
|
||||
assertEquals(400271, ClockPanel.stringToSeconds("111:11:11"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void properIntuitiveTimeStringShouldReturnCorrectSeconds()
|
||||
{
|
||||
assertEquals(5, ClockPanel.stringToSeconds("5s"));
|
||||
assertEquals(50, ClockPanel.stringToSeconds("50s"));
|
||||
assertEquals(120, ClockPanel.stringToSeconds("2m"));
|
||||
assertEquals(120, ClockPanel.stringToSeconds("120s"));
|
||||
assertEquals(1200, ClockPanel.stringToSeconds("20m"));
|
||||
|
||||
assertEquals(121, ClockPanel.stringToSeconds("2m1s"));
|
||||
assertEquals(121, ClockPanel.stringToSeconds("2m 1s"));
|
||||
assertEquals(3660, ClockPanel.stringToSeconds("1h 1m"));
|
||||
assertEquals(3660, ClockPanel.stringToSeconds("61m"));
|
||||
assertEquals(3660, ClockPanel.stringToSeconds("3660s"));
|
||||
assertEquals(9000, ClockPanel.stringToSeconds("2h 30m"));
|
||||
assertEquals(9033, ClockPanel.stringToSeconds("2h 30m 33s"));
|
||||
assertEquals(82800, ClockPanel.stringToSeconds("23h"));
|
||||
assertEquals(400271, ClockPanel.stringToSeconds("111h 11m 11s"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incorrectTimeStringShouldThrowException()
|
||||
{
|
||||
Class numberEx = NumberFormatException.class;
|
||||
Class dateTimeEx = DateTimeParseException.class;
|
||||
|
||||
tryFail("a", numberEx);
|
||||
tryFail("abc", numberEx);
|
||||
tryFail("aa:bb:cc", numberEx);
|
||||
tryFail("01:12=", numberEx);
|
||||
|
||||
tryFail("s", dateTimeEx);
|
||||
tryFail("1s 1m", dateTimeEx);
|
||||
tryFail("20m:10s", dateTimeEx);
|
||||
tryFail("20hh10m10s", dateTimeEx);
|
||||
}
|
||||
|
||||
private void tryFail(String input, Class<?> expectedException)
|
||||
{
|
||||
try
|
||||
{
|
||||
ClockPanel.stringToSeconds(input);
|
||||
fail("Should have thrown " + expectedException.getSimpleName());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
assertEquals(expectedException, exception.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.timetracking.farming;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class FarmingWorldTest
|
||||
{
|
||||
@Test
|
||||
public void testInit()
|
||||
{
|
||||
new FarmingWorld();
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018 Abex
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.timetracking.farming;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ErrorCollector;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
public class PatchImplementationTest
|
||||
{
|
||||
@Rule
|
||||
public ErrorCollector collector = new ErrorCollector();
|
||||
|
||||
@Test
|
||||
public void testRange()
|
||||
{
|
||||
for (PatchImplementation impl : PatchImplementation.values())
|
||||
{
|
||||
Map<Produce, boolean[]> harvestStages = new HashMap<>();
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
PatchState s = impl.forVarbitValue(i);
|
||||
if (s != null)
|
||||
{
|
||||
String pfx = impl.name() + "[" + i + "]";
|
||||
collector.checkThat(pfx + ": cropState", s.getCropState(), notNullValue());
|
||||
collector.checkThat(pfx + ": produce", s.getProduce(), notNullValue());
|
||||
collector.checkThat(pfx + ": negative stage", s.getStage(), greaterThanOrEqualTo(0));
|
||||
int stages = s.getProduce().getStages();
|
||||
if (s.getCropState() == CropState.HARVESTABLE)
|
||||
{
|
||||
stages = s.getProduce().getHarvestStages();
|
||||
}
|
||||
collector.checkThat(pfx + ": out of bounds stage", s.getStage(), lessThan(stages));
|
||||
if (s.getCropState() == CropState.DEAD || s.getCropState() == CropState.DISEASED)
|
||||
{
|
||||
collector.checkThat(pfx + ": dead seed", s.getStage(), greaterThan(0));
|
||||
}
|
||||
if (s.getCropState() == CropState.GROWING && s.getProduce() != Produce.WEEDS && s.getStage() < stages)
|
||||
{
|
||||
harvestStages.computeIfAbsent(s.getProduce(), k -> new boolean[s.getProduce().getStages()])[s.getStage()] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<Produce, boolean[]> produce : harvestStages.entrySet())
|
||||
{
|
||||
boolean[] states = produce.getValue();
|
||||
// Alot of time the final stage is not hit, because some plants do not have a "Check-health" stage
|
||||
for (int i = 0; i < states.length - 1; i++)
|
||||
{
|
||||
collector.checkThat(produce.getKey().getName() + " stage " + i + " never found by varbit", states[i], is(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.twitch.irc;
|
||||
|
||||
import java.util.Map;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MessageTest
|
||||
{
|
||||
@Test
|
||||
public void testParse()
|
||||
{
|
||||
Message message = Message.parse("@badges=subscriber/0;color=;display-name=kappa_kid_;emotes=;id=6539b42a-e945-4a83-a5b7-018149ca9fa7;mod=0;room-id=27107346;subscriber=1;tmi-sent-ts=1535926830652;turbo=0;user-id=33390095;user-type= :kappa_kid_!kappa_kid_@kappa_kid_.tmi.twitch.tv PRIVMSG #b0aty :how do u add charges to that zeah book?");
|
||||
Map<String, String> messageTags = message.getTags();
|
||||
assertEquals("subscriber/0", messageTags.get("badges"));
|
||||
assertEquals("kappa_kid_!kappa_kid_@kappa_kid_.tmi.twitch.tv", message.getSource());
|
||||
assertEquals("PRIVMSG", message.getCommand());
|
||||
assertEquals("#b0aty", message.getArguments()[0]);
|
||||
assertEquals("how do u add charges to that zeah book?", message.getArguments()[1]);
|
||||
|
||||
message = Message.parse("@badges=moderator/1,subscriber/12,bits/10000;color=#008000;display-name=Am_Sephiroth;emotes=;id=7d516b7c-de7a-4c8b-ad23-d8880b55d46b;login=am_sephiroth;mod=1;msg-id=subgift;msg-param-months=8;msg-param-recipient-display-name=IntRS;msg-param-recipient-id=189672346;msg-param-recipient-user-name=intrs;msg-param-sender-count=215;msg-param-sub-plan-name=Sick\\sNerd\\sSubscription\\s;msg-param-sub-plan=1000;room-id=49408183;subscriber=1;system-msg=Am_Sephiroth\\sgifted\\sa\\sTier\\s1\\ssub\\sto\\sIntRS!\\sThey\\shave\\sgiven\\s215\\sGift\\sSubs\\sin\\sthe\\schannel!;tmi-sent-ts=1535980032939;turbo=0;user-id=69539403;user-type=mod :tmi.twitch.tv USERNOTICE #sick_nerd");
|
||||
messageTags = message.getTags();
|
||||
assertEquals("Am_Sephiroth gifted a Tier 1 sub to IntRS! They have given 215 Gift Subs in the channel!", messageTags.get("system-msg"));
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.plugins.worldmap;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TeleportLocationDataTest
|
||||
{
|
||||
@Test
|
||||
public void testResources()
|
||||
{
|
||||
for (TeleportLocationData data : TeleportLocationData.values())
|
||||
{
|
||||
String path = data.getIconPath();
|
||||
assertNotNull(path);
|
||||
assertNotNull(path, getClass().getResourceAsStream(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
package net.runelite.client.rs;
|
||||
|
||||
import java.io.IOException;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adam
|
||||
*/
|
||||
public class ClientConfigLoaderTest
|
||||
{
|
||||
@Test
|
||||
public void test() throws IOException
|
||||
{
|
||||
final ClientConfigLoader loader = new ClientConfigLoader(new OkHttpClient());
|
||||
final RSConfig config = loader.fetch();
|
||||
|
||||
for (String key : config.getClassLoaderProperties().keySet())
|
||||
{
|
||||
System.out.println(key + ": " + config.getClassLoaderProperties().get(key));
|
||||
}
|
||||
|
||||
System.out.println("Applet properties:");
|
||||
|
||||
for (String key : config.getAppletProperties().keySet())
|
||||
{
|
||||
System.out.println(key + ": " + config.getAppletProperties().get(key));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2017, Tyler <https://github.com/tylerthardy>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.ui;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import org.junit.Test;
|
||||
|
||||
public class FontManagerTest
|
||||
{
|
||||
@Test
|
||||
public void getRunescapeFont()
|
||||
{
|
||||
assertNotNull(FontManager.getRunescapeFont());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getRunescapeSmallFont()
|
||||
{
|
||||
assertNotNull(FontManager.getRunescapeSmallFont());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.ui.overlay;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class OverlayManagerTest
|
||||
{
|
||||
class TestOverlay extends Overlay
|
||||
{
|
||||
TestOverlay(OverlayPosition position, OverlayPriority priority)
|
||||
{
|
||||
setPosition(position);
|
||||
setPriority(priority);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverlayA extends Overlay
|
||||
{
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverlayB extends Overlay
|
||||
{
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEquality()
|
||||
{
|
||||
Overlay a1 = new OverlayA();
|
||||
Overlay a2 = new OverlayA();
|
||||
Overlay b = new OverlayB();
|
||||
// The same instance of the same overlay should be equal
|
||||
assertTrue(a1.equals(a1));
|
||||
// A different instance of the same overlay should not be equal by default
|
||||
assertFalse(a1.equals(a2));
|
||||
// A different instance of a different overlay should not be equal
|
||||
assertFalse(a1.equals(b));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSort()
|
||||
{
|
||||
// High priorities overlays render first
|
||||
Overlay tlh = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.HIGH);
|
||||
Overlay tll = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.LOW);
|
||||
List<Overlay> overlays = Arrays.asList(tlh, tll);
|
||||
overlays.sort(OverlayManager.OVERLAY_COMPARATOR);
|
||||
assertEquals(tlh, overlays.get(0));
|
||||
assertEquals(tll, overlays.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSortDynamic()
|
||||
{
|
||||
// Dynamic overlays render before static overlays
|
||||
Overlay tlh = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.HIGH);
|
||||
Overlay dyn = new TestOverlay(OverlayPosition.DYNAMIC, OverlayPriority.HIGH);
|
||||
List<Overlay> overlays = Arrays.asList(tlh, dyn);
|
||||
overlays.sort(OverlayManager.OVERLAY_COMPARATOR);
|
||||
assertEquals(dyn, overlays.get(0));
|
||||
assertEquals(tlh, overlays.get(1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTooltips()
|
||||
{
|
||||
// Tooltip overlay renders after everything
|
||||
Overlay t = new TestOverlay(OverlayPosition.TOOLTIP, OverlayPriority.HIGH);
|
||||
Overlay dyn = new TestOverlay(OverlayPosition.DYNAMIC, OverlayPriority.HIGH);
|
||||
Overlay tlh = new TestOverlay(OverlayPosition.TOP_LEFT, OverlayPriority.HIGH);
|
||||
List<Overlay> overlays = Arrays.asList(t, dyn, tlh);
|
||||
overlays.sort(OverlayManager.OVERLAY_COMPARATOR);
|
||||
assertEquals(dyn, overlays.get(0));
|
||||
assertEquals(tlh, overlays.get(1));
|
||||
assertEquals(t, overlays.get(2));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.ui.overlay.components;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TextComponentTest
|
||||
{
|
||||
@Mock
|
||||
private Graphics2D graphics;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
when(graphics.getFontMetrics()).thenReturn(mock(FontMetrics.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRender()
|
||||
{
|
||||
TextComponent textComponent = new TextComponent();
|
||||
textComponent.setText("test");
|
||||
textComponent.setColor(Color.RED);
|
||||
textComponent.render(graphics);
|
||||
verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt());
|
||||
verify(graphics, atLeastOnce()).setColor(Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRender2()
|
||||
{
|
||||
TextComponent textComponent = new TextComponent();
|
||||
textComponent.setText("<col=0000ff>test");
|
||||
textComponent.render(graphics);
|
||||
verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt());
|
||||
verify(graphics, atLeastOnce()).setColor(Color.BLUE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRender3()
|
||||
{
|
||||
TextComponent textComponent = new TextComponent();
|
||||
textComponent.setText("<col=0000ff>test<col=00ff00> test");
|
||||
textComponent.render(graphics);
|
||||
verify(graphics, atLeastOnce()).drawString(eq("test"), anyInt(), anyInt());
|
||||
verify(graphics, atLeastOnce()).drawString(eq(" test"), anyInt(), anyInt());
|
||||
verify(graphics, atLeastOnce()).setColor(Color.BLUE);
|
||||
verify(graphics, atLeastOnce()).setColor(Color.GREEN);
|
||||
}
|
||||
}
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.ui.overlay.components.table;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.FontMetrics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.List;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import org.mockito.Mock;
|
||||
import static org.mockito.Mockito.atLeastOnce;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TableComponentTest
|
||||
{
|
||||
@Mock
|
||||
private Graphics2D graphics;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
when(graphics.getFontMetrics()).thenReturn(mock(FontMetrics.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRender()
|
||||
{
|
||||
TableComponent tableComponent = new TableComponent();
|
||||
tableComponent.addRow("test");
|
||||
tableComponent.setDefaultAlignment(TableAlignment.CENTER);
|
||||
tableComponent.setDefaultColor(Color.RED);
|
||||
tableComponent.render(graphics);
|
||||
verify(graphics, times(2)).drawString(eq("test"), anyInt(), anyInt());
|
||||
verify(graphics, atLeastOnce()).setColor(Color.RED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testColors()
|
||||
{
|
||||
TableComponent tableComponent = new TableComponent();
|
||||
tableComponent.addRow("test", "test", "test", "<col=ffff00>test", "test");
|
||||
tableComponent.setColumns("", "", "");
|
||||
List<TableElement> elements = tableComponent.getColumns();
|
||||
elements.get(0).setColor(Color.RED);
|
||||
elements.get(1).setColor(Color.GREEN);
|
||||
elements.get(2).setColor(Color.BLUE);
|
||||
tableComponent.render(graphics);
|
||||
verify(graphics, atLeastOnce()).setColor(Color.RED);
|
||||
verify(graphics, atLeastOnce()).setColor(Color.GREEN);
|
||||
verify(graphics, atLeastOnce()).setColor(Color.BLUE);
|
||||
verify(graphics, atLeastOnce()).setColor(Color.YELLOW);
|
||||
verify(graphics, atLeastOnce()).setColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ColorUtilTest
|
||||
{
|
||||
private static final Map<Color, String> COLOR_HEXSTRING_MAP = new HashMap<Color, String>()
|
||||
{{
|
||||
put(Color.BLACK, "000000");
|
||||
put(new Color(0x1), "000001");
|
||||
put(new Color(0x100000), "100000");
|
||||
put(Color.RED, "ff0000");
|
||||
put(Color.GREEN, "00ff00");
|
||||
put(Color.BLUE, "0000ff");
|
||||
put(new Color(0xA1B2C3), "a1b2c3");
|
||||
put(Color.WHITE, "ffffff");
|
||||
}};
|
||||
|
||||
@Test
|
||||
public void colorTag()
|
||||
{
|
||||
COLOR_HEXSTRING_MAP.forEach((color, hex) ->
|
||||
{
|
||||
assertEquals("<col=" + hex + ">", ColorUtil.colorTag(color));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void prependColorTag()
|
||||
{
|
||||
COLOR_HEXSTRING_MAP.forEach((color, hex) ->
|
||||
{
|
||||
assertEquals("<col=" + hex + ">test", ColorUtil.prependColorTag("test", color));
|
||||
assertEquals("<col=" + hex + ">", ColorUtil.prependColorTag("", color));
|
||||
});
|
||||
|
||||
assertEquals("<col=ff0000>94<col=ffffff>/99", ColorUtil.prependColorTag("94" + ColorUtil.prependColorTag("/99", Color.WHITE), Color.RED));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wrapWithColorTag()
|
||||
{
|
||||
COLOR_HEXSTRING_MAP.forEach((color, hex) ->
|
||||
{
|
||||
assertEquals("<col=" + hex + ">test</col>", ColorUtil.wrapWithColorTag("test", color));
|
||||
assertEquals("<col=" + hex + "></col>", ColorUtil.wrapWithColorTag("", color));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toHexColor()
|
||||
{
|
||||
COLOR_HEXSTRING_MAP.forEach((color, hex) ->
|
||||
{
|
||||
assertEquals("#" + hex, ColorUtil.toHexColor(color));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void colorLerp()
|
||||
{
|
||||
assertEquals(Color.WHITE, ColorUtil.colorLerp(Color.WHITE, Color.WHITE, 0.9));
|
||||
assertEquals(new Color(128, 128, 128), ColorUtil.colorLerp(Color.BLACK, Color.WHITE, 0.5));
|
||||
assertEquals(Color.BLACK, ColorUtil.colorLerp(Color.BLACK, Color.CYAN, 0));
|
||||
assertEquals(Color.CYAN, ColorUtil.colorLerp(Color.BLACK, Color.CYAN, 1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void colorToHexCode()
|
||||
{
|
||||
COLOR_HEXSTRING_MAP.forEach((color, hex) ->
|
||||
{
|
||||
assertEquals(hex, ColorUtil.colorToHexCode(color));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isFullyTransparent()
|
||||
{
|
||||
for (Color color : COLOR_HEXSTRING_MAP.keySet())
|
||||
{
|
||||
assertFalse(ColorUtil.isFullyTransparent(color));
|
||||
}
|
||||
assertTrue(ColorUtil.isFullyTransparent(new Color(0, 0, 0, 0)));
|
||||
assertFalse(ColorUtil.isFullyTransparent(new Color(0, 0, 0, 1)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isNotFullyTransparent()
|
||||
{
|
||||
for (Color color : COLOR_HEXSTRING_MAP.keySet())
|
||||
{
|
||||
assertTrue(ColorUtil.isNotFullyTransparent(color));
|
||||
}
|
||||
assertFalse(ColorUtil.isNotFullyTransparent(new Color(0, 0, 0, 0)));
|
||||
assertTrue(ColorUtil.isNotFullyTransparent(new Color(0, 0, 0, 1)));
|
||||
}
|
||||
}
|
||||
@@ -1,439 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import java.awt.Color;
|
||||
import static java.awt.Color.BLACK;
|
||||
import static java.awt.Color.BLUE;
|
||||
import static java.awt.Color.GRAY;
|
||||
import static java.awt.Color.GREEN;
|
||||
import static java.awt.Color.RED;
|
||||
import static java.awt.Color.WHITE;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.awt.image.DataBufferInt;
|
||||
import java.util.Arrays;
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nonnull;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ImageUtilTest
|
||||
{
|
||||
private static final Color BLACK_HALF_TRANSPARENT = new Color(0, 0, 0, 128);
|
||||
private static final Color BLACK_TRANSPARENT = new Color(0, true);
|
||||
private static final int CORNER_SIZE = 2;
|
||||
private static final int CENTERED_SIZE = 3;
|
||||
|
||||
private static final BufferedImage BLACK_PIXEL_TOP_LEFT;
|
||||
private static final BufferedImage BLACK_PIXEL_TOP_RIGHT;
|
||||
private static final BufferedImage BLACK_PIXEL_BOTTOM_LEFT;
|
||||
private static final BufferedImage BLACK_PIXEL_BOTTOM_RIGHT;
|
||||
|
||||
static
|
||||
{
|
||||
BLACK_PIXEL_TOP_LEFT = new BufferedImage(CORNER_SIZE, CORNER_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
BLACK_PIXEL_TOP_LEFT.setRGB(0, 0, BLACK.getRGB());
|
||||
|
||||
BLACK_PIXEL_TOP_RIGHT = new BufferedImage(CORNER_SIZE, CORNER_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
BLACK_PIXEL_TOP_RIGHT.setRGB(1, 0, BLACK.getRGB());
|
||||
|
||||
BLACK_PIXEL_BOTTOM_LEFT = new BufferedImage(CORNER_SIZE, CORNER_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
BLACK_PIXEL_BOTTOM_LEFT.setRGB(0, 1, BLACK.getRGB());
|
||||
|
||||
BLACK_PIXEL_BOTTOM_RIGHT = new BufferedImage(CORNER_SIZE, CORNER_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
BLACK_PIXEL_BOTTOM_RIGHT.setRGB(1, 1, BLACK.getRGB());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bufferedImageFromImage()
|
||||
{
|
||||
final BufferedImage buffered = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
assertEquals(buffered, ImageUtil.bufferedImageFromImage(buffered));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void grayscaleOffset()
|
||||
{
|
||||
// grayscaleOffset(BufferedImage image, int offset)
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(BLACK), -255)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(new Color(50, 50, 50)), ImageUtil.grayscaleOffset(oneByOne(BLACK), 50)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(GRAY), ImageUtil.grayscaleOffset(oneByOne(BLACK), 128)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(GRAY), -255)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(WHITE), ImageUtil.grayscaleOffset(oneByOne(BLACK), 255)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(new Color(200, 200, 200)), ImageUtil.grayscaleOffset(oneByOne(WHITE), -55)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(WHITE), ImageUtil.grayscaleOffset(oneByOne(WHITE), 55)));
|
||||
|
||||
// grayscaleOffset(BufferedImage image, float percentage)
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(BLACK), 0f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(BLACK), 1f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(BLACK), 2f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(GRAY), 0f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(GRAY), ImageUtil.grayscaleOffset(oneByOne(GRAY), 1f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(WHITE), ImageUtil.grayscaleOffset(oneByOne(GRAY), 2f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.grayscaleOffset(oneByOne(WHITE), 0f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(GRAY), ImageUtil.grayscaleOffset(oneByOne(WHITE), 0.503f))); // grayscaleOffset does Math.floor
|
||||
assertTrue(bufferedImagesEqual(oneByOne(WHITE), ImageUtil.grayscaleOffset(oneByOne(WHITE), 1f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(WHITE), ImageUtil.grayscaleOffset(oneByOne(WHITE), 2f)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alphaOffset()
|
||||
{
|
||||
// alphaOffset(BufferedImage image, int offset)
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), -255)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(new Color(0, 0, 0, 50)), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), 50)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_HALF_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), 128)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_HALF_TRANSPARENT), -255)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), 255)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(new Color(0, 0, 0, 200)), ImageUtil.alphaOffset(oneByOne(BLACK), -55)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.alphaOffset(oneByOne(BLACK), 255)));
|
||||
|
||||
// alphaOffset(BufferedImage image, float offset)
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), 0f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), 1f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_TRANSPARENT), 2f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_HALF_TRANSPARENT), 0f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_HALF_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK_HALF_TRANSPARENT), 1f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.alphaOffset(oneByOne(BLACK_HALF_TRANSPARENT), 2f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK), 0f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_HALF_TRANSPARENT), ImageUtil.alphaOffset(oneByOne(BLACK), 0.503f))); // opacityOffset does Math.floor
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.alphaOffset(oneByOne(BLACK), 1f)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.alphaOffset(oneByOne(BLACK), 2f)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void grayscaleImage()
|
||||
{
|
||||
final BufferedImage[] grayscaleColors = new BufferedImage[] {
|
||||
oneByOne(WHITE),
|
||||
oneByOne(GRAY),
|
||||
oneByOne(BLACK),
|
||||
oneByOne(BLACK_HALF_TRANSPARENT),
|
||||
oneByOne(BLACK_TRANSPARENT),
|
||||
};
|
||||
final BufferedImage[] nonGrayscaleColors = new BufferedImage[] {
|
||||
oneByOne(RED),
|
||||
oneByOne(GREEN),
|
||||
oneByOne(BLUE),
|
||||
};
|
||||
|
||||
for (BufferedImage image : grayscaleColors)
|
||||
{
|
||||
assertTrue(isGrayscale(image));
|
||||
}
|
||||
for (BufferedImage image : nonGrayscaleColors)
|
||||
{
|
||||
assertFalse(isGrayscale(image));
|
||||
}
|
||||
for (BufferedImage image : ArrayUtils.addAll(grayscaleColors, nonGrayscaleColors))
|
||||
{
|
||||
assertTrue(isGrayscale(ImageUtil.grayscaleImage(image)));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resizeImage()
|
||||
{
|
||||
// TODO: test image contents after changing size
|
||||
|
||||
final BufferedImage larger = ImageUtil.resizeImage(oneByOne(BLACK), 46, 46);
|
||||
final BufferedImage smaller = ImageUtil.resizeImage(centeredPixel(WHITE), 1, 1);
|
||||
final BufferedImage stretched = ImageUtil.resizeImage(solidColor(30, 30, RED), 12, 34);
|
||||
|
||||
assertEquals(46, larger.getWidth());
|
||||
assertEquals(46, larger.getHeight());
|
||||
assertEquals(1, smaller.getWidth());
|
||||
assertEquals(1, smaller.getHeight());
|
||||
assertEquals(12, stretched.getWidth());
|
||||
assertEquals(34, stretched.getHeight());
|
||||
|
||||
final BufferedImage[] assertSameAfterResize = new BufferedImage[] {
|
||||
oneByOne(WHITE),
|
||||
oneByOne(GRAY),
|
||||
oneByOne(BLACK),
|
||||
oneByOne(RED),
|
||||
oneByOne(GREEN),
|
||||
oneByOne(BLUE),
|
||||
oneByOne(BLACK_HALF_TRANSPARENT),
|
||||
oneByOne(BLACK_TRANSPARENT),
|
||||
centeredPixel(WHITE),
|
||||
centeredPixel(GRAY),
|
||||
centeredPixel(BLACK),
|
||||
BLACK_PIXEL_TOP_LEFT,
|
||||
BLACK_PIXEL_TOP_RIGHT,
|
||||
BLACK_PIXEL_BOTTOM_LEFT,
|
||||
BLACK_PIXEL_BOTTOM_RIGHT,
|
||||
};
|
||||
for (BufferedImage image : assertSameAfterResize)
|
||||
{
|
||||
assertTrue(bufferedImagesEqual(image, ImageUtil.resizeImage(image, image.getWidth(), image.getHeight())));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void resizeCanvas()
|
||||
{
|
||||
assertTrue(bufferedImagesEqual(centeredPixel(BLACK), ImageUtil.resizeCanvas(oneByOne(BLACK), 3, 3)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.resizeCanvas(oneByOne(BLACK), 1, 1)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK), ImageUtil.resizeCanvas(centeredPixel(BLACK), 1, 1)));
|
||||
|
||||
BufferedImage expected = new BufferedImage(2, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
expected.setRGB(1, 0, BLACK.getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.resizeCanvas(oneByOne(BLACK), 2, 1)));
|
||||
|
||||
expected = new BufferedImage(1, 2, BufferedImage.TYPE_INT_ARGB);
|
||||
expected.setRGB(0, 1, BLACK.getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.resizeCanvas(oneByOne(BLACK), 1, 2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rotateImage()
|
||||
{
|
||||
// TODO: Test more than 90° rotations
|
||||
|
||||
// Evenly-sized images (2x2)
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_TOP_RIGHT, ImageUtil.rotateImage(BLACK_PIXEL_TOP_LEFT, Math.PI / 2)));
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_BOTTOM_RIGHT, ImageUtil.rotateImage(BLACK_PIXEL_TOP_LEFT, Math.PI)));
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_BOTTOM_LEFT, ImageUtil.rotateImage(BLACK_PIXEL_TOP_LEFT, Math.PI * 3 / 2)));
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_TOP_LEFT, ImageUtil.rotateImage(BLACK_PIXEL_TOP_LEFT, Math.PI * 2)));
|
||||
|
||||
// Unevenly-sized images (2x1); when rotated 90° become (2x2) images
|
||||
final BufferedImage twoByOneLeft = new BufferedImage(2, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
twoByOneLeft.setRGB(0, 0, BLACK.getRGB());
|
||||
final BufferedImage twoByTwoRight = new BufferedImage(2, 1, BufferedImage.TYPE_INT_ARGB);
|
||||
twoByTwoRight.setRGB(1, 0, BLACK.getRGB());
|
||||
final BufferedImage oneByTwoTop = new BufferedImage(2, 2, BufferedImage.TYPE_INT_ARGB);
|
||||
oneByTwoTop.setRGB(1, 0, new Color(0, 0, 0, 127).getRGB());
|
||||
final BufferedImage oneByTwoBottom = new BufferedImage(2, 2, BufferedImage.TYPE_INT_ARGB);
|
||||
oneByTwoBottom.setRGB(0, 0, new Color(0, 0, 0, 127).getRGB());
|
||||
oneByTwoBottom.setRGB(0, 1, BLACK.getRGB());
|
||||
|
||||
assertTrue(bufferedImagesEqual(oneByTwoTop, ImageUtil.rotateImage(twoByOneLeft, Math.PI / 2)));
|
||||
assertTrue(bufferedImagesEqual(twoByTwoRight, ImageUtil.rotateImage(twoByOneLeft, Math.PI)));
|
||||
assertTrue(bufferedImagesEqual(oneByTwoBottom, ImageUtil.rotateImage(twoByOneLeft, Math.PI * 3 / 2)));
|
||||
assertTrue(bufferedImagesEqual(twoByOneLeft, ImageUtil.rotateImage(twoByOneLeft, Math.PI * 2)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flipImage()
|
||||
{
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_TOP_LEFT, ImageUtil.flipImage(BLACK_PIXEL_TOP_LEFT, false, false)));
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_TOP_RIGHT, ImageUtil.flipImage(BLACK_PIXEL_TOP_LEFT, true, false)));
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_BOTTOM_LEFT, ImageUtil.flipImage(BLACK_PIXEL_TOP_LEFT, false, true)));
|
||||
assertTrue(bufferedImagesEqual(BLACK_PIXEL_BOTTOM_RIGHT, ImageUtil.flipImage(BLACK_PIXEL_TOP_LEFT, true, true)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fillImage()
|
||||
{
|
||||
// fillImage(BufferedImage image, Color color)
|
||||
assertTrue(bufferedImagesEqual(centeredPixel(GRAY), ImageUtil.fillImage(centeredPixel(BLACK), GRAY)));
|
||||
assertTrue(bufferedImagesEqual(solidColor(3, 3, GREEN), ImageUtil.fillImage(solidColor(3, 3, BLACK), GREEN)));
|
||||
assertTrue(bufferedImagesEqual(oneByOne(BLACK_TRANSPARENT), ImageUtil.fillImage(oneByOne(BLACK_TRANSPARENT), WHITE)));
|
||||
|
||||
// fillImage(BufferedImage image, Color color, Predicate<Color> fillCondition)
|
||||
BufferedImage expected = solidColor(CORNER_SIZE, CORNER_SIZE, WHITE);
|
||||
expected.setRGB(0, 0, new Color(0, true).getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.fillImage(BLACK_PIXEL_TOP_LEFT, WHITE, ColorUtil::isFullyTransparent)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void outlineImage()
|
||||
{
|
||||
// outlineImage(BufferedImage image, Color color)
|
||||
BufferedImage expected = new BufferedImage(CENTERED_SIZE, CENTERED_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < expected.getWidth(); x++)
|
||||
{
|
||||
for (int y = 0; y < expected.getHeight(); y++)
|
||||
{
|
||||
if (x != 1 && y != 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
expected.setRGB(x, y, BLACK.getRGB());
|
||||
}
|
||||
}
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.outlineImage(centeredPixel(BLACK), BLACK)));
|
||||
expected.setRGB(1, 1, WHITE.getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.outlineImage(centeredPixel(WHITE), BLACK)));
|
||||
expected = solidColor(CORNER_SIZE, CORNER_SIZE, WHITE);
|
||||
expected.setRGB(0, 0, BLACK.getRGB());
|
||||
expected.setRGB(1, 1, new Color(0, true).getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.outlineImage(BLACK_PIXEL_TOP_LEFT, WHITE)));
|
||||
|
||||
// outlineImage(BufferedImage image, Color color, Predicate<Color> fillCondition)
|
||||
BufferedImage test = new BufferedImage(CORNER_SIZE, CORNER_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
test.setRGB(0, 0, BLACK.getRGB());
|
||||
test.setRGB(1, 0, GRAY.getRGB());
|
||||
expected = test;
|
||||
expected.setRGB(0, 1, BLUE.getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.outlineImage(test, BLUE, (color -> color.equals(BLACK)))));
|
||||
|
||||
// outlineImage(BufferedImage image, Color color, Boolean outlineCorners)
|
||||
expected = solidColor(CORNER_SIZE, CORNER_SIZE, WHITE);
|
||||
expected.setRGB(0, 0, BLACK.getRGB());
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.outlineImage(BLACK_PIXEL_TOP_LEFT, WHITE, true)));
|
||||
assertTrue(bufferedImagesEqual(solidColor(3, 3, BLACK), ImageUtil.outlineImage(centeredPixel(BLACK), BLACK, true)));
|
||||
|
||||
// outlineImage(BufferedImage image, Color color, Predicate<Color> fillCondition, Boolean outlineCorners)
|
||||
test = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB);
|
||||
test.setRGB(2, 2, BLACK.getRGB());
|
||||
test.setRGB(1, 2, new Color(50, 50, 50).getRGB());
|
||||
test.setRGB(3, 2, new Color(100, 100, 100).getRGB());
|
||||
test.setRGB(2, 3, new Color(150, 150, 150).getRGB());
|
||||
expected = test;
|
||||
expected.setRGB(2, 1, RED.getRGB());
|
||||
expected.setRGB(3, 1, RED.getRGB());
|
||||
expected.setRGB(4, 1, RED.getRGB());
|
||||
expected.setRGB(4, 2, RED.getRGB());
|
||||
expected.setRGB(1, 3, RED.getRGB());
|
||||
expected.setRGB(3, 3, RED.getRGB());
|
||||
expected.setRGB(4, 3, RED.getRGB());
|
||||
expected.setRGB(1, 4, RED.getRGB());
|
||||
expected.setRGB(2, 4, RED.getRGB());
|
||||
expected.setRGB(3, 4, RED.getRGB());
|
||||
Predicate<Color> testPredicate = (color -> ColorUtil.isNotFullyTransparent(color) && color.getRed() > 75 && color.getGreen() > 75 && color.getBlue() > 75);
|
||||
assertTrue(bufferedImagesEqual(expected, ImageUtil.outlineImage(test, RED, testPredicate, true)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares whether two {@link BufferedImage}s are equal in data.
|
||||
*
|
||||
* @param expected The first {@link BufferedImage} to be compared.
|
||||
* @param actual The second {@link BufferedImage} to be compared.
|
||||
* @return A boolean indicating whether the given {@link BufferedImage}s are of the same image data.
|
||||
*/
|
||||
private boolean bufferedImagesEqual(final @Nonnull BufferedImage expected, final @Nonnull BufferedImage actual)
|
||||
{
|
||||
if (expected.getWidth() != actual.getWidth())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!expected.getColorModel().equals(actual.getColorModel()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final DataBuffer aBuffer = expected.getRaster().getDataBuffer();
|
||||
final DataBuffer bBuffer = actual.getRaster().getDataBuffer();
|
||||
final DataBufferInt aBufferInt = (DataBufferInt) aBuffer;
|
||||
final DataBufferInt bBufferInt = (DataBufferInt) bBuffer;
|
||||
|
||||
if (aBufferInt.getNumBanks() != bBufferInt.getNumBanks())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < aBufferInt.getNumBanks(); i++)
|
||||
{
|
||||
final int[] aDataBank = aBufferInt.getData(i);
|
||||
final int[] bDataBank = bBufferInt.getData(i);
|
||||
if (!Arrays.equals(aDataBank, bDataBank))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a {@link BufferedImage} contains only grayscale pixel data.
|
||||
*
|
||||
* @param image The image to be checked.
|
||||
* @return A boolean indicating whether all of the given image's pixels are grayscale.
|
||||
*/
|
||||
private boolean isGrayscale(final @Nonnull BufferedImage image)
|
||||
{
|
||||
for (int x = 0; x < image.getWidth(); x++)
|
||||
{
|
||||
for (int y = 0; y < image.getHeight(); y++)
|
||||
{
|
||||
final int color = image.getRGB(x, y);
|
||||
final int red = (color & 0xff0000) >> 16;
|
||||
final int green = (color & 0xff00) >> 8;
|
||||
final int blue = color & 0xff;
|
||||
if (red != green
|
||||
|| green != blue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BufferedImage} of a 1-by-1px image of the given color.
|
||||
*
|
||||
* @param color The color to use for the image's single pixel.
|
||||
* @return A {@link BufferedImage} containing a single pixel of the given color.
|
||||
*/
|
||||
private BufferedImage oneByOne(final @Nonnull Color color)
|
||||
{
|
||||
return solidColor(1, 1, color);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BufferedImage} of a single pixel of the given color centered in a 3-by-3px
|
||||
* image.
|
||||
*
|
||||
* @param color The color to use for the centered pixel.
|
||||
* @return A {@link BufferedImage} with completely transparent pixels and one pixel of the
|
||||
* given color in the center.
|
||||
*/
|
||||
private BufferedImage centeredPixel(final @Nonnull Color color)
|
||||
{
|
||||
final BufferedImage out = new BufferedImage(CENTERED_SIZE, CENTERED_SIZE, BufferedImage.TYPE_INT_ARGB);
|
||||
out.setRGB(1, 1, color.getRGB());
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BufferedImage} of a solid color of given width and height.
|
||||
*
|
||||
* @param width The desired width of the color image.
|
||||
* @param height The desired height of the color image.
|
||||
* @param color The desired color of the image.
|
||||
* @return A {@link BufferedImage} of given dimensions filled with the given color.
|
||||
*/
|
||||
private BufferedImage solidColor(final int width, final int height, final @Nonnull Color color)
|
||||
{
|
||||
final BufferedImage out = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
out.setRGB(x, y, color.getRGB());
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, TheStonedTurtle <https://github.com/TheStonedTurtle>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.http.api.loottracker.GameItem;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class ItemUtilTest
|
||||
{
|
||||
private static final Set<Integer> SOME_IDS = ImmutableSet.of(ItemID.MITHRIL_BAR, ItemID.DRAGON_BONES);
|
||||
private static final Set<Integer> WRONG_IDS = ImmutableSet.of(ItemID.SCYTHE_OF_VITUR, ItemID.TWISTED_BOW);
|
||||
private static final Set<Integer> MIX_IDS = ImmutableSet.of(
|
||||
ItemID.MITHRIL_BAR, ItemID.DRAGON_BONES,
|
||||
ItemID.SCYTHE_OF_VITUR, ItemID.TWISTED_BOW
|
||||
);
|
||||
|
||||
private static final Map<Integer, GameItem> SOME_MAP = new HashMap<>();
|
||||
private static final Map<Integer, GameItem> ALL_MAP = new HashMap<>();
|
||||
|
||||
private static final Item[] items = new Item[6];
|
||||
|
||||
static
|
||||
{
|
||||
SOME_MAP.put(ItemID.MITHRIL_BAR, new GameItem(ItemID.MITHRIL_BAR, 6));
|
||||
SOME_MAP.put(ItemID.DRAGON_BONES, new GameItem(ItemID.DRAGON_BONES, 2));
|
||||
|
||||
ALL_MAP.putAll(SOME_MAP);
|
||||
ALL_MAP.put(ItemID.COINS_995, new GameItem(ItemID.COINS_995, 1000));
|
||||
ALL_MAP.put(ItemID.CHEWED_BONES, new GameItem(ItemID.CHEWED_BONES, 1));
|
||||
|
||||
items[0] = createItem(ItemID.MITHRIL_BAR, 3);
|
||||
items[1] = createItem(ItemID.DRAGON_BONES, 1);
|
||||
items[2] = createItem(ItemID.COINS_995, 1000);
|
||||
|
||||
items[3] = createItem(ItemID.MITHRIL_BAR, 3);
|
||||
items[4] = createItem(ItemID.DRAGON_BONES, 1);
|
||||
items[5] = createItem(ItemID.CHEWED_BONES, 1);
|
||||
}
|
||||
|
||||
private static Item createItem(int id, int qty)
|
||||
{
|
||||
Item i = mock(Item.class);
|
||||
when(i.getId())
|
||||
.thenReturn(id);
|
||||
when(i.getQuantity())
|
||||
.thenReturn(qty);
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toGameItemMap()
|
||||
{
|
||||
Map<Integer, GameItem> itemMap = ItemUtil.toGameItemMap(items, SOME_IDS);
|
||||
assertEquals(SOME_MAP, itemMap);
|
||||
assertNotEquals(ALL_MAP, itemMap);
|
||||
|
||||
Map<Integer, GameItem> itemMap2 = ItemUtil.toGameItemMap(items);
|
||||
assertNotEquals(SOME_MAP, itemMap2);
|
||||
assertEquals(ALL_MAP, itemMap2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsAllItemIds()
|
||||
{
|
||||
assertTrue(ItemUtil.containsAllItemIds(items, SOME_IDS));
|
||||
assertFalse(ItemUtil.containsAllItemIds(items, WRONG_IDS));
|
||||
assertFalse(ItemUtil.containsAllItemIds(items, MIX_IDS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsAnyItemId()
|
||||
{
|
||||
assertTrue(ItemUtil.containsAnyItemId(items, SOME_IDS));
|
||||
assertFalse(ItemUtil.containsAnyItemId(items, WRONG_IDS));
|
||||
assertTrue(ItemUtil.containsAnyItemId(items, MIX_IDS));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsItemId()
|
||||
{
|
||||
assertTrue(ItemUtil.containsItemId(items, ItemID.COINS_995));
|
||||
assertFalse(ItemUtil.containsItemId(items, ItemID.TWISTED_BOW));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void containsAllGameItems()
|
||||
{
|
||||
assertTrue(ItemUtil.containsAllGameItems(items, SOME_MAP.values()));
|
||||
assertTrue(ItemUtil.containsAllGameItems(items, ALL_MAP.values()));
|
||||
|
||||
Collection<GameItem> wrongItems = new ArrayList<>(SOME_MAP.values());
|
||||
wrongItems.add(new GameItem(ItemID.TWISTED_BOW, 1));
|
||||
assertFalse(ItemUtil.containsAllGameItems(items, wrongItems));
|
||||
|
||||
assertFalse(ItemUtil.containsAllGameItems(items, new GameItem(ItemID.MITHRIL_BAR, 7)));
|
||||
assertTrue(ItemUtil.containsAllGameItems(items, new GameItem(ItemID.MITHRIL_BAR, 6)));
|
||||
assertTrue(ItemUtil.containsAllGameItems(items, new GameItem(ItemID.MITHRIL_BAR, 5)));
|
||||
assertFalse(ItemUtil.containsAllGameItems(items, new GameItem(ItemID.MITHRIL_BAR, 5), new GameItem(ItemID.TWISTED_BOW, 1)));
|
||||
}
|
||||
}
|
||||
@@ -1,159 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, arlyon <https://github.com/arlyon>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.util.Locale;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
public class StackFormatterTest
|
||||
{
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
Locale.setDefault(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quantityToRSDecimalStackSize()
|
||||
{
|
||||
assertEquals("0", StackFormatter.quantityToRSDecimalStack(0));
|
||||
assertEquals("8500", StackFormatter.quantityToRSDecimalStack(8_500));
|
||||
assertEquals("10K", StackFormatter.quantityToRSDecimalStack(10_000));
|
||||
assertEquals("21.7K", StackFormatter.quantityToRSDecimalStack(21_700));
|
||||
assertEquals("100K", StackFormatter.quantityToRSDecimalStack(100_000));
|
||||
assertEquals("100.3K", StackFormatter.quantityToRSDecimalStack(100_300));
|
||||
assertEquals("1M", StackFormatter.quantityToRSDecimalStack(1_000_000));
|
||||
assertEquals("8.4M", StackFormatter.quantityToRSDecimalStack(8_450_000));
|
||||
assertEquals("10M", StackFormatter.quantityToRSDecimalStack(10_000_000));
|
||||
assertEquals("12.8M", StackFormatter.quantityToRSDecimalStack(12_800_000));
|
||||
assertEquals("100M", StackFormatter.quantityToRSDecimalStack(100_000_000));
|
||||
assertEquals("250.1M", StackFormatter.quantityToRSDecimalStack(250_100_000));
|
||||
assertEquals("1B", StackFormatter.quantityToRSDecimalStack(1_000_000_000));
|
||||
assertEquals("1.5B", StackFormatter.quantityToRSDecimalStack(1500_000_000));
|
||||
assertEquals("2.1B", StackFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quantityToRSStackSize()
|
||||
{
|
||||
assertEquals("0", StackFormatter.quantityToRSStackSize(0));
|
||||
assertEquals("99999", StackFormatter.quantityToRSStackSize(99_999));
|
||||
assertEquals("100K", StackFormatter.quantityToRSStackSize(100_000));
|
||||
assertEquals("10M", StackFormatter.quantityToRSStackSize(10_000_000));
|
||||
assertEquals("2147M", StackFormatter.quantityToRSStackSize(Integer.MAX_VALUE));
|
||||
|
||||
assertEquals("0", StackFormatter.quantityToRSStackSize(-0));
|
||||
assertEquals("-400", StackFormatter.quantityToRSStackSize(-400));
|
||||
assertEquals("-400K", StackFormatter.quantityToRSStackSize(-400_000));
|
||||
assertEquals("-40M", StackFormatter.quantityToRSStackSize(-40_000_000));
|
||||
assertEquals("-2147M", StackFormatter.quantityToRSStackSize(Integer.MIN_VALUE));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quantityToStackSize()
|
||||
{
|
||||
assertEquals("0", StackFormatter.quantityToStackSize(0));
|
||||
assertEquals("999", StackFormatter.quantityToStackSize(999));
|
||||
assertEquals("1,000", StackFormatter.quantityToStackSize(1000));
|
||||
assertEquals("9,450", StackFormatter.quantityToStackSize(9450));
|
||||
assertEquals("14.5K", StackFormatter.quantityToStackSize(14_500));
|
||||
assertEquals("99.9K", StackFormatter.quantityToStackSize(99_920));
|
||||
assertEquals("100K", StackFormatter.quantityToStackSize(100_000));
|
||||
assertEquals("10M", StackFormatter.quantityToStackSize(10_000_000));
|
||||
assertEquals("2.14B", StackFormatter.quantityToStackSize(Integer.MAX_VALUE));
|
||||
assertEquals("100B", StackFormatter.quantityToStackSize(100_000_000_000L));
|
||||
|
||||
assertEquals("0", StackFormatter.quantityToStackSize(-0));
|
||||
assertEquals("-400", StackFormatter.quantityToStackSize(-400));
|
||||
assertEquals("-400K", StackFormatter.quantityToStackSize(-400_000));
|
||||
assertEquals("-40M", StackFormatter.quantityToStackSize(-40_000_000));
|
||||
assertEquals("-2.14B", StackFormatter.quantityToStackSize(Integer.MIN_VALUE));
|
||||
assertEquals("-400B", StackFormatter.quantityToStackSize(-400_000_000_000L));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quantityToPreciseStackSize()
|
||||
{
|
||||
assertEquals("0", StackFormatter.quantityToRSDecimalStack(0));
|
||||
assertEquals("8500", StackFormatter.quantityToRSDecimalStack(8_500, true));
|
||||
assertEquals("10K", StackFormatter.quantityToRSDecimalStack(10_000, true));
|
||||
assertEquals("21.7K", StackFormatter.quantityToRSDecimalStack(21_710, true));
|
||||
assertEquals("100K", StackFormatter.quantityToRSDecimalStack(100_000, true));
|
||||
assertEquals("100.3K", StackFormatter.quantityToRSDecimalStack(100_310, true));
|
||||
assertEquals("1M", StackFormatter.quantityToRSDecimalStack(1_000_000, true));
|
||||
assertEquals("8.45M", StackFormatter.quantityToRSDecimalStack(8_450_000, true));
|
||||
assertEquals("8.451M", StackFormatter.quantityToRSDecimalStack(8_451_000, true));
|
||||
assertEquals("10M", StackFormatter.quantityToRSDecimalStack(10_000_000, true));
|
||||
assertEquals("12.8M", StackFormatter.quantityToRSDecimalStack(12_800_000, true));
|
||||
assertEquals("12.85M", StackFormatter.quantityToRSDecimalStack(12_850_000, true));
|
||||
assertEquals("12.851M", StackFormatter.quantityToRSDecimalStack(12_851_000, true));
|
||||
assertEquals("100M", StackFormatter.quantityToRSDecimalStack(100_000_000, true));
|
||||
assertEquals("250.1M", StackFormatter.quantityToRSDecimalStack(250_100_000, true));
|
||||
assertEquals("250.151M", StackFormatter.quantityToRSDecimalStack(250_151_000, true));
|
||||
assertEquals("1B", StackFormatter.quantityToRSDecimalStack(1_000_000_000, true));
|
||||
assertEquals("1.5B", StackFormatter.quantityToRSDecimalStack(1500_000_000, true));
|
||||
assertEquals("1.55B", StackFormatter.quantityToRSDecimalStack(1550_000_000, true));
|
||||
assertEquals("2.147B", StackFormatter.quantityToRSDecimalStack(Integer.MAX_VALUE, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void stackSizeToQuantity() throws ParseException
|
||||
{
|
||||
assertEquals(0, StackFormatter.stackSizeToQuantity("0"));
|
||||
assertEquals(907, StackFormatter.stackSizeToQuantity("907"));
|
||||
assertEquals(1200, StackFormatter.stackSizeToQuantity("1200"));
|
||||
assertEquals(10_500, StackFormatter.stackSizeToQuantity("10,500"));
|
||||
assertEquals(10_500, StackFormatter.stackSizeToQuantity("10.5K"));
|
||||
assertEquals(33_560_000, StackFormatter.stackSizeToQuantity("33.56M"));
|
||||
assertEquals(2_000_000_000, StackFormatter.stackSizeToQuantity("2B"));
|
||||
|
||||
assertEquals(0, StackFormatter.stackSizeToQuantity("-0"));
|
||||
assertEquals(-400, StackFormatter.stackSizeToQuantity("-400"));
|
||||
assertEquals(-400_000, StackFormatter.stackSizeToQuantity("-400k"));
|
||||
assertEquals(-40_543_000, StackFormatter.stackSizeToQuantity("-40.543M"));
|
||||
|
||||
try
|
||||
{
|
||||
StackFormatter.stackSizeToQuantity("0L");
|
||||
fail("Should have thrown an exception for invalid suffix.");
|
||||
}
|
||||
catch (ParseException ignore)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
StackFormatter.stackSizeToQuantity("badstack");
|
||||
fail("Should have thrown an exception for improperly formatted stack.");
|
||||
}
|
||||
catch (ParseException ignore)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Joshua Filby <joshua@filby.me>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
public class TextTest
|
||||
{
|
||||
@Test
|
||||
public void removeTags()
|
||||
{
|
||||
assertEquals("Test", Text.removeTags("<col=FFFFFF>Test</col>"));
|
||||
assertEquals("Test", Text.removeTags("<img=1><s>Test</s>"));
|
||||
assertEquals("Zezima (level-126)", Text.removeTags("<col=ffffff><img=2>Zezima<col=00ffff> (level-126)"));
|
||||
assertEquals("", Text.removeTags("<colrandomtext test>"));
|
||||
assertEquals("Not so much.", Text.removeTags("<col=FFFFFF This is a very special message.</col>Not so much."));
|
||||
assertEquals("Use Item -> Man", Text.removeTags("Use Item -> Man"));
|
||||
assertEquals("a < b", Text.removeTags("a < b"));
|
||||
assertEquals("Remove no tags", Text.removeTags("Remove no tags"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package net.runelite.client.util;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static net.runelite.client.util.WildcardMatcher.matches;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import org.junit.Test;
|
||||
|
||||
public class WildcardMatcherTest
|
||||
{
|
||||
@Test
|
||||
public void testMatches()
|
||||
{
|
||||
assertTrue(matches("rune*", "rune pouch"));
|
||||
assertTrue(matches("rune*", "Rune pouch"));
|
||||
assertFalse(matches("Abyssal whip", "Adamant dagger"));
|
||||
assertTrue(matches("rune*", "Runeite Ore"));
|
||||
assertTrue(matches("Abyssal whip", "Abyssal whip"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user