diff options
author | Allan Wang <me@allanwang.ca> | 2017-12-31 03:10:58 -0500 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-12-31 03:10:58 -0500 |
commit | b556c42daa61c99c1a2f8de06e1c526425228450 (patch) | |
tree | 5b4c29c3d49a2a8ce33c40c36afdf0e80956f3ee /app | |
parent | 6ca914798fb7d2f8712ab04e6885155d3ca3b632 (diff) | |
download | frost-b556c42daa61c99c1a2f8de06e1c526425228450.tar.gz frost-b556c42daa61c99c1a2f8de06e1c526425228450.tar.bz2 frost-b556c42daa61c99c1a2f8de06e1c526425228450.zip |
Mock logger in unit tests
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt | 2 | ||||
-rw-r--r-- | app/src/test/kotlin/android/util/Log.java | 60 |
2 files changed, 60 insertions, 2 deletions
diff --git a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt index ca4aa4ac..ae8652e6 100644 --- a/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt +++ b/app/src/main/kotlin/com/pitchedapps/frost/facebook/requests/FbRequest.kt @@ -106,14 +106,12 @@ fun String.getAuth(): RequestAuth { val text = StringEscapeUtils.unescapeEcmaScript(it) val fb_dtsg = FB_DTSG_MATCHER.find(text)[1] if (fb_dtsg != null) { - L._d { "fb_dtsg for ${auth.userId}: $fb_dtsg" } auth = auth.copy(fb_dtsg = fb_dtsg) if (auth.isValid) return auth } val rev = FB_REV_MATCHER.find(text)[1] if (rev != null) { - L._d { "rev for ${auth.userId}: $rev" } auth = auth.copy(rev = rev) if (auth.isValid) return auth } diff --git a/app/src/test/kotlin/android/util/Log.java b/app/src/test/kotlin/android/util/Log.java new file mode 100644 index 00000000..e7095563 --- /dev/null +++ b/app/src/test/kotlin/android/util/Log.java @@ -0,0 +1,60 @@ +package android.util; + +import java.util.Locale; + +/** + * Created by Allan Wang on 31/12/17. + */ +public class Log { + + /** + * Priority constant for the println method; use Log.v. + */ + public static final int VERBOSE = 2; + + /** + * Priority constant for the println method; use Log.d. + */ + public static final int DEBUG = 3; + + /** + * Priority constant for the println method; use Log.i. + */ + public static final int INFO = 4; + + /** + * Priority constant for the println method; use Log.e. + */ + public static final int ERROR = 6; + + public static int e(String tag, String msg, Throwable t) { + System.err.println("ERROR: " + tag + ": " + msg + "\n\tThrowable: " + t.getMessage()); + return 0; + } + + public static int println(int priority, String tag, String message) { + switch (priority) { + case VERBOSE: + p("V", tag, message); + break; + case INFO: + p("I", tag, message); + break; + case DEBUG: + p("D", tag, message); + break; + case ERROR: + p("E", tag, message); + break; + default: + p("L " + priority, tag, message); + break; + } + return 0; + } + + private static void p(String flag, String tag, String msg) { + System.out.println(String.format(Locale.CANADA, "%s: %s: %s", flag, tag, msg)); + } + +}
\ No newline at end of file |