Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ dependencies {
}
}
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'commons-codec:commons-codec:1.15'
implementation 'cglib:cglib:3.3.0'
implementation 'commons-validator:commons-validator:1.7'
implementation 'org.apache.commons:commons-lang3:3.12.0'
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/appium/java_client/ComparesImages.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;
import io.appium.java_client.imagecomparison.SimilarityMatchingOptions;
import io.appium.java_client.imagecomparison.SimilarityMatchingResult;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Base64;
import java.util.Map;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -93,8 +93,8 @@ default FeaturesMatchingResult matchImagesFeatures(File image1, File image2) thr
*/
default FeaturesMatchingResult matchImagesFeatures(File image1, File image2,
@Nullable FeaturesMatchingOptions options) throws IOException {
return matchImagesFeatures(Base64.encodeBase64(FileUtils.readFileToByteArray(image1)),
Base64.encodeBase64(FileUtils.readFileToByteArray(image2)), options);
return matchImagesFeatures(Base64.getEncoder().encode(FileUtils.readFileToByteArray(image1)),
Base64.getEncoder().encode(FileUtils.readFileToByteArray(image2)), options);
}

/**
Expand Down Expand Up @@ -160,8 +160,8 @@ default OccurrenceMatchingResult findImageOccurrence(File fullImage, File partia
default OccurrenceMatchingResult findImageOccurrence(File fullImage, File partialImage,
@Nullable OccurrenceMatchingOptions options)
throws IOException {
return findImageOccurrence(Base64.encodeBase64(FileUtils.readFileToByteArray(fullImage)),
Base64.encodeBase64(FileUtils.readFileToByteArray(partialImage)), options);
return findImageOccurrence(Base64.getEncoder().encode(FileUtils.readFileToByteArray(fullImage)),
Base64.getEncoder().encode(FileUtils.readFileToByteArray(partialImage)), options);
}

/**
Expand Down Expand Up @@ -227,7 +227,7 @@ default SimilarityMatchingResult getImagesSimilarity(File image1, File image2) t
default SimilarityMatchingResult getImagesSimilarity(File image1, File image2,
@Nullable SimilarityMatchingOptions options)
throws IOException {
return getImagesSimilarity(Base64.encodeBase64(FileUtils.readFileToByteArray(image1)),
Base64.encodeBase64(FileUtils.readFileToByteArray(image2)), options);
return getImagesSimilarity(Base64.getEncoder().encode(FileUtils.readFileToByteArray(image1)),
Base64.getEncoder().encode(FileUtils.readFileToByteArray(image2)), options);
}
}
4 changes: 2 additions & 2 deletions src/main/java/io/appium/java_client/PushesFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static io.appium.java_client.MobileCommand.pushFileCommand;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Base64;

public interface PushesFiles extends ExecutesMethod {

Expand Down Expand Up @@ -57,7 +57,7 @@ default void pushFile(String remotePath, File file) throws IOException {
throw new IOException(String.format("The given file %s doesn't exist",
file.getAbsolutePath()));
}
pushFile(remotePath, Base64.encodeBase64(FileUtils.readFileToByteArray(file)));
pushFile(remotePath, Base64.getEncoder().encode(FileUtils.readFileToByteArray(file)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import lombok.AccessLevel;
import lombok.Getter;
import org.apache.commons.codec.binary.Base64;

import org.openqa.selenium.Point;
import org.openqa.selenium.Rectangle;
Expand All @@ -28,6 +27,7 @@
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import java.util.Map;

public abstract class ComparisonResult {
Expand Down Expand Up @@ -70,7 +70,7 @@ public byte[] getVisualization() {
* @throws IOException On file system I/O error.
*/
public void storeVisualization(File destination) throws IOException {
final byte[] data = Base64.decodeBase64(getVisualization());
final byte[] data = Base64.getDecoder().decode(getVisualization());
try (OutputStream stream = new FileOutputStream(destination)) {
stream.write(data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import static org.junit.jupiter.api.Assertions.fail;

import io.appium.java_client.appmanagement.ApplicationState;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
Expand All @@ -37,6 +36,7 @@
import java.io.File;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

public class AndroidDriverTest extends BaseAndroidTest {
Expand Down Expand Up @@ -155,7 +155,7 @@ public void closeAppTest() {

@Test
public void pushFileTest() {
byte[] data = Base64.encodeBase64(
byte[] data = Base64.getEncoder().encode(
"The eventual code is no more than the deposit of your understanding. ~E. W. Dijkstra"
.getBytes());
driver.pushFile("/data/local/tmp/remote.txt", data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Base64;

import io.appium.java_client.imagecomparison.FeatureDetector;
import io.appium.java_client.imagecomparison.FeaturesMatchingOptions;
import io.appium.java_client.imagecomparison.FeaturesMatchingResult;
Expand All @@ -30,15 +32,14 @@
import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;
import io.appium.java_client.imagecomparison.SimilarityMatchingOptions;
import io.appium.java_client.imagecomparison.SimilarityMatchingResult;
import org.apache.commons.codec.binary.Base64;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.OutputType;

public class ImagesComparisonTest extends BaseAndroidTest {

@Test
public void verifyFeaturesMatching() {
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
byte[] screenshot = Base64.getEncoder().encode(driver.getScreenshotAs(OutputType.BYTES));
FeaturesMatchingResult result = driver
.matchImagesFeatures(screenshot, screenshot, new FeaturesMatchingOptions()
.withDetectorName(FeatureDetector.ORB)
Expand All @@ -56,7 +57,7 @@ public void verifyFeaturesMatching() {

@Test
public void verifyOccurrencesLookup() {
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
byte[] screenshot = Base64.getEncoder().encode(driver.getScreenshotAs(OutputType.BYTES));
OccurrenceMatchingResult result = driver
.findImageOccurrence(screenshot, screenshot, new OccurrenceMatchingOptions()
.withEnabledVisualization());
Expand All @@ -66,7 +67,7 @@ public void verifyOccurrencesLookup() {

@Test
public void verifySimilarityCalculation() {
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
byte[] screenshot = Base64.getEncoder().encode(driver.getScreenshotAs(OutputType.BYTES));
SimilarityMatchingResult result = driver
.getImagesSimilarity(screenshot, screenshot, new SimilarityMatchingOptions()
.withEnabledVisualization());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import java.util.Base64;

import io.appium.java_client.imagecomparison.FeatureDetector;
import io.appium.java_client.imagecomparison.FeaturesMatchingOptions;
import io.appium.java_client.imagecomparison.FeaturesMatchingResult;
Expand All @@ -30,15 +32,14 @@
import io.appium.java_client.imagecomparison.OccurrenceMatchingResult;
import io.appium.java_client.imagecomparison.SimilarityMatchingOptions;
import io.appium.java_client.imagecomparison.SimilarityMatchingResult;
import org.apache.commons.codec.binary.Base64;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.OutputType;

public class ImagesComparisonTest extends AppIOSTest {

@Test
public void verifyFeaturesMatching() {
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
byte[] screenshot = Base64.getEncoder().encode(driver.getScreenshotAs(OutputType.BYTES));
FeaturesMatchingResult result = driver
.matchImagesFeatures(screenshot, screenshot, new FeaturesMatchingOptions()
.withDetectorName(FeatureDetector.ORB)
Expand All @@ -56,7 +57,7 @@ public void verifyFeaturesMatching() {

@Test
public void verifyOccurrencesSearch() {
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
byte[] screenshot = Base64.getEncoder().encode(driver.getScreenshotAs(OutputType.BYTES));
OccurrenceMatchingResult result = driver
.findImageOccurrence(screenshot, screenshot, new OccurrenceMatchingOptions()
.withEnabledVisualization());
Expand All @@ -66,7 +67,7 @@ public void verifyOccurrencesSearch() {

@Test
public void verifySimilarityCalculation() {
byte[] screenshot = Base64.encodeBase64(driver.getScreenshotAs(OutputType.BYTES));
byte[] screenshot = Base64.getEncoder().encode(driver.getScreenshotAs(OutputType.BYTES));
SimilarityMatchingResult result = driver
.getImagesSimilarity(screenshot, screenshot, new SimilarityMatchingOptions()
.withEnabledVisualization());
Expand Down