Merge remote-tracking branch 'Upstream/master'
# Conflicts: # runelite-api/src/main/java/net/runelite/api/Client.java # runelite-api/src/main/java/net/runelite/api/TileItem.java # runelite-api/src/main/java/net/runelite/api/events/ItemDespawned.java # runelite-api/src/main/java/net/runelite/api/events/ItemQuantityChanged.java # runelite-api/src/main/java/net/runelite/api/events/ItemSpawned.java # runelite-client/src/main/java/net/runelite/client/game/ItemManager.java # runelite-client/src/main/java/net/runelite/client/plugins/banktags/tabs/TabInterface.java # runelite-client/src/main/java/net/runelite/client/plugins/chatboxperformance/ChatboxPerformancePlugin.java # runelite-client/src/main/java/net/runelite/client/plugins/grounditems/GroundItemsPlugin.java # runelite-client/src/main/java/net/runelite/client/plugins/groundmarkers/GroundMarkerPlugin.java # runelite-client/src/main/java/net/runelite/client/plugins/interfacestyles/InterfaceStylesPlugin.java # runelite-client/src/main/java/net/runelite/client/plugins/loottracker/LootTrackerPlugin.java # runelite-client/src/main/java/net/runelite/client/plugins/mta/enchantment/EnchantmentRoom.java # runelite-client/src/main/java/net/runelite/client/plugins/npchighlight/NpcIndicatorsPlugin.java # runelite-client/src/main/java/net/runelite/client/plugins/objectindicators/ObjectIndicatorsPlugin.java
This commit is contained in:
@@ -67,17 +67,9 @@ public class ContainerCalculationTest
|
||||
@Test
|
||||
public void testCalculate()
|
||||
{
|
||||
Item coins = mock(Item.class);
|
||||
when(coins.getId())
|
||||
.thenReturn(ItemID.COINS_995);
|
||||
when(coins.getQuantity())
|
||||
.thenReturn(Integer.MAX_VALUE);
|
||||
Item coins = new Item(ItemID.COINS_995, Integer.MAX_VALUE);
|
||||
|
||||
Item whip = mock(Item.class);
|
||||
when(whip.getId())
|
||||
.thenReturn(ItemID.ABYSSAL_WHIP);
|
||||
when(whip.getQuantity())
|
||||
.thenReturn(1_000_000_000);
|
||||
Item whip = new Item(ItemID.ABYSSAL_WHIP, 1_000_000_000);
|
||||
|
||||
Item[] items = ImmutableList.of(
|
||||
coins,
|
||||
|
||||
@@ -54,7 +54,6 @@ public class ChatFilterPluginTest
|
||||
private ChatFilterConfig chatFilterConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Player localPlayer;
|
||||
|
||||
@Inject
|
||||
@@ -121,6 +120,16 @@ public class ChatFilterPluginTest
|
||||
assertNull(chatFilterPlugin.censorMessage("te\u008Cst"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReplayedMessage()
|
||||
{
|
||||
when(chatFilterConfig.filterType()).thenReturn(ChatFilterType.REMOVE_MESSAGE);
|
||||
when(chatFilterConfig.filteredWords()).thenReturn("hello osrs");
|
||||
|
||||
chatFilterPlugin.updateFilteredPatterns();
|
||||
assertNull(chatFilterPlugin.censorMessage("hello\u00A0osrs"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMessageFromFriendIsFiltered()
|
||||
{
|
||||
|
||||
@@ -44,6 +44,8 @@ import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class EmojiPluginTest
|
||||
@@ -113,4 +115,17 @@ public class EmojiPluginTest
|
||||
|
||||
verify(messageNode).setRuneLiteFormatMessage("<img=10>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmojiUpdateMessage()
|
||||
{
|
||||
String PARTY_POPPER = "<img=" + (-1 + Emoji.getEmoji("@@@").ordinal()) + '>';
|
||||
String OPEN_MOUTH = "<img=" + (-1 + Emoji.getEmoji(":O").ordinal()) + '>';
|
||||
assertNull(emojiPlugin.updateMessage("@@@@@"));
|
||||
assertEquals(PARTY_POPPER, emojiPlugin.updateMessage("@@@"));
|
||||
assertEquals(PARTY_POPPER + ' ' + PARTY_POPPER, emojiPlugin.updateMessage("@@@ @@@"));
|
||||
assertEquals(PARTY_POPPER + ' ' + OPEN_MOUTH, emojiPlugin.updateMessage("@@@\u00A0:O"));
|
||||
assertEquals(PARTY_POPPER + ' ' + OPEN_MOUTH + ' ' + PARTY_POPPER, emojiPlugin.updateMessage("@@@\u00A0:O @@@"));
|
||||
assertEquals(PARTY_POPPER + " Hello World " + PARTY_POPPER, emojiPlugin.updateMessage("@@@\u00A0Hello World\u00A0@@@"));
|
||||
}
|
||||
}
|
||||
@@ -135,8 +135,7 @@ public class ItemChargePluginTest
|
||||
when(client.getItemContainer(eq(InventoryID.EQUIPMENT))).thenReturn(equipmentItemContainer);
|
||||
Item[] items = new Item[EquipmentInventorySlot.RING.getSlotIdx() + 1];
|
||||
when(equipmentItemContainer.getItems()).thenReturn(items);
|
||||
Item ring = mock(Item.class);
|
||||
when(ring.getId()).thenReturn(ItemID.RING_OF_FORGING);
|
||||
Item ring = new Item(ItemID.RING_OF_FORGING, 1);
|
||||
items[EquipmentInventorySlot.RING.getSlotIdx()] = ring;
|
||||
// Run message
|
||||
chatMessage = new ChatMessage(null, ChatMessageType.GAMEMESSAGE, "", USED_RING_OF_FORGING, "", 0);
|
||||
|
||||
@@ -100,18 +100,13 @@ public class ItemsKeptOnDeathPluginTest
|
||||
when(itemManager.canonicalize(id)).thenReturn(id);
|
||||
when(itemManager.getItemPrice(id, true)).thenReturn(price);
|
||||
|
||||
return mockItem(id, qty);
|
||||
return item(id, qty);
|
||||
}
|
||||
|
||||
// Creates a mocked item
|
||||
private Item mockItem(final int id, final int qty)
|
||||
// Creates a new item
|
||||
private static Item item(final int id, final int qty)
|
||||
{
|
||||
Item item = mock(Item.class);
|
||||
|
||||
when(item.getId()).thenReturn(id);
|
||||
when(item.getQuantity()).thenReturn(qty);
|
||||
|
||||
return item;
|
||||
return new Item(id, qty);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -126,12 +126,12 @@ public class MotherlodePluginTest
|
||||
// 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),
|
||||
item(ItemID.RUNITE_ORE, 1),
|
||||
item(ItemID.GOLDEN_NUGGET, 4),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
|
||||
};
|
||||
when(inventory.getItems())
|
||||
@@ -145,16 +145,16 @@ public class MotherlodePluginTest
|
||||
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),
|
||||
item(ItemID.RUNITE_ORE, 1),
|
||||
item(ItemID.RUNITE_ORE, 1),
|
||||
item(ItemID.GOLDEN_NUGGET, 8),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.COAL, 1),
|
||||
item(ItemID.ADAMANTITE_ORE, 1),
|
||||
|
||||
};
|
||||
when(inventory.getItems())
|
||||
@@ -171,11 +171,8 @@ public class MotherlodePluginTest
|
||||
verifyNoMoreInteractions(motherlodeSession);
|
||||
}
|
||||
|
||||
private static Item mockItem(int itemId, int quantity)
|
||||
private static Item item(int itemId, int quantity)
|
||||
{
|
||||
Item item = mock(Item.class);
|
||||
when(item.getId()).thenReturn(itemId);
|
||||
when(item.getQuantity()).thenReturn(quantity);
|
||||
return item;
|
||||
return new Item(itemId, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.ui.overlay.components;
|
||||
|
||||
import java.awt.FontMetrics;
|
||||
import static net.runelite.client.ui.overlay.components.TooltipComponent.calculateTextWidth;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
import static org.mockito.Matchers.anyString;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class TooltipComponentTest
|
||||
{
|
||||
@Test
|
||||
public void testCalculateTextWidth()
|
||||
{
|
||||
FontMetrics fontMetics = mock(FontMetrics.class);
|
||||
when(fontMetics.stringWidth(anyString())).thenAnswer((invocation) -> ((String) invocation.getArguments()[0]).length());
|
||||
|
||||
assertEquals(11, calculateTextWidth(fontMetics, "line1<col=ff0000>>line2"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user