app-tests module merged into app module
This commit is contained in:
parent
7da69a2083
commit
60d65d52df
@ -1,56 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2014 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
def app = project(':app')
|
|
||||||
compile app
|
|
||||||
|
|
||||||
testCompile app.android.applicationVariants.toList().first().javaCompile.classpath
|
|
||||||
testCompile app.android.applicationVariants.toList().first().javaCompile.outputs.files
|
|
||||||
testCompile files(app.android.bootClasspath)
|
|
||||||
|
|
||||||
testCompile 'junit:junit:4.11'
|
|
||||||
testCompile 'org.robolectric:robolectric:2.3'
|
|
||||||
testCompile 'org.mockito:mockito-all:1.9.5'
|
|
||||||
testCompile 'org.skyscreamer:jsonassert:1.2.3'
|
|
||||||
testCompile 'com.android.support:support-v4:22.1.1'
|
|
||||||
testCompile 'com.android.support:appcompat-v7:22.1.1'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(Test) {
|
|
||||||
scanForTestClasses = false
|
|
||||||
include "**/*Test.class"
|
|
||||||
exclude "**/*AndroidCalculatorEditorViewTest*"
|
|
||||||
exclude "**/*CalculatorWizardActivityTest*"
|
|
||||||
exclude "**/*OnScreenCalculatorWizardStepTest*"
|
|
||||||
exclude "**/*CalculatorWizardTest*"
|
|
||||||
exclude "**/*WizardStepTest*"
|
|
||||||
exclude "**/*AngleUnitsButtonTest*"
|
|
||||||
exclude "**/*NumeralBasesButtonTest*"
|
|
||||||
}
|
|
||||||
|
|
||||||
test {
|
|
||||||
maxParallelForks = 15
|
|
||||||
forkEvery = 1
|
|
||||||
}
|
|
@ -1,80 +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 android.content.Context;
|
|
||||||
|
|
||||||
import org.mockito.Mockito;
|
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistory;
|
|
||||||
import org.solovyev.android.calculator.plot.CalculatorPlotter;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import jscl.JsclMathEngine;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* User: serso
|
|
||||||
* Date: 10/7/12
|
|
||||||
* Time: 8:56 PM
|
|
||||||
*/
|
|
||||||
public class CalculatorTestUtils {
|
|
||||||
|
|
||||||
public static void staticSetUp(@Nullable Context context) 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(CalculatorPlotter.class), null);
|
|
||||||
Locator.getInstance().getEngine().init();
|
|
||||||
|
|
||||||
if (context != null) {
|
|
||||||
initViews(context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void initViews(@Nonnull Context context) {
|
|
||||||
final AndroidCalculatorEditorView editor = new AndroidCalculatorEditorView(context);
|
|
||||||
editor.init();
|
|
||||||
Locator.getInstance().getEditor().setView(editor);
|
|
||||||
|
|
||||||
final AndroidCalculatorDisplayView display = new AndroidCalculatorDisplayView(context);
|
|
||||||
display.init(context);
|
|
||||||
Locator.getInstance().getDisplay().setView(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void staticSetUp() throws Exception {
|
|
||||||
staticSetUp(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
static CalculatorEngineImpl newCalculatorEngine() {
|
|
||||||
final MathEntityDao mathEntityDao = Mockito.mock(MathEntityDao.class);
|
|
||||||
|
|
||||||
final JsclMathEngine jsclEngine = JsclMathEngine.getInstance();
|
|
||||||
|
|
||||||
final CalculatorVarsRegistry varsRegistry = new CalculatorVarsRegistry(jsclEngine.getConstantsRegistry(), mathEntityDao);
|
|
||||||
final CalculatorFunctionsMathRegistry functionsRegistry = new CalculatorFunctionsMathRegistry(jsclEngine.getFunctionsRegistry(), mathEntityDao);
|
|
||||||
final CalculatorOperatorsMathRegistry operatorsRegistry = new CalculatorOperatorsMathRegistry(jsclEngine.getOperatorsRegistry(), mathEntityDao);
|
|
||||||
final CalculatorPostfixFunctionsRegistry postfixFunctionsRegistry = new CalculatorPostfixFunctionsRegistry(jsclEngine.getPostfixFunctionsRegistry(), mathEntityDao);
|
|
||||||
|
|
||||||
return new CalculatorEngineImpl(jsclEngine, varsRegistry, functionsRegistry, operatorsRegistry, postfixFunctionsRegistry, null);
|
|
||||||
}
|
|
||||||
}
|
|
@ -106,6 +106,22 @@ dependencies {
|
|||||||
testCompile group: 'junit', name: 'junit', version: '4.11'
|
testCompile group: 'junit', name: 'junit', version: '4.11'
|
||||||
testCompile group: 'net.sf.opencsv', name: 'opencsv', version: '2.0'
|
testCompile group: 'net.sf.opencsv', name: 'opencsv', version: '2.0'
|
||||||
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0'
|
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0'
|
||||||
|
testCompile "org.robolectric:robolectric:3.0"
|
||||||
|
testCompile 'org.mockito:mockito-all:1.9.5'
|
||||||
|
testCompile 'org.skyscreamer:jsonassert:1.2.3'
|
||||||
|
testCompile (name: 'org.apache.http.legacy', ext: 'jar')
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(Test) {
|
||||||
|
scanForTestClasses = false
|
||||||
|
include "**/*Test.class"
|
||||||
|
exclude "**/*AndroidCalculatorEditorViewTest*"
|
||||||
|
exclude "**/*CalculatorWizardActivityTest*"
|
||||||
|
exclude "**/*OnScreenCalculatorWizardStepTest*"
|
||||||
|
exclude "**/*CalculatorWizardTest*"
|
||||||
|
exclude "**/*WizardStepTest*"
|
||||||
|
exclude "**/*AngleUnitsButtonTest*"
|
||||||
|
exclude "**/*NumeralBasesButtonTest*"
|
||||||
}
|
}
|
||||||
|
|
||||||
task androidJavadocs(type: Javadoc) {
|
task androidJavadocs(type: Javadoc) {
|
||||||
@ -203,4 +219,8 @@ uploadArchives {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
BIN
app/misc/libs/org.apache.http.legacy.jar
Normal file
BIN
app/misc/libs/org.apache.http.legacy.jar
Normal file
Binary file not shown.
@ -24,6 +24,10 @@ package org.solovyev.android;
|
|||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.solovyev.android.calculator.BuildConfig;
|
||||||
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
|
import org.solovyev.android.calculator.units.CalculatorNumeralBase;
|
||||||
import org.solovyev.common.units.Unit;
|
import org.solovyev.common.units.Unit;
|
||||||
import org.solovyev.common.units.UnitConverter;
|
import org.solovyev.common.units.UnitConverter;
|
||||||
@ -40,6 +44,8 @@ import static org.junit.Assert.assertTrue;
|
|||||||
* Date: 4/21/12
|
* Date: 4/21/12
|
||||||
* Time: 8:24 PM
|
* Time: 8:24 PM
|
||||||
*/
|
*/
|
||||||
|
@Config(constants = BuildConfig.class)
|
||||||
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
public class AndroidNumeralBaseTest {
|
public class AndroidNumeralBaseTest {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
@ -1,12 +1,12 @@
|
|||||||
package org.solovyev.android;
|
package org.solovyev.android;
|
||||||
|
|
||||||
import org.junit.runners.model.InitializationError;
|
import org.junit.runners.model.InitializationError;
|
||||||
import org.robolectric.AndroidManifest;
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
import org.robolectric.manifest.AndroidManifest;
|
||||||
import org.robolectric.res.Fs;
|
import org.robolectric.res.Fs;
|
||||||
|
|
||||||
public class CalculatorTestRunner extends RobolectricTestRunner {
|
public class CalculatorTestRunner extends RobolectricGradleTestRunner {
|
||||||
private static final int MAX_SDK_SUPPORTED_BY_ROBOLECTRIC = 18;
|
private static final int MAX_SDK_SUPPORTED_BY_ROBOLECTRIC = 18;
|
||||||
|
|
||||||
public CalculatorTestRunner(Class<?> testClass) throws InitializationError {
|
public CalculatorTestRunner(Class<?> testClass) throws InitializationError {
|
||||||
@ -15,9 +15,10 @@ public class CalculatorTestRunner extends RobolectricTestRunner {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected AndroidManifest getAppManifest(Config config) {
|
protected AndroidManifest getAppManifest(Config config) {
|
||||||
final String manifestFilePath = "android-app/src/main/AndroidManifest.xml";
|
final String manifestFilePath = "app/src/main/AndroidManifest.xml";
|
||||||
final String resourcesFilePath = "android-app/src/main/res";
|
final String resourcesFilePath = "app/src/main/res";
|
||||||
return new AndroidManifest(Fs.fileFromPath(manifestFilePath), Fs.fileFromPath(resourcesFilePath)) {
|
final String assetsFilePath = "app/src/main/assets";
|
||||||
|
return new AndroidManifest(Fs.fileFromPath(manifestFilePath), Fs.fileFromPath(resourcesFilePath), Fs.fileFromPath(assetsFilePath)) {
|
||||||
@Override
|
@Override
|
||||||
public int getTargetSdkVersion() {
|
public int getTargetSdkVersion() {
|
||||||
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
|
return MAX_SDK_SUPPORTED_BY_ROBOLECTRIC;
|
@ -41,6 +41,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
* Date: 10/13/12
|
* Date: 10/13/12
|
||||||
* Time: 1:11 PM
|
* Time: 1:11 PM
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@RunWith(value = CalculatorTestRunner.class)
|
@RunWith(value = CalculatorTestRunner.class)
|
||||||
public class AndroidCalculatorEditorViewTest {
|
public class AndroidCalculatorEditorViewTest {
|
||||||
|
|
@ -11,7 +11,7 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -19,7 +19,7 @@ import javax.annotation.Nonnull;
|
|||||||
import static org.mockito.Matchers.argThat;
|
import static org.mockito.Matchers.argThat;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.robolectric.Robolectric.application;
|
import static org.robolectric.RuntimeEnvironment.application;
|
||||||
import static org.solovyev.android.calculator.CalculatorBroadcaster.ACTION_DISPLAY_STATE_CHANGED;
|
import static org.solovyev.android.calculator.CalculatorBroadcaster.ACTION_DISPLAY_STATE_CHANGED;
|
||||||
import static org.solovyev.android.calculator.CalculatorBroadcaster.ACTION_EDITOR_STATE_CHANGED;
|
import static org.solovyev.android.calculator.CalculatorBroadcaster.ACTION_EDITOR_STATE_CHANGED;
|
||||||
import static org.solovyev.android.calculator.CalculatorEventType.display_state_changed;
|
import static org.solovyev.android.calculator.CalculatorEventType.display_state_changed;
|
||||||
@ -27,7 +27,7 @@ import static org.solovyev.android.calculator.CalculatorEventType.editor_state_c
|
|||||||
import static org.solovyev.android.calculator.CalculatorEventType.editor_state_changed_light;
|
import static org.solovyev.android.calculator.CalculatorEventType.editor_state_changed_light;
|
||||||
|
|
||||||
@Config(manifest = Config.NONE)
|
@Config(manifest = Config.NONE)
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
public class CalculatorBroadcasterTest {
|
public class CalculatorBroadcasterTest {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -35,7 +35,7 @@ public class CalculatorBroadcasterTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
broadcaster = new CalculatorBroadcaster(application, preferences);
|
broadcaster = new CalculatorBroadcaster(application, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -5,20 +5,20 @@ import android.content.Intent;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.robolectric.Robolectric.application;
|
import static org.robolectric.RuntimeEnvironment.application;
|
||||||
import static org.solovyev.android.calculator.CalculatorButton.four;
|
import static org.solovyev.android.calculator.CalculatorButton.four;
|
||||||
import static org.solovyev.android.calculator.CalculatorReceiver.ACTION_BUTTON_ID_EXTRA;
|
import static org.solovyev.android.calculator.CalculatorReceiver.ACTION_BUTTON_ID_EXTRA;
|
||||||
import static org.solovyev.android.calculator.CalculatorReceiver.ACTION_BUTTON_PRESSED;
|
import static org.solovyev.android.calculator.CalculatorReceiver.ACTION_BUTTON_PRESSED;
|
||||||
import static org.solovyev.android.calculator.CalculatorReceiver.newButtonClickedIntent;
|
import static org.solovyev.android.calculator.CalculatorReceiver.newButtonClickedIntent;
|
||||||
|
|
||||||
@Config(manifest = Config.NONE)
|
@Config(manifest = Config.NONE)
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
public class CalculatorReceiverTest {
|
public class CalculatorReceiverTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.solovyev.android.calculator.history.CalculatorHistory;
|
import org.solovyev.android.calculator.history.CalculatorHistory;
|
||||||
@ -63,6 +65,25 @@ public class CalculatorTestUtils {
|
|||||||
Locator.getInstance().getEngine().setDecimalGroupSymbols(decimalGroupSymbols);
|
Locator.getInstance().getEngine().setDecimalGroupSymbols(decimalGroupSymbols);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void staticSetUp(@Nullable Context context) 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(CalculatorPlotter.class), null);
|
||||||
|
Locator.getInstance().getEngine().init();
|
||||||
|
|
||||||
|
if (context != null) {
|
||||||
|
initViews(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void initViews(@Nonnull Context context) {
|
||||||
|
final AndroidCalculatorEditorView editor = new AndroidCalculatorEditorView(context);
|
||||||
|
editor.init();
|
||||||
|
Locator.getInstance().getEditor().setView(editor);
|
||||||
|
|
||||||
|
final AndroidCalculatorDisplayView display = new AndroidCalculatorDisplayView(context);
|
||||||
|
display.init(context);
|
||||||
|
Locator.getInstance().getDisplay().setView(display);
|
||||||
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
static CalculatorEngineImpl newCalculatorEngine() {
|
static CalculatorEngineImpl newCalculatorEngine() {
|
||||||
final MathEntityDao mathEntityDao = Mockito.mock(MathEntityDao.class);
|
final MathEntityDao mathEntityDao = Mockito.mock(MathEntityDao.class);
|
||||||
|
@ -7,9 +7,12 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
|
import org.robolectric.Shadows;
|
||||||
|
import org.robolectric.annotation.Config;
|
||||||
import org.robolectric.res.Attribute;
|
import org.robolectric.res.Attribute;
|
||||||
import org.robolectric.shadows.ShadowActivity;
|
import org.robolectric.shadows.ShadowActivity;
|
||||||
|
import org.solovyev.android.calculator.BuildConfig;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
@ -25,7 +28,8 @@ import static org.mockito.Mockito.times;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.solovyev.android.calculator.CalculatorTestUtils.staticSetUp;
|
import static org.solovyev.android.calculator.CalculatorTestUtils.staticSetUp;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@Config(constants = BuildConfig.class)
|
||||||
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
public class AngleUnitsButtonTest {
|
public class AngleUnitsButtonTest {
|
||||||
|
|
||||||
private AngleUnitsButton button;
|
private AngleUnitsButton button;
|
||||||
@ -35,7 +39,7 @@ public class AngleUnitsButtonTest {
|
|||||||
staticSetUp();
|
staticSetUp();
|
||||||
|
|
||||||
final Activity context = Robolectric.buildActivity(Activity.class).create().get();
|
final Activity context = Robolectric.buildActivity(Activity.class).create().get();
|
||||||
final ShadowActivity activity = Robolectric.shadowOf(context);
|
final ShadowActivity activity = Shadows.shadowOf(context);
|
||||||
button = new AngleUnitsButton(context, activity.createAttributeSet(new ArrayList<Attribute>(), AngleUnitsButton.class));
|
button = new AngleUnitsButton(context, activity.createAttributeSet(new ArrayList<Attribute>(), AngleUnitsButton.class));
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,8 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.Robolectric;
|
||||||
import org.robolectric.RobolectricTestRunner;
|
import org.robolectric.RobolectricGradleTestRunner;
|
||||||
|
import org.robolectric.Shadows;
|
||||||
import org.robolectric.res.Attribute;
|
import org.robolectric.res.Attribute;
|
||||||
import org.robolectric.shadows.ShadowActivity;
|
import org.robolectric.shadows.ShadowActivity;
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ import static org.mockito.Mockito.times;
|
|||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.solovyev.android.calculator.CalculatorTestUtils.staticSetUp;
|
import static org.solovyev.android.calculator.CalculatorTestUtils.staticSetUp;
|
||||||
|
|
||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricGradleTestRunner.class)
|
||||||
public class NumeralBasesButtonTest {
|
public class NumeralBasesButtonTest {
|
||||||
|
|
||||||
private NumeralBasesButton button;
|
private NumeralBasesButton button;
|
||||||
@ -35,7 +36,7 @@ public class NumeralBasesButtonTest {
|
|||||||
staticSetUp();
|
staticSetUp();
|
||||||
|
|
||||||
final Activity context = Robolectric.buildActivity(Activity.class).create().get();
|
final Activity context = Robolectric.buildActivity(Activity.class).create().get();
|
||||||
final ShadowActivity activity = Robolectric.shadowOf(context);
|
final ShadowActivity activity = Shadows.shadowOf(context);
|
||||||
button = new NumeralBasesButton(context, activity.createAttributeSet(new ArrayList<Attribute>(), NumeralBasesButton.class));
|
button = new NumeralBasesButton(context, activity.createAttributeSet(new ArrayList<Attribute>(), NumeralBasesButton.class));
|
||||||
}
|
}
|
||||||
|
|
@ -31,6 +31,8 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
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.RuntimeEnvironment;
|
||||||
|
import org.robolectric.Shadows;
|
||||||
import org.robolectric.shadows.ShadowActivity;
|
import org.robolectric.shadows.ShadowActivity;
|
||||||
import org.robolectric.util.ActivityController;
|
import org.robolectric.util.ActivityController;
|
||||||
import org.solovyev.android.CalculatorTestRunner;
|
import org.solovyev.android.CalculatorTestRunner;
|
||||||
@ -61,7 +63,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
controller = Robolectric.buildActivity(WizardActivity.class);
|
controller = Robolectric.buildActivity(WizardActivity.class);
|
||||||
activity = controller.get();
|
activity = controller.get();
|
||||||
wizards = new CalculatorWizards(Robolectric.application);
|
wizards = new CalculatorWizards(RuntimeEnvironment.application);
|
||||||
activity.setWizards(wizards);
|
activity.setWizards(wizards);
|
||||||
controller.attach();
|
controller.attach();
|
||||||
controller.create();
|
controller.create();
|
||||||
@ -155,7 +157,7 @@ public class CalculatorWizardActivityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testShouldStartWizardActivityAfterStart() throws Exception {
|
public void testShouldStartWizardActivityAfterStart() throws Exception {
|
||||||
final ShadowActivity shadowActivity = Robolectric.shadowOf(controller.get());
|
final ShadowActivity shadowActivity = Shadows.shadowOf(controller.get());
|
||||||
WizardUi.startWizard(activity.getWizards(), CalculatorWizards.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
|
WizardUi.startWizard(activity.getWizards(), CalculatorWizards.DEFAULT_WIZARD_FLOW, shadowActivity.getApplicationContext());
|
||||||
assertNotNull(shadowActivity.getNextStartedActivity());
|
assertNotNull(shadowActivity.getNextStartedActivity());
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ package org.solovyev.android.calculator.wizard;
|
|||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.Robolectric;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.solovyev.android.CalculatorTestRunner;
|
import org.solovyev.android.CalculatorTestRunner;
|
||||||
import org.solovyev.android.wizard.Wizard;
|
import org.solovyev.android.wizard.Wizard;
|
||||||
import org.solovyev.android.wizard.WizardFlow;
|
import org.solovyev.android.wizard.WizardFlow;
|
||||||
@ -35,7 +35,7 @@ public class CalculatorWizardTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
wizards = new CalculatorWizards(Robolectric.application);
|
wizards = new CalculatorWizards(RuntimeEnvironment.application);
|
||||||
wizard = wizards.getWizard(null);
|
wizard = wizards.getWizard(null);
|
||||||
defaultWizard = wizards.getWizard(CalculatorWizards.DEFAULT_WIZARD_FLOW);
|
defaultWizard = wizards.getWizard(CalculatorWizards.DEFAULT_WIZARD_FLOW);
|
||||||
}
|
}
|
@ -1,2 +1 @@
|
|||||||
include ':app'
|
include ':app'
|
||||||
include ':app-tests'
|
|
||||||
|
Loading…
Reference in New Issue
Block a user