Skip to content

Commit

Permalink
fix #16 ScreenshotDriver is memory-lealing
Browse files Browse the repository at this point in the history
  • Loading branch information
kazurayam committed Jun 26, 2020
1 parent 6e2ed22 commit b539a22
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 352 deletions.
90 changes: 90 additions & 0 deletions .project
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,95 @@
<arguments>(.*\.svn-base$)|(.*\.png$)|(.*\.log$)|(.*\.xlsx$)|(.*\.xls$)|(.*\.csv$)|(.*\.txt$)</arguments>
</matcher>
</filter>
<filter>
<id>1584569183548</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>.*\.svn$</arguments>
</matcher>
</filter>
<filter>
<id>1584569183564</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>(.*\.svn-base$)|(.*\.png$)|(.*\.log$)|(.*\.xlsx$)|(.*\.xls$)|(.*\.csv$)|(.*\.txt$)</arguments>
</matcher>
</filter>
<filter>
<id>1584750789699</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>.*\.svn$</arguments>
</matcher>
</filter>
<filter>
<id>1584750789706</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>(.*\.svn-base$)|(.*\.png$)|(.*\.log$)|(.*\.xlsx$)|(.*\.xls$)|(.*\.csv$)|(.*\.txt$)</arguments>
</matcher>
</filter>
<filter>
<id>1592205954787</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>.*\.svn$</arguments>
</matcher>
</filter>
<filter>
<id>1592205954794</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>(.*\.svn-base$)|(.*\.png$)|(.*\.log$)|(.*\.xlsx$)|(.*\.xls$)|(.*\.csv$)|(.*\.txt$)</arguments>
</matcher>
</filter>
<filter>
<id>1592212555723</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>.*\.svn$</arguments>
</matcher>
</filter>
<filter>
<id>1592212555742</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>(.*\.svn-base$)|(.*\.png$)|(.*\.log$)|(.*\.xlsx$)|(.*\.xls$)|(.*\.csv$)|(.*\.txt$)</arguments>
</matcher>
</filter>
<filter>
<id>1593206788323</id>
<name></name>
<type>10</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>.*\.svn$</arguments>
</matcher>
</filter>
<filter>
<id>1593206788330</id>
<name></name>
<type>6</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>(.*\.svn-base$)|(.*\.png$)|(.*\.log$)|(.*\.xlsx$)|(.*\.xls$)|(.*\.csv$)|(.*\.txt$)</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
6 changes: 4 additions & 2 deletions Keywords/com/kazurayam/ksbackyard/QuietBrowser.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.kms.katalon.core.network.ProxyInformation
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.driver.WebUIDriverType

@Deprecated
class QuietBrowser {

static ProxyInformation proxyInformation = RunConfiguration.getProxyInformation()
Expand Down Expand Up @@ -124,7 +125,7 @@ class QuietBrowser {
sb.append("proxyInformation.getPassword() = ${proxyInformation.getPassword()}\n")
return sb.toString()
}

private static String getAllMimeTypesAsString() {
return [
"application/gzip",
Expand Down Expand Up @@ -159,6 +160,7 @@ class QuietBrowser {
"image/svg+xml",
"text/csv",
"text/plain",
"text/xml"].join(",")
"text/xml"
].join(",")
}
}
12 changes: 9 additions & 3 deletions Keywords/com/kazurayam/ksbackyard/ScreenshotDriver.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class ScreenshotDriver {
*/
static void saveElementImage(WebDriver webDriver, WebElement webElement, File file) {
BufferedImage image = takeElementImage(webDriver, webElement)
ImageIO.write(image, "PNG", file)
new FileOutputStream(file).withCloseable { res ->
ImageIO.write(image, "PNG", res)
}
}


Expand Down Expand Up @@ -220,7 +222,9 @@ class ScreenshotDriver {
static void saveEntirePageImage(WebDriver webDriver, File file, Options options)
{
BufferedImage image = takeEntirePageImage(webDriver, options)
ImageIO.write(image, "PNG", file)
new FileOutputStream(file).withCloseable { res ->
ImageIO.write(image, "PNG", res)
}
}

/**
Expand All @@ -234,7 +238,9 @@ class ScreenshotDriver {
static void saveEntirePageImage(WebDriver webDriver, File file, Integer timeout = DEFAULT_SCROLLING_TIMEOUT)
{
BufferedImage image = takeEntirePageImage(webDriver, timeout)
ImageIO.write(image, "PNG", file)
new FileOutputStream(file).withCloseable { res ->
ImageIO.write(image, "PNG", res)
}
}

//-------------
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {

group = 'com.kazurayam'
jar.archiveBaseName = "ksbackyard"
version = '0.39.0'
version = '0.40.0'

ext {
groovyVersion = '2.4.7'
Expand Down
10 changes: 1 addition & 9 deletions docs/api/allclasses-frame.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,12 @@
<h1 class="bar">All Classes</h1>
<div class="indexContainer">
<ul>
<li><a href="com/kazurayam/ksbackyard/AllTests.html" title="class in com.kazurayam.ksbackyard" target="classFrame">AllTests</a></li>
<li><a href="com/kazurayam/ksbackyard/Assert.html" title="class in com.kazurayam.ksbackyard" target="classFrame">Assert</a></li>
<li><a href="com/kazurayam/ksbackyard/ImageCollectionDiffer.html" title="class in com.kazurayam.ksbackyard" target="classFrame">ImageCollectionDiffer</a></li>
<li><a href="com/kazurayam/ksbackyard/ImageCollectionDiffer.VisualTestingListenerNotifyingKatalon.html" title="class in com.kazurayam.ksbackyard.ImageCollectionDiffer" target="classFrame">ImageCollectionDiffer.VisualTestingListenerNotifyingKatalon</a></li>
<li><a href="com/kazurayam/ksbackyard/OSIdentifier.html" title="class in com.kazurayam.ksbackyard" target="classFrame">OSIdentifier</a></li>
<li><a href="com/kazurayam/ksbackyard/Assert.html" title="class in com.kazurayam.ksbackyard" target="classFrame">Assert</a></li>
<li><a href="com/kazurayam/ksbackyard/QuietBrowser.html" title="class in com.kazurayam.ksbackyard" target="classFrame">QuietBrowser</a></li>
<li><a href="com/kazurayam/ksbackyard/RunConfigurationWrapper.html" title="class in com.kazurayam.ksbackyard" target="classFrame">RunConfigurationWrapper</a></li>
<li><a href="com/kazurayam/ksbackyard/ScreenshotDriver.html" title="class in com.kazurayam.ksbackyard" target="classFrame">ScreenshotDriver</a></li>
<li><a href="com/kazurayam/ksbackyard/ScreenshotDriver.Options.html" title="class in com.kazurayam.ksbackyard.ScreenshotDriver" target="classFrame">ScreenshotDriver.Options</a></li>
<li><a href="com/kazurayam/ksbackyard/ScreenshotDriver.Options.Builder.html" title="class in com.kazurayam.ksbackyard.ScreenshotDriver.Options" target="classFrame">ScreenshotDriver.Options.Builder</a></li>
<li><a href="com/kazurayam/ksbackyard/TestObjectSupport.html" title="class in com.kazurayam.ksbackyard" target="classFrame">TestObjectSupport</a></li>
<li><a href="com/kazurayam/ksbackyard/URLParser.html" title="class in com.kazurayam.ksbackyard" target="classFrame">URLParser</a></li>
<li><a href="com/kazurayam/ksbackyard/Version.html" title="class in com.kazurayam.ksbackyard" target="classFrame">Version</a></li>
<li><a href="com/kazurayam/ksbackyard/YouTubeVideoVerifier.html" title="class in com.kazurayam.ksbackyard" target="classFrame">YouTubeVideoVerifier</a></li>

</ul>
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/com/kazurayam/ksbackyard/Assert.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<html>
<head>
<!-- Generated by groovydoc -->
<title>Assert (ksbackyard API)</title>
<title>Assert (ksbackyard 0.40.0 API)</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
Expand All @@ -37,7 +37,7 @@
<body class="center">
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="Assert (ksbackyard API)";
parent.document.title="Assert (ksbackyard 0.40.0 API)";
}
//-->
</script>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/com/kazurayam/ksbackyard/QuietBrowser.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<html>
<head>
<!-- Generated by groovydoc -->
<title>QuietBrowser (ksbackyard API)</title>
<title>QuietBrowser (ksbackyard 0.40.0 API)</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
Expand All @@ -37,7 +37,7 @@
<body class="center">
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="QuietBrowser (ksbackyard API)";
parent.document.title="QuietBrowser (ksbackyard 0.40.0 API)";
}
//-->
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<html>
<head>
<!-- Generated by groovydoc -->
<title>ScreenshotDriver.Options.Builder (ksbackyard API)</title>
<title>ScreenshotDriver.Options.Builder (ksbackyard 0.40.0 API)</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
Expand All @@ -37,7 +37,7 @@
<body class="center">
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ScreenshotDriver.Options.Builder (ksbackyard API)";
parent.document.title="ScreenshotDriver.Options.Builder (ksbackyard 0.40.0 API)";
}
//-->
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<html>
<head>
<!-- Generated by groovydoc -->
<title>ScreenshotDriver.Options (ksbackyard API)</title>
<title>ScreenshotDriver.Options (ksbackyard 0.40.0 API)</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../../../groovy.ico" type="image/x-icon" rel="shortcut icon">
Expand All @@ -37,7 +37,7 @@
<body class="center">
<script type="text/javascript"><!--
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="ScreenshotDriver.Options (ksbackyard API)";
parent.document.title="ScreenshotDriver.Options (ksbackyard 0.40.0 API)";
}
//-->
</script>
Expand Down
Loading

0 comments on commit b539a22

Please sign in to comment.