From 5dfa37788c7f039eff00b27cc0ca8b9b9a71f60e Mon Sep 17 00:00:00 2001 From: Javier Date: Sat, 20 Mar 2021 23:57:51 +0100 Subject: Initial import --- app/src/test/java/android/util/Log.java | 23 +++++++++++++ .../com/javispedro/rempe/MainActivityTest.java | 40 ++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 app/src/test/java/android/util/Log.java create mode 100644 app/src/test/java/com/javispedro/rempe/MainActivityTest.java (limited to 'app/src/test/java') diff --git a/app/src/test/java/android/util/Log.java b/app/src/test/java/android/util/Log.java new file mode 100644 index 0000000..e117d5d --- /dev/null +++ b/app/src/test/java/android/util/Log.java @@ -0,0 +1,23 @@ +package android.util; + +public class Log { + public static int d(String tag, String msg) { + System.err.println("DEBUG: " + tag + ": " + msg); + return 0; + } + + public static int i(String tag, String msg) { + System.err.println("INFO: " + tag + ": " + msg); + return 0; + } + + public static int w(String tag, String msg) { + System.err.println("WARN: " + tag + ": " + msg); + return 0; + } + + public static int e(String tag, String msg) { + System.err.println("ERROR: " + tag + ": " + msg); + return 0; + } +} diff --git a/app/src/test/java/com/javispedro/rempe/MainActivityTest.java b/app/src/test/java/com/javispedro/rempe/MainActivityTest.java new file mode 100644 index 0000000..fe0f4c5 --- /dev/null +++ b/app/src/test/java/com/javispedro/rempe/MainActivityTest.java @@ -0,0 +1,40 @@ +package com.javispedro.rempe; + +import org.junit.Test; + +import java.util.ArrayList; +import java.util.Random; + +import static org.junit.Assert.assertEquals; + +public class MainActivityTest { + private final static String TAG = "MainActivityTest"; + + @Test + public void setDeviceNumberList() { + final MainActivity activity = new MainActivity(); + final Random r = new Random(); + + ArrayList list = new ArrayList(); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + list.add(r.nextInt(30000)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + for (int i = 0; i < 400; ++i) { + list.add(r.nextInt(list.size()), r.nextInt(60000)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + list.add(r.nextInt(list.size()), r.nextInt(60000)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + + list.remove(r.nextInt(list.size() - 1)); + activity.setDeviceNumberList(list); + assertEquals(list, activity.getDeviceNumberList()); + } + } +} \ No newline at end of file -- cgit v1.2.3