-
Notifications
You must be signed in to change notification settings - Fork 49
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
Conversation
@@ -51,6 +51,7 @@ public boolean isRebaseable() { | |||
FAILED, | |||
WARNING, | |||
REBASED, | |||
PROCESSING_ERROR | |||
PROCESSING_ERROR, | |||
CONDITIONAL, |
There was a problem hiding this comment.
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
There was a problem hiding this 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
7b2bc1a
to
ee98394
Compare
&& mask.getPixelDifferenceCount() == 0; | ||
} | ||
|
||
private void addPixelDifferenceDataToRestult(ComparatorStepResult result, |
There was a problem hiding this comment.
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
78e40b0
to
4983ee8
Compare
There was a problem hiding this 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()) { |
There was a problem hiding this comment.
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 { | ||
|
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
As discussed with @Skejven, please add following changes on report level:
|
} | ||
|
||
@Test | ||
public void Comparator_hasMaskThresholdWithAcceptableDifference_withoutThreshold_expectFalse() { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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?
Please update integration-tests with some example usages of new threshold parameters (e.g. in integration-tests/test-suite/partials/layout.xml file). |
a0a97af
to
bbe1b50
Compare
private final ComparatorProperties properties; | ||
|
||
private final ArtifactsDAO artifactsDAO; | ||
|
||
private Optional<Integer> pixelThreshold = Optional.empty(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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`. |
There was a problem hiding this comment.
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++; |
There was a problem hiding this comment.
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?
There was a problem hiding this 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; |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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."
121aca4
to
2312405
Compare
…t comparator, created new status conditionally passed
329bb24
to
6831e14
Compare
Please also update documentation of Report webapp, e.g.:
|
644af33
to
87a4f61
Compare
…github.com/Cognifide/aet into newfeature/layout_comparator_with_treshold
@@ -148,5 +148,117 @@ | |||
<url href="comparators/layout/success.jsp" /> | |||
</urls> | |||
</test> | |||
|
|||
<test name="F-comparator-Layout-pixel-threshold"> |
There was a problem hiding this comment.
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++; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can increase passed
. Now, it is evaluating there: https://github.com/Cognifide/aet/blob/f2dbc057f4278e8335583c8cfad43a43b0deb0ee/report/src/main/webapp/app/layout/sidepanel/sidepanel.view.html#L119
What do you think, which way will be better?
I am not 100% sure, why it works in toolbar:
https://github.com/Cognifide/aet/blob/f2dbc057f4278e8335583c8cfad43a43b0deb0ee/report/src/main/webapp/app/layout/toolbar/toolbarTop.view.html#L56
but as you can see on the screen shot, it works correctly:
https://github.com/Cognifide/aet/blob/f2dbc057f4278e8335583c8cfad43a43b0deb0ee/documentation/src/main/wiki/assets/suiteReport/layout-conditionally-passed.PNG
I think @m-suchorski know it better ;)
343f24d
to
a47c9aa
Compare
6847792
to
f2dbc05
Compare
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
Checklist:
I hereby agree to the terms of the AET Contributor License Agreement.