From 914e0f9e852ecbb7871d1d24241ecc3849922f9f Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sat, 28 Oct 2017 19:09:42 +0200 Subject: [PATCH 01/18] set version to 0.8.3-SNAPSHOT --- CHANGELOG.md | 33 +++++++++++++++++++ docker/RELEASE/Dockerfile | 10 +++--- docker/RELEASE/README.md | 3 +- docker/SNAPSHOT-local_from-Tomcat/Dockerfile | 2 +- docker/SNAPSHOT-local_from-Ubuntu/Dockerfile | 2 +- .../test_conf-default-algo/Dockerfile | 2 +- .../test_conf-env_debug/Dockerfile | 2 +- .../test_conf-piwik/Dockerfile | 2 +- .../pre-requisites_from-Ubuntu/Dockerfile | 2 +- documentation/pom.xml | 4 +-- engine/api/pom.xml | 4 +-- engine/hsv/pom.xml | 4 +-- engine/impl/pom.xml | 4 +-- engine/pom.xml | 4 +-- engine/utils/pom.xml | 4 +-- pom.xml | 2 +- webapp/pom.xml | 4 +-- .../WEB-INF/template/template_variables.jspf | 2 +- 18 files changed, 62 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cbca7c2..1e11a557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,38 @@ # CHANGELOG +Contrast-Finder 0.8.3, 2017-11-xx +--------------------------------- + +Upgrade-o-meter: just replace the .war file and restart Tomcat + +### New Feature +none + +### Security +none + +### Outdated dependencies +none + +### Bug +none + +### Improvement +none + +### Refactoring +none + +### Configuration +none + +### Documentation +none + +### Task +none + + Contrast-Finder 0.8.2, 2017-10-28 --------------------------------- diff --git a/docker/RELEASE/Dockerfile b/docker/RELEASE/Dockerfile index 0b5bf0ea..cac62697 100644 --- a/docker/RELEASE/Dockerfile +++ b/docker/RELEASE/Dockerfile @@ -1,7 +1,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu LABEL org.label-schema.schema-version = "1.0.0-rc.1" \ org.label-schema.name = "Contrast-Finder - WebApp" \ - org.label-schema.version = "0.8.2" \ + org.label-schema.version = "0.8.3-SNAPSHOT" \ org.label-schema.url = "https://contrast-finder.org" \ org.label-schema.vcs-url = "https://github.com/Asqatasun/Contrast-Finder" \ org.label-schema.docker.cmd = "docker run -p 8087:8080 -d asqatasun/contrast-finder" \ @@ -13,9 +13,9 @@ LABEL org.label-schema.schema-version = "1.0.0-rc.1" # # --- Building this docker image # docker build -t asqatasun/contrast-finder . -# docker build -t asqatasun/contrast-finder --build-arg CONTRAST_FINDER_RELEASE=0.8.2 . -# docker build -t asqatasun/contrast-finder --build-arg SRC_URL_PREFIX=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.2/ . -# docker build -t asqatasun/contrast-finder --build-arg SRC_URL=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.2/contrast-finder_0.8.2.i386.tar.gz . +# docker build -t asqatasun/contrast-finder --build-arg CONTRAST_FINDER_RELEASE=0.8.3-SNAPSHOT . +# docker build -t asqatasun/contrast-finder --build-arg SRC_URL_PREFIX=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.3-SNAPSHOT/ . +# docker build -t asqatasun/contrast-finder --build-arg SRC_URL=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.3-SNAPSHOT/contrast-finder_0.8.3-SNAPSHOT.i386.tar.gz . # # --- Launch a container # docker run -p 127.0.0.1:8087:8080 --name contrast.finder -d asqatasun/contrast-finder @@ -36,7 +36,7 @@ LABEL org.label-schema.schema-version = "1.0.0-rc.1" ################################################################### # build variables -ARG CONTRAST_FINDER_RELEASE="0.8.2" +ARG CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" ARG SRC_URL_PREFIX="https://github.com/Asqatasun/Contrast-Finder/releases/download/v${CONTRAST_FINDER_RELEASE}" ARG SRC_URL="${SRC_URL_PREFIX}/contrast-finder_${CONTRAST_FINDER_RELEASE}.i386.tar.gz" diff --git a/docker/RELEASE/README.md b/docker/RELEASE/README.md index 5674b351..52d58a32 100644 --- a/docker/RELEASE/README.md +++ b/docker/RELEASE/README.md @@ -7,7 +7,8 @@ Tool to provide color combination for a good (accessible, WCAG-compliant) contra Supported tags and respective `Dockerfile` links : * [pre-requisites_from-Ubuntu](https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile) -* [v0.8.2, latest](https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/RELEASE/Dockerfile) +* [v0.8.3-SNAPSHOT, latest](https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/RELEASE/Dockerfile) +* [v0.8.2](https://github.com/Asqatasun/Contrast-Finder/blob/v0.8.2/docker/RELEASE/Dockerfile) * [v0.8.1](https://github.com/Asqatasun/Contrast-Finder/blob/v0.8.1/docker/RELEASE/Dockerfile) * [v0.8.0](https://github.com/Asqatasun/Contrast-Finder/blob/v0.8.0/docker/RELEASE/Dockerfile) * [v0.7.0](https://github.com/Asqatasun/Contrast-Finder/blob/v0.7.0/docker/RELEASE/Dockerfile) diff --git a/docker/SNAPSHOT-local_from-Tomcat/Dockerfile b/docker/SNAPSHOT-local_from-Tomcat/Dockerfile index 066bb727..d2299f79 100644 --- a/docker/SNAPSHOT-local_from-Tomcat/Dockerfile +++ b/docker/SNAPSHOT-local_from-Tomcat/Dockerfile @@ -25,7 +25,7 @@ FROM tomcat:7.0-jre7 ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.2" +ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" ENV TOMCAT_WEBAPP_DIR="/usr/local/tomcat/webapps" # Prepare Contrast-Finder diff --git a/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile index 2502827d..d3d6e45f 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.2" +ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" # Add contrast-finder .war ADD contrast-finder_${CONTRAST_FINDER_RELEASE}.i386.tar.gz /root diff --git a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile index 7b2d0423..d1dc4c23 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.2" +ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" ENV CONF_DEFAULT_ALGO="Rgb" # ENV CONF_DEFAULT_ALGO="Rgb" # ENV CONF_DEFAULT_ALGO="HSV" diff --git a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile index 97ed185d..f270759f 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.2" +ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" ENV CONF_ENV="debug" # Add contrast-finder .war diff --git a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile index 7a676fba..960925ca 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.2" +ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" ENV PIWIK_KEY="9" ENV PIWIK_URL="http://localhost/piwik/" diff --git a/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile b/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile index 3453fdd9..472a28bc 100644 --- a/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile +++ b/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:14.04 LABEL org.label-schema.schema-version = "1.0.0-rc.1" \ org.label-schema.name = "Contrast-Finder - WebApp pre-requisites" \ - org.label-schema.version = "0.8.2" \ + org.label-schema.version = "0.8.3-SNAPSHOT" \ org.label-schema.url = "https://contrast-finder.org" \ org.label-schema.vcs-url = "https://github.com/Asqatasun/Contrast-Finder" # ----> documentation http://label-schema.org/ diff --git a/documentation/pom.xml b/documentation/pom.xml index 3623a424..2b637373 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -4,11 +4,11 @@ org.asqatasun contrast-finder - 0.8.2 + 0.8.3-SNAPSHOT documentation pom - 0.8.2 + 0.8.3-SNAPSHOT contrast-finder-documentation diff --git a/engine/api/pom.xml b/engine/api/pom.xml index 501aeee6..f945b1a2 100644 --- a/engine/api/pom.xml +++ b/engine/api/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.2 + 0.8.3-SNAPSHOT contrast-finder-api - 0.8.2 + 0.8.3-SNAPSHOT jar api diff --git a/engine/hsv/pom.xml b/engine/hsv/pom.xml index e2c8d1b0..61f83ed8 100644 --- a/engine/hsv/pom.xml +++ b/engine/hsv/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.2 + 0.8.3-SNAPSHOT contrast-finder-hsv - 0.8.2 + 0.8.3-SNAPSHOT jar hsv diff --git a/engine/impl/pom.xml b/engine/impl/pom.xml index 6e92996b..ef860a2a 100644 --- a/engine/impl/pom.xml +++ b/engine/impl/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.2 + 0.8.3-SNAPSHOT contrast-finder-impl - 0.8.2 + 0.8.3-SNAPSHOT jar impl diff --git a/engine/pom.xml b/engine/pom.xml index c27178fd..071d8a21 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -4,10 +4,10 @@ org.asqatasun contrast-finder - 0.8.2 + 0.8.3-SNAPSHOT engine - 0.8.2 + 0.8.3-SNAPSHOT pom contrast-finder-engine diff --git a/engine/utils/pom.xml b/engine/utils/pom.xml index 1a0d298c..3c124d29 100644 --- a/engine/utils/pom.xml +++ b/engine/utils/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.2 + 0.8.3-SNAPSHOT contrast-finder-utils - 0.8.2 + 0.8.3-SNAPSHOT jar utils diff --git a/pom.xml b/pom.xml index 39e87914..c3edd8c5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.asqatasun contrast-finder pom - 0.8.2 + 0.8.3-SNAPSHOT Contrast-Finder diff --git a/webapp/pom.xml b/webapp/pom.xml index 778c441b..28013ff8 100644 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -4,10 +4,10 @@ org.asqatasun contrast-finder - 0.8.2 + 0.8.3-SNAPSHOT webapp - 0.8.2 + 0.8.3-SNAPSHOT war contrast-finder-webapp diff --git a/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf b/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf index 5023741c..f13ad6d6 100644 --- a/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf +++ b/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf @@ -2,7 +2,7 @@ <%@ page pageEncoding="UTF-8" %> <%-- APP version --%> - + <%-- APP Name --%> From 2778887fcf2f0214a6ecd2984794cbced1d871f5 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Thu, 2 Nov 2017 00:52:31 +0100 Subject: [PATCH 02/18] Updated Other-contrast-tools.md --- documentation/en/Other-contrast-tools.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/documentation/en/Other-contrast-tools.md b/documentation/en/Other-contrast-tools.md index c5aa3243..24b0243a 100644 --- a/documentation/en/Other-contrast-tools.md +++ b/documentation/en/Other-contrast-tools.md @@ -22,7 +22,9 @@ * http://www.visionaustralia.org/digital-access-determinator * http://a11yrocks.com/colorPalette/ * http://colorsafe.co/ - * https://github.com/donnieberg/accessible-color-palette/ + * src: https://github.com/donnieberg/accessible-color-palette/ +* https://ryanhemphill.github.io/contrast-colorblind-colorpicker/ + * src: https://github.com/ryanhemphill/contrast-colorblind-colorpicker * https://github.com/johnotander/get-contrast * http://www.randoma11y.com/ * https://www.joedolson.com/tools/color-contrast-tester.php From e09147fddff40d084ffc78d011dad02ea2237b03 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Thu, 2 Nov 2017 00:54:35 +0100 Subject: [PATCH 03/18] typo --- documentation/en/Other-contrast-tools.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/en/Other-contrast-tools.md b/documentation/en/Other-contrast-tools.md index 24b0243a..9ff20ca2 100644 --- a/documentation/en/Other-contrast-tools.md +++ b/documentation/en/Other-contrast-tools.md @@ -9,6 +9,7 @@ * src: https://github.com/moroshko/accessible-colors ## Other contrast tools (which are actually good, but it appears we don't them) + * http://webaim.org/resources/contrastchecker/ * http://contrastchecker.com/ * http://leaverou.github.io/contrast-ratio/ @@ -19,6 +20,7 @@ * src: https://github.com/andrewbrandwood/a11y-image-text ### Other contrast tools + * http://www.visionaustralia.org/digital-access-determinator * http://a11yrocks.com/colorPalette/ * http://colorsafe.co/ @@ -33,7 +35,6 @@ * https://toolness.github.io/accessible-color-matrix/ * https://addons.mozilla.org/fr/firefox/addon/wcag-contrast-checker/ * https://hexnaw.com/ - * http://jxnblk.com/colorable/ * https://colorable.jxnblk.com/ * http://jxnblk.com/hello-color/ From 208423feccdc9ec286ad67bf416a3d98d20164d1 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sat, 18 Nov 2017 02:03:29 +0100 Subject: [PATCH 04/18] fixed #101 - Upgraded outdated dependency: commons-lang3 (3.7) commons-lang3 3.7 instead of 3.6 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c3edd8c5..d938ada4 100644 --- a/pom.xml +++ b/pom.xml @@ -41,7 +41,7 @@ 1.4 4.1 1.2 - 3.6 + 3.7 4.12 1.2.3 1.0.0 From 10411a94e4a731e8df4b3e0c37ad8e5e021eaa4b Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sat, 18 Nov 2017 02:05:08 +0100 Subject: [PATCH 05/18] fixed #102 - Upgraded outdated dependency: markdown-page-generator-plugin markdown-page-generator-plugin 2.0.0 instead of 1.0.0 --- documentation/pom.xml | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/documentation/pom.xml b/documentation/pom.xml index 2b637373..ff3509e6 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -27,7 +27,7 @@ com.ruleoftech markdown-page-generator-plugin - 1.0.0 + 2.0.0 @@ -35,7 +35,7 @@ com.ruleoftech markdown-page-generator-plugin - 1.0.0 + 2.0.0 process-sources diff --git a/pom.xml b/pom.xml index d938ada4..57d3b93d 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 3.7 4.12 1.2.3 - 1.0.0 + 2.0.0 3.7.0 From fa34871d8af115c7c713aa391d28bf7cdc24c46b Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sat, 18 Nov 2017 02:30:57 +0100 Subject: [PATCH 06/18] fixed #103 - Upgraded outdated dependency: maven-javadoc-plugin (3.0.0-M1) maven-javadoc-plugin 3.0.0-M1 instead of 2.10.4 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 57d3b93d..9b88804a 100644 --- a/pom.xml +++ b/pom.xml @@ -50,7 +50,7 @@ 3.7.0 2.20.1 2.9 - 2.10.4 + 3.0.0-M1 2.17 1.4.5 From 15568d1ee9a59d13ea309edcfaaf85c751af0187 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sat, 18 Nov 2017 02:31:48 +0100 Subject: [PATCH 07/18] fixed pom.xml for maven-project-info-reports-plugin --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b88804a..14b6a09b 100644 --- a/pom.xml +++ b/pom.xml @@ -207,7 +207,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - ${maven-project-info-reports-plugin} + ${maven-project-info-reports-plugin.version} + + org.apache.maven.plugins + maven-jxr-plugin + ${maven-jxr-plugin.version} + + + 3.1 From 5e00ef189b01ec808f2125dfff37a8f9e168bfdc Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sun, 19 Nov 2017 08:32:03 +0100 Subject: [PATCH 11/18] updated pom.xml (typo) --- documentation/pom.xml | 9 +-------- pom.xml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/documentation/pom.xml b/documentation/pom.xml index ff3509e6..dd389ec7 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -23,19 +23,12 @@ https://asqatasun.org - - - com.ruleoftech - markdown-page-generator-plugin - 2.0.0 - - + com.ruleoftech markdown-page-generator-plugin - 2.0.0 process-sources diff --git a/pom.xml b/pom.xml index 766c2e0b..1f664322 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,20 @@ + + 4.0.0 org.asqatasun @@ -14,6 +30,7 @@ https://contrast-finder.org + 2008 Asqatasun.org https://asqatasun.org @@ -21,6 +38,20 @@ Finds correct color contrasts for web accessibility (a11y, WCAG) + + scm:git:https://github.com/Asqatasun/Contrast-Finder.git + https://github.com/Asqatasun/Contrast-Finder + scm:git:git@github.com:Asqatasun/Contrast-Finder.git + HEAD + + + github + https://github.com/Asqatasun/Contrast-Finder/issues + + + travis-ci + https://travis-ci.org/Asqatasun/Contrast-Finder + documentation From 3e37f4b4b926fcd98dccbb6924a28c188af1f745 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sun, 19 Nov 2017 08:33:29 +0100 Subject: [PATCH 12/18] Fixed #106 - Added unit tests coverage report (jacoco-maven-plugin) --- CHANGELOG.md | 1 + .../AbstractColorFinderImplTest.java | 5 ++ .../hsv/ColorFinderHsvPsychoTest.java | 7 ++- .../hsv/ColorFinderHsvTest.java | 13 ++++++ .../hsv/ColorFinderRgbTest.java | 4 ++ .../colorconvertor/ColorConverterTest.java | 46 ++++++++++++++++--- .../colornamelookup/ColorNameLookupTest.java | 5 ++ .../contrastchecker/ContrastCheckerTest.java | 2 + pom.xml | 26 +++++++++++ 9 files changed, 101 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6bf7c49..7b9cc335 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ none ### Task - [#104 - Added maven-jxr-plugin (needed for maven-checkstyle-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/104) +- [#106 - Added unit tests coverage report (jacoco-maven-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/106) diff --git a/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java b/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java index 386f2598..5dcf7577 100644 --- a/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java +++ b/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java @@ -6,6 +6,7 @@ import java.awt.Color; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test /** * @@ -30,6 +31,7 @@ protected void tearDown() throws Exception { /** * Test of findColors method, of class AbstractColorFinderImpl. */ + @Test public void testFindColorsWithValidContrastWithBackgroundTested() { System.out.println("findColorsWithValidContrastWithBackgroundTested"); Color foregroundColor = null; @@ -45,6 +47,7 @@ public void testFindColorsWithValidContrastWithBackgroundTested() { /** * Test of findColors method, of class AbstractColorFinderImpl. */ + @Test public void testFindColorsWithValidContrastWithForegroundTested() { System.out.println("findColorsWithValidContrastWithForegroundTested"); Color foregroundColor = null; @@ -60,6 +63,7 @@ public void testFindColorsWithValidContrastWithForegroundTested() { /** * Test of findColors method, of class AbstractColorFinderImpl. */ + @Test public void testFindColorsWithInvalidContrastWithBackgroundTested() { System.out.println("findColorsWithInvalidContrastWithBackgroundTested"); Color foregroundColor = null; @@ -75,6 +79,7 @@ public void testFindColorsWithInvalidContrastWithBackgroundTested() { /** * Test of findColors method, of class AbstractColorFinderImpl. */ + @Test public void testFindColorsWithInvalidContrastWithForegroundTested() { System.out.println("findColorsWithInvalidContrastWithForegroundTested"); Color foregroundColor = null; diff --git a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java index 60bf45a5..92df1638 100644 --- a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java +++ b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java @@ -9,6 +9,8 @@ import java.util.List; import static junit.framework.Assert.assertEquals; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.asqatasun.contrastfinder.result.ColorCombinaison; @@ -36,6 +38,7 @@ protected void tearDown() throws Exception { super.tearDown(); } + @Test public void testFindColorsNearColorOrange() { System.out.println("FindColorsNearColor"); Color foregroundColor = new Color(255, 165, 0); @@ -69,7 +72,8 @@ public void testFindColorsNearColorOrange() { // } // LOGGER.debug("Out of bound values " + counter ); } - + +// @Test // public void testFindColorsNearColor() { // System.out.println("FindColorsNearColor"); // Color foregroundColor = new Color(127, 127, 127); @@ -89,6 +93,7 @@ public void testFindColorsNearColorOrange() { /** * Test of getColorFinderKey method, of class ColorFinderHsvPsycho. */ + @Test public void testGetColorFinderKey() { System.out.println("Key"); ColorFinderHsv instance = new ColorFinderHsv(); diff --git a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java index 8e39ffd6..a370b712 100644 --- a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java +++ b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java @@ -24,6 +24,8 @@ import java.util.List; import static junit.framework.Assert.assertEquals; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.asqatasun.contrastfinder.result.ColorCombinaison; @@ -53,6 +55,7 @@ protected void tearDown() throws Exception { /** * Test of findColors method, of class ColorFinderHsv. */ + @Test public void testFindColorsWithFgAndBg() { System.out.println("FindColorsWithFgAndBg"); Color foregroundColor = new Color(127, 127, 127); @@ -74,6 +77,7 @@ public void testFindColorsWithFgAndBg() { assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor()); } + @Test public void testFindColorsWithFgAndBg2() { System.out.println("FindColorsWithFgAndBg2"); Color foregroundColor = new Color(127, 127, 127); @@ -95,6 +99,7 @@ public void testFindColorsWithFgAndBg2() { assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor()); } + @Test public void testFindColorsBornBlack() { System.out.println("FindColorsBornBlack"); Color foregroundColor = new Color(1, 1, 1); @@ -111,6 +116,7 @@ public void testFindColorsBornBlack() { assertEquals(firstColor, colorCombinaison.get(0).getColor()); } + @Test public void testFindColorsBornBlack2() { System.out.println("FindColorsBornBlack2"); Color foregroundColor = new Color(1, 1, 1); @@ -127,6 +133,7 @@ public void testFindColorsBornBlack2() { assertEquals(firstColor, colorCombinaison.get(0).getColor()); } + @Test public void testFindColorsBornWhite() { System.out.println("FindColorsBornWhite"); Color foregroundColor = new Color(254, 254, 254); @@ -148,6 +155,7 @@ public void testFindColorsBornWhite() { assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor()); } + @Test public void testFindColorsBornWhite2() { System.out.println("FindColorsBornWhite2"); Color foregroundColor = new Color(254, 254, 254); @@ -172,6 +180,7 @@ public void testFindColorsBornWhite2() { /** * Test of findColors method, of class ColorFinderHsv. */ + @Test public void testFindColorsGreenAlert() { System.out.println("FindColorsGreenAlert"); Color foregroundColor = new Color(70, 136, 71); @@ -193,6 +202,7 @@ public void testFindColorsGreenAlert() { assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor()); } + @Test public void testFindColorsGreenAlert2() { System.out.println("FindColorsGreenAlert2"); Color foregroundColor = new Color(70, 136, 71); @@ -214,6 +224,7 @@ public void testFindColorsGreenAlert2() { assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor()); } + @Test public void testFindColorsNearColor() { System.out.println("FindColorsNearColor"); Color foregroundColor = new Color(1, 0, 1); @@ -234,6 +245,7 @@ public void testFindColorsNearColor() { assertEquals(endColor, colorCombinaison.get(sizeList - 1).getColor()); } + @Test public void testFindColorsNearColor2() { System.out.println("FindColorsNearColor2"); Color foregroundColor = new Color(255, 165, 0); @@ -249,6 +261,7 @@ public void testFindColorsNearColor2() { } } + @Test public void testGetColorFinderKey() { System.out.println("Key"); ColorFinderHsv instance = new ColorFinderHsv(); diff --git a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java index 47e40e8f..3e1c17cd 100644 --- a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java +++ b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java @@ -8,6 +8,8 @@ import java.util.ArrayList; import java.util.List; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test + import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.asqatasun.contrastfinder.result.ColorCombinaison; @@ -34,6 +36,7 @@ protected void tearDown() throws Exception { super.tearDown(); } + @Test public void testFindColorsNearColorOrange() { System.out.println("FindColorsNearColor"); Color foregroundColor = new Color(255, 255, 255); @@ -51,6 +54,7 @@ public void testFindColorsNearColorOrange() { /** * Test of getColorFinderKey method, of class ColorFinderRgb. */ + @Test public void testGetColorFinderKey() { System.out.println("Key"); ColorFinderHsv instance = new ColorFinderHsv(); diff --git a/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java b/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java index 9da65e68..852ef8be 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java @@ -22,6 +22,7 @@ import java.awt.Color; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test /** * @@ -46,6 +47,7 @@ protected void tearDown() throws Exception { /** * Test of offsetHsbColor method, of class ColorConverter. */ +// @Test // public void testOffsetHsbColor() { // System.out.println("offsetHsbColor"); // Color bgColor = null; @@ -62,6 +64,7 @@ protected void tearDown() throws Exception { // /** // * Test of setBrightnessToColor method, of class ColorConverter. // */ +// @Test // public void testSetBrightnessToColor() { // System.out.println("setBrightnessToColor"); // Float Brightness = null; @@ -76,6 +79,7 @@ protected void tearDown() throws Exception { // /** // * Test of getBrightness method, of class ColorConverter. // */ +// @Test // public void testGetBrightness() { // System.out.println("getBrightness"); // Color bgColor = null; @@ -89,6 +93,7 @@ protected void tearDown() throws Exception { // /** // * Test of getSaturation method, of class ColorConverter. // */ +// @Test // public void testGetSaturation() { // System.out.println("getSaturation"); // Color bgColor = null; @@ -102,6 +107,7 @@ protected void tearDown() throws Exception { /** * Test of getHue method, of class ColorConverter. */ + @Test public void testGetHue() { System.out.println("getHue"); Color bgColor = new Color(128, 127, 127); @@ -113,6 +119,7 @@ public void testGetHue() { // /** // * Test of offsetRgbColor method, of class ColorConverter. // */ +// @Test // public void testOffsetRgbColor() { // System.out.println("offsetRgbColor"); // Color bgColor = null; @@ -129,6 +136,7 @@ public void testGetHue() { /** * Test of hex2Rgb method, of class ColorConverter. */ +// @Test // public void testHex2Rgb() { // System.out.println("hex2Rgb"); // String colorStr = ""; @@ -142,6 +150,7 @@ public void testGetHue() { // formatColor() ///////////////////////////////////////////////////////////////////// + @Test public void testFormatColorRgbLastParenthesisIsMissing() { String expResult = "rgb(255,255,255)"; String colorStr = "rgb(255,255,255"; // # must be added @@ -155,6 +164,7 @@ public void testFormatColorRgbLastParenthesisIsMissing() { assertEquals(expResult, result); } + @Test public void testFormatColorRgbToLowerCase() { System.out.println("formatColorRgbToLowerCase [RGB(255,255,255)]"); String colorStr = "RGB(255,255,255)"; @@ -163,6 +173,7 @@ public void testFormatColorRgbToLowerCase() { assertEquals(expResult, result); } + @Test public void testFormatColorRgb() { System.out.println("formatColorRgb [ rgb( 255, 255, 255 ) ]"); String colorStr = " rgb( 255, 255, 255 ) "; @@ -172,7 +183,7 @@ public void testFormatColorRgb() { } - + @Test public void testFormatColorRgbShortWidthSpace() { System.out.println("formatColorRgbShortWidthSpace [ 255, 255, 255 ]"); String colorStr = " 255, 255, 255 "; @@ -181,6 +192,7 @@ public void testFormatColorRgbShortWidthSpace() { assertEquals(expResult, result); } + @Test public void testFormatColorRgbShort() { System.out.println("formatColorRgbShort [255,255,255]"); String colorStr = "255,255,255"; @@ -189,7 +201,7 @@ public void testFormatColorRgbShort() { assertEquals(expResult, result); } - + @Test public void testFormatColorNotValidHex() { System.out.println("formatColorNotValidHex [Ff]"); String colorStr = "Ff"; // # must be added @@ -198,6 +210,7 @@ public void testFormatColorNotValidHex() { assertEquals(expResult, result); } + @Test public void testFormatColorNotValidHex2() { System.out.println("formatColorNotValidHex2 [FfFf]"); String colorStr = "FfFf"; // # must be added @@ -206,6 +219,7 @@ public void testFormatColorNotValidHex2() { assertEquals(expResult, result); } + @Test public void testFormatColorNotValidHexLetter2() { System.out.println("formatColorNotValidHexLetter2 [#ZzZ]"); String colorStr = "#ZzZ"; // # must be added @@ -214,6 +228,7 @@ public void testFormatColorNotValidHexLetter2() { assertEquals(expResult, result); } + @Test public void testFormatColorNotValidHexLetter() { System.out.println("formatColorNotValidHexLetter [ZzZ]"); String colorStr = "ZzZ"; // # must be added @@ -222,6 +237,7 @@ public void testFormatColorNotValidHexLetter() { assertEquals(expResult, result); } + @Test public void testFormatColorHexAddHash() { System.out.println("formatColorHexAddHash [000000]"); String colorStr = "000000"; // # must be added @@ -230,6 +246,7 @@ public void testFormatColorHexAddHash() { assertEquals(expResult, result); } + @Test public void testFormatColorHexNotAddHash() { System.out.println("formatColorHexNotAddHash [#000000]"); String colorStr = "#000000"; // # must not be added @@ -238,6 +255,7 @@ public void testFormatColorHexNotAddHash() { assertEquals(expResult, result); } + @Test public void testFormatColorHexTrim() { System.out.println("formatColorHexTrim [ #000000 ]"); String colorStr = " #000000 "; @@ -246,6 +264,7 @@ public void testFormatColorHexTrim() { assertEquals(expResult, result); } + @Test public void testFormatColorHexToUpperCase() { System.out.println("formatColorHexToUpperCase [#ffffff]"); String colorStr = "#ffffff"; @@ -254,7 +273,7 @@ public void testFormatColorHexToUpperCase() { assertEquals(expResult, result); } - + @Test public void testFormatColorHex() { System.out.println("formatColorHex [ ffffff ]"); String colorStr = " ffffff "; @@ -266,7 +285,7 @@ public void testFormatColorHex() { // Color colorFromRgbStr() ///////////////////////////////////////////////////////////////////// - + @Test public void testColorFromRgbStrBadRedValue() { String colorStr = "256, 0, 0"; System.out.println("colorFromRgbStrBadRedValue ["+ colorStr +"]"); @@ -275,6 +294,7 @@ public void testColorFromRgbStrBadRedValue() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrBadGreenValue() { String colorStr = "0, 256, 0"; System.out.println("colorFromRgbStrBadGreenValue ["+ colorStr +"]"); @@ -283,6 +303,7 @@ public void testColorFromRgbStrBadGreenValue() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrBadBlueValue() { String colorStr = "0, 0, 256"; System.out.println("colorFromRgbStrBadBlueValue ["+ colorStr +"]"); @@ -291,6 +312,7 @@ public void testColorFromRgbStrBadBlueValue() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStr() { String colorStr = " rgb(175, 175, 175) "; System.out.println("colorFromRgbStr ["+ colorStr +"]"); @@ -299,6 +321,7 @@ public void testColorFromRgbStr() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrShort() { String colorStr = "175, 175, 175"; System.out.println("colorFromRgbStrShort ["+ colorStr +"]"); @@ -307,6 +330,7 @@ public void testColorFromRgbStrShort() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrBlack() { String colorStr = "rgb(0,0,0)"; System.out.println("colorFromRgbStrBlack ["+ colorStr +"]"); @@ -315,6 +339,7 @@ public void testColorFromRgbStrBlack() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrWhite() { String colorStr = "rgb(255,255,255)"; System.out.println("colorFromRgbStrWhite ["+ colorStr +"]"); @@ -323,6 +348,7 @@ public void testColorFromRgbStrWhite() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrPink() { String colorStr = "rgb(255,175,175)"; System.out.println("colorFromRgbStrPink ["+ colorStr +"]"); @@ -331,7 +357,7 @@ public void testColorFromRgbStrPink() { assertEquals(expResult, result); } - + @Test public void testColorFromRgbStrBlackShort() { String colorStr = "0,0,0"; System.out.println("colorFromRgbStrBlackShort ["+ colorStr +"]"); @@ -340,6 +366,7 @@ public void testColorFromRgbStrBlackShort() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrWhiteShort() { String colorStr = "255,255,255"; System.out.println("colorFromRgbStrWhiteShort ["+ colorStr +"]"); @@ -348,6 +375,7 @@ public void testColorFromRgbStrWhiteShort() { assertEquals(expResult, result); } + @Test public void testColorFromRgbStrPinkShort() { String colorStr = "255,175,175"; System.out.println("colorFromRgbStrPinkShort ["+ colorStr +"]"); @@ -360,6 +388,8 @@ public void testColorFromRgbStrPinkShort() { // String rgb2Hex() ///////////////////////////////////////////////////////////////////// + + @Test public void testRgb2hexBlack() { System.out.println("Rgb2hexBlack"); Color color = Color.BLACK; @@ -367,7 +397,8 @@ public void testRgb2hexBlack() { String result = ColorConverter.rgb2Hex(color); assertEquals(expResult, result); } - + + @Test public void testRgb2hexWhite() { System.out.println("Rgb2hexWhite"); Color color = Color.WHITE; @@ -375,7 +406,8 @@ public void testRgb2hexWhite() { String result = ColorConverter.rgb2Hex(color); assertEquals(expResult, result); } - + + @Test public void testRgb2hexPink() { System.out.println("Rgb2hexPink"); Color color = Color.PINK; diff --git a/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java b/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java index 9a2757dd..9b696eeb 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java @@ -22,6 +22,7 @@ import java.awt.Color; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test /** * @@ -45,6 +46,7 @@ protected void tearDown() throws Exception { // @@@TODO add test for getColorNameFromStr + @Test public void testGetColorFromNameWhite() { String colorStr = "white"; System.out.println("GetColorFromNameWhite ["+ colorStr +"]"); @@ -54,6 +56,7 @@ public void testGetColorFromNameWhite() { assertEquals(expResult, result); } + @Test public void testGetColorFromNameSilver() { String colorStr = "silver"; System.out.println("GetColorFromNameSilver ["+ colorStr +"]"); @@ -63,6 +66,7 @@ public void testGetColorFromNameSilver() { assertEquals(expResult, result); } + @Test public void testGetColorFromNameDarkMagenta() { String colorStr = "DarkMagenta"; System.out.println("GetColorFromNameDarkMagenta ["+ colorStr +"]"); @@ -72,6 +76,7 @@ public void testGetColorFromNameDarkMagenta() { assertEquals(expResult, result); } + @Test public void testGetColorFromNameBadCaseWidthSpaces() { String colorStr = " darkmagenta "; System.out.println("GetColorFromNameBadCaseWidthSpaces ["+ colorStr +"]"); diff --git a/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java b/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java index ad91a4a6..9dfabbc0 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java @@ -23,6 +23,7 @@ import java.awt.Color; import java.text.DecimalFormat; import junit.framework.TestCase; +import org.junit.Test; // Junit anotation @Test /** * @@ -45,6 +46,7 @@ protected void tearDown() throws Exception { /** * Test of getConstrastRatio method, of class ContrastChecker. */ + @Test public void testGetConstrastRatio() { System.out.println("getConstrastRatio"); diff --git a/pom.xml b/pom.xml index 1f664322..3b5fd5aa 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,7 @@ 2.5 2.17 3.0.2 + 0.7.9 3.1 @@ -229,6 +230,31 @@ + + + org.jacoco + jacoco-maven-plugin + ${jacoco-maven-plugin.version} + + + + prepare-agent + + + + report + prepare-package + + report + + + + + From daacab2e0e95e366029aa806f2f55bfcf1129c81 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sun, 19 Nov 2017 12:54:32 +0100 Subject: [PATCH 13/18] typo --- .../asqatasun/contrastfinder/AbstractColorFinderImplTest.java | 2 +- .../asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java | 2 +- .../org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java | 2 +- .../org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java b/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java index 5dcf7577..6aa62903 100644 --- a/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java +++ b/engine/api/src/test/java/org/asqatasun/contrastfinder/AbstractColorFinderImplTest.java @@ -6,7 +6,7 @@ import java.awt.Color; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test /** * diff --git a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java index 92df1638..29f96fe3 100644 --- a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java +++ b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvPsychoTest.java @@ -9,7 +9,7 @@ import java.util.List; import static junit.framework.Assert.assertEquals; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java index a370b712..cd279eb8 100644 --- a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java +++ b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderHsvTest.java @@ -24,7 +24,7 @@ import java.util.List; import static junit.framework.Assert.assertEquals; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java index 3e1c17cd..b82bddb1 100644 --- a/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java +++ b/engine/hsv/src/test/java/org/asqatasun/contrastfinder/hsv/ColorFinderRgbTest.java @@ -8,7 +8,7 @@ import java.util.ArrayList; import java.util.List; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test import org.slf4j.Logger; import org.slf4j.LoggerFactory; From fefc24a9bd4ffe2b7d3242fcf1d97f3f830890e1 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sun, 19 Nov 2017 19:04:59 +0100 Subject: [PATCH 14/18] fixed #107 - Added missing unit tests for engine/utils/* --- CHANGELOG.md | 1 + .../utils/colorconvertor/ColorConverter.java | 37 +- .../colorconvertor/ColorConverterTest.java | 667 +++++++++++++++--- .../colornamelookup/ColorNameLookupTest.java | 44 +- .../contrastchecker/ContrastCheckerTest.java | 159 +++-- .../DistanceCalculatorTest.java | 76 ++ 6 files changed, 828 insertions(+), 156 deletions(-) create mode 100644 engine/utils/src/test/java/org/asqatasun/utils/distancecalculator/DistanceCalculatorTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b9cc335..bfaf4db7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,7 @@ none ### Task - [#104 - Added maven-jxr-plugin (needed for maven-checkstyle-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/104) - [#106 - Added unit tests coverage report (jacoco-maven-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/106) +- [#107 - Added missing unit tests for engine/utils/*](https://github.com/Asqatasun/Contrast-Finder/issues/107) diff --git a/engine/utils/src/main/java/org/asqatasun/utils/colorconvertor/ColorConverter.java b/engine/utils/src/main/java/org/asqatasun/utils/colorconvertor/ColorConverter.java index 603a5e7a..230f7f67 100644 --- a/engine/utils/src/main/java/org/asqatasun/utils/colorconvertor/ColorConverter.java +++ b/engine/utils/src/main/java/org/asqatasun/utils/colorconvertor/ColorConverter.java @@ -80,7 +80,7 @@ public static Color offsetHsbColor(Color color, float offsetHue, float offsetSat /** * @param color - * @return the brightness of the given color + * @return the brightness (hsb) of the given color */ public static Float getBrightness(Color color) { float[] hsbValues = new float[MAX_COMPONENT]; @@ -92,7 +92,7 @@ public static Float getBrightness(Color color) { /** * @param color - * @return the saturation of the given color + * @return the saturation (hsb) of the given color */ public static Float getSaturation(Color color) { float[] hsbValues = new float[MAX_COMPONENT]; @@ -104,7 +104,7 @@ public static Float getSaturation(Color color) { /** * @param color - * @return the hue of the given color + * @return the hue (hsb) of the given color */ public static Float getHue(Color color) { float[] hsbValues = new float[MAX_COMPONENT]; @@ -115,6 +115,9 @@ public static Float getHue(Color color) { } /** + * @todo check if offset* is valid for Color (ex: WHITE 255,255,255 with +10) + * @todo check if color is not null + * * @param bgColor * @param offsetRed * @param offsetGreen @@ -175,7 +178,7 @@ public static Color colorFromStr(String colorStr) { /** - * @param colorStr ex: silver, red, SteelBlue, ... + * @param colorStr color name (ex: silver, red, SteelBlue, ...) * @return Color object or NULL */ public static Color colorFromColorName(String colorStr) { @@ -213,20 +216,22 @@ public static Color colorFromRgbStr(String colorStr) { * @return the RGB Color from hex Color */ public static Color hex2Rgb(String colorStr) { - if (colorStr.charAt(0) == '#') { - String str = colorStr.substring(1); - if (str.matches(HEXADECIMAL_DICTIONNARY) + if(colorStr.length() > 0){ + if (colorStr.charAt(0) == '#') { + String str = colorStr.substring(1); + if (str.matches(HEXADECIMAL_DICTIONNARY) && str.length() == RGB_HEXA_LENGTH) { - return getNewColor(str); - } else if (str.matches(HEXADECIMAL_DICTIONNARY) + return getNewColor(str); + } else if (str.matches(HEXADECIMAL_DICTIONNARY) && str.length() == RGB_SHORT_HEXA_LENGTH) { - return getNewColorShortHexa(str); - } - } else if (colorStr.matches(HEXADECIMAL_DICTIONNARY)) { - if (colorStr.length() == RGB_HEXA_LENGTH) { - return getNewColor(colorStr); - } else if (colorStr.length() == RGB_SHORT_HEXA_LENGTH) { - return getNewColorShortHexa(colorStr); + return getNewColorShortHexa(str); + } + } else if (colorStr.matches(HEXADECIMAL_DICTIONNARY)) { + if (colorStr.length() == RGB_HEXA_LENGTH) { + return getNewColor(colorStr); + } else if (colorStr.length() == RGB_SHORT_HEXA_LENGTH) { + return getNewColorShortHexa(colorStr); + } } } return null; diff --git a/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java b/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java index 852ef8be..a00dba3d 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/colorconvertor/ColorConverterTest.java @@ -22,7 +22,7 @@ import java.awt.Color; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test /** * @@ -76,97 +76,212 @@ protected void tearDown() throws Exception { // fail("The test case is a prototype."); // } // -// /** -// * Test of getBrightness method, of class ColorConverter. -// */ -// @Test -// public void testGetBrightness() { -// System.out.println("getBrightness"); -// Color bgColor = null; -// Float expResult = null; -// Float result = ColorConverter.getBrightness(bgColor); -// assertEquals(expResult, result); -// // TODO review the generated test code and remove the default call to fail. -// fail("The test case is a prototype."); -// } -// -// /** -// * Test of getSaturation method, of class ColorConverter. -// */ -// @Test -// public void testGetSaturation() { -// System.out.println("getSaturation"); -// Color bgColor = null; -// Float expResult = null; -// Float result = ColorConverter.getSaturation(bgColor); -// assertEquals(expResult, result); -// // TODO review the generated test code and remove the default call to fail. -// fail("The test case is a prototype."); -// } + /** + * Test of getBrightness method, of class ColorConverter. + */ + @Test + public void testGetBrightness() { + System.out.println("---- getBrightness -----"); + + Color colorA = Color.BLACK; + Float expResult = (float) 0.0; + Float result = ColorConverter.getBrightness(colorA); + System.out.println("BLACK - Brightness: ["+ result +"]"); + assertEquals(expResult, result); + + colorA = Color.WHITE; + expResult = (float) 1.0; + result = ColorConverter.getBrightness(colorA); + System.out.println("WHITE - Brightness: ["+ result +"]"); + assertEquals(expResult, result); + + colorA = new Color(70, 136, 71); // #468847 = rgb(70, 136, 71) = hsl(120, 32%, 40%) + expResult = (float) 0.53333336; + result = ColorConverter.getBrightness(colorA); + System.out.println("rgb(70, 136, 71) - Brightness: ["+ result +"]"); + assertEquals(expResult, result); + } + + + + /** + * Test of getSaturation method, of class ColorConverter. + */ + @Test + public void testGetSaturation() { + System.out.println("---- getSaturation -----"); + + Color colorA = Color.BLACK; + Float expResult = (float) 0.0; + Float result = ColorConverter.getSaturation(colorA); + System.out.println("BLACK - Saturation: ["+ result +"]"); + assertEquals(expResult, result); + + colorA = Color.WHITE; + expResult = (float) 0.0; + result = ColorConverter.getSaturation(colorA); + System.out.println("WHITE - Saturation: ["+ result +"]"); + assertEquals(expResult, result); + + colorA = new Color(70, 136, 71); // #468847 = rgb(70, 136, 71) = hsl(120, 32%, 40%) + expResult = (float) 0.4852941; + result = ColorConverter.getSaturation(colorA); + System.out.println("rgb(70, 136, 71) - Saturation: ["+ result +"]"); + assertEquals(expResult, result); + + } /** * Test of getHue method, of class ColorConverter. */ @Test public void testGetHue() { - System.out.println("getHue"); - Color bgColor = new Color(128, 127, 127); - Color result = ColorConverter.offsetHsbColor(bgColor, Float.valueOf(0.1f), Float.valueOf(0.0f), Float.valueOf(0.0f)); - System.out.println(result.toString()); - System.out.println("Hue : " + result); + System.out.println("---- getHue -----"); + + Color colorA = Color.BLACK; + Float expResult = (float) 0.0; + Float result = ColorConverter.getHue(colorA); + System.out.println("BLACK - Hue: ["+ result +"]"); + assertEquals(expResult, result); + + colorA = Color.WHITE; + expResult = (float) 0.0; + result = ColorConverter.getHue(colorA); + System.out.println("WHITE - Hue: ["+ result +"]"); + assertEquals(expResult, result); + + colorA = new Color(70, 136, 71); // #468847 = rgb(70, 136, 71) = hsl(120, 32%, 40%) + expResult = (float) 0.33585858; + result = ColorConverter.getHue(colorA); + System.out.println("rgb(70, 136, 71) - Hue: ["+ result +"]"); + assertEquals(expResult, result); } -// -// /** -// * Test of offsetRgbColor method, of class ColorConverter. -// */ -// @Test -// public void testOffsetRgbColor() { -// System.out.println("offsetRgbColor"); -// Color bgColor = null; -// int offsetRed = 0; -// int offsetGreen = 0; -// int offsetBlue = 0; -// Color expResult = null; -// Color result = ColorConverter.offsetRgbColor(bgColor, offsetRed, offsetGreen, offsetBlue); -// assertEquals(expResult, result); -// // TODO review the generated test code and remove the default call to fail. -// fail("The test case is a prototype."); -// } -// + + /** - * Test of hex2Rgb method, of class ColorConverter. + * Test of getHue method, of class ColorConverter. */ -// @Test -// public void testHex2Rgb() { -// System.out.println("hex2Rgb"); -// String colorStr = ""; -// Color expResult = null; -// Color result = ColorConverter.hex2Rgb(colorStr); -// assertEquals(expResult, result); -// // TODO review the generated test code and remove the default call to fail. -// fail("The test case is a prototype."); -// } + @Test + public void testGetHue_old() { + // System.out.println("getHue"); + // Color bgColor = new Color(128, 127, 127); + // Color result = ColorConverter.offsetHsbColor(bgColor, Float.valueOf(0.1f), Float.valueOf(0.0f), Float.valueOf(0.0f)); + // System.out.println(result.toString()); + // System.out.println("Hue : " + result); + } + + /** + * Test of offsetRgbColor method, of class ColorConverter. + */ + @Test + public void testOffsetRgbColor() { + System.out.println("---------- offsetRgbColor ----------------"); + Color colorA; + Color expResult; + Color result; + int offsetRed; + int offsetGreen; + int offsetBlue; + + colorA = Color.BLACK; + offsetRed = 10; + offsetGreen = 20; + offsetBlue = 30; + expResult = new Color(10, 20, 30); + result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); + System.out.println("OffsetRgbColor BLACK + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); + assertEquals(expResult, result); + + colorA = new Color(70, 136, 71); // #468847 + offsetRed = 100; + offsetGreen = 100; + offsetBlue = 100; + expResult = new Color(170, 236, 171); + result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); + System.out.println("OffsetRgbColor #468847 + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); + assertEquals(expResult, result); + + colorA = Color.WHITE; + offsetRed = -10; + offsetGreen = -20; + offsetBlue = -30; + expResult = new Color(245,235,225); + result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); + System.out.println("OffsetRgbColor WHITE + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); + assertEquals(expResult, result); + + colorA = Color.WHITE; + offsetRed = 0; + offsetGreen = 0; + offsetBlue = 0; + expResult = new Color(255,255,255); + result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); + System.out.println("OffsetRgbColor WHITE + ["+ offsetRed +", "+ offsetGreen +", "+ offsetBlue +"] = " + result.toString()); + assertEquals(expResult, result); + + System.out.println("--------------------------"); + } + + + /** + * Test of offsetRgbColor method, of class ColorConverter. + * + * @todo check if offset* is valid for Color (ex: WHITE 255,255,255 with +10) + * @todo check if color is not null + */ + @Test + public void testOffsetRgbColor_badValue() { + System.out.println("---------- offsetRgbColor BAD Value ----------------"); + System.out.println(" ------> @todo check if offset* is valid for Color (ex: WHITE 255,255,255 with +10)"); + System.out.println("------> @todo check if color is not null"); + Color colorA; + + Color result; + int offsetRed; + int offsetGreen; + int offsetBlue; + + colorA = null; + offsetRed = 10; + offsetGreen = 0; + offsetBlue = 0; + // result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); + // ---------> java.lang.NullPointerException + // ------> @todo check if color is not null + + colorA = Color.WHITE; + offsetRed = 10; + offsetGreen = 0; + offsetBlue = 0; + // result = ColorConverter.offsetRgbColor(colorA, offsetRed, offsetGreen, offsetBlue); + // ---------> color parameter outside of expected range: + // ------> @todo check if offset* is valid for Color (ex: WHITE 255,255,255 with +10) + + System.out.println("--------------------------"); + } + + // formatColor() ///////////////////////////////////////////////////////////////////// @Test - public void testFormatColorRgbLastParenthesisIsMissing() { + public void testFormatColorStrRgbLastParenthesisIsMissing() { String expResult = "rgb(255,255,255)"; String colorStr = "rgb(255,255,255"; // # must be added - System.out.println("formatColorRgblastParenthesisIsMissing ["+ colorStr +"]"); + System.out.println("formatColorStr - RgblastParenthesisIsMissing ["+ colorStr +"]"); String result = ColorConverter.formatColorStr(colorStr); assertEquals(expResult, result); colorStr = " rgb( 255, 255, 255 "; // # must be added - System.out.println("formatColorRgblastParenthesisIsMissing ["+ colorStr +"]"); + System.out.println("formatColorStr - RgblastParenthesisIsMissing ["+ colorStr +"]"); result = ColorConverter.formatColorStr(colorStr); assertEquals(expResult, result); } @Test - public void testFormatColorRgbToLowerCase() { - System.out.println("formatColorRgbToLowerCase [RGB(255,255,255)]"); + public void testFormatColorStrRgbToLowerCase() { + System.out.println("fformatColorStr - RgbToLowerCase [RGB(255,255,255)]"); String colorStr = "RGB(255,255,255)"; String expResult = "rgb(255,255,255)"; String result = ColorConverter.formatColorStr(colorStr); @@ -174,8 +289,8 @@ public void testFormatColorRgbToLowerCase() { } @Test - public void testFormatColorRgb() { - System.out.println("formatColorRgb [ rgb( 255, 255, 255 ) ]"); + public void testFormatColorStrRgb() { + System.out.println("formatColorStr - Rgb [ rgb( 255, 255, 255 ) ]"); String colorStr = " rgb( 255, 255, 255 ) "; String expResult = "rgb(255,255,255)"; String result = ColorConverter.formatColorStr(colorStr); @@ -184,8 +299,8 @@ public void testFormatColorRgb() { @Test - public void testFormatColorRgbShortWidthSpace() { - System.out.println("formatColorRgbShortWidthSpace [ 255, 255, 255 ]"); + public void testFormatColorStrRgbShortWidthSpace() { + System.out.println("formatColorStr - RgbShortWidthSpace [ 255, 255, 255 ]"); String colorStr = " 255, 255, 255 "; String expResult = "rgb(255,255,255)"; String result = ColorConverter.formatColorStr(colorStr); @@ -193,8 +308,8 @@ public void testFormatColorRgbShortWidthSpace() { } @Test - public void testFormatColorRgbShort() { - System.out.println("formatColorRgbShort [255,255,255]"); + public void testFormatColorStrRgbShort() { + System.out.println("formatColorStr - RgbShort [255,255,255]"); String colorStr = "255,255,255"; String expResult = "rgb(255,255,255)"; String result = ColorConverter.formatColorStr(colorStr); @@ -202,8 +317,8 @@ public void testFormatColorRgbShort() { } @Test - public void testFormatColorNotValidHex() { - System.out.println("formatColorNotValidHex [Ff]"); + public void testFormatColorStrNotValidHex() { + System.out.println("formatColorStr - NotValidHex [Ff]"); String colorStr = "Ff"; // # must be added String expResult = "Ff"; String result = ColorConverter.formatColorStr(colorStr); @@ -211,8 +326,8 @@ public void testFormatColorNotValidHex() { } @Test - public void testFormatColorNotValidHex2() { - System.out.println("formatColorNotValidHex2 [FfFf]"); + public void testFormatColorStrNotValidHex2() { + System.out.println("formatColorStr - NotValidHex2 [FfFf]"); String colorStr = "FfFf"; // # must be added String expResult = "FfFf"; String result = ColorConverter.formatColorStr(colorStr); @@ -220,8 +335,8 @@ public void testFormatColorNotValidHex2() { } @Test - public void testFormatColorNotValidHexLetter2() { - System.out.println("formatColorNotValidHexLetter2 [#ZzZ]"); + public void testFormatColorStrNotValidHexLetter2() { + System.out.println("formatColorStr - NotValidHexLetter2 [#ZzZ]"); String colorStr = "#ZzZ"; // # must be added String expResult = "#ZzZ"; String result = ColorConverter.formatColorStr(colorStr); @@ -229,8 +344,8 @@ public void testFormatColorNotValidHexLetter2() { } @Test - public void testFormatColorNotValidHexLetter() { - System.out.println("formatColorNotValidHexLetter [ZzZ]"); + public void testFormatColorStrNotValidHexLetter() { + System.out.println("formatColorStr - NotValidHexLetter [ZzZ]"); String colorStr = "ZzZ"; // # must be added String expResult = "ZzZ"; String result = ColorConverter.formatColorStr(colorStr); @@ -238,8 +353,8 @@ public void testFormatColorNotValidHexLetter() { } @Test - public void testFormatColorHexAddHash() { - System.out.println("formatColorHexAddHash [000000]"); + public void testFormatColorStrHexAddHash() { + System.out.println("formatColorStr - HexAddHash [000000]"); String colorStr = "000000"; // # must be added String expResult = "#000000"; String result = ColorConverter.formatColorStr(colorStr); @@ -247,8 +362,8 @@ public void testFormatColorHexAddHash() { } @Test - public void testFormatColorHexNotAddHash() { - System.out.println("formatColorHexNotAddHash [#000000]"); + public void testFormatColorStrHexNotAddHash() { + System.out.println("formatColorStr - HexNotAddHash [#000000]"); String colorStr = "#000000"; // # must not be added String expResult = "#000000"; String result = ColorConverter.formatColorStr(colorStr); @@ -256,8 +371,8 @@ public void testFormatColorHexNotAddHash() { } @Test - public void testFormatColorHexTrim() { - System.out.println("formatColorHexTrim [ #000000 ]"); + public void testFormatColorStrHexTrim() { + System.out.println("formatColorStr - HexTrim [ #000000 ]"); String colorStr = " #000000 "; String expResult = "#000000"; String result = ColorConverter.formatColorStr(colorStr); @@ -265,8 +380,8 @@ public void testFormatColorHexTrim() { } @Test - public void testFormatColorHexToUpperCase() { - System.out.println("formatColorHexToUpperCase [#ffffff]"); + public void testFormatColorStrHexToUpperCase() { + System.out.println("formatColorStr - HexToUpperCase [#ffffff]"); String colorStr = "#ffffff"; String expResult = "#FFFFFF"; String result = ColorConverter.formatColorStr(colorStr); @@ -274,17 +389,63 @@ public void testFormatColorHexToUpperCase() { } @Test - public void testFormatColorHex() { - System.out.println("formatColorHex [ ffffff ]"); + public void testFormatColorStrHex() { + System.out.println("formatColorStr - Hex [ ffffff ]"); String colorStr = " ffffff "; String expResult = "#FFFFFF"; String result = ColorConverter.formatColorStr(colorStr); assertEquals(expResult, result); } + @Test + public void testFormatColorStrNameBadCase() { + System.out.println("formatColorStr - Name [ wHite ]"); + String colorStr = " wHite "; + String expResult = "White"; + String result = ColorConverter.formatColorStr(colorStr); + assertEquals(expResult, result); + } + + @Test + public void testFormatColorStrNameWithSpace() { + System.out.println("formatColorStr - Name [ dark magenta ]"); + String colorStr = " dark magenta "; + String expResult = "DarkMagenta"; + String result = ColorConverter.formatColorStr(colorStr); + assertEquals(expResult, result); + } + + @Test + public void testFormatColorStrBadName() { + System.out.println("formatColorStr - BadName [wHite_BadName]"); + String colorStr = "wHite_BadName"; + String expResult = colorStr; + String result = ColorConverter.formatColorStr(colorStr); + assertEquals(expResult, result); + } + + // Color colorFromRgbStr() ///////////////////////////////////////////////////////////////////// + @Test + public void testColorFromRgbStrBadFormat() { + String colorStr = "#255,0,0"; + System.out.println("colorFromRgbStrBadRedValue ["+ colorStr +"]"); + Color expResult = null; + Color result = ColorConverter.colorFromRgbStr(colorStr); + assertEquals(expResult, result); + } + + @Test + public void testColorFromRgbStrBadValue() { + String colorStr = "-1, 0, 0"; + System.out.println("colorFromRgbStrBadValue ["+ colorStr +"]"); + Color expResult = null; + Color result = ColorConverter.colorFromRgbStr(colorStr); + assertEquals(expResult, result); + } + @Test public void testColorFromRgbStrBadRedValue() { String colorStr = "256, 0, 0"; @@ -385,6 +546,117 @@ public void testColorFromRgbStrPinkShort() { } +// String hex2Rgb(Color color) +///////////////////////////////////////////////////////////////////// + + /** + * Test of hex2Rgb method, of class ColorConverter. + * String hex2Rgb(Color color) + */ + @Test + public void testHex2Rgb_color() { + System.out.println("---- Hex2Rgb_color --------------------"); + Color colorA; + String expResult; + String result; + + colorA = Color.WHITE; + System.out.println("hex2Rgb [Color.WHITE]"); + expResult = "rgb(255, 255, 255)"; + result = ColorConverter.hex2Rgb(colorA); + assertEquals(expResult, result); + + colorA = Color.BLACK; + System.out.println("hex2Rgb [Color.BLACK]"); + expResult = "rgb(0, 0, 0)"; + result = ColorConverter.hex2Rgb(colorA); + assertEquals(expResult, result); + + System.out.println("--------------------------"); + } + + +// Color hex2Rgb(String colorStr) +///////////////////////////////////////////////////////////////////// + + /** + * Test of hex2Rgb method, of class ColorConverter. + * Color hex2Rgb(String colorStr) + */ + @Test + public void testHex2Rgb_str() { + System.out.println("---- Hex2Rgb_str --------------------"); + String colorStr = "FFFFFF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + Color expResult = Color.WHITE; + Color result = ColorConverter.hex2Rgb(colorStr); + assertEquals(expResult, result); + + colorStr = "FFF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + expResult = Color.WHITE; + result = ColorConverter.hex2Rgb(colorStr); + assertEquals(expResult, result); + + colorStr = "#FFFFFF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + expResult = Color.WHITE; + result = ColorConverter.hex2Rgb(colorStr); + assertEquals(expResult, result); + + colorStr = "#FFF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + expResult = Color.WHITE; + result = ColorConverter.hex2Rgb(colorStr); + assertEquals(expResult, result); + + System.out.println("--------------------------"); + } + + public void testHex2Rgb_strBadValue() { + System.out.println("---- Hex2Rgb_strBadValue --------------------"); + String colorStr = ""; + Color result = null; + + colorStr = ""; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + colorStr = "#ZZZ"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + colorStr = "ZZZ"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + colorStr = "#FF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + colorStr = "FF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + colorStr = "#FFFF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + colorStr = "FFFF"; + System.out.println("hex2Rgb string ["+ colorStr +"]"); + result = ColorConverter.hex2Rgb(colorStr); + assertNull(result); + + System.out.println("--------------------------"); + } + + // String rgb2Hex() ///////////////////////////////////////////////////////////////////// @@ -415,5 +687,218 @@ public void testRgb2hexPink() { String result = ColorConverter.rgb2Hex(color); assertEquals(expResult, result); } + +// String rgb2Hsl() +///////////////////////////////////////////////////////////////////// + + @Test + public void testRgb2Hsl() { + System.out.println("------------ rgb2Hsl ----------------"); + Color colorA; + String result; + String expResult; + + colorA = Color.BLACK; + result = ColorConverter.rgb2Hsl(colorA); + expResult = "hsl(0, 0%, 0%)"; + assertEquals(expResult, result); + System.out.println("rgb2Hsl BLACK to ["+ expResult +"]"); + + colorA = Color.WHITE; + result = ColorConverter.rgb2Hsl(colorA); + expResult = "hsl(0, 0%, 100%)"; + System.out.println("rgb2Hsl WHITE to ["+ expResult +"]"); + assertEquals(expResult, result); + + colorA = new Color(70, 136, 71); // #468847 + result = ColorConverter.rgb2Hsl(colorA); + expResult = "hsl(120, 32%, 40%)"; + System.out.println("rgb2Hsl #468847 to ["+ expResult +"]"); + assertEquals(expResult, result); + + System.out.println("--------------------------"); + } + + +// colorFromStr +///////////////////////////////////////////////////////////////////// + + @Test + public void testColorFromStr() { + System.out.println("------------ ColorFromStr ----------------"); + String colorStr; + Color result; + Color expResult; + + colorStr = "#FFF"; + expResult = Color.WHITE; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "#FFFFFF"; + expResult = Color.WHITE; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "FFF"; + expResult = Color.WHITE; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "FFFFFF"; + expResult = Color.WHITE; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "rgb(255,255,255)"; + expResult = Color.WHITE; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "rgb(139,0,139"; + expResult = new Color(139,0,139); + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "139,0,139"; + expResult = new Color(139,0,139); + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = " wHite "; + expResult = Color.WHITE; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = " BlaCK "; + expResult = Color.BLACK; + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + colorStr = "darkmagenta"; + expResult = new Color(139,0,139); + result = ColorConverter.colorFromStr(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromStr ["+ colorStr +"]"); + + System.out.println("--------------------------"); + } + + @Test + public void testColorFromStr_badValue() { + System.out.println("------------ ColorFromStr BAD value ----------------"); + String colorStr; + Color result; + Color expResult; + + colorStr = "256,0,0"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "rgb(256,0,0)"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "rgb(256,0,0"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "FF"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "FFFFFFFFFFFFF"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "#FF"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "#FFFFFFFFFFFFF"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = "badColorName_WHITE"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = ""; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + System.out.println("--------------------------"); + } + +// colorFromColorName() +///////////////////////////////////////////////////////////////////// + + @Test + public void testColorFromColorName() { + System.out.println("------------ colorFromColorName ----------------"); + String colorStr; + Color result; + Color expResult; + + colorStr = " wHite "; + expResult = Color.WHITE; + result = ColorConverter.colorFromColorName(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromColorName ["+ colorStr +"]"); + + colorStr = " BlaCK "; + expResult = Color.BLACK; + result = ColorConverter.colorFromColorName(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromColorName ["+ colorStr +"]"); + + colorStr = "darkmagenta"; + expResult = new Color(139,0,139); + result = ColorConverter.colorFromColorName(colorStr); + assertEquals(expResult, result); + System.out.println("colorFromColorName ["+ colorStr +"]"); + + System.out.println("--------------------------"); + } + + @Test + public void testColorFromColorName_badValue() { + System.out.println("------------ colorFromColorName BAD value----------------"); + String colorStr; + Color result; + + colorStr = "badColorName_WHITE"; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + colorStr = ""; + result = ColorConverter.colorFromColorName(colorStr); + assertNull(result); + System.out.println("colorFromColorName BAD value ["+ colorStr +"]"); + + System.out.println("--------------------------"); + } + + + } diff --git a/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java b/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java index 9b696eeb..1e28723e 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/colornamelookup/ColorNameLookupTest.java @@ -22,7 +22,7 @@ import java.awt.Color; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test /** * @@ -46,6 +46,47 @@ protected void tearDown() throws Exception { // @@@TODO add test for getColorNameFromStr + ///// getColorFromName /////////////////////////////////////////////// + + @Test + public void testGetColorNameFromStrWhite() { + String colorStr = "white"; + System.out.println("GetColorNameFromStr ["+ colorStr +"]"); + ColorNameLookup c = new ColorNameLookup(); + String result = c.getColorNameFromStr(colorStr); + assertEquals("White", result); + } + + @Test + public void testGetColorNameFromStrBadColorName() { + String colorStr = "BadColorName"; + System.out.println("GetColorNameFromStr ["+ colorStr +"]"); + ColorNameLookup c = new ColorNameLookup(); + String result = c.getColorNameFromStr(colorStr); + assertEquals("", result); + } + + @Test + public void testGetColorNameFromStrBadCaseWidthSpaces() { + String colorStr = " darkmagenta "; + System.out.println("GetColorNameFromStr ["+ colorStr +"]"); + ColorNameLookup c = new ColorNameLookup(); + String result = c.getColorNameFromStr(colorStr); + assertEquals("DarkMagenta", result); + } + + + ///// getColorFromName /////////////////////////////////////////////// + + @Test + public void testGetColorFromNameBadColorName() { + String colorStr = "BadColorName"; + System.out.println("GetColorFromNameBadColorName ["+ colorStr +"]"); + ColorNameLookup c = new ColorNameLookup(); + Color result = c.getColorFromName(colorStr); + assertNull(result); + } + @Test public void testGetColorFromNameWhite() { String colorStr = "white"; @@ -86,5 +127,4 @@ public void testGetColorFromNameBadCaseWidthSpaces() { assertEquals(expResult, result); } - } diff --git a/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java b/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java index 9dfabbc0..62372b37 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java @@ -23,7 +23,7 @@ import java.awt.Color; import java.text.DecimalFormat; import junit.framework.TestCase; -import org.junit.Test; // Junit anotation @Test +import org.junit.Test; // Junit 4 anotation @Test /** * @@ -43,60 +43,125 @@ protected void tearDown() throws Exception { super.tearDown(); } + /////////////////////////////////////////////////////////////////// + @Test + public void testisContrastValidWhiteBlack() { + Color colorA = Color.WHITE; + Color colorB = Color.BLACK; + float coef = (float) 3.5; + System.out.println("ContrastChecker - isContrastValid WhiteBlack : [WHITE] and [BLACK] for ["+ coef +"] = TRUE"); + boolean result = ContrastChecker.isContrastValid(colorA, colorB, coef); + assertTrue(result); + } + + @Test + public void testisContrastValidTwoGreenFail() { + Color colorA = new Color(70, 136, 71); // #468847 + Color colorB = new Color(223, 240, 216); // #DFF0D8 + float coef = (float) 4; + System.out.println("ContrastChecker - isContrastValid TwoGreenFail : [#468847] and [#DFF0D8] for ["+ coef +"] = FALSE"); + boolean result = ContrastChecker.isContrastValid(colorA, colorB, coef); + assertFalse(result); + } + + @Test + public void testisContrastValidTwoGreenPass() { + Color colorA = new Color(70, 136, 71); // #468847 + Color colorB = new Color(223, 240, 216); // #DFF0D8 + float coef = (float) 3.5; + System.out.println("ContrastChecker - isContrastValid TwoGreenPass : [#468847] and [#DFF0D8] for ["+ coef +"] = TRUE"); + boolean result = ContrastChecker.isContrastValid(colorA, colorB, coef); + assertTrue(result); + } + + /////////////////////////////////////////////////////////////////// + @Test + public void testgetConstrastRatio5DigitRound() { + Color colorA = new Color(70, 136, 71); // #468847 + Color colorB = new Color(223, 240, 216); // #DFF0D8 + double result = ContrastChecker.getConstrastRatio5DigitRound(colorA, colorB); + System.out.println("getConstrastRatio5DigitRound : [#468847] and [#DFF0D8] = ["+ result +"] "); + assertEquals(3.61029, result, 0.00000001); + + result = ContrastChecker.getConstrastRatio5DigitRound(colorB, colorA); + System.out.println("getConstrastRatio5DigitRound : [#DFF0D8] and [#468847] = ["+ result +"] "); + assertEquals(3.61029, result, 0.00000001); + } + /////////////////////////////////////////////////////////////////// + @Test + public void testDistanceColor() { + Color colorA = new Color(70, 136, 71); // #468847 + Color colorB = new Color(66, 118, 69); // #427645 + float result = (float) ContrastChecker.distanceColor(colorA, colorB); + System.out.println("DistanceColor : [#468847] and [#DFF0D8] = ["+ result +"] "); + assertEquals(18.547237, result, 0.000001); + + result = (float) ContrastChecker.distanceColor(colorB, colorA); + System.out.println("DistanceColor : [#468847] and [#DFF0D8] = ["+ result +"] "); + assertEquals(18.547237, result, 0.000001); + + colorA = Color.WHITE; + colorB = new Color(192,192,192); // Silver + result = (float) ContrastChecker.distanceColor(colorB, colorA); + System.out.println("DistanceColor : [WHITE] and [silver] = ["+ result +"] "); + assertEquals(109.119201, result, 0.000001); + + colorA = Color.BLACK; + colorB = Color.WHITE; + result = (float) ContrastChecker.distanceColor(colorB, colorA); + System.out.println("DistanceColor : [BLACK] and [WHITE] = ["+ result +"] "); + assertEquals(441.672943, result, 0.000001); + } + + /** * Test of getConstrastRatio method, of class ContrastChecker. */ @Test public void testGetConstrastRatio() { - System.out.println("getConstrastRatio"); - - DecimalFormat df = new DecimalFormat("#.##"); - + System.out.println("---- getConstrastRatio --------------"); + DecimalFormat df = new DecimalFormat("#.####"); + /////////////////////////////////////////////////////////////////////// Color fgColor = new Color(70, 136, 71); Color bgColor = new Color(223, 240, 216); -// ContrastChecker instance = new ContrastChecker(); - - - double result = ContrastChecker.getConstrastRatio(bgColor, fgColor); System.out.println("result :" + result); -// assertEquals("21", df.format(result)); -// -// bgColor = new Color(255, 255, 255); -// fgColor = new Color(0, 0, 0); -//// instance = new ContrastChecker(); -// -// result = ContrastChecker.getConstrastRatio(fgColor, bgColor); -// System.out.println("result :" + result); -// assertEquals("21", String.format("%.2g", result)); -// -// fgColor = new Color(255, 53, 255); -// bgColor = new Color(18, 52, 95); -// -// result = ContrastChecker.getConstrastRatio(fgColor, bgColor); -// System.out.println("result :" + result); -// assertEquals("4,28", df.format(result)); -// -// bgColor = new Color(255, 53, 255); -// fgColor = new Color(18, 52, 95); -// -// result = ContrastChecker.getConstrastRatio(fgColor, bgColor); -// System.out.println("result :" + result); -// assertEquals("4.28", String.format("%.3g", result)); -// -// bgColor = new Color(255, 255, 255); -// fgColor = new Color(255, 255, 255); -// -// result = ContrastChecker.getConstrastRatio(fgColor, bgColor); -// System.out.println("result :" + result); -// assertEquals("1.00", String.format("%.3g", result)); -// -// bgColor = new Color(53, 53, 53); -// fgColor = new Color(53, 53, 53); -// -// result = ContrastChecker.getConstrastRatio(fgColor, bgColor); -// System.out.println("result :" + result); -// assertEquals("1.00", String.format("%.3g", result)); - + assertEquals("3,6103", df.format(result)); + /////////////////////////////////////////////////////////////////////// + fgColor = new Color(223, 240, 216); + bgColor = new Color(70, 136, 71); + result = ContrastChecker.getConstrastRatio(bgColor, fgColor); + System.out.println("result :" + result); + assertEquals("3,6103", df.format(result)); + /////////////////////////////////////////////////////////////////////// + bgColor = new Color(255, 255, 255); + fgColor = new Color(0, 0, 0); + result = ContrastChecker.getConstrastRatio(fgColor, bgColor); + System.out.println("result :" + result); + assertEquals("21", String.format("%.2g", result)); + /////////////////////////////////////////////////////////////////////// + fgColor = new Color(255, 53, 255); + bgColor = new Color(18, 52, 95); + result = ContrastChecker.getConstrastRatio(fgColor, bgColor); + System.out.println("result :" + result); + assertEquals("4,2833", df.format(result)); + /////////////////////////////////////////////////////////////////////// + bgColor = new Color(255, 53, 255); + fgColor = new Color(18, 52, 95); + result = ContrastChecker.getConstrastRatio(fgColor, bgColor); + System.out.println("result :" + result); + assertEquals("4,28", String.format("%.3g", result)); + /////////////////////////////////////////////////////////////////////// + bgColor = new Color(255, 255, 255); + fgColor = new Color(255, 255, 255); + result = ContrastChecker.getConstrastRatio(fgColor, bgColor); + System.out.println("result :" + result); + assertEquals("1,00", String.format("%.3g", result)); + /////////////////////////////////////////////////////////////////////// + bgColor = new Color(53, 53, 53); + fgColor = new Color(53, 53, 53); + result = ContrastChecker.getConstrastRatio(fgColor, bgColor); + System.out.println("result :" + result); + assertEquals("1,00", String.format("%.3g", result)); } } diff --git a/engine/utils/src/test/java/org/asqatasun/utils/distancecalculator/DistanceCalculatorTest.java b/engine/utils/src/test/java/org/asqatasun/utils/distancecalculator/DistanceCalculatorTest.java new file mode 100644 index 00000000..8ca5bc2a --- /dev/null +++ b/engine/utils/src/test/java/org/asqatasun/utils/distancecalculator/DistanceCalculatorTest.java @@ -0,0 +1,76 @@ +/* + * Contrast Finder + * Copyright (C) 2008-2017 Asqatasun.org + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * Contact us by mail: asqatasun AT asqatasun DOT org + */ +package org.asqatasun.utils.distancecalculator; + +//import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +//import static org.junit.Assert.assertFalse; +//import static org.junit.Assert.assertNotNull; +//import static org.junit.Assert.assertNotSame; +//import static org.junit.Assert.assertNull; +//import static org.junit.Assert.assertSame; +//import static org.junit.Assert.assertThat; +//import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import org.junit.Test; // Junit 4 anotation @Test + +/** + * use Junit 4 syntax + */ +public class DistanceCalculatorTest { + + @Test + public void testCalculateWhiteBlack() { + Color colorA = Color.WHITE; + Color colorB = Color.BLACK; + System.out.println("DistanceCalculator - CalculateWhiteBlack : [WHITE] and [BLACK]"); + double result = DistanceCalculator.calculate(colorA, colorB); + assertEquals(367.77, result, 0.001); + } + + @Test + public void testCalculateBlackWhite() { + Color colorA = Color.BLACK; + Color colorB = Color.WHITE; + System.out.println("DistanceCalculator - CalculateBlackWhite : [BLACK] and [WHITE]"); + double result = DistanceCalculator.calculate(colorA, colorB); + assertEquals(367.77, result, 0.001); + } + + @Test + public void testCalculateWhiteSilverRgb() { + Color colorA = Color.WHITE; + Color colorB = new Color(192,192,192); // Silver + System.out.println("DistanceCalculator - CalculateWhiteSilverRgb : [WHITE] and [rgb(192,192,192) = SILVER]"); + double result = DistanceCalculator.calculate(colorA, colorB); + assertEquals(90.86, result, 0.001); + } + + @Test + public void testCalculateTwoGreenRgb() { + Color colorA = new Color(70, 136, 71); // #468847 + Color colorB = new Color(66, 118, 69); // #427645 + System.out.println("DistanceCalculator - CalculateTwoGreenRgb : [rgb(70, 136, 71) = #468847] and [rgb(66, 118, 69) = #427645]"); + double result = DistanceCalculator.calculate(colorA, colorB); + assertEquals(18.07, result, 0.001); + } + +} From 6c73d47d99896bcc3a6b684d5a0ed0823589d113 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sun, 19 Nov 2017 19:56:27 +0100 Subject: [PATCH 15/18] fix Travis build for #107 --- .../contrastchecker/ContrastCheckerTest.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java b/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java index 62372b37..9f560540 100644 --- a/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java +++ b/engine/utils/src/test/java/org/asqatasun/utils/contrastchecker/ContrastCheckerTest.java @@ -21,7 +21,6 @@ package org.asqatasun.utils.contrastchecker; import java.awt.Color; -import java.text.DecimalFormat; import junit.framework.TestCase; import org.junit.Test; // Junit 4 anotation @Test @@ -120,48 +119,47 @@ public void testDistanceColor() { @Test public void testGetConstrastRatio() { System.out.println("---- getConstrastRatio --------------"); - DecimalFormat df = new DecimalFormat("#.####"); /////////////////////////////////////////////////////////////////////// Color fgColor = new Color(70, 136, 71); Color bgColor = new Color(223, 240, 216); double result = ContrastChecker.getConstrastRatio(bgColor, fgColor); System.out.println("result :" + result); - assertEquals("3,6103", df.format(result)); + assertEquals(3.6102927, result, 0.0000001); /////////////////////////////////////////////////////////////////////// fgColor = new Color(223, 240, 216); bgColor = new Color(70, 136, 71); result = ContrastChecker.getConstrastRatio(bgColor, fgColor); System.out.println("result :" + result); - assertEquals("3,6103", df.format(result)); + assertEquals(3.6102927, result, 0.0000001); /////////////////////////////////////////////////////////////////////// bgColor = new Color(255, 255, 255); fgColor = new Color(0, 0, 0); result = ContrastChecker.getConstrastRatio(fgColor, bgColor); System.out.println("result :" + result); - assertEquals("21", String.format("%.2g", result)); + assertEquals(21.0000000, result, 0.0000001); /////////////////////////////////////////////////////////////////////// fgColor = new Color(255, 53, 255); bgColor = new Color(18, 52, 95); result = ContrastChecker.getConstrastRatio(fgColor, bgColor); System.out.println("result :" + result); - assertEquals("4,2833", df.format(result)); + assertEquals(4.2833245, result, 0.0000001); /////////////////////////////////////////////////////////////////////// bgColor = new Color(255, 53, 255); fgColor = new Color(18, 52, 95); result = ContrastChecker.getConstrastRatio(fgColor, bgColor); System.out.println("result :" + result); - assertEquals("4,28", String.format("%.3g", result)); + assertEquals(4.2833245, result, 0.0000001); /////////////////////////////////////////////////////////////////////// bgColor = new Color(255, 255, 255); fgColor = new Color(255, 255, 255); result = ContrastChecker.getConstrastRatio(fgColor, bgColor); System.out.println("result :" + result); - assertEquals("1,00", String.format("%.3g", result)); + assertEquals(1.0000000, result, 0.0000001); /////////////////////////////////////////////////////////////////////// bgColor = new Color(53, 53, 53); fgColor = new Color(53, 53, 53); result = ContrastChecker.getConstrastRatio(fgColor, bgColor); System.out.println("result :" + result); - assertEquals("1,00", String.format("%.3g", result)); + assertEquals(1.0000000, result, 0.0000001); } } From 303d5121dcc79d7e413a3e3c220f985f10232c70 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Sun, 19 Nov 2017 21:30:10 +0100 Subject: [PATCH 16/18] delete unused files (*/AppTest.java) --- .../contrast/finder/api/AppTest.java | 38 ------------------- .../asqatasun/color/result/impl/AppTest.java | 38 ------------------- 2 files changed, 76 deletions(-) delete mode 100644 engine/api/src/test/java/org/asqatasun/contrast/finder/api/AppTest.java delete mode 100644 engine/impl/src/test/java/org/asqatasun/color/result/impl/AppTest.java diff --git a/engine/api/src/test/java/org/asqatasun/contrast/finder/api/AppTest.java b/engine/api/src/test/java/org/asqatasun/contrast/finder/api/AppTest.java deleted file mode 100644 index 5af40480..00000000 --- a/engine/api/src/test/java/org/asqatasun/contrast/finder/api/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asqatasun.contrast.finder.api; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/engine/impl/src/test/java/org/asqatasun/color/result/impl/AppTest.java b/engine/impl/src/test/java/org/asqatasun/color/result/impl/AppTest.java deleted file mode 100644 index a81b4b5b..00000000 --- a/engine/impl/src/test/java/org/asqatasun/color/result/impl/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.asqatasun.color.result.impl; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} From ae6ae0eba2e6140ab3f7f0579f946c8012e70663 Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Tue, 28 Nov 2017 19:38:15 +0100 Subject: [PATCH 17/18] Fixed #100 - Upgraded SpringFramework (4.3.13 instead of 4.3.12) --- CHANGELOG.md | 1 + webapp/pom.xml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfaf4db7..3aa18ff5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ none none ### Outdated dependencies +- [#100 - Upgraded SpringFramework (4.3.13 instead of 4.3.12)](https://github.com/Asqatasun/Contrast-Finder/issues/100) - [#101 - Upgraded commons-lang3 (3.7 instead of 3.6)](https://github.com/Asqatasun/Contrast-Finder/issues/101) - [#102 - Upgraded markdown-page-generator-plugin (2.0.0 instead of 1.0.0)](https://github.com/Asqatasun/Contrast-Finder/issues/102) - [#103 - Upgraded maven-javadoc-plugin (3.0.0-M1 instead of 2.10.4)](https://github.com/Asqatasun/Contrast-Finder/issues/103) diff --git a/webapp/pom.xml b/webapp/pom.xml index 28013ff8..b517fa18 100644 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -28,7 +28,7 @@ UTF-8 - 4.3.12.RELEASE + 4.3.13.RELEASE 4.2.3.RELEASE 1.5.2 1.2.5 From 58fb8f2223d9ac7169073c30ebce8adb3c5b2ece Mon Sep 17 00:00:00 2001 From: Fabrice Gangler Date: Tue, 28 Nov 2017 22:53:10 +0100 Subject: [PATCH 18/18] set version to 0.8.3 --- CHANGELOG.md | 23 +------------------ docker/RELEASE/Dockerfile | 10 ++++---- docker/RELEASE/README.md | 2 +- docker/SNAPSHOT-local_from-Tomcat/Dockerfile | 2 +- docker/SNAPSHOT-local_from-Ubuntu/Dockerfile | 2 +- .../test_conf-default-algo/Dockerfile | 2 +- .../test_conf-env_debug/Dockerfile | 2 +- .../test_conf-piwik/Dockerfile | 2 +- .../pre-requisites_from-Ubuntu/Dockerfile | 2 +- documentation/pom.xml | 4 ++-- engine/api/pom.xml | 4 ++-- engine/hsv/pom.xml | 4 ++-- engine/impl/pom.xml | 4 ++-- engine/pom.xml | 4 ++-- engine/utils/pom.xml | 4 ++-- pom.xml | 2 +- webapp/pom.xml | 4 ++-- .../WEB-INF/template/template_variables.jspf | 2 +- 18 files changed, 29 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3aa18ff5..9a546762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,16 +1,10 @@ # CHANGELOG -Contrast-Finder 0.8.3, 2017-11-xx +Contrast-Finder 0.8.3, 2017-11-28 --------------------------------- Upgrade-o-meter: just replace the .war file and restart Tomcat -### New Feature -none - -### Security -none - ### Outdated dependencies - [#100 - Upgraded SpringFramework (4.3.13 instead of 4.3.12)](https://github.com/Asqatasun/Contrast-Finder/issues/100) - [#101 - Upgraded commons-lang3 (3.7 instead of 3.6)](https://github.com/Asqatasun/Contrast-Finder/issues/101) @@ -18,21 +12,6 @@ none - [#103 - Upgraded maven-javadoc-plugin (3.0.0-M1 instead of 2.10.4)](https://github.com/Asqatasun/Contrast-Finder/issues/103) - [#105 - Upgraded org.owasp:dependency-check (3.0.2 instead of 1.4.5)](https://github.com/Asqatasun/Contrast-Finder/issues/105) -### Bug -none - -### Improvement -none - -### Refactoring -none - -### Configuration -none - -### Documentation -none - ### Task - [#104 - Added maven-jxr-plugin (needed for maven-checkstyle-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/104) - [#106 - Added unit tests coverage report (jacoco-maven-plugin)](https://github.com/Asqatasun/Contrast-Finder/issues/106) diff --git a/docker/RELEASE/Dockerfile b/docker/RELEASE/Dockerfile index cac62697..fdfa1011 100644 --- a/docker/RELEASE/Dockerfile +++ b/docker/RELEASE/Dockerfile @@ -1,7 +1,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu LABEL org.label-schema.schema-version = "1.0.0-rc.1" \ org.label-schema.name = "Contrast-Finder - WebApp" \ - org.label-schema.version = "0.8.3-SNAPSHOT" \ + org.label-schema.version = "0.8.3" \ org.label-schema.url = "https://contrast-finder.org" \ org.label-schema.vcs-url = "https://github.com/Asqatasun/Contrast-Finder" \ org.label-schema.docker.cmd = "docker run -p 8087:8080 -d asqatasun/contrast-finder" \ @@ -13,9 +13,9 @@ LABEL org.label-schema.schema-version = "1.0.0-rc.1" # # --- Building this docker image # docker build -t asqatasun/contrast-finder . -# docker build -t asqatasun/contrast-finder --build-arg CONTRAST_FINDER_RELEASE=0.8.3-SNAPSHOT . -# docker build -t asqatasun/contrast-finder --build-arg SRC_URL_PREFIX=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.3-SNAPSHOT/ . -# docker build -t asqatasun/contrast-finder --build-arg SRC_URL=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.3-SNAPSHOT/contrast-finder_0.8.3-SNAPSHOT.i386.tar.gz . +# docker build -t asqatasun/contrast-finder --build-arg CONTRAST_FINDER_RELEASE=0.8.3 . +# docker build -t asqatasun/contrast-finder --build-arg SRC_URL_PREFIX=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.3/ . +# docker build -t asqatasun/contrast-finder --build-arg SRC_URL=https://github.com/Asqatasun/Contrast-Finder/releases/download/v0.8.3/contrast-finder_0.8.3.i386.tar.gz . # # --- Launch a container # docker run -p 127.0.0.1:8087:8080 --name contrast.finder -d asqatasun/contrast-finder @@ -36,7 +36,7 @@ LABEL org.label-schema.schema-version = "1.0.0-rc.1" ################################################################### # build variables -ARG CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" +ARG CONTRAST_FINDER_RELEASE="0.8.3" ARG SRC_URL_PREFIX="https://github.com/Asqatasun/Contrast-Finder/releases/download/v${CONTRAST_FINDER_RELEASE}" ARG SRC_URL="${SRC_URL_PREFIX}/contrast-finder_${CONTRAST_FINDER_RELEASE}.i386.tar.gz" diff --git a/docker/RELEASE/README.md b/docker/RELEASE/README.md index 52d58a32..f53ab303 100644 --- a/docker/RELEASE/README.md +++ b/docker/RELEASE/README.md @@ -7,7 +7,7 @@ Tool to provide color combination for a good (accessible, WCAG-compliant) contra Supported tags and respective `Dockerfile` links : * [pre-requisites_from-Ubuntu](https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile) -* [v0.8.3-SNAPSHOT, latest](https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/RELEASE/Dockerfile) +* [v0.8.3, latest](https://github.com/Asqatasun/Contrast-Finder/blob/master/docker/RELEASE/Dockerfile) * [v0.8.2](https://github.com/Asqatasun/Contrast-Finder/blob/v0.8.2/docker/RELEASE/Dockerfile) * [v0.8.1](https://github.com/Asqatasun/Contrast-Finder/blob/v0.8.1/docker/RELEASE/Dockerfile) * [v0.8.0](https://github.com/Asqatasun/Contrast-Finder/blob/v0.8.0/docker/RELEASE/Dockerfile) diff --git a/docker/SNAPSHOT-local_from-Tomcat/Dockerfile b/docker/SNAPSHOT-local_from-Tomcat/Dockerfile index d2299f79..b7e687c5 100644 --- a/docker/SNAPSHOT-local_from-Tomcat/Dockerfile +++ b/docker/SNAPSHOT-local_from-Tomcat/Dockerfile @@ -25,7 +25,7 @@ FROM tomcat:7.0-jre7 ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" +ENV CONTRAST_FINDER_RELEASE="0.8.3" ENV TOMCAT_WEBAPP_DIR="/usr/local/tomcat/webapps" # Prepare Contrast-Finder diff --git a/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile index d3d6e45f..a086619b 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" +ENV CONTRAST_FINDER_RELEASE="0.8.3" # Add contrast-finder .war ADD contrast-finder_${CONTRAST_FINDER_RELEASE}.i386.tar.gz /root diff --git a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile index d1dc4c23..a828216a 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-default-algo/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" +ENV CONTRAST_FINDER_RELEASE="0.8.3" ENV CONF_DEFAULT_ALGO="Rgb" # ENV CONF_DEFAULT_ALGO="Rgb" # ENV CONF_DEFAULT_ALGO="HSV" diff --git a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile index f270759f..43d1a528 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-env_debug/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" +ENV CONTRAST_FINDER_RELEASE="0.8.3" ENV CONF_ENV="debug" # Add contrast-finder .war diff --git a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile index 960925ca..8c0321b5 100644 --- a/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile +++ b/docker/SNAPSHOT-local_from-Ubuntu/test_conf-piwik/Dockerfile @@ -19,7 +19,7 @@ FROM asqatasun/contrast-finder:pre-requisites_from-Ubuntu ################################################################### # environment variables -ENV CONTRAST_FINDER_RELEASE="0.8.3-SNAPSHOT" +ENV CONTRAST_FINDER_RELEASE="0.8.3" ENV PIWIK_KEY="9" ENV PIWIK_URL="http://localhost/piwik/" diff --git a/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile b/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile index 472a28bc..97b925a8 100644 --- a/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile +++ b/docker/pre-requisites/pre-requisites_from-Ubuntu/Dockerfile @@ -1,7 +1,7 @@ FROM ubuntu:14.04 LABEL org.label-schema.schema-version = "1.0.0-rc.1" \ org.label-schema.name = "Contrast-Finder - WebApp pre-requisites" \ - org.label-schema.version = "0.8.3-SNAPSHOT" \ + org.label-schema.version = "0.8.3" \ org.label-schema.url = "https://contrast-finder.org" \ org.label-schema.vcs-url = "https://github.com/Asqatasun/Contrast-Finder" # ----> documentation http://label-schema.org/ diff --git a/documentation/pom.xml b/documentation/pom.xml index dd389ec7..18607c06 100644 --- a/documentation/pom.xml +++ b/documentation/pom.xml @@ -4,11 +4,11 @@ org.asqatasun contrast-finder - 0.8.3-SNAPSHOT + 0.8.3 documentation pom - 0.8.3-SNAPSHOT + 0.8.3 contrast-finder-documentation diff --git a/engine/api/pom.xml b/engine/api/pom.xml index f945b1a2..33946f9f 100644 --- a/engine/api/pom.xml +++ b/engine/api/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.3-SNAPSHOT + 0.8.3 contrast-finder-api - 0.8.3-SNAPSHOT + 0.8.3 jar api diff --git a/engine/hsv/pom.xml b/engine/hsv/pom.xml index 61f83ed8..cf0b5c22 100644 --- a/engine/hsv/pom.xml +++ b/engine/hsv/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.3-SNAPSHOT + 0.8.3 contrast-finder-hsv - 0.8.3-SNAPSHOT + 0.8.3 jar hsv diff --git a/engine/impl/pom.xml b/engine/impl/pom.xml index ef860a2a..3ce85d73 100644 --- a/engine/impl/pom.xml +++ b/engine/impl/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.3-SNAPSHOT + 0.8.3 contrast-finder-impl - 0.8.3-SNAPSHOT + 0.8.3 jar impl diff --git a/engine/pom.xml b/engine/pom.xml index 071d8a21..48875b6f 100644 --- a/engine/pom.xml +++ b/engine/pom.xml @@ -4,10 +4,10 @@ org.asqatasun contrast-finder - 0.8.3-SNAPSHOT + 0.8.3 engine - 0.8.3-SNAPSHOT + 0.8.3 pom contrast-finder-engine diff --git a/engine/utils/pom.xml b/engine/utils/pom.xml index 3c124d29..67479083 100644 --- a/engine/utils/pom.xml +++ b/engine/utils/pom.xml @@ -4,10 +4,10 @@ org.asqatasun engine - 0.8.3-SNAPSHOT + 0.8.3 contrast-finder-utils - 0.8.3-SNAPSHOT + 0.8.3 jar utils diff --git a/pom.xml b/pom.xml index 3b5fd5aa..1b8dd58b 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ org.asqatasun contrast-finder pom - 0.8.3-SNAPSHOT + 0.8.3 Contrast-Finder diff --git a/webapp/pom.xml b/webapp/pom.xml index b517fa18..24d9b977 100644 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -4,10 +4,10 @@ org.asqatasun contrast-finder - 0.8.3-SNAPSHOT + 0.8.3 webapp - 0.8.3-SNAPSHOT + 0.8.3 war contrast-finder-webapp diff --git a/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf b/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf index f13ad6d6..7bd91ecb 100644 --- a/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf +++ b/webapp/src/main/webapp/WEB-INF/template/template_variables.jspf @@ -2,7 +2,7 @@ <%@ page pageEncoding="UTF-8" %> <%-- APP version --%> - + <%-- APP Name --%>