summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorParménides GV <parmegv@sdf.org>2015-04-28 13:48:20 +0200
committerParménides GV <parmegv@sdf.org>2015-04-28 13:48:20 +0200
commit834fe99739264d498e3e8c87002b0e92cf8160a0 (patch)
tree56dff5b31c73d850a597ed83afb03347ac6d1e09
parent232b9d1b562c752a281935f05af55e1b13f33127 (diff)
Take screenshots of the changes.
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java55
-rw-r--r--app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java7
2 files changed, 62 insertions, 0 deletions
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java
new file mode 100644
index 00000000..91d51402
--- /dev/null
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/Screenshot.java
@@ -0,0 +1,55 @@
+package se.leap.bitmaskclient.test;
+
+import com.robotium.solo.*;
+
+import java.text.*;
+import java.util.*;
+
+public class Screenshot {
+ private static String default_name = Screenshot.class.getPackage().getName();
+ private static DateFormat date_format = DateFormat.getDateTimeInstance();
+ private static int DEFAULT_MILLISECONDS_TO_SLEEP = 500;
+ private static int milliseconds_to_sleep = 0;
+ private static Solo solo;
+
+ public static void initialize(Solo solo) {
+ Screenshot.solo = solo;
+ }
+
+ public static void take(String name) {
+ solo.takeScreenshot(name.replace(" ", "_") + " " + getTimeStamp());
+ }
+
+ public static void takeWithSleep(String name) {
+ sleepBefore();
+ take(name);
+ }
+
+ public static void take() {
+ sleepBefore();
+ solo.takeScreenshot(default_name + "_" + getTimeStamp());
+ }
+
+ public static void takeWithSleep() {
+ sleepBefore();
+ take();
+ }
+
+ private static String getTimeStamp() {
+ return date_format.format(Calendar.getInstance().getTime()).replace(" ", "_").replace("/", "_").replace(":", "_");
+ }
+
+ public static void setTimeToSleep(double seconds) {
+ long milliseconds_to_sleep = Math.round(seconds * 1000);
+ Screenshot.milliseconds_to_sleep = Math.round(milliseconds_to_sleep);
+ }
+
+ private static void sleepBefore() {
+ if(milliseconds_to_sleep == 0)
+ solo.sleep(DEFAULT_MILLISECONDS_TO_SLEEP);
+ else
+ solo.sleep(milliseconds_to_sleep);
+ milliseconds_to_sleep = 0;
+ }
+}
+
diff --git a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
index 18d7b45d..13ca4431 100644
--- a/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
+++ b/app/src/androidTest/java/se/leap/bitmaskclient/test/testDashboardIntegration.java
@@ -30,6 +30,7 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
super.setUp();
context = getInstrumentation().getContext();
solo = new Solo(getInstrumentation(), getActivity());
+ Screenshot.initialize(solo);
ConnectionManager.setMobileDataEnabled(true, context);
solo.unlockScreen();
if (solo.searchText(solo.getString(R.string.configuration_wizard_title)))
@@ -46,11 +47,17 @@ public class testDashboardIntegration extends ActivityInstrumentationTestCase2<D
* I cannot automate that dialog.
*/
public void testOnOffOpenVpn() {
+ Screenshot.take("Initial UI");
clickVpnButton();
+ Screenshot.setTimeToSleep(5);
+ Screenshot.takeWithSleep("Turning VPN on");
turningEipOn();
+ Screenshot.setTimeToSleep(0.5);
+ Screenshot.takeWithSleep("VPN turned on");
clickVpnButton();
turningEipOff();
+ Screenshot.take("VPN turned off");
clickVpnButton();
turningEipOn();