summaryrefslogtreecommitdiff
path: root/app/src/androidTest/legacy/Screenshot.java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2018-02-06 15:05:02 +0100
committercyBerta <cyberta@riseup.net>2018-02-06 15:05:02 +0100
commit1a37ac3f86e0bd44842a0fcd86de7c160acfbb04 (patch)
treebc32fb50b59c415097804fd7bbdb296641310cde /app/src/androidTest/legacy/Screenshot.java
parenta1ac4910f062ca8aca06e0468fffef751d3bb714 (diff)
parentedd34192484f4eb618fdcc2a68b18168c155d63c (diff)
Merge branch 'origin_0.9.8' into fupduck_8826_custom_provider
Diffstat (limited to 'app/src/androidTest/legacy/Screenshot.java')
-rw-r--r--app/src/androidTest/legacy/Screenshot.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/src/androidTest/legacy/Screenshot.java b/app/src/androidTest/legacy/Screenshot.java
new file mode 100644
index 00000000..ade28b73
--- /dev/null
+++ b/app/src/androidTest/legacy/Screenshot.java
@@ -0,0 +1,54 @@
+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() {
+ take(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;
+ }
+}
+