-
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
Bugfix/resolution and subimage issues #518
Merged
Merged
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
23c4767
Minimum resolution height set to 1 px to prevent error
tkaik e66ea3d
screen collectors validates subimage size on full img
tkaik 39d9c37
Sample site and test suite cases for resolution height/paratial size …
tkaik 589e1be
Merge branch 'master' of https://github.com/Cognifide/aet into bugfix…
tkaik cb014fe
license header for new files; test-suite fixes
tkaik 8b1a0a8
Minimum height set to 1px while getting partial screenshot
Cich0sza 522f26f
cleanup
Cich0sza ebc842c
Update CHANGELOG.md
Cich0sza c245de5
Merge branch 'master' into bugfix/resolution-and-subimage-issues
Cich0sza fc00e36
refactor
Cich0sza 3df4f83
Merge remote-tracking branch 'origin/bugfix/resolution-and-subimage-i…
Cich0sza 12aa32f
Add screen collector unit test
Cich0sza 4c3f01e
Add tests to ScreenCollector
Cich0sza 8a046d8
Merge branch 'master' into bugfix/resolution-and-subimage-issues
Cich0sza 4b36e67
Update test case
Cich0sza b01cc3f
Update integration tests number
Cich0sza 7aea1e4
Merge branch 'master' into bugfix/resolution-and-subimage-issues
Cich0sza a7bc060
Update filtering.feature tests number
Cich0sza 2e2e7f1
Merge branch 'master' into bugfix/resolution-and-subimage-issues
tkaik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
...rc/test/java/com/cognifide/aet/job/common/collectors/screen/ScreenCollectorImageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/** | ||
* AET | ||
* <p> | ||
* Copyright (C) 2013 Cognifide Limited | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.cognifide.aet.job.common.collectors.screen; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.runners.MockitoJUnitRunner; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.Point; | ||
|
||
import javax.imageio.ImageIO; | ||
import java.awt.*; | ||
import java.awt.image.BufferedImage; | ||
import java.io.File; | ||
|
||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@RunWith(MockitoJUnitRunner.class) | ||
public class ScreenCollectorImageTest { | ||
|
||
private static final Color black = new Color(0); | ||
|
||
@InjectMocks | ||
private ScreenCollector screenCollector; | ||
|
||
private BufferedImage testImage; | ||
|
||
|
||
@Before | ||
public void setup() throws Exception { | ||
String path = getClass().getResource("/screens/48x48.png").getFile(); | ||
File image = new File(path); | ||
testImage = ImageIO.read(image); | ||
} | ||
|
||
@Test | ||
public void testSubImageSize() { | ||
Point point = new org.openqa.selenium.Point(12, 12); | ||
Dimension dimension = new Dimension(24, 24); | ||
|
||
BufferedImage subImage = screenCollector.getSubImage(testImage, point, dimension); | ||
|
||
assertThat(subImage.getHeight()).isEqualTo(24); | ||
assertThat(subImage.getWidth()).isEqualTo(24); | ||
|
||
} | ||
|
||
@Test | ||
public void testSubImageContent() { | ||
Point point = new org.openqa.selenium.Point(12, 12); | ||
Dimension dimension = new Dimension(24, 24); | ||
|
||
BufferedImage subImage = screenCollector.getSubImage(testImage, point, dimension); | ||
boolean onlyBlack = true; | ||
|
||
for (int i = 0; i < subImage.getHeight(); i++) { | ||
for (int j = 0; j < subImage.getWidth(); j++) { | ||
onlyBlack &= black.equals(new Color(subImage.getRGB(i, j))); | ||
} | ||
} | ||
assertThat(onlyBlack).isTrue(); | ||
} | ||
|
||
@Test | ||
public void testSubImageSize_whenElementIsHidden() { | ||
Point point = new Point(0, 0); | ||
Dimension dimension = new Dimension(0, 0); | ||
|
||
BufferedImage subImage = screenCollector.getSubImage(testImage, point, dimension); | ||
|
||
assertThat(subImage.getHeight()).isEqualTo(1); | ||
assertThat(subImage.getWidth()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
public void testSubImageSize_whenElementIsBiggerThanImage() { | ||
Point point = new Point(20, 20); | ||
Dimension dimension = new Dimension(48, 48); | ||
|
||
BufferedImage subImage = screenCollector.getSubImage(testImage, point, dimension); | ||
|
||
assertThat(subImage.getHeight()).isEqualTo(28); | ||
assertThat(subImage.getWidth()).isEqualTo(28); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions
28
integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/0px_height_page.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%-- | ||
|
||
AET | ||
|
||
Copyright (C) 2013 Cognifide Limited | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
--%> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AET Demo Page</title> | ||
</head> | ||
<body style="display:none"> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
...n-tests/sample-site/src/main/webapp/sanity/comparators/layout/0px_height_page_partial.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<%-- | ||
|
||
AET | ||
|
||
Copyright (C) 2013 Cognifide Limited | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
--%> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AET Demo Page</title> | ||
</head> | ||
<body style="display:none"> | ||
<h1 class="someclass" style="display:none"></h1> | ||
</body> | ||
</html> |
28 changes: 28 additions & 0 deletions
28
integration-tests/sample-site/src/main/webapp/sanity/comparators/layout/1px_height_page.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<%-- | ||
|
||
AET | ||
|
||
Copyright (C) 2013 Cognifide Limited | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
--%> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AET Demo Page</title> | ||
</head> | ||
<body style="height:1px"> | ||
</body> | ||
</html> |
29 changes: 29 additions & 0 deletions
29
...-tests/sample-site/src/main/webapp/sanity/comparators/layout/partial_bigger_than_page.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<%-- | ||
|
||
AET | ||
|
||
Copyright (C) 2013 Cognifide Limited | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
--%> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>AET Demo Page</title> | ||
</head> | ||
<body style="height:10px"> | ||
<div style="height:100px"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 am not 100% sure but with a change in integration tests you should also update https://github.com/Cognifide/aet/blob/master/integration-tests/sanity-functional/src/test/resources/features/filtering.feature or/and https://github.com/Cognifide/aet/blob/master/integration-tests/sanity-functional/src/test/java/com/cognifide/aet/sanity/functional/HomePageTilesTest.java
I remember that documentation contains some tutorial on how to run these tests but unfortunately I cannot find it :P