|
| 1 | +package com.github.sarxos.webcam.util.jh; |
| 2 | + |
| 3 | +import java.awt.image.BufferedImage; |
| 4 | + |
| 5 | +import org.assertj.core.api.Assertions; |
| 6 | +import org.junit.Test; |
| 7 | + |
| 8 | + |
| 9 | +public class JHBlurFilterTest { |
| 10 | + |
| 11 | + @Test |
| 12 | + public void test_filterNonPremultiplied() { |
| 13 | + |
| 14 | + final JHBlurFilter filter = new JHBlurFilter(); |
| 15 | + filter.setPremultiplyAlpha(false); |
| 16 | + |
| 17 | + final BufferedImage bi1 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); |
| 18 | + final BufferedImage bi2 = filter.filter(bi1, null); |
| 19 | + |
| 20 | + Assertions |
| 21 | + .assertThat(bi1.getWidth()) |
| 22 | + .isEqualTo(bi2.getWidth()); |
| 23 | + Assertions |
| 24 | + .assertThat(bi1.getHeight()) |
| 25 | + .isEqualTo(bi2.getHeight()); |
| 26 | + Assertions |
| 27 | + .assertThat(bi1.getType()) |
| 28 | + .isEqualTo(bi2.getType()); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void test_filterPremultiplied() { |
| 33 | + |
| 34 | + final JHBlurFilter filter = new JHBlurFilter(); |
| 35 | + filter.setPremultiplyAlpha(true); |
| 36 | + |
| 37 | + final BufferedImage bi1 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB); |
| 38 | + final BufferedImage bi2 = filter.filter(bi1, null); |
| 39 | + |
| 40 | + Assertions |
| 41 | + .assertThat(bi1.getWidth()) |
| 42 | + .isEqualTo(bi2.getWidth()); |
| 43 | + Assertions |
| 44 | + .assertThat(bi1.getHeight()) |
| 45 | + .isEqualTo(bi2.getHeight()); |
| 46 | + Assertions |
| 47 | + .assertThat(bi1.getType()) |
| 48 | + .isEqualTo(bi2.getType()); |
| 49 | + } |
| 50 | + |
| 51 | + @Test |
| 52 | + public void test_setGetPremultiplyAlpha() { |
| 53 | + |
| 54 | + final JHBlurFilter filter = new JHBlurFilter(); |
| 55 | + |
| 56 | + filter.setPremultiplyAlpha(true); |
| 57 | + Assertions |
| 58 | + .assertThat(filter.getPremultiplyAlpha()) |
| 59 | + .isTrue(); |
| 60 | + |
| 61 | + filter.setPremultiplyAlpha(false); |
| 62 | + Assertions |
| 63 | + .assertThat(filter.getPremultiplyAlpha()) |
| 64 | + .isFalse(); |
| 65 | + } |
| 66 | +} |
0 commit comments