wizard added

This commit is contained in:
Sergey Solovyev
2013-06-18 00:44:44 +04:00
parent 6ef4354f2c
commit 4840b6e25b
14 changed files with 289 additions and 196 deletions

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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());
}
}

View File

@@ -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));
}
}

View File

@@ -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<CalculatorWizardActivity> 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());
}
}