imagecomparison-parent


Лицензия

Лицензия

Категории

Категории

Сеть
Группа

Группа

net.avh4.util
Идентификатор

Идентификатор

imagecomparison-parent
Последняя версия

Последняя версия

0.3.2
Дата

Дата

Тип

Тип

pom
Описание

Описание

imagecomparison-parent
Ссылка на сайт

Ссылка на сайт

https://github.com/avh4/imagecomparison
Система контроля версий

Система контроля версий

https://github.com/avh4/imagecomparison

Скачать imagecomparison-parent

Имя Файла Размер
imagecomparison-parent-0.3.2.pom 1 KB
Обзор

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/net.avh4.util/imagecomparison-parent/ -->
<dependency>
    <groupId>net.avh4.util</groupId>
    <artifactId>imagecomparison-parent</artifactId>
    <version>0.3.2</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/net.avh4.util/imagecomparison-parent/
implementation 'net.avh4.util:imagecomparison-parent:0.3.2'
// https://jarcasting.com/artifacts/net.avh4.util/imagecomparison-parent/
implementation ("net.avh4.util:imagecomparison-parent:0.3.2")
'net.avh4.util:imagecomparison-parent:pom:0.3.2'
<dependency org="net.avh4.util" name="imagecomparison-parent" rev="0.3.2">
  <artifact name="imagecomparison-parent" type="pom" />
</dependency>
@Grapes(
@Grab(group='net.avh4.util', module='imagecomparison-parent', version='0.3.2')
)
libraryDependencies += "net.avh4.util" % "imagecomparison-parent" % "0.3.2"
[net.avh4.util/imagecomparison-parent "0.3.2"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

  • imagecomparison
  • imagecomparison-swing
  • imagecomparison-swt

Build Status

Usage

Add the following dependencies to your pom.xml:

  <dependency>
    <groupId>net.avh4.util</groupId>
    <artifactId>imagecomparison</artifactId>
    <version>0.3.1</version>
  </dependency>
  <!-- if you will be comparing AWT components, Swing JComponents or JFrames: -->
  <dependency>
    <groupId>net.avh4.util</groupId>
    <artifactId>imagecomparison-swing</artifactId>
    <version>0.3.1</version>
    <scope>runtime</scope>
  </dependency>
  <!-- if you will be comparing SWT components -->
  <dependency>
    <groupId>net.avh4.util</groupId>
    <artifactId>imagecomparison-swt</artifactId>
    <version>0.3.1</version>
    <scope>runtime</scope>
  </dependency>

isApproved() hamcrest matcher

import static net.avh4.util.imagecomparison.hamcrest.ImageComparisonMatchers.*;

public class MyJComponentTest {
  @Test public void testInitialState() throws Exception {
    MyJComponent subject = new MyJComponent();
    assertThat(subject, isApproved());
  }
}

This will assert that the rendering of subject matches MyJComponentTest.testInitialState.png (taken from the test class and method name), which will be loaded from the classpath in the same package as the test class.

You'll probably see something like this:

Failed tests: 
  testInitialState(MyJComponentTest): 
Expected: something that looks like MyJComponentTest.testInitialState.png (800x600)
     but: images don't match: First incorrect pixel was (0, 0): expected 0xffffff, but got 0x0

The actual rendering of the object will be written to ./MyJComponentTest.testInitialState.png for you to inspect.

looksLike() hamcrest matcher

You can also compare objects to specific image files.

assertThat(subject, looksLike("snazzy-dashboard.png"));

Comparison API

ImageComparisonResult result = ImageComparison.compare(new MyJComponent(), "./snazzy-dashboard.png");
boolean renderingMatches = result.isEqual();
if (!renderingMatches) {
  System.out.println(result.getFailureMessage());
  result.writeActualImageToFile("failed-rendering.png");
}

What you can test

The looks-like checker currently can check the following types of objects:

  • java.awt.image.BufferedImage
  • with imagecomparison-swing: java.awt.Component
  • with imagecomparison-swing: javax.swing.JComponent
  • with imagecomparison-swing: javax.swing.JFrame
  • with imagecomparison-swt: org.eclipse.swt.graphics.Image
  • with imagecomparison-swt: org.eclipse.swt.graphics.ImageData
  • with imagecomparison-swt: org.eclipse.swt.widgets.Control

Additional renderers can be added by implementing net.avh4.util.imagerender.Renderer and registering in META-INF/services (see ServiceLoader).

Версии библиотеки

Версия
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.2
0.1.1
0.1.0
0.0.6
0.0.5