Skip to content

Commit

Permalink
Create a 'pure' Java common module for sharing code.
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Feb 4, 2017
1 parent 6a6940c commit 461fd94
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 12 deletions.
15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
</properties>

<modules>
<module>spoon-common</module>
<module>spoon-client</module>
<module>spoon-runner</module>
</modules>
Expand Down Expand Up @@ -121,7 +122,21 @@
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
Expand Down
5 changes: 5 additions & 0 deletions spoon-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spoon-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions spoon-client/src/main/java/com/squareup/spoon/Spoon.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
import static android.os.Environment.getExternalStorageDirectory;
import static com.squareup.spoon.Chmod.chmodPlusR;
import static com.squareup.spoon.Chmod.chmodPlusRWX;
import static com.squareup.spoon.internal.Constants.NAME_SEPARATOR;
import static com.squareup.spoon.internal.Constants.SPOON_FILES;
import static com.squareup.spoon.internal.Constants.SPOON_SCREENSHOTS;

/** Utility class for capturing screenshots for Spoon. */
public final class Spoon {
static final String SPOON_SCREENSHOTS = "spoon-screenshots";
static final String SPOON_FILES = "spoon-files";
static final String NAME_SEPARATOR = "_";
static final String TEST_CASE_CLASS_JUNIT_3 = "android.test.InstrumentationTestCase";
static final String TEST_CASE_METHOD_JUNIT_3 = "runMethod";
static final String TEST_CASE_CLASS_JUNIT_4 = "org.junit.runners.model.FrameworkMethod$1";
Expand Down
18 changes: 18 additions & 0 deletions spoon-common/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.squareup.spoon</groupId>
<artifactId>parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>

<artifactId>spoon-common</artifactId>
<name>Spoon Common</name>

<properties>
<java.version>1.6</java.version>
</properties>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.squareup.spoon.internal;

public interface Constants {
String SPOON_SCREENSHOTS = "spoon-screenshots";
String SPOON_FILES = "spoon-files";
String NAME_SEPARATOR = "_";
}
2 changes: 1 addition & 1 deletion spoon-runner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>spoon-client</artifactId>
<artifactId>spoon-common</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.Collections.unmodifiableList;
import static com.squareup.spoon.SpoonLogger.logError;
import static java.util.Collections.unmodifiableList;

/** Represents the result of a single test method on a single device. */
public final class DeviceTestResult {
/** Separator between screenshot timestamp and tag. */
public static final String SCREENSHOT_SEPARATOR = Spoon.NAME_SEPARATOR;

public enum Status {
PASS, FAIL
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
import static com.android.ddmlib.FileListingService.FileEntry;
import static com.android.ddmlib.SyncService.getNullProgressMonitor;
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.squareup.spoon.Spoon.SPOON_FILES;
import static com.squareup.spoon.Spoon.SPOON_SCREENSHOTS;
import static com.squareup.spoon.SpoonLogger.logDebug;
import static com.squareup.spoon.SpoonLogger.logError;
import static com.squareup.spoon.SpoonLogger.logInfo;
import static com.squareup.spoon.SpoonUtils.GSON;
import static com.squareup.spoon.SpoonUtils.createAnimatedGif;
import static com.squareup.spoon.SpoonUtils.obtainDirectoryFileEntry;
import static com.squareup.spoon.SpoonUtils.obtainRealDevice;
import static com.squareup.spoon.internal.Constants.SPOON_FILES;
import static com.squareup.spoon.internal.Constants.SPOON_SCREENSHOTS;

/** Represents a single device and the test configuration to be executed. */
public final class SpoonDeviceRunner {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringEscapeUtils;

import static com.squareup.spoon.DeviceTestResult.SCREENSHOT_SEPARATOR;
import static com.squareup.spoon.internal.Constants.NAME_SEPARATOR;

/** Utilities for representing the execution in HTML. */
final class HtmlUtils {
Expand Down Expand Up @@ -134,7 +134,7 @@ static String prettifyImageName(String imageName) {
imageName = FilenameUtils.removeExtension(imageName);

// Remove the timestamp information.
imageName = imageName.split(SCREENSHOT_SEPARATOR, 2)[1];
imageName = imageName.split(NAME_SEPARATOR, 2)[1];

StringBuilder pretty = new StringBuilder();
for (String part : imageName.replace('_', '-').split("-")) {
Expand Down

0 comments on commit 461fd94

Please sign in to comment.