diff --git a/android-app/pom.xml b/android-app/pom.xml
index 602c23aa..d1ba1c4a 100644
--- a/android-app/pom.xml
+++ b/android-app/pom.xml
@@ -123,9 +123,9 @@
- com.pivotallabs
+ org.robolectric
robolectric
- 1.2
+ 2.1.1
test
diff --git a/android-app/project.properties b/android-app/project.properties
index 8c2eef84..c2cbeb1a 100644
--- a/android-app/project.properties
+++ b/android-app/project.properties
@@ -8,23 +8,28 @@
# project structure.
# Project target.
-target=android-15
+target=android-17
android.library.reference.1=../android-app-core
android.library.reference.2=../android-app-widget
android.library.reference.3=../android-app-onscreen
-android.library.reference.4=gen-external-apklibs/org.solovyev.android_android-common-all_1.0.7-SNAPSHOT
-android.library.reference.5=gen-external-apklibs/org.solovyev.android_android-common-ads_1.0.7-SNAPSHOT
-android.library.reference.6=gen-external-apklibs/org.solovyev.android_android-common-core_1.0.7-SNAPSHOT
-android.library.reference.7=gen-external-apklibs/org.solovyev.android_android-common-billing_1.0.7-SNAPSHOT
-android.library.reference.8=gen-external-apklibs/org.solovyev.android_android-common-db_1.0.7-SNAPSHOT
-android.library.reference.9=gen-external-apklibs/org.solovyev.android_android-common-http_1.0.7-SNAPSHOT
-android.library.reference.10=gen-external-apklibs/org.solovyev.android_android-common-list_1.0.7-SNAPSHOT
-android.library.reference.11=gen-external-apklibs/org.solovyev.android_android-common-view_1.0.7-SNAPSHOT
-android.library.reference.12=gen-external-apklibs/org.solovyev.android_android-common-preferences_1.0.7-SNAPSHOT
-android.library.reference.13=gen-external-apklibs/org.solovyev.android_android-common-menu_1.0.7-SNAPSHOT
-android.library.reference.14=gen-external-apklibs/org.solovyev.android_android-common-other_1.0.7-SNAPSHOT
-android.library.reference.15=gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.0.7-SNAPSHOT
-android.library.reference.16=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
-android.library.reference.17=gen-external-apklibs/org.solovyev.android_android-common-keyboard_1.0.7-SNAPSHOT
+android.library.reference.4=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-all_1.1.1-SNAPSHOT
+android.library.reference.5=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-ads_1.1.1-SNAPSHOT
+android.library.reference.6=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-core_1.1.1-SNAPSHOT
+android.library.reference.7=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-billing_1.1.1-SNAPSHOT
+android.library.reference.8=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-db_1.1.1-SNAPSHOT
+android.library.reference.9=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-security_1.1.1-SNAPSHOT
+android.library.reference.10=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-http_1.1.1-SNAPSHOT
+android.library.reference.11=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-lists_1.1.1-SNAPSHOT
+android.library.reference.12=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-views_1.1.1-SNAPSHOT
+android.library.reference.13=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-preferences_1.1.1-SNAPSHOT
+android.library.reference.14=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-menus_1.1.1-SNAPSHOT
+android.library.reference.15=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-other_1.1.1-SNAPSHOT
+android.library.reference.16=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-sherlock_1.1.1-SNAPSHOT
+android.library.reference.17=gen-external-apklibs/com.actionbarsherlock_actionbarsherlock_4.2.0
+android.library.reference.18=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-keyboards_1.1.1-SNAPSHOT
+android.library.reference.19=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-app_1.1.1-SNAPSHOT
+android.library.reference.20=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-networks_1.1.1-SNAPSHOT
+android.library.reference.21=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-fragments_1.1.1-SNAPSHOT
+android.library.reference.22=../android-app-widget/gen-external-apklibs/org.solovyev.android_android-common-tasks_1.1.1-SNAPSHOT
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java
new file mode 100644
index 00000000..b6d0b062
--- /dev/null
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorMode.java
@@ -0,0 +1,50 @@
+package org.solovyev.android.calculator.wizard;
+
+import android.content.SharedPreferences;
+import jscl.AngleUnit;
+import org.solovyev.android.calculator.CalculatorPreferences;
+import org.solovyev.android.calculator.R;
+import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
+
+import javax.annotation.Nonnull;
+
+import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
+
+/**
+* User: serso
+* Date: 6/17/13
+* Time: 9:30 PM
+*/
+enum CalculatorMode {
+ simple(R.string.cpp_wizard_mode_simple) {
+ @Override
+ protected void apply(@Nonnull SharedPreferences preferences) {
+ CalculatorPreferences.Gui.layout.putPreference(preferences, CalculatorPreferences.Gui.Layout.simple);
+ CalculatorPreferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.deg);
+ AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, false);
+ AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, true);
+ }
+ },
+
+ engineer(R.string.cpp_wizard_mode_engineer) {
+ @Override
+ protected void apply(@Nonnull SharedPreferences preferences) {
+ CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator);
+ CalculatorPreferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.rad);
+ AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, true);
+ AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, false);
+ }
+ };
+
+ private final int nameResId;
+
+ CalculatorMode(int nameResId) {
+ this.nameResId = nameResId;
+ }
+
+ int getNameResId() {
+ return nameResId;
+ }
+
+ protected abstract void apply(@Nonnull SharedPreferences preferences);
+}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivity.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivity.java
index 2118d775..62b06d84 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivity.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivity.java
@@ -5,7 +5,6 @@ import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
-import android.view.ViewGroup;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import org.solovyev.android.calculator.R;
@@ -46,7 +45,6 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
private View prevButton;
private View nextButton;
private View finishButton;
- private ViewGroup wizardContent;
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -56,7 +54,6 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
prevButton = findViewById(R.id.wizard_prev_button);
nextButton = findViewById(R.id.wizard_next_button);
finishButton = findViewById(R.id.wizard_finish_button);
- wizardContent = (ViewGroup) findViewById(R.id.wizard_content);
String wizardName = null;
WizardStep step = null;
@@ -79,62 +76,113 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
final FragmentManager fm = getSupportFragmentManager();
final FragmentTransaction ft = fm.beginTransaction();
- if (this.step != null) {
- final Fragment oldFragment = fm.findFragmentByTag(this.step.getFragmentTag());
- if (oldFragment != null) {
- ft.hide(oldFragment);
- }
- }
+ hideFragment(fm, ft);
this.step = step;
- Fragment newFragment = fm.findFragmentByTag(step.getFragmentTag());
- if(newFragment == null) {
- newFragment = Fragment.instantiate(this, step.getFragmentClass().getName());
- ft.add(R.id.wizard_content, newFragment, step.getFragmentTag());
- } else {
- ft.show(newFragment);
- }
+ showFragment(fm, ft);
ft.commit();
- final WizardStep nextStep = flow.getNextStep(step);
- if (nextStep == null) {
- finishButton.setVisibility(VISIBLE);
- finishButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- finish();
- }
- });
+ initNextButton();
+ initPrevButton();
+ }
+ }
- nextButton.setVisibility(GONE);
- nextButton.setOnClickListener(null);
- } else {
- finishButton.setVisibility(GONE);
- finishButton.setOnClickListener(null);
-
- nextButton.setVisibility(VISIBLE);
- nextButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- setStep(nextStep);
- }
- });
- }
-
- final WizardStep prevStep = flow.getPrevStep(step);
- if (prevStep == null) {
- prevButton.setVisibility(GONE);
- prevButton.setOnClickListener(null);
- } else {
- prevButton.setVisibility(VISIBLE);
- prevButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
+ private void initPrevButton() {
+ final WizardStep prevStep = flow.getPrevStep(step);
+ if (prevStep == null) {
+ prevButton.setVisibility(GONE);
+ prevButton.setOnClickListener(null);
+ } else {
+ prevButton.setVisibility(VISIBLE);
+ prevButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (tryGoPrev()) {
setStep(prevStep);
}
- });
+ }
+ });
+ }
+ }
+
+ private void initNextButton() {
+ final WizardStep nextStep = flow.getNextStep(step);
+ if (nextStep == null) {
+ finishButton.setVisibility(VISIBLE);
+ finishButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (tryGoNext()) {
+ finish();
+ }
+ }
+ });
+
+ nextButton.setVisibility(GONE);
+ nextButton.setOnClickListener(null);
+ } else {
+ finishButton.setVisibility(GONE);
+ finishButton.setOnClickListener(null);
+
+ nextButton.setVisibility(VISIBLE);
+ nextButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ if (tryGoNext()) {
+ setStep(nextStep);
+ }
+ }
+ });
+ }
+ }
+
+ private boolean tryGoPrev() {
+ if (this.step == null) {
+ return true;
+ } else {
+ final Fragment fragment = getSupportFragmentManager().findFragmentByTag(this.step.getFragmentTag());
+ if (fragment != null) {
+ return this.step.onPrev(fragment);
+ } else {
+ return true;
+ }
+ }
+ }
+
+ private boolean tryGoNext() {
+ if (this.step == null) {
+ return true;
+ } else {
+ final Fragment fragment = getSupportFragmentManager().findFragmentByTag(this.step.getFragmentTag());
+ if (fragment != null) {
+ return this.step.onNext(fragment);
+ } else {
+ return true;
+ }
+ }
+ }
+
+ @Nonnull
+ private Fragment showFragment(@Nonnull FragmentManager fm, @Nonnull FragmentTransaction ft) {
+ Fragment newFragment = fm.findFragmentByTag(this.step.getFragmentTag());
+
+ if (newFragment == null) {
+ newFragment = Fragment.instantiate(this, this.step.getFragmentClass().getName());
+ ft.add(R.id.wizard_content, newFragment, this.step.getFragmentTag());
+ } else {
+ ft.show(newFragment);
+ }
+
+ return newFragment;
+ }
+
+ private void hideFragment(@Nonnull FragmentManager fm, @Nonnull FragmentTransaction ft) {
+ if (this.step != null) {
+ final Fragment oldFragment = fm.findFragmentByTag(this.step.getFragmentTag());
+ if (oldFragment != null) {
+ ft.hide(oldFragment);
}
}
}
@@ -146,4 +194,11 @@ public final class CalculatorWizardActivity extends SherlockFragmentActivity {
out.putSerializable(STEP, step);
}
+ WizardStep getStep() {
+ return step;
+ }
+
+ WizardFlow getFlow() {
+ return flow;
+ }
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java
index a86169ff..9cb6e9a5 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/ChooseModeWizardStep.java
@@ -1,39 +1,30 @@
package org.solovyev.android.calculator.wizard;
import android.content.Context;
-import android.content.SharedPreferences;
import android.os.Bundle;
-import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Spinner;
import android.widget.TextView;
-import jscl.AngleUnit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-import org.solovyev.android.calculator.CalculatorPreferences;
+import com.actionbarsherlock.app.SherlockFragment;
import org.solovyev.android.calculator.R;
-import org.solovyev.android.calculator.model.AndroidCalculatorEngine;
import org.solovyev.android.list.ListItem;
import org.solovyev.android.list.ListItemAdapter;
-import com.actionbarsherlock.app.SherlockFragment;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.ArrayList;
+import java.util.List;
-import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.main_calculator;
-import static org.solovyev.android.calculator.CalculatorPreferences.Gui.Layout.simple;
+import static org.solovyev.android.calculator.wizard.CalculatorMode.simple;
/**
* User: serso
* Date: 6/16/13
* Time: 9:59 PM
*/
-public final class ChooseModeWizardStep extends SherlockFragment implements WizardStepFragment {
+public final class ChooseModeWizardStep extends SherlockFragment {
@Nullable
private Spinner layoutSpinner;
@@ -49,33 +40,25 @@ public final class ChooseModeWizardStep extends SherlockFragment implements Wiza
layoutSpinner = (Spinner) root.findViewById(R.id.wizard_mode_spinner);
final List listItems = new ArrayList();
- for (Mode mode : Mode.values()) {
+ for (CalculatorMode mode : CalculatorMode.values()) {
listItems.add(new ModeListItem(mode));
}
layoutSpinner.setAdapter(ListItemAdapter.newInstance(getActivity(), listItems));
}
- @Override
- public boolean onNext() {
+ @Nonnull
+ CalculatorMode getSelectedMode() {
+ CalculatorMode mode = simple;
+
if (layoutSpinner != null) {
final int position = layoutSpinner.getSelectedItemPosition();
- final Mode mode;
- if (position >= 0 && position < Mode.values().length) {
- mode = Mode.values()[position];
- } else {
- mode = Mode.Simple;
+ if (position >= 0 && position < CalculatorMode.values().length) {
+ mode = CalculatorMode.values()[position];
}
-
- mode.apply(PreferenceManager.getDefaultSharedPreferences(getActivity()));
}
- return true;
- }
-
- @Override
- public boolean onPrev() {
- return true;
+ return mode;
}
/*
@@ -89,9 +72,9 @@ public final class ChooseModeWizardStep extends SherlockFragment implements Wiza
private static final class ModeListItem implements ListItem {
@Nonnull
- private final Mode mode;
+ private final CalculatorMode mode;
- private ModeListItem(@Nonnull Mode mode) {
+ private ModeListItem(@Nonnull CalculatorMode mode) {
this.mode = mode;
}
@@ -122,37 +105,4 @@ public final class ChooseModeWizardStep extends SherlockFragment implements Wiza
}
}
- private static enum Mode {
- Simple(R.string.cpp_wizard_mode_simple) {
- @Override
- protected void apply(@Nonnull SharedPreferences preferences) {
- CalculatorPreferences.Gui.layout.putPreference(preferences, simple);
- CalculatorPreferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.deg);
- AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, false);
- AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, true);
- }
- },
-
- Engineer(R.string.cpp_wizard_mode_engineer) {
- @Override
- protected void apply(@Nonnull SharedPreferences preferences) {
- CalculatorPreferences.Gui.layout.putPreference(preferences, main_calculator);
- CalculatorPreferences.Calculations.preferredAngleUnits.putPreference(preferences, AngleUnit.rad);
- AndroidCalculatorEngine.Preferences.scienceNotation.putPreference(preferences, true);
- AndroidCalculatorEngine.Preferences.roundResult.putPreference(preferences, false);
- }
- };
-
- private final int nameResId;
-
- Mode(int nameResId) {
- this.nameResId = nameResId;
- }
-
- private int getNameResId() {
- return nameResId;
- }
-
- protected abstract void apply(@Nonnull SharedPreferences preferences);
- }
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStep.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStep.java
index a38f2ae2..e51b4638 100644
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStep.java
+++ b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStep.java
@@ -1,5 +1,6 @@
package org.solovyev.android.calculator.wizard;
+import android.preference.PreferenceManager;
import android.support.v4.app.Fragment;
import javax.annotation.Nonnull;
@@ -11,8 +12,34 @@ import javax.annotation.Nonnull;
*/
enum WizardStep {
- welcome(WelcomeWizardStep.class),
- choose_mode(ChooseModeWizardStep.class);
+ welcome(WelcomeWizardStep.class) {
+ @Override
+ boolean onNext(@Nonnull Fragment fragment) {
+ return true;
+ }
+
+ @Override
+ boolean onPrev(@Nonnull Fragment fragment) {
+ return true;
+ }
+ },
+
+ choose_mode(ChooseModeWizardStep.class) {
+ @Override
+ boolean onNext(@Nonnull Fragment f) {
+ final ChooseModeWizardStep fragment = (ChooseModeWizardStep) f;
+
+ final CalculatorMode mode = fragment.getSelectedMode();
+ mode.apply(PreferenceManager.getDefaultSharedPreferences(f.getActivity()));
+
+ return true;
+ }
+
+ @Override
+ boolean onPrev(@Nonnull Fragment fragment) {
+ return true;
+ }
+ };
@Nonnull
private final Class extends Fragment> fragmentClass;
@@ -29,4 +56,7 @@ enum WizardStep {
Class extends Fragment> getFragmentClass() {
return fragmentClass;
}
+
+ abstract boolean onNext(@Nonnull Fragment fragment);
+ abstract boolean onPrev(@Nonnull Fragment fragment);
}
diff --git a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStepFragment.java b/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStepFragment.java
deleted file mode 100644
index e164ea3b..00000000
--- a/android-app/src/main/java/org/solovyev/android/calculator/wizard/WizardStepFragment.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.solovyev.android.calculator.wizard;
-
-public interface WizardStepFragment {
-
- public boolean onNext();
-
- public boolean onPrev();
-}
diff --git a/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java b/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java
index 7be4a8ed..6fd1f398 100644
--- a/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java
+++ b/android-app/src/test/java/org/solovyev/android/calculator/AndroidCalculatorEditorViewTest.java
@@ -4,13 +4,16 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
/**
* User: serso
* Date: 10/13/12
* Time: 1:11 PM
*/
-@RunWith(value = CalculatorppTestRunner.class)
+@Config(manifest = Config.DEFAULT)
+@RunWith(value = RobolectricTestRunner.class)
public class AndroidCalculatorEditorViewTest {
@BeforeClass
diff --git a/android-app/src/test/java/org/solovyev/android/calculator/CalculatorppTestRunner.java b/android-app/src/test/java/org/solovyev/android/calculator/CalculatorppTestRunner.java
deleted file mode 100644
index 946a802c..00000000
--- a/android-app/src/test/java/org/solovyev/android/calculator/CalculatorppTestRunner.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package org.solovyev.android.calculator;
-
-import com.xtremelabs.robolectric.RobolectricConfig;
-import com.xtremelabs.robolectric.RobolectricTestRunner;
-import org.junit.runners.model.InitializationError;
-
-import javax.annotation.Nonnull;
-import java.io.File;
-
-/**
- * User: serso
- * Date: 10/7/12
- * Time: 5:36 PM
- */
-public class CalculatorppTestRunner extends RobolectricTestRunner {
-
- public CalculatorppTestRunner(@Nonnull Class> testClass) throws InitializationError {
- super(testClass, new File("."));
- }
-
- @Override
- public void setupApplicationState(RobolectricConfig robolectricConfig) {
- try {
- CalculatorTestUtils.staticSetUp();
- } catch (Exception e) {
- throw new AssertionError(e);
- }
- super.setupApplicationState(robolectricConfig);
- }
-}
diff --git a/android-app/src/test/java/org/solovyev/android/calculator/model/VarTest.java b/android-app/src/test/java/org/solovyev/android/calculator/model/VarTest.java
index 3b4f0435..a99e920f 100644
--- a/android-app/src/test/java/org/solovyev/android/calculator/model/VarTest.java
+++ b/android-app/src/test/java/org/solovyev/android/calculator/model/VarTest.java
@@ -7,13 +7,14 @@
package org.solovyev.android.calculator.model;
import jscl.math.function.IConstant;
-import junit.framework.Assert;
import org.junit.Test;
import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;
import java.io.StringWriter;
+import static org.junit.Assert.assertEquals;
+
/**
* User: serso
* Date: 11/7/11
@@ -49,7 +50,7 @@ public class VarTest {
final Serializer serializer = new Persister();
serializer.write(vars, sw);
- Assert.assertEquals(xml, sw.toString());
+ assertEquals(xml, sw.toString());
final Vars result = serializer.read(Vars.class, xml);
final IConstant actualFirst = result.getEntities().get(0);
@@ -61,8 +62,8 @@ public class VarTest {
}
private void areEqual(IConstant expected, IConstant actual) {
- Assert.assertEquals(expected.getName(), actual.getName());
- Assert.assertEquals(expected.getDescription(), actual.getDescription());
- Assert.assertEquals(expected.getValue(), actual.getValue());
+ assertEquals(expected.getName(), actual.getName());
+ assertEquals(expected.getDescription(), actual.getDescription());
+ assertEquals(expected.getValue(), actual.getValue());
}
}
diff --git a/android-app/src/test/java/org/solovyev/android/calculator/plot/CalculatorGraph2dViewTest.java b/android-app/src/test/java/org/solovyev/android/calculator/plot/CalculatorGraph2dViewTest.java
index bef4ef6b..a5c92e07 100644
--- a/android-app/src/test/java/org/solovyev/android/calculator/plot/CalculatorGraph2dViewTest.java
+++ b/android-app/src/test/java/org/solovyev/android/calculator/plot/CalculatorGraph2dViewTest.java
@@ -1,8 +1,9 @@
package org.solovyev.android.calculator.plot;
-import junit.framework.Assert;
import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
/**
* User: serso
* Date: 1/15/13
@@ -12,19 +13,19 @@ public class CalculatorGraph2dViewTest {
@Test
public void testFormatTick() throws Exception {
- Assert.assertEquals("23324", CalculatorGraph2dView.formatTick(23324.0f, 0));
- Assert.assertEquals("23324.1", CalculatorGraph2dView.formatTick(23324.1f, 1));
+ assertEquals("23324", CalculatorGraph2dView.formatTick(23324.0f, 0));
+ assertEquals("23324.1", CalculatorGraph2dView.formatTick(23324.1f, 1));
}
@Test
public void testCountTickDigits() throws Exception {
- Assert.assertEquals(0, CalculatorGraph2dView.countTickDigits(1));
- Assert.assertEquals(0, CalculatorGraph2dView.countTickDigits(10));
- Assert.assertEquals(0, CalculatorGraph2dView.countTickDigits(100));
- Assert.assertEquals(1, CalculatorGraph2dView.countTickDigits(0.9f));
- Assert.assertEquals(1, CalculatorGraph2dView.countTickDigits(0.2f));
- Assert.assertEquals(1, CalculatorGraph2dView.countTickDigits(0.1f));
- Assert.assertEquals(2, CalculatorGraph2dView.countTickDigits(0.099f));
- Assert.assertEquals(3, CalculatorGraph2dView.countTickDigits(0.009f));
+ assertEquals(0, CalculatorGraph2dView.countTickDigits(1));
+ assertEquals(0, CalculatorGraph2dView.countTickDigits(10));
+ assertEquals(0, CalculatorGraph2dView.countTickDigits(100));
+ assertEquals(1, CalculatorGraph2dView.countTickDigits(0.9f));
+ assertEquals(1, CalculatorGraph2dView.countTickDigits(0.2f));
+ assertEquals(1, CalculatorGraph2dView.countTickDigits(0.1f));
+ assertEquals(2, CalculatorGraph2dView.countTickDigits(0.099f));
+ assertEquals(3, CalculatorGraph2dView.countTickDigits(0.009f));
}
}
diff --git a/android-app/src/test/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivityTest.java b/android-app/src/test/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivityTest.java
new file mode 100644
index 00000000..d80bc71a
--- /dev/null
+++ b/android-app/src/test/java/org/solovyev/android/calculator/wizard/CalculatorWizardActivityTest.java
@@ -0,0 +1,36 @@
+package org.solovyev.android.calculator.wizard;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.Robolectric;
+import org.robolectric.RobolectricTestRunner;
+import org.robolectric.annotation.Config;
+import org.robolectric.util.ActivityController;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+/**
+ * User: serso
+ * Date: 6/17/13
+ * Time: 9:57 PM
+ */
+@Config(manifest = "android-app/AndroidManifest.xml")
+@RunWith(value = RobolectricTestRunner.class)
+public class CalculatorWizardActivityTest {
+
+ @Test
+ public void testRestoreState() throws Exception {
+ final ActivityController controller = Robolectric.buildActivity(CalculatorWizardActivity.class);
+ controller.attach();
+ controller.create();
+
+ final CalculatorWizardActivity activity = controller.get();
+ activity.onCreate(null);
+ assertNotNull(activity.getFlow());
+ assertNotNull(activity.getStep());
+ assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
+
+
+ }
+}
diff --git a/core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java b/core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
index 11022a22..33f02781 100644
--- a/core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
+++ b/core/src/test/java/org/solovyev/android/calculator/CalculatorTestUtils.java
@@ -1,15 +1,15 @@
package org.solovyev.android.calculator;
import jscl.JsclMathEngine;
-import junit.framework.Assert;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
+import org.junit.Assert;
import org.mockito.Mockito;
import org.solovyev.android.calculator.external.CalculatorExternalListenersContainer;
import org.solovyev.android.calculator.history.CalculatorHistory;
import org.solovyev.android.calculator.jscl.JsclOperation;
import org.solovyev.android.calculator.plot.CalculatorPlotter;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import java.io.*;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
public class CalculatorTestUtils {
// in seconds
- public static final int TIMEOUT = 3;
+ public static final int TIMEOUT = 10;
public static void staticSetUp() throws Exception {
Locator.getInstance().init(new CalculatorImpl(), newCalculatorEngine(), Mockito.mock(CalculatorClipboard.class), Mockito.mock(CalculatorNotifier.class), Mockito.mock(CalculatorHistory.class), new SystemOutCalculatorLogger(), Mockito.mock(CalculatorPreferenceService.class), Mockito.mock(CalculatorKeyboard.class), Mockito.mock(CalculatorExternalListenersContainer.class), Mockito.mock(CalculatorPlotter.class));
diff --git a/pom.xml b/pom.xml
index 6c2f746b..d509748b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -256,7 +256,7 @@
org.apache.maven.plugins
maven-surefire-plugin
- 2.12.4
+ 2.15
always