Fix history test

This commit is contained in:
serso 2016-03-27 20:59:53 +02:00
parent f123646400
commit 2529e4132f
4 changed files with 23 additions and 34 deletions

View File

@ -31,8 +31,8 @@ android {
defaultConfig {
minSdkVersion 9
targetSdkVersion 23
versionCode 143
versionName '2.1.4'
versionCode 144
versionName '2.2.0b'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
generatedDensities = []
}

View File

@ -175,6 +175,10 @@ public class History {
});
}
void setLoaded(boolean loaded) {
this.loaded = loaded;
}
@NonNull
File getSavedHistoryFile() {
return new File(filesDir, "history-saved.json");

View File

@ -22,28 +22,10 @@
package org.solovyev.android.calculator.history;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.anyString;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.solovyev.android.calculator.Engine.Preferences.groupingSeparator;
import static org.solovyev.android.calculator.Tests.sameThreadExecutor;
import static org.solovyev.android.calculator.jscl.JsclOperation.numeric;
import android.content.SharedPreferences;
import android.os.Handler;
import android.os.Looper;
import com.squareup.otto.Bus;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@ -53,19 +35,21 @@ import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.solovyev.android.CalculatorTestRunner;
import org.solovyev.android.calculator.BuildConfig;
import org.solovyev.android.calculator.Display;
import org.solovyev.android.calculator.DisplayState;
import org.solovyev.android.calculator.Editor;
import org.solovyev.android.calculator.EditorState;
import org.solovyev.android.calculator.ErrorReporter;
import org.solovyev.android.calculator.*;
import org.solovyev.android.calculator.json.Json;
import org.solovyev.android.io.FileSystem;
import javax.annotation.Nonnull;
import java.io.File;
import java.util.List;
import javax.annotation.Nonnull;
import static org.junit.Assert.*;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.*;
import static org.solovyev.android.calculator.Engine.Preferences.groupingSeparator;
import static org.solovyev.android.calculator.Tests.sameThreadExecutor;
import static org.solovyev.android.calculator.jscl.JsclOperation.numeric;
@Config(constants = BuildConfig.class, sdk = CalculatorTestRunner.SUPPORTED_SDK)
@RunWith(RobolectricGradleTestRunner.class)
@ -87,6 +71,7 @@ public class HistoryTest {
when(history.preferences.edit()).thenReturn(editor);
when(editor.remove(anyString())).thenReturn(editor);
history.editor = mock(Editor.class);
history.setLoaded(true);
}
@After
@ -308,7 +293,7 @@ public class HistoryTest {
history.init(sameThreadExecutor());
Robolectric.flushForegroundThreadScheduler();
verify(history.fileSystem).write(eq(history.getSavedHistoryFile()), eq(
"[{\"e\":{\"t\":\"1+1\",\"s\":3},\"d\":{\"t\":\"Error\"},\"t\":100000000}]"));
"[{\"e\":{\"t\":\"1+1\",\"s\":3},\"d\":{\"t\":\"Error\",\"v\":true},\"t\":100000000}]"));
}
@Test

View File

@ -1,13 +1,13 @@
package jscl.math;
import au.com.bytecode.opencsv.CSVReader;
import com.google.common.base.Function;
import jscl.JsclMathEngine;
import jscl.MathEngine;
import jscl.text.ParseException;
import jscl.util.ExpressionGeneratorWithInput;
import org.junit.Assert;
import org.junit.Test;
import org.solovyev.common.Functor;
import javax.annotation.Nonnull;
import java.io.InputStreamReader;
@ -21,7 +21,7 @@ import java.util.List;
*/
public class NumeralBaseConversionTest {
public static void testExpression(@Nonnull String[] line, @Nonnull Functor<String, String> converter) throws ParseException {
public static void testExpression(@Nonnull String[] line, @Nonnull Function<String, String> converter) throws ParseException {
final String dec = line[0].toUpperCase();
final String hex = "0x:" + line[1].toUpperCase();
final String bin = "0b:" + line[2].toUpperCase();
@ -96,7 +96,7 @@ public class NumeralBaseConversionTest {
}
}
private static class DummyExpression implements Functor<String, String> {
private static class DummyExpression implements Function<String, String> {
@Nonnull
@Override
@ -105,7 +105,7 @@ public class NumeralBaseConversionTest {
}
}
private static class Expression1 implements Functor<String, String> {
private static class Expression1 implements Function<String, String> {
@Nonnull
@Override
@ -114,7 +114,7 @@ public class NumeralBaseConversionTest {
}
}
private static class Expression2 implements Functor<String, String> {
private static class Expression2 implements Function<String, String> {
@Nonnull
@Override
@ -123,7 +123,7 @@ public class NumeralBaseConversionTest {
}
}
private static class Expression3 implements Functor<String, String> {
private static class Expression3 implements Function<String, String> {
@Nonnull
@Override