From 91a8a1122b2f2f2eaf7e33f019ea987fa48b4856 Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 14 Jan 2016 16:03:57 +0100 Subject: [PATCH] Logger -> ErrorReporter --- .../AbstractCalculatorMathRegistry.java | 4 +- .../android/calculator/AcraErrorReporter.java | 40 +++++++++ .../calculator/AndroidCalculatorLogger.java | 64 ------------- .../org/solovyev/android/calculator/App.java | 5 -- .../android/calculator/AppModule.java | 41 +++++++-- .../calculator/CalculatorApplication.java | 17 ++-- .../calculator/CalculatorDialogActivity.java | 2 +- .../calculator/CalculatorEngineImpl.java | 4 +- .../android/calculator/CalculatorImpl.java | 4 +- .../android/calculator/CalculatorLocator.java | 4 +- .../solovyev/android/calculator/Display.java | 2 +- .../solovyev/android/calculator/Editor.java | 17 +--- .../android/calculator/ErrorReporter.java | 30 +++++++ .../solovyev/android/calculator/Locator.java | 10 +-- ...orLogger.java => SystemErrorReporter.java} | 22 ++--- .../calculator/SystemOutCalculatorLogger.java | 64 ------------- .../android/calculator/history/History.java | 89 ++++++++++++------- .../calculator/view/EditorTextProcessor.java | 31 ++----- .../calculator/view/TextHighlighter.java | 13 ++- .../org/solovyev/android/io/BaseIoLoader.java | 6 +- .../org/solovyev/android/io/BaseIoSaver.java | 12 +-- .../org/solovyev/android/io/FileLoader.java | 2 +- .../org/solovyev/android/io/FileSaver.java | 3 +- .../calculator/AbstractCalculatorTest.java | 2 +- .../calculator/CalculatorTestUtils.java | 21 +++-- .../calculator/history/HistoryTest.java | 5 +- 26 files changed, 240 insertions(+), 274 deletions(-) create mode 100644 app/src/main/java/org/solovyev/android/calculator/AcraErrorReporter.java delete mode 100644 app/src/main/java/org/solovyev/android/calculator/AndroidCalculatorLogger.java create mode 100644 app/src/main/java/org/solovyev/android/calculator/ErrorReporter.java rename app/src/main/java/org/solovyev/android/calculator/{CalculatorLogger.java => SystemErrorReporter.java} (68%) delete mode 100644 app/src/main/java/org/solovyev/android/calculator/SystemOutCalculatorLogger.java diff --git a/app/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java b/app/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java index 58f9f9b4..6b68142e 100644 --- a/app/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java +++ b/app/src/main/java/org/solovyev/android/calculator/AbstractCalculatorMathRegistry.java @@ -89,7 +89,7 @@ public abstract class AbstractCalculatorMathRegistry builder = createBuilder(entity); add(builder); } catch (RuntimeException e) { - Locator.getInstance().getLogger().error(null, e.getLocalizedMessage(), e); + Locator.getInstance().getErrorReporter().onException(e); notCreatedEntities.add(entity); } } @@ -107,7 +107,7 @@ public abstract class AbstractCalculatorMathRegistry messages = new ArrayList(); while (messageRegistry.hasMessage()) { @@ -279,7 +279,7 @@ public class CalculatorImpl implements Calculator, CalculatorEventListener { } } catch (Throwable e) { // todo serso: not good but we need proper synchronization - logger.error("Calculator", e.getMessage(), e); + errorReporter.onException(e); } } diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java b/app/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java index ccbb4edd..e3030010 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java +++ b/app/src/main/java/org/solovyev/android/calculator/CalculatorLocator.java @@ -32,7 +32,7 @@ public interface CalculatorLocator { @Nonnull CalculatorEngine engine, @Nonnull CalculatorClipboard clipboard, @Nonnull CalculatorNotifier notifier, - @Nonnull CalculatorLogger logger, + @Nonnull ErrorReporter errorReporter, @Nonnull CalculatorPreferenceService preferenceService, @Nonnull Keyboard keyboard, @Nonnull CalculatorPlotter plotter); @@ -53,7 +53,7 @@ public interface CalculatorLocator { CalculatorNotifier getNotifier(); @Nonnull - CalculatorLogger getLogger(); + ErrorReporter getErrorReporter(); @Nonnull CalculatorPlotter getPlotter(); diff --git a/app/src/main/java/org/solovyev/android/calculator/Display.java b/app/src/main/java/org/solovyev/android/calculator/Display.java index 777d4443..81d6a011 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Display.java +++ b/app/src/main/java/org/solovyev/android/calculator/Display.java @@ -66,7 +66,7 @@ public class Display implements CalculatorEventListener { @Inject public Display(@Nonnull Calculator calculator) { - this.lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId()); + lastEvent = new CalculatorEventHolder(CalculatorUtils.createFirstEventDataId()); calculator.addCalculatorEventListener(this); } diff --git a/app/src/main/java/org/solovyev/android/calculator/Editor.java b/app/src/main/java/org/solovyev/android/calculator/Editor.java index 7a7f8ba5..c7d63fbb 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Editor.java +++ b/app/src/main/java/org/solovyev/android/calculator/Editor.java @@ -27,7 +27,6 @@ import android.content.SharedPreferences; import com.squareup.otto.Bus; import org.solovyev.android.Check; -import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessorEditorResult; import org.solovyev.android.calculator.view.EditorTextProcessor; @@ -43,7 +42,7 @@ public class Editor { private static final String TAG = App.subTag("Editor"); @Nullable - private final TextProcessor textProcessor; + private final EditorTextProcessor textProcessor; @Nullable private EditorView view; @Nonnull @@ -53,11 +52,7 @@ public class Editor { @Inject public Editor(@Nonnull SharedPreferences preferences) { - this(new EditorTextProcessor(preferences)); - } - - public Editor(@Nullable TextProcessor textProcessor) { - this.textProcessor = textProcessor; + textProcessor = new EditorTextProcessor(preferences); } public static int clamp(int selection, @Nonnull CharSequence text) { @@ -92,12 +87,8 @@ public class Editor { public EditorState onTextChanged(@Nonnull EditorState newState) { Check.isMainThread(); if (textProcessor != null) { - try { - final TextProcessorEditorResult result = textProcessor.process(newState.getTextString()); - newState = EditorState.create(result.getCharSequence(), newState.selection + result.getOffset()); - } catch (CalculatorParseException e) { - Locator.getInstance().getLogger().error(TAG, e.getMessage(), e); - } + final TextProcessorEditorResult result = textProcessor.process(newState.getTextString()); + newState = EditorState.create(result.getCharSequence(), newState.selection + result.getOffset()); } final EditorState oldState = state; state = newState; diff --git a/app/src/main/java/org/solovyev/android/calculator/ErrorReporter.java b/app/src/main/java/org/solovyev/android/calculator/ErrorReporter.java new file mode 100644 index 00000000..c5121dec --- /dev/null +++ b/app/src/main/java/org/solovyev/android/calculator/ErrorReporter.java @@ -0,0 +1,30 @@ +/* + * Copyright 2013 serso aka se.solovyev + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * Contact details + * + * Email: se.solovyev@gmail.com + * Site: http://se.solovyev.org + */ + +package org.solovyev.android.calculator; + +import javax.annotation.Nonnull; + +public interface ErrorReporter { + void onException(@Nonnull Throwable e); + void onError(@Nonnull String message); +} diff --git a/app/src/main/java/org/solovyev/android/calculator/Locator.java b/app/src/main/java/org/solovyev/android/calculator/Locator.java index 57c26057..a996d949 100644 --- a/app/src/main/java/org/solovyev/android/calculator/Locator.java +++ b/app/src/main/java/org/solovyev/android/calculator/Locator.java @@ -39,7 +39,7 @@ public class Locator implements CalculatorLocator { @Nonnull private CalculatorNotifier calculatorNotifier = new DummyCalculatorNotifier(); @Nonnull - private CalculatorLogger calculatorLogger = new SystemOutCalculatorLogger(); + private ErrorReporter errorReporter = new SystemErrorReporter(); @Nonnull private CalculatorClipboard calculatorClipboard = new DummyCalculatorClipboard(); @Nonnull @@ -61,7 +61,7 @@ public class Locator implements CalculatorLocator { @Nonnull CalculatorEngine engine, @Nonnull CalculatorClipboard clipboard, @Nonnull CalculatorNotifier notifier, - @Nonnull CalculatorLogger logger, + @Nonnull ErrorReporter errorReporter, @Nonnull CalculatorPreferenceService preferenceService, @Nonnull Keyboard keyboard, @Nonnull CalculatorPlotter plotter) { @@ -70,7 +70,7 @@ public class Locator implements CalculatorLocator { this.calculatorEngine = engine; this.calculatorClipboard = clipboard; this.calculatorNotifier = notifier; - this.calculatorLogger = logger; + this.errorReporter = errorReporter; this.calculatorPreferenceService = preferenceService; this.calculatorPlotter = plotter; @@ -113,8 +113,8 @@ public class Locator implements CalculatorLocator { @Override @Nonnull - public CalculatorLogger getLogger() { - return calculatorLogger; + public ErrorReporter getErrorReporter() { + return errorReporter; } @Nonnull diff --git a/app/src/main/java/org/solovyev/android/calculator/CalculatorLogger.java b/app/src/main/java/org/solovyev/android/calculator/SystemErrorReporter.java similarity index 68% rename from app/src/main/java/org/solovyev/android/calculator/CalculatorLogger.java rename to app/src/main/java/org/solovyev/android/calculator/SystemErrorReporter.java index 0f332d63..a5b2a1a1 100644 --- a/app/src/main/java/org/solovyev/android/calculator/CalculatorLogger.java +++ b/app/src/main/java/org/solovyev/android/calculator/SystemErrorReporter.java @@ -25,19 +25,15 @@ package org.solovyev.android.calculator; import javax.annotation.Nonnull; import javax.annotation.Nullable; -/** - * User: serso - * Date: 10/11/12 - * Time: 12:11 AM - */ -public interface CalculatorLogger { +public class SystemErrorReporter implements ErrorReporter { - void debug(@Nullable String tag, @Nonnull String message); - - void debug(@Nullable String tag, @Nullable String message, @Nonnull Throwable e); - - void error(@Nullable String tag, @Nullable String message, @Nonnull Throwable e); - - void error(@Nullable String tag, @Nullable String message); + @Override + public void onException(@Nonnull Throwable e) { + e.printStackTrace(System.out); + } + @Override + public void onError(@Nullable String message) { + System.out.println(message); + } } diff --git a/app/src/main/java/org/solovyev/android/calculator/SystemOutCalculatorLogger.java b/app/src/main/java/org/solovyev/android/calculator/SystemOutCalculatorLogger.java deleted file mode 100644 index 37ba5f44..00000000 --- a/app/src/main/java/org/solovyev/android/calculator/SystemOutCalculatorLogger.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 2013 serso aka se.solovyev - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Contact details - * - * Email: se.solovyev@gmail.com - * Site: http://se.solovyev.org - */ - -package org.solovyev.android.calculator; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -/** - * User: serso - * Date: 10/11/12 - * Time: 12:12 AM - */ -public class SystemOutCalculatorLogger implements CalculatorLogger { - - @Nonnull - private static final String TAG = SystemOutCalculatorLogger.class.getSimpleName(); - - @Override - public void debug(@Nullable String tag, @Nullable String message) { - System.out.println(getTag(tag) + ": " + message); - } - - @Nonnull - private String getTag(@Nullable String tag) { - return tag != null ? tag : TAG; - } - - @Override - public void debug(@Nullable String tag, @Nullable String message, @Nonnull Throwable e) { - debug(tag, message); - e.printStackTrace(System.out); - } - - @Override - public void error(@Nullable String tag, @Nullable String message, @Nonnull Throwable e) { - System.out.println(getTag(tag) + ": " + message); - e.printStackTrace(System.out); - } - - @Override - public void error(@Nullable String tag, @Nullable String message) { - System.out.println(getTag(tag) + ": " + message); - } -} diff --git a/app/src/main/java/org/solovyev/android/calculator/history/History.java b/app/src/main/java/org/solovyev/android/calculator/history/History.java index 7a4c39a9..46e67d2b 100644 --- a/app/src/main/java/org/solovyev/android/calculator/history/History.java +++ b/app/src/main/java/org/solovyev/android/calculator/history/History.java @@ -41,12 +41,13 @@ 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.Locator; +import org.solovyev.android.calculator.ErrorReporter; import org.solovyev.android.calculator.model.AndroidCalculatorEngine.Preferences; import org.solovyev.android.io.FileLoader; import org.solovyev.android.io.FileSaver; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; @@ -65,6 +66,7 @@ import static android.text.TextUtils.isEmpty; public class History { public static final String TAG = App.subTag("History"); + public static final String OLD_HISTORY_PREFS_KEY = "org.solovyev.android.calculator.CalculatorModel_history"; private static final ChangedEvent CHANGED_EVENT_RECENT = new ChangedEvent(true); private static final ChangedEvent CHANGED_EVENT_SAVED = new ChangedEvent(false); private static final int MAX_INTERMEDIATE_STREAK = 5; @@ -76,29 +78,23 @@ public class History { private final RecentHistory recent = new RecentHistory(); @Nonnull private final List saved = new ArrayList<>(); - @Nonnull - private final Application application; - @Nonnull - private final Bus bus; + @Inject + Application application; + @Inject + Bus bus; @Inject Handler handler; @Inject SharedPreferences preferences; @Inject Editor editor; - @Inject - public History(@NonNull Application application, @NonNull Bus bus, @Nonnull @Named(AppModule.THREAD_INIT) Executor initThread) { - this.application = application; - this.bus = bus; - this.bus.register(this); - initThread.execute(new Runnable() { - @Override - public void run() { - init(); - } - }); - } + Display display; + @Inject + ErrorReporter errorReporter; + @Inject + @Named(AppModule.THREAD_BACKGROUND) + Executor backgroundThread; @Nullable static List convertOldHistory(@NonNull String xml) { @@ -120,7 +116,7 @@ public class History { } @Nonnull - static List loadStates(@Nonnull File file) { + static List loadStates(@Nonnull File file) throws IOException, JSONException { if (!file.exists()) { return Collections.emptyList(); } @@ -128,12 +124,7 @@ public class History { if (isEmpty(json)) { return Collections.emptyList(); } - try { - return RecentHistory.fromJson(new JSONArray(json.toString())); - } catch (JSONException e) { - Locator.getInstance().getLogger().error(TAG, e.getMessage(), e); - } - return Collections.emptyList(); + return RecentHistory.fromJson(new JSONArray(json.toString())); } private static boolean isIntermediate(@Nonnull String olderText, @@ -183,6 +174,21 @@ public class History { return sb.toString(); } + @Inject + public History() { + } + + public void init(@NonNull Executor initThread) { + Check.isMainThread(); + bus.register(this); + initThread.execute(new Runnable() { + @Override + public void run() { + initAsync(); + } + }); + } + @NonNull private File getSavedHistoryFile() { return new File(application.getFilesDir(), "history-saved.json"); @@ -195,7 +201,7 @@ public class History { private void migrateOldHistory() { try { - final String xml = preferences.getString("org.solovyev.android.calculator.CalculatorModel_history", null); + final String xml = preferences.getString(OLD_HISTORY_PREFS_KEY, null); if (isEmpty(xml)) { return; } @@ -205,16 +211,17 @@ public class History { } final JSONArray json = RecentHistory.toJson(states); FileSaver.save(getSavedHistoryFile(), json.toString()); - } catch (Exception e) { - Locator.getInstance().getLogger().error(TAG, e.getMessage(), e); + preferences.edit().remove(OLD_HISTORY_PREFS_KEY).apply(); + } catch (IOException e) { + errorReporter.onException(e); } } - private void init() { + private void initAsync() { Check.isNotMainThread(); migrateOldHistory(); - final List recentStates = loadStates(getRecentHistoryFile()); - final List savedStates = loadStates(getSavedHistoryFile()); + final List recentStates = tryLoadStates(getRecentHistoryFile()); + final List savedStates = tryLoadStates(getSavedHistoryFile()); handler.post(new Runnable() { @Override public void run() { @@ -226,6 +233,16 @@ public class History { }); } + @Nonnull + private List tryLoadStates(@NonNull File file) { + try { + return loadStates(file); + } catch (IOException | JSONException e) { + errorReporter.onException(e); + } + return Collections.emptyList(); + } + public void addRecent(@Nonnull HistoryState state) { Check.isMainThread(); recent.add(state); @@ -318,8 +335,8 @@ public class History { } private void applyHistoryState(@Nonnull HistoryState state) { - App.getEditor().setState(state.editor); - App.getDisplay().setState(state.display); + editor.setState(state.editor); + display.setState(state.display); } public void removeSaved(@Nonnull HistoryState state) { @@ -364,12 +381,16 @@ public class History { Check.isMainThread(); // don't need to save intermediate states, thus {@link History#getRecent} final List states = recent ? getRecent() : getSaved(); - App.getBackground().execute(new Runnable() { + backgroundThread.execute(new Runnable() { @Override public void run() { final File file = recent ? getRecentHistoryFile() : getSavedHistoryFile(); final JSONArray array = RecentHistory.toJson(states); - FileSaver.save(file, array.toString()); + try { + FileSaver.save(file, array.toString()); + } catch (IOException e) { + errorReporter.onException(e); + } } }); } diff --git a/app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java b/app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java index 419b726e..b233dd1c 100644 --- a/app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java +++ b/app/src/main/java/org/solovyev/android/calculator/view/EditorTextProcessor.java @@ -2,17 +2,14 @@ package org.solovyev.android.calculator.view; import android.app.Application; import android.content.SharedPreferences; -import android.util.Log; import org.solovyev.android.calculator.App; -import org.solovyev.android.calculator.CalculatorParseException; import org.solovyev.android.calculator.Preferences; import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessorEditorResult; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import javax.inject.Inject; import static org.solovyev.android.calculator.Preferences.Gui.colorDisplay; import static org.solovyev.android.calculator.Preferences.Gui.theme; @@ -22,7 +19,7 @@ public final class EditorTextProcessor implements TextProcessor textHighlighter; + private TextHighlighter textHighlighter; public EditorTextProcessor(@Nonnull SharedPreferences preferences) { preferences.registerOnSharedPreferenceChangeListener(this); @@ -31,30 +28,16 @@ public final class EditorTextProcessor implements TextProcessor getTextHighlighter() { + private TextHighlighter getTextHighlighter() { if (textHighlighter == null) { onSharedPreferenceChanged(App.getPreferences(), theme.getKey()); } diff --git a/app/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java b/app/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java index af5fe425..8ebd55a0 100644 --- a/app/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java +++ b/app/src/main/java/org/solovyev/android/calculator/view/TextHighlighter.java @@ -26,17 +26,24 @@ import android.graphics.Typeface; import android.text.SpannableStringBuilder; import android.text.style.ForegroundColorSpan; import android.text.style.StyleSpan; + import com.google.common.collect.Lists; + import org.solovyev.android.Check; -import org.solovyev.android.calculator.*; +import org.solovyev.android.calculator.BaseNumberBuilder; +import org.solovyev.android.calculator.CalculatorEngine; +import org.solovyev.android.calculator.LiteNumberBuilder; +import org.solovyev.android.calculator.Locator; +import org.solovyev.android.calculator.NumberBuilder; import org.solovyev.android.calculator.math.MathType; import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessorEditorResult; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; +import javax.annotation.Nonnull; + public class TextHighlighter implements TextProcessor { private final int red; @@ -76,7 +83,7 @@ public class TextHighlighter implements TextProcessor>(), "test", 0))); - Locator.getInstance().init(new CalculatorImpl(Mockito.mock(Bus.class), Mockito.mock(Executor.class)), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(Keyboard.class), Mockito.mock(CalculatorPlotter.class)); + Locator.getInstance().init(new CalculatorImpl(Mockito.mock(Bus.class), Mockito.mock(Executor.class)), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), new SystemErrorReporter(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(Keyboard.class), Mockito.mock(CalculatorPlotter.class)); Locator.getInstance().getEngine().init(); final DecimalFormatSymbols decimalGroupSymbols = new DecimalFormatSymbols(); @@ -64,7 +73,7 @@ public class CalculatorTestUtils { } public static void staticSetUp(@Nullable Context context) throws Exception { - Locator.getInstance().init(new CalculatorImpl(Mockito.mock(Bus.class), Mockito.mock(Executor.class)), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(Keyboard.class), Mockito.mock(CalculatorPlotter.class)); + Locator.getInstance().init(new CalculatorImpl(Mockito.mock(Bus.class), Mockito.mock(Executor.class)), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), new SystemErrorReporter(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(Keyboard.class), Mockito.mock(CalculatorPlotter.class)); Locator.getInstance().getEngine().init(); if (context != null) { diff --git a/app/src/test/java/org/solovyev/android/calculator/history/HistoryTest.java b/app/src/test/java/org/solovyev/android/calculator/history/HistoryTest.java index b3e301ab..e95e700e 100644 --- a/app/src/test/java/org/solovyev/android/calculator/history/HistoryTest.java +++ b/app/src/test/java/org/solovyev/android/calculator/history/HistoryTest.java @@ -43,7 +43,6 @@ import org.solovyev.android.calculator.jscl.JsclOperation; import java.io.File; import java.util.List; -import java.util.concurrent.Executor; import javax.annotation.Nonnull; @@ -65,7 +64,9 @@ public class HistoryTest { @Before public void setUp() throws Exception { - history = new History(RuntimeEnvironment.application, mock(Bus.class), mock(Executor.class)); + history = new History(); + history.application = RuntimeEnvironment.application; + history.bus = mock(Bus.class); history.handler = mock(Handler.class); history.preferences = mock(SharedPreferences.class); history.editor = mock(Editor.class);