This commit is contained in:
Sergey Solovyev 2013-06-18 14:39:20 +04:00
parent 4840b6e25b
commit 072ee452ad
9 changed files with 52 additions and 51 deletions

View File

@ -59,6 +59,17 @@
<artifactId>support-v4</artifactId> <artifactId>support-v4</artifactId>
</dependency> </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -41,6 +41,8 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
@Nonnull @Nonnull
private ExternalCalculatorIntentHandler intentHandler = new CalculatorWidgetIntentHandler(this); private ExternalCalculatorIntentHandler intentHandler = new CalculatorWidgetIntentHandler(this);
private boolean initialized = false;
/* /*
********************************************************************** **********************************************************************
@ -51,9 +53,6 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
*/ */
protected AbstractCalculatorWidgetProvider() { protected AbstractCalculatorWidgetProvider() {
final Class<? extends AppWidgetProvider> componentClass = this.getComponentClass();
Locator.getInstance().getExternalListenersContainer().addExternalListener(componentClass);
} }
/* /*
@ -68,6 +67,12 @@ abstract class AbstractCalculatorWidgetProvider extends AppWidgetProvider implem
public void onEnabled(Context context) { public void onEnabled(Context context) {
super.onEnabled(context); super.onEnabled(context);
if (!initialized) {
final Class<? extends AppWidgetProvider> componentClass = this.getComponentClass();
Locator.getInstance().getExternalListenersContainer().addExternalListener(componentClass);
initialized = true;
}
getCursorColor(context); getCursorColor(context);
} }

View File

@ -125,7 +125,6 @@
<dependency> <dependency>
<groupId>org.robolectric</groupId> <groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId> <artifactId>robolectric</artifactId>
<version>2.1.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>

View File

@ -1,35 +0,0 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
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=../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

View File

@ -1,18 +1,24 @@
package org.solovyev.android.calculator; package org.solovyev.android.calculator;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config; import org.solovyev.common.text.Strings;
/** /**
* User: serso * User: serso
* Date: 10/13/12 * Date: 10/13/12
* Time: 1:11 PM * Time: 1:11 PM
*/ */
@Config(manifest = Config.DEFAULT)
@RunWith(value = RobolectricTestRunner.class) @RunWith(value = RobolectricTestRunner.class)
public class AndroidCalculatorEditorViewTest { public class AndroidCalculatorEditorViewTest {
@ -34,7 +40,7 @@ public class AndroidCalculatorEditorViewTest {
@Test @Test
public void testAsyncWork() throws Exception { public void testAsyncWork() throws Exception {
/* final int threadNum = 10; final int threadNum = 10;
final int count = 10; final int count = 10;
final int maxTextLength = 100; final int maxTextLength = 100;
@ -78,6 +84,6 @@ public class AndroidCalculatorEditorViewTest {
Assert.assertFalse(error.get()); Assert.assertFalse(error.get());
} else { } else {
Assert.fail("Too long execution!"); Assert.fail("Too long execution!");
}*/ }
} }
} }

View File

@ -9,7 +9,8 @@ package org.solovyev.android.calculator;
import android.graphics.Color; import android.graphics.Color;
import jscl.MathEngine; import jscl.MathEngine;
import jscl.NumeralBase; import jscl.NumeralBase;
import junit.framework.Assert;
import org.junit.Assert;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.solovyev.android.calculator.text.TextProcessor; import org.solovyev.android.calculator.text.TextProcessor;

View File

@ -1,5 +1,8 @@
package org.solovyev.android.calculator.plot; package org.solovyev.android.calculator.plot;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import org.junit.Test; import org.junit.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -14,8 +17,15 @@ public class CalculatorGraph2dViewTest {
@Test @Test
public void testFormatTick() throws Exception { public void testFormatTick() throws Exception {
assertEquals("23324", CalculatorGraph2dView.formatTick(23324.0f, 0)); assertEquals("23324", CalculatorGraph2dView.formatTick(23324.0f, 0));
final DecimalFormat format = (DecimalFormat) DecimalFormat.getInstance();
final DecimalFormatSymbols decimalFormatSymbols = format.getDecimalFormatSymbols();
if (',' == decimalFormatSymbols.getDecimalSeparator()) {
assertEquals("23324,1", CalculatorGraph2dView.formatTick(23324.1f, 1));
} else if ('.' == decimalFormatSymbols.getDecimalSeparator()) {
assertEquals("23324.1", CalculatorGraph2dView.formatTick(23324.1f, 1)); assertEquals("23324.1", CalculatorGraph2dView.formatTick(23324.1f, 1));
} }
}
@Test @Test
public void testCountTickDigits() throws Exception { public void testCountTickDigits() throws Exception {

View File

@ -4,7 +4,6 @@ import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.robolectric.Robolectric; import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner; import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.util.ActivityController; import org.robolectric.util.ActivityController;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -15,7 +14,6 @@ import static org.junit.Assert.assertNotNull;
* Date: 6/17/13 * Date: 6/17/13
* Time: 9:57 PM * Time: 9:57 PM
*/ */
@Config(manifest = "android-app/AndroidManifest.xml")
@RunWith(value = RobolectricTestRunner.class) @RunWith(value = RobolectricTestRunner.class)
public class CalculatorWizardActivityTest { public class CalculatorWizardActivityTest {
@ -26,11 +24,8 @@ public class CalculatorWizardActivityTest {
controller.create(); controller.create();
final CalculatorWizardActivity activity = controller.get(); final CalculatorWizardActivity activity = controller.get();
activity.onCreate(null);
assertNotNull(activity.getFlow()); assertNotNull(activity.getFlow());
assertNotNull(activity.getStep()); assertNotNull(activity.getStep());
assertEquals(activity.getFlow().getFirstStep(), activity.getStep()); assertEquals(activity.getFlow().getFirstStep(), activity.getStep());
} }
} }

11
pom.xml
View File

@ -181,6 +181,13 @@
<version>4.11</version> <version>4.11</version>
</dependency> </dependency>
<dependency>
<groupId>org.robolectric</groupId>
<artifactId>robolectric</artifactId>
<version>2.1.1</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>com.google.android</groupId> <groupId>com.google.android</groupId>
<artifactId>android</artifactId> <artifactId>android</artifactId>
@ -258,7 +265,9 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version> <version>2.15</version>
<configuration> <configuration>
<forkMode>always</forkMode> <parallel>classes</parallel>
<forkCount>1</forkCount>
<reuseForks>false</reuseForks>
</configuration> </configuration>
</plugin> </plugin>