forked from roughike/BottomBar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
62 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 47 additions & 1 deletion
48
bottom-bar/src/androidTest/java/com/roughike/bottombar/BottomBarTabTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,63 @@ | ||
package com.roughike.bottombar; | ||
|
||
import android.os.Bundle; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.widget.FrameLayout; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* Created by iiro on 22.8.2016. | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class BottomBarTabTest { | ||
private FrameLayout tabContainer; | ||
private BottomBarTab tab; | ||
|
||
@Before | ||
public void setUp() { | ||
tabContainer = new FrameLayout(InstrumentationRegistry.getContext()); | ||
tab = new BottomBarTab(InstrumentationRegistry.getContext()); | ||
|
||
tabContainer.addView(tab); | ||
} | ||
|
||
@Test | ||
public void correctLayoutReturned_ForFixedTab() { | ||
tab.setType(BottomBarTab.Type.FIXED); | ||
assertEquals(R.layout.bb_bottom_bar_item_fixed, tab.getLayoutResource()); | ||
} | ||
|
||
@Test | ||
public void test() { | ||
public void correctLayoutReturned_ForShiftingTab() { | ||
tab.setType(BottomBarTab.Type.SHIFTING); | ||
assertEquals(R.layout.bb_bottom_bar_item_shifting, tab.getLayoutResource()); | ||
} | ||
|
||
@Test | ||
public void correctLayoutReturned_ForTabletTab() { | ||
tab.setType(BottomBarTab.Type.TABLET); | ||
assertEquals(R.layout.bb_bottom_bar_item_fixed_tablet, tab.getLayoutResource()); | ||
} | ||
|
||
@Test | ||
public void testSavedStateWithBadge_StaysIntact() { | ||
tab.setBadgeCount(5); | ||
tab.setIndexInContainer(69); | ||
assertEquals(69, tab.getIndexInTabContainer()); | ||
|
||
Bundle savedState = (Bundle) tab.onSaveInstanceState(); | ||
assertEquals(5, savedState.getInt(BottomBarBadge.STATE_COUNT + 69)); | ||
|
||
tab.setBadgeCount(9); | ||
assertEquals(9, tab.badge.getCount()); | ||
|
||
tab.onRestoreInstanceState(savedState); | ||
assertEquals(5, tab.badge.getCount()); | ||
} | ||
} |