project: Merge upstream
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
||||
public class ContainableFrameTest
|
||||
{
|
||||
@Test
|
||||
public void testJdk8231564()
|
||||
{
|
||||
assertTrue(ContainableFrame.jdk8231564("11.0.8"));
|
||||
assertFalse(ContainableFrame.jdk8231564("11.0.7"));
|
||||
assertFalse(ContainableFrame.jdk8231564("1.8.0_261"));
|
||||
assertFalse(ContainableFrame.jdk8231564("12.0.0"));
|
||||
assertFalse(ContainableFrame.jdk8231564("13.0.0"));
|
||||
assertFalse(ContainableFrame.jdk8231564("14.0.0"));
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,8 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.config.OpenOSRSConfig;
|
||||
import net.runelite.client.config.RuneLiteConfig;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
@@ -58,6 +60,14 @@ public class InfoBoxManagerTest
|
||||
@Bind
|
||||
private OpenOSRSConfig openOSRSConfig;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private ConfigManager configManager;
|
||||
|
||||
@Mock
|
||||
@Bind
|
||||
private Client client;
|
||||
|
||||
@Before
|
||||
public void before()
|
||||
{
|
||||
|
||||
@@ -28,8 +28,6 @@ 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
|
||||
@@ -97,26 +95,4 @@ public class ColorUtilTest
|
||||
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)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ 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;
|
||||
@@ -256,11 +255,6 @@ public class ImageUtilTest
|
||||
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
|
||||
@@ -287,39 +281,11 @@ public class ImageUtilTest
|
||||
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)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user