Project restructure

We don't need to separate widget/onscreen from the main module, let's merge them together.
This commit is contained in:
serso
2015-01-26 10:41:52 +01:00
parent 90daad7de5
commit 24f18b8aae
389 changed files with 885 additions and 2058 deletions

View File

@@ -71,40 +71,36 @@
<orderEntry type="library" exported="" scope="TEST" name="wagon-http-shared-1.0-beta-6" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="xercesMinimal-1.9.6.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="nekohtml-1.9.6.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_preferences_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="simple-xml-2.6.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_core_build_libs_core_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="commons-cli-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="annotations-2.0.1" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="core" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="internal_impl-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_views_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_lists_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="stax-1.2.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_other_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_menus_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_com_android_support_support_v4_21_0_3_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-msg-1.0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="support-annotations-21.0.3" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_db_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-listeners-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="guava-11.0.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-text-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="acra-4.5.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_wizard_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_checkout_0_6_0_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_core_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_com_google_android_gms_play_services_6_5_87_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-core-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="jscl-1.0.8" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_security_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="common-security-1.0.7" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="classes" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_android_calculatorpp_android_app_build_intermediates_classes_debug" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_android_calculatorpp_android_app_build_intermediates_dependency_cache_debug" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_com_actionbarsherlock_actionbarsherlock_4_4_0_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_exploded_aar_org_solovyev_android_android_common_sherlock_1_1_18_classes_jar" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_classes_debug" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="_home_serso_projects_java_serso_android_calculatorpp_android_app_build_intermediates_dependency_cache_debug" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="android" level="project" />
</component>
</module>

View File

@@ -44,6 +44,8 @@ tasks.withType(Test) {
exclude "**/*OnScreenCalculatorWizardStepTest*"
exclude "**/*CalculatorWizardTest*"
exclude "**/*WizardStepTest*"
exclude "**/*AngleUnitsButtonTest*"
exclude "**/*NumeralBasesButtonTest*"
}
test {

View File

@@ -0,0 +1,68 @@
package org.solovyev.android.calculator;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import javax.annotation.Nonnull;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.robolectric.Robolectric.application;
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.CalculatorEventType.*;
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class CalculatorBroadcasterTest {
@Nonnull
private CalculatorBroadcaster broadcaster;
@Before
public void setUp() throws Exception {
broadcaster = new CalculatorBroadcaster(application);
}
@Test
public void testShouldSendEditorStateChangedIntent() throws Exception {
assertIntentSent(editor_state_changed, ACTION_EDITOR_STATE_CHANGED);
}
@Test
public void testShouldSendEditorStateChangedLiteIntent() throws Exception {
assertIntentSent(editor_state_changed_light, ACTION_EDITOR_STATE_CHANGED);
}
@Test
public void testShouldSendDisplayStateChangedIntent() throws Exception {
assertIntentSent(display_state_changed, ACTION_DISPLAY_STATE_CHANGED);
}
private void assertIntentSent(@Nonnull CalculatorEventType eventType, final String expectedAction) {
final BroadcastReceiver receiver = Mockito.mock(BroadcastReceiver.class);
application.registerReceiver(receiver, new IntentFilter(expectedAction));
broadcaster.onCalculatorEvent(CalculatorEventDataImpl.newInstance(1L, 1L), eventType, null);
verify(receiver, times(1)).onReceive(Mockito.<Context>any(), argThat(new BaseMatcher<Intent>() {
@Override
public boolean matches(Object o) {
return ((Intent) o).getAction().equals(expectedAction);
}
@Override
public void describeTo(Description description) {
}
}));
}
}

View File

@@ -0,0 +1,41 @@
package org.solovyev.android.calculator;
import android.content.Intent;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.mockito.Mockito.*;
import static org.robolectric.Robolectric.application;
import static org.solovyev.android.calculator.CalculatorButton.four;
import static org.solovyev.android.calculator.CalculatorReceiver.*;
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class CalculatorReceiverTest {
@Test
public void testShouldPressButtonOnIntent() throws Exception {
Locator.setKeyboard(mock(CalculatorKeyboard.class));
final Intent intent = newButtonClickedIntent(application, four);
new CalculatorReceiver().onReceive(application, intent);
verify(Locator.getInstance().getKeyboard(), times(1)).buttonPressed(Mockito.anyString());
verify(Locator.getInstance().getKeyboard(), times(1)).buttonPressed("4");
}
@Test
public void testShouldDoNothingIfButtonInvalid() throws Exception {
Locator.setKeyboard(mock(CalculatorKeyboard.class));
final Intent intent = new Intent(application, CalculatorReceiver.class);
intent.setAction(ACTION_BUTTON_PRESSED);
intent.putExtra(ACTION_BUTTON_ID_EXTRA, "test!@");
new CalculatorReceiver().onReceive(application, intent);
verify(Locator.getInstance().getKeyboard(), times(0)).buttonPressed(Mockito.anyString());
}
}

View File

@@ -0,0 +1,66 @@
package org.solovyev.android.calculator.view;
import android.app.Activity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.res.Attribute;
import org.robolectric.shadows.ShadowActivity;
import java.util.ArrayList;
import static jscl.AngleUnit.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.solovyev.android.calculator.CalculatorTestUtils.staticSetUp;
@RunWith(RobolectricTestRunner.class)
public class AngleUnitsButtonTest {
private AngleUnitsButton button;
@Before
public void setUp() throws Exception {
staticSetUp();
final Activity context = Robolectric.buildActivity(Activity.class).create().get();
final ShadowActivity activity = Robolectric.shadowOf(context);
button = new AngleUnitsButton(context, activity.createAttributeSet(new ArrayList<Attribute>(), AngleUnitsButton.class));
}
@Test
public void testShouldReturnDifferentColorsForDifferentAngleUnits() throws Exception {
button.setAngleUnit(deg);
assertEquals(button.getDirectionTextColor(deg.name()), button.getDirectionTextColor(deg.name()));
assertEquals(button.getDirectionTextColor(grad.name()), button.getDirectionTextColor(rad.name()));
assertNotSame(button.getDirectionTextColor(deg.name()), button.getDirectionTextColor(rad.name()));
assertNotSame(button.getDirectionTextColor(deg.name()), button.getDirectionTextColor(grad.name()));
assertNotSame(button.getDirectionTextColor(deg.name()), button.getDirectionTextColor(turns.name()));
}
@Test
public void testIsCurrentAngleUnits() throws Exception {
button.setAngleUnit(rad);
assertTrue(button.isCurrentAngleUnits(rad.name()));
assertFalse(button.isCurrentAngleUnits(deg.name()));
assertFalse(button.isCurrentAngleUnits(grad.name()));
}
@Test
public void testInvalidateShouldBeCalledOnlyWhenChangeIsDone() throws Exception {
button.setAngleUnit(rad);
button = Mockito.spy(button);
button.setAngleUnit(deg);
verify(button, times(1)).invalidate();
button.setAngleUnit(deg);
verify(button, times(1)).invalidate();
}
}

View File

@@ -0,0 +1,66 @@
package org.solovyev.android.calculator.view;
import android.app.Activity;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.res.Attribute;
import org.robolectric.shadows.ShadowActivity;
import java.util.ArrayList;
import static jscl.NumeralBase.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.solovyev.android.calculator.CalculatorTestUtils.staticSetUp;
@RunWith(RobolectricTestRunner.class)
public class NumeralBasesButtonTest {
private NumeralBasesButton button;
@Before
public void setUp() throws Exception {
staticSetUp();
final Activity context = Robolectric.buildActivity(Activity.class).create().get();
final ShadowActivity activity = Robolectric.shadowOf(context);
button = new NumeralBasesButton(context, activity.createAttributeSet(new ArrayList<Attribute>(), NumeralBasesButton.class));
}
@Test
public void testShouldReturnDifferentColorsForDifferentNumeralBase() throws Exception {
button.setNumeralBase(dec);
assertEquals(button.getDirectionTextColor(dec.name()), button.getDirectionTextColor(dec.name()));
assertEquals(button.getDirectionTextColor(hex.name()), button.getDirectionTextColor(bin.name()));
assertNotSame(button.getDirectionTextColor(dec.name()), button.getDirectionTextColor(bin.name()));
assertNotSame(button.getDirectionTextColor(dec.name()), button.getDirectionTextColor(hex.name()));
assertNotSame(button.getDirectionTextColor(dec.name()), button.getDirectionTextColor(oct.name()));
}
@Test
public void testIsCurrentNumeralBase() throws Exception {
button.setNumeralBase(dec);
assertTrue(button.isCurrentNumberBase(dec.name()));
assertFalse(button.isCurrentNumberBase(hex.name()));
assertFalse(button.isCurrentNumberBase(bin.name()));
}
@Test
public void testInvalidateShouldBeCalledOnlyWhenChangeIsDone() throws Exception {
button.setNumeralBase(dec);
button = Mockito.spy(button);
button.setNumeralBase(hex);
verify(button, times(1)).invalidate();
button.setNumeralBase(hex);
verify(button, times(1)).invalidate();
}
}