Skip to content

Commit

Permalink
Add unit test for JHBlurFilter
Browse files Browse the repository at this point in the history
  • Loading branch information
sarxos committed Sep 14, 2017
1 parent 55c9bda commit 524f7ba
Showing 1 changed file with 66 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.github.sarxos.webcam.util.jh;

import java.awt.image.BufferedImage;

import org.assertj.core.api.Assertions;
import org.junit.Test;


public class JHBlurFilterTest {

@Test
public void test_filterNonPremultiplied() {

final JHBlurFilter filter = new JHBlurFilter();
filter.setPremultiplyAlpha(false);

final BufferedImage bi1 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
final BufferedImage bi2 = filter.filter(bi1, null);

Assertions
.assertThat(bi1.getWidth())
.isEqualTo(bi2.getWidth());
Assertions
.assertThat(bi1.getHeight())
.isEqualTo(bi2.getHeight());
Assertions
.assertThat(bi1.getType())
.isEqualTo(bi2.getType());
}

@Test
public void test_filterPremultiplied() {

final JHBlurFilter filter = new JHBlurFilter();
filter.setPremultiplyAlpha(true);

final BufferedImage bi1 = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
final BufferedImage bi2 = filter.filter(bi1, null);

Assertions
.assertThat(bi1.getWidth())
.isEqualTo(bi2.getWidth());
Assertions
.assertThat(bi1.getHeight())
.isEqualTo(bi2.getHeight());
Assertions
.assertThat(bi1.getType())
.isEqualTo(bi2.getType());
}

@Test
public void test_setGetPremultiplyAlpha() {

final JHBlurFilter filter = new JHBlurFilter();

filter.setPremultiplyAlpha(true);
Assertions
.assertThat(filter.getPremultiplyAlpha())
.isTrue();

filter.setPremultiplyAlpha(false);
Assertions
.assertThat(filter.getPremultiplyAlpha())
.isFalse();
}
}

0 comments on commit 524f7ba

Please sign in to comment.