Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newfeature/layout comparator with treshold #293

Merged
merged 22 commits into from
Aug 14, 2018

Conversation

plutasnyy
Copy link
Contributor

@plutasnyy plutasnyy commented Jul 25, 2018

I created error treshold

Description

I added error treshold in pixels and percentages for screen comparator, also I had to create new status for frontend because we would like to know which test passed without changes and which test passed with changes. We changed css and html files for support new status with @m-suchorski . Finally I modified and added a little bit unit tests.

Motivation and Context

For example, the time on the screenshot may be different, and the application may pass this test.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

I hereby agree to the terms of the AET Contributor License Agreement.

@plutasnyy plutasnyy requested a review from tkaik July 25, 2018 11:28
@@ -51,6 +51,7 @@ public boolean isRebaseable() {
FAILED,
WARNING,
REBASED,
PROCESSING_ERROR
PROCESSING_ERROR,
CONDITIONAL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest changing it to CONDITIONAL_PASS

Copy link
Contributor

@tkaik tkaik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, the ImageComparisonResult should only keep a result of image comparison, so it should not keep the threshold values or the methods for checking if the thresholds are not reached. This logic can be moved to e.g. LayoutComparator

EDIT: Please also fix typos: treshold -> threshold

@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch 3 times, most recently from 7b2bc1a to ee98394 Compare July 27, 2018 05:28
&& mask.getPixelDifferenceCount() == 0;
}

private void addPixelDifferenceDataToRestult(ComparatorStepResult result,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the typo Restult -> Result

@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch from 78e40b0 to 4983ee8 Compare July 27, 2018 10:53
Copy link
Contributor

@malaskowski malaskowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's discuss having additional conditionally passed status and marking it as a separate statistic.

ComparatorStepResult result = new ComparatorStepResult(null, ComparatorStepResult.Status.PASSED,
false);
boolean hasMaskThresholdWithAcceptableDifference(ImageComparisonResult mask) {
if (this.pixelThreshold.isPresent() && this.percentageThreshold.isPresent()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this reference is unnecessary here, please remove it.

} catch (Exception e) {
throw new ProcessingException(e.getMessage(), e);
} finally {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this empty line.

@@ -60,6 +60,7 @@ $warning: #f0ad4e;
$rebased: #0097fe;
$failed: #bb5a5a;
$passed: #6f9f00;
$conditionallyPassed: #aacc2d;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about marking conditionally passed as a separate statistic and color.
There should be proper filter to show conditionally passed, but let's not introduce additional color for now.

@tkaik
Copy link
Contributor

tkaik commented Jul 30, 2018

As discussed with @Skejven, please add following changes on report level:

  • number of PASS results should include conditional passed, e.g. change "0 (1)" to "1 (1)"
  • use same color for conditional and regular pass (green)
  • add different icon for Conditional Passed on both URL and Test level (e.g. https://fontawesome.com/icons/dot-circle?style=solid )
  • add filter to "Show only conditionally passed" (existing "show passed urls" filter will also show conditionals)
    CC @m-suchorski

}

@Test
public void Comparator_hasMaskThresholdWithAcceptableDifference_withoutThreshold_expectFalse() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comparator_ prefix is not needed in test names - please use Tests naming convention


svg {
svg {
Copy link
Contributor

@tkaik tkaik Jul 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the formatting here (indentations and keep a space after : )

| Parameter | Value | Description | Mandatory |
| --------- | ----- | ----------- | --------- |
| `pixelThreshold` | int (bigger than 0) | The value to set the error threshold in pixels | no |
| `percentageThreshold` | double (0 to 100) | The value to set the error threshold in percentages | no |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This documentation is missing some details - how the threshold mechanism works and what will happen on report if the difference will be below/equal/above threshold?

@tkaik
Copy link
Contributor

tkaik commented Jul 31, 2018

Please update integration-tests with some example usages of new threshold parameters (e.g. in integration-tests/test-suite/partials/layout.xml file).

@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch from a0a97af to bbe1b50 Compare August 1, 2018 07:41
private final ComparatorProperties properties;

private final ArtifactsDAO artifactsDAO;

private Optional<Integer> pixelThreshold = Optional.empty();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Optional as a field type is not a good practice. Please use Integer instead.

}

private boolean isAcceptablePixelChange(ImageComparisonResult mask) {
return mask.getPixelDifferenceCount() <= this.pixelThreshold.get();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will get NPE if pixelThreshold is absent.

import java.awt.image.BufferedImage;
import java.util.Optional;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like unused import.

| --------- | ----- | ----------- | --------- |
| `pixelThreshold` | int (bigger than 0) | The value to set the error threshold in pixels e.g if difference between photos is smaller or equal to `pixelThreshold`, the test will pass. In case of difference is bigger than `pixelThreshold`, the test will fail. | no |
| `percentageThreshold` | double (0 to 100) | It works as `pixelThreshold` but values are in percentages | no |
When you provide `pixelThreshold` and `percentageThreshold` test will pass only if pixel difference is smaller or equal than `pixelThreshold` and percentage difference is smaller or equal than `percentageThreshold`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is something wrong with the formatting, maybe put extra blank line between the table and sentence in line 17.

@@ -287,6 +291,14 @@ define(['angularAMD', 'metadataCacheService', 'metadataEndpointService'],
}
}

function conditionallyPassed() {
decoratedObject.total++;
decoratedObject.conditionallyPassed++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should also increase passed value here?

Copy link
Contributor

@malaskowski malaskowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update CHANGELOG according to AET Contributing rules

private final ComparatorProperties properties;

private final ArtifactsDAO artifactsDAO;

private Integer pixelThreshold = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to assign null. This is default value of java Object.

if (params.containsKey(PIXEL_THRESHOLD_PARAM)) {
setPixelThreshold(Integer.valueOf(params.get(PIXEL_THRESHOLD_PARAM)));
ParametersValidator.checkParameter(pixelThreshold >= 0,
"Pixel threshold should be greater than 0");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Condition above says greater or equal than 0 :)

setPercentageThreshold(Double.valueOf(params.get(PERCENTAGE_THRESHOLD_PARAM)));
ParametersValidator
.checkRange(percentageThreshold.intValue(), 0, 100,
"Wrong percentage threshold value");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe that message would be more verbose:

"Percentage threshold should be a decimal value between 0 and 100."

@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch from 121aca4 to 2312405 Compare August 1, 2018 13:01
@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch from 329bb24 to 6831e14 Compare August 1, 2018 13:16
@tkaik
Copy link
Contributor

tkaik commented Aug 2, 2018

Please also update documentation of Report webapp, e.g.:

@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch from 644af33 to 87a4f61 Compare August 2, 2018 10:04
@@ -148,5 +148,117 @@
<url href="comparators/layout/success.jsp" />
</urls>
</test>

<test name="F-comparator-Layout-pixel-threshold">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update expected number of failed/passed tests in bobcat tests (integration-tests/sanity-functional)

@@ -287,6 +291,14 @@ define(['angularAMD', 'metadataCacheService', 'metadataEndpointService'],
}
}

function conditionallyPassed() {
decoratedObject.total++;
decoratedObject.conditionallyPassed++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to increase passed value here or not?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@malaskowski malaskowski mentioned this pull request Aug 7, 2018
6 tasks
@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch 4 times, most recently from 343f24d to a47c9aa Compare August 9, 2018 13:48
@plutasnyy plutasnyy force-pushed the newfeature/layout_comparator_with_treshold branch from 6847792 to f2dbc05 Compare August 10, 2018 07:15
@tkaik tkaik merged commit fecce3b into master Aug 14, 2018
@tMaxx tMaxx deleted the newfeature/layout_comparator_with_treshold branch August 6, 2020 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants