|
|
@@ -9,6 +9,10 @@ import java.util.Properties; |
|
|
|
import java.util.regex.Matcher; |
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
import org.apache.commons.io.FileUtils; |
|
|
|
import org.apache.commons.io.filefilter.DirectoryFileFilter; |
|
|
|
import org.apache.commons.io.filefilter.SuffixFileFilter; |
|
|
|
|
|
|
|
import com.vaadin.event.ShortcutAction.KeyCode; |
|
|
|
import com.vaadin.event.ShortcutListener; |
|
|
|
import com.vaadin.server.ExternalResource; |
|
|
@@ -35,11 +39,11 @@ public class ScreenshotBrowser extends UI { |
|
|
|
* 3 - platform |
|
|
|
* 4 - browser name |
|
|
|
* 5 - browser version |
|
|
|
* 6 - additional qualifiers |
|
|
|
* 7 - identifier |
|
|
|
* 6 - identifier |
|
|
|
* 7 - additional identifiers |
|
|
|
*/ |
|
|
|
private static final Pattern screenshotNamePattern = Pattern |
|
|
|
.compile("(.+?)-(.+?)_(.+?)_(.+?)_(.+?)(_.+)?_(.+?)\\.png\\.html"); |
|
|
|
.compile("(.+?)-(.+?)_(.+?)_(.+?)_(.*?)_(.+?)(_.+)?\\.png\\.html"); |
|
|
|
|
|
|
|
public static enum Action { |
|
|
|
ACCEPT { |
|
|
@@ -97,7 +101,7 @@ public class ScreenshotBrowser extends UI { |
|
|
|
} |
|
|
|
|
|
|
|
private static File getReferenceDir() { |
|
|
|
return new File(screenshotDir, "reference"); |
|
|
|
return new File(screenshotDir, "reference-screenshots"); |
|
|
|
} |
|
|
|
|
|
|
|
private static File getAlternative(File baseFile, |
|
|
@@ -146,12 +150,12 @@ public class ScreenshotBrowser extends UI { |
|
|
|
return matcher.group(4) + " " + matcher.group(5); |
|
|
|
} |
|
|
|
|
|
|
|
public String getQualifiers() { |
|
|
|
return matcher.group(6); |
|
|
|
} |
|
|
|
|
|
|
|
public String getIdentifier() { |
|
|
|
return matcher.group(7); |
|
|
|
String additional = matcher.group(7); |
|
|
|
if (additional != null) { |
|
|
|
return matcher.group(6) + additional; |
|
|
|
} |
|
|
|
return matcher.group(6); |
|
|
|
} |
|
|
|
|
|
|
|
public void setAction(Action action) { |
|
|
@@ -176,7 +180,8 @@ public class ScreenshotBrowser extends UI { |
|
|
|
|
|
|
|
left.setMargin(true); |
|
|
|
left.setSpacing(true); |
|
|
|
left.setSizeFull(); |
|
|
|
left.setSizeUndefined(); |
|
|
|
left.setWidth("270px"); |
|
|
|
|
|
|
|
left.addComponent( |
|
|
|
createActionButton("Accept changes", 'j', Action.ACCEPT)); |
|
|
@@ -199,15 +204,17 @@ public class ScreenshotBrowser extends UI { |
|
|
|
left.addComponent(expandSpacer); |
|
|
|
left.setExpandRatio(expandSpacer, 1); |
|
|
|
|
|
|
|
left.addComponent(new Label( |
|
|
|
"Press the j, k or l keys to quickly select an action for the selected item.")); |
|
|
|
Label instructions = new Label( |
|
|
|
"Press the j, k or l keys to quickly select an action for the selected item."); |
|
|
|
instructions.setWidth("100%"); |
|
|
|
left.addComponent(instructions); |
|
|
|
|
|
|
|
root.setExpandRatio(left, 1); |
|
|
|
root.setSizeFull(); |
|
|
|
|
|
|
|
setCompositionRoot(root); |
|
|
|
setHeight("850px"); |
|
|
|
setWidth("100%"); |
|
|
|
setWidth("1800px"); |
|
|
|
} |
|
|
|
|
|
|
|
private Button createActionButton(String caption, char shortcut, |
|
|
@@ -216,6 +223,11 @@ public class ScreenshotBrowser extends UI { |
|
|
|
caption + " <strong>" + shortcut + "</strong>", |
|
|
|
createSetActionListener(action)); |
|
|
|
button.setCaptionAsHtml(true); |
|
|
|
if (!Action.IGNORE.equals(action)) { |
|
|
|
// other actions disabled for now since the functionality was |
|
|
|
// designed for a different directory structure, needs reworking |
|
|
|
button.setEnabled(false); |
|
|
|
} |
|
|
|
return button; |
|
|
|
} |
|
|
|
|
|
|
@@ -253,7 +265,7 @@ public class ScreenshotBrowser extends UI { |
|
|
|
@Override |
|
|
|
protected void init(VaadinRequest request) { |
|
|
|
table.setWidth("100%"); |
|
|
|
table.setHeight("100%"); |
|
|
|
table.setPageLength(10); |
|
|
|
|
|
|
|
table.setMultiSelect(true); |
|
|
|
table.addValueChangeListener(event -> { |
|
|
@@ -274,9 +286,8 @@ public class ScreenshotBrowser extends UI { |
|
|
|
|
|
|
|
refreshTableContainer(); |
|
|
|
|
|
|
|
VerticalLayout mainLayout = new VerticalLayout(table, viewer); |
|
|
|
mainLayout.setExpandRatio(table, 1); |
|
|
|
mainLayout.setSizeFull(); |
|
|
|
VerticalLayout mainLayout = new VerticalLayout(viewer, table); |
|
|
|
mainLayout.setSizeUndefined(); |
|
|
|
|
|
|
|
setSizeFull(); |
|
|
|
setContent(mainLayout); |
|
|
@@ -339,10 +350,10 @@ public class ScreenshotBrowser extends UI { |
|
|
|
} |
|
|
|
|
|
|
|
private void refreshTableContainer() { |
|
|
|
File errorsDir = new File(screenshotDir, "errors"); |
|
|
|
File errorsDir = new File(screenshotDir, "error-screenshots"); |
|
|
|
|
|
|
|
File[] failures = errorsDir |
|
|
|
.listFiles((dir, name) -> name.endsWith(".html")); |
|
|
|
Collection<File> failures = FileUtils.listFiles(errorsDir, |
|
|
|
new SuffixFileFilter(".html"), DirectoryFileFilter.DIRECTORY); |
|
|
|
|
|
|
|
BeanItemContainer<ComparisonFailure> container = new BeanItemContainer<>( |
|
|
|
ComparisonFailure.class); |
|
|
@@ -352,7 +363,7 @@ public class ScreenshotBrowser extends UI { |
|
|
|
|
|
|
|
table.setContainerDataSource(container); |
|
|
|
table.setVisibleColumns("testClass", "testMethod", "browser", |
|
|
|
"qualifiers", "identifier", "action"); |
|
|
|
"identifier", "action"); |
|
|
|
if (container.size() > 0) { |
|
|
|
table.select(container.firstItemId()); |
|
|
|
} |