-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28e6070
commit 5b5065d
Showing
5 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
packages/patrol/android/src/main/LambdatestPatrolJUnitRunner.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,54 @@ | ||
package pl.leancode.patrol; | ||
|
||
import android.util.Log; | ||
import pl.leancode.patrol.contracts.PatrolAppServiceClientException; | ||
|
||
import java.net.Inet4Address; | ||
import java.net.NetworkInterface; | ||
import java.net.SocketException; | ||
import java.util.Enumeration; | ||
import java.util.Objects; | ||
|
||
public class LambdatestPatrolJUnitRunner extends PatrolJUnitRunner { | ||
@Override | ||
public PatrolAppServiceClient createAppServiceClient() { | ||
// Create client with a default constructor (localhost:8082) by default. | ||
PatrolAppServiceClient client = new PatrolAppServiceClient(); | ||
waitForPatrolAppService(); | ||
|
||
try { | ||
client.listDartTests(); | ||
|
||
//TODO verify in a project where we use Browserstack | ||
} catch (PatrolAppServiceClientException ex) { | ||
ex.printStackTrace(); | ||
// If the client on localhost:8082 fails, let's apply the wokraround | ||
Logger.INSTANCE.i("PatrolAppServiceClientException in createAppServiceClient " + ex.getMessage()); | ||
Logger.INSTANCE.i("LOOPBACK: " + getLoopback()); | ||
client = new PatrolAppServiceClient(getLoopback()); | ||
} | ||
|
||
return client; | ||
} | ||
|
||
public String getLoopback() { | ||
try { | ||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); | ||
while (interfaces.hasMoreElements()) { | ||
NetworkInterface i = interfaces.nextElement(); | ||
Log.d("LOOPBACK", i.getDisplayName()); | ||
if (Objects.equals(i.getDisplayName(), "tun0")) { | ||
for (java.net.InterfaceAddress a : i.getInterfaceAddresses()) { | ||
if (a.getAddress() instanceof Inet4Address) { | ||
return a.getAddress().toString().substring(1); | ||
} | ||
} | ||
} | ||
|
||
} | ||
} catch (SocketException e) { | ||
} | ||
|
||
return null; | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 | ||
android.useAndroidX=true | ||
android.enableJetifier=true |
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