Skip to content

Commit

Permalink
Moved the tests to the library module.
Browse files Browse the repository at this point in the history
  • Loading branch information
roughike committed Aug 21, 2016
1 parent 2e35fb9 commit 967dc1e
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 88 deletions.
8 changes: 4 additions & 4 deletions .idea/runConfigurations/All_Tests.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* Now we're animating the color change on tab titles and icons.
* Fixed a bug where the BottomBar wouldn't hide completely when it was both shy and drawing under navbar.
* Made setItems to be public to allow writing tests without a designated Activity & support inflating the BottomBar programmatically.

### 2.0.1

Expand Down
2 changes: 0 additions & 2 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/instant-run-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
Expand All @@ -107,7 +106,6 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
Expand Down
2 changes: 0 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
Expand Down
8 changes: 0 additions & 8 deletions app/src/androidTest/res/xml/dummy_tab_xml.xml

This file was deleted.

29 changes: 16 additions & 13 deletions bottom-bar/bottom-bar.iml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
Expand All @@ -81,7 +73,14 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/docs" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
Expand All @@ -99,22 +98,26 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/poms" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" exported="" scope="TEST" name="dexmaker-1.2" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="runner-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="exposed-instrumentation-api-publish-0.5" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="rules-0.5" level="project" />
<orderEntry type="library" exported="" name="design-23.3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="dexmaker-mockito-1.2" level="project" />
<orderEntry type="library" exported="" name="recyclerview-v7-23.3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="hamcrest-core-1.3" level="project" />
<orderEntry type="library" exported="" name="support-v4-23.3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="junit-4.12" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="mockito-core-1.10.19" level="project" />
<orderEntry type="library" exported="" name="support-annotations-23.3.0" level="project" />
<orderEntry type="library" exported="" name="support-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="animated-vector-drawable-23.3.0" level="project" />
<orderEntry type="library" exported="" name="design-23.3.0" level="project" />
<orderEntry type="library" exported="" scope="TEST" name="objenesis-2.1" level="project" />
<orderEntry type="library" exported="" name="appcompat-v7-23.3.0" level="project" />
</component>
</module>
9 changes: 9 additions & 0 deletions bottom-bar/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
}

Expand All @@ -42,6 +44,13 @@ dependencies {
compile 'com.android.support:design:' + rootProject.ext.supportLibraryVersion

testCompile 'junit:junit:' + rootProject.ext.junitVersion

androidTestCompile 'junit:junit:4.12'
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile 'org.mockito:mockito-core:1.+'
androidTestCompile "com.google.dexmaker:dexmaker:1.2"
androidTestCompile "com.google.dexmaker:dexmaker-mockito:1.2"
}

apply plugin: 'com.github.dcendents.android-maven'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
package com.roughike.bottombar;

import android.os.Bundle;
import android.support.test.InstrumentationRegistry;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import com.example.bottombar.sample.BadgeActivity;
import com.example.bottombar.sample.R;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand All @@ -24,33 +20,36 @@
*/
@RunWith(AndroidJUnit4.class)
@LargeTest
public class BadgeActivityTest {
@Rule
public ActivityTestRule<BadgeActivity> badgeActivityRule =
new ActivityTestRule<>(BadgeActivity.class);

public class BadgeTest {
private BottomBar bottomBar;
private BottomBarTab nearby;

@Before
public void setUp() {
bottomBar = (BottomBar) badgeActivityRule.getActivity().findViewById(R.id.bottomBar);
nearby = bottomBar.getTabWithId(R.id.tab_nearby);
bottomBar = new BottomBar(InstrumentationRegistry.getContext());
bottomBar.setItems(com.roughike.bottombar.test.R.xml.dummy_tabs_three);
nearby = bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_nearby);
nearby.setBadgeCount(5);
}

@Test
public void hasNoBadges_ExceptNearby() {
assertNull(bottomBar.getTabWithId(R.id.tab_favorites).badge);
assertNull(bottomBar.getTabWithId(R.id.tab_friends).badge);
assertNull(bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_favorites).badge);
assertNull(bottomBar.getTabWithId(com.roughike.bottombar.test.R.id.tab_friends).badge);

assertNotNull(nearby.badge);
}

@Test
@UiThreadTest
public void whenTabWithBadgeClicked_BadgeIsHidden() {
bottomBar.selectTabWithId(R.id.tab_nearby);
assertFalse(nearby.badge.isVisible());
InstrumentationRegistry.getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
bottomBar.selectTabWithId(com.roughike.bottombar.test.R.id.tab_nearby);
assertFalse(nearby.badge.isVisible());
}
});
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class TabParserTest {
@Before
public void setUp() throws Exception {
context = InstrumentationRegistry.getContext();
tabs = new TabParser(context, new TabParser.Config.Builder().build(), com.example.bottombar.sample.test.R.xml.dummy_tab_xml)
tabs = new TabParser(context, new TabParser.Config.Builder().build(), com.roughike.bottombar.test.R.xml.dummy_tabs_five)
.getTabs();
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public void correctActiveColors() {
assertEquals(Color.parseColor("#FF0000"), tabs.get(0).getActiveColor());

assertEquals(
ContextCompat.getColor(context, com.example.bottombar.sample.test.R.color.test_random_color),
ContextCompat.getColor(context, com.roughike.bottombar.test.R.color.test_random_color),
tabs.get(1).getActiveColor()
);

Expand All @@ -88,7 +88,7 @@ public void iconResourcesExist() {

@Test
public void iconResourceIdsAsExpected() {
int expectedId = com.example.bottombar.sample.test.R.drawable.empty_icon;
int expectedId = com.roughike.bottombar.test.R.drawable.empty_icon;

assertEquals(expectedId, tabs.get(0).getIconResId());
assertEquals(expectedId, tabs.get(1).getIconResId());
Expand Down
Loading

0 comments on commit 967dc1e

Please sign in to comment.