-
Notifications
You must be signed in to change notification settings - Fork 9
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
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
app/src/test/java/com/permissionnanny/TextDialogStubViewTest.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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.permissionnanny; | ||
|
||
import android.view.View; | ||
import android.view.ViewStub; | ||
import android.widget.TextView; | ||
import com.permissionnanny.common.test.NannyTestCase; | ||
import org.junit.Before; | ||
import org.junit.ClassRule; | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.RuleChain; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
|
||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
/** | ||
* | ||
*/ | ||
@RunWith(NannyAppTestRunner.class) | ||
public class TextDialogStubViewTest extends NannyTestCase { | ||
|
||
@ClassRule public static final RuleChain CLASS_RULES = NannyAppTestRunner.newClassRules(); | ||
@Rule public final RuleChain TEST_RULES = NannyAppTestRunner.newTestRules(this); | ||
|
||
TextDialogStubView mTextDialogStubView; | ||
@Mock ConfirmRequestBinder mConfirmRequestBinder; | ||
@Mock ViewStub mViewStub; | ||
@Mock View vRoot; | ||
@Mock TextView tvReason; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
mTextDialogStubView = new TextDialogStubView(mConfirmRequestBinder); | ||
when(mViewStub.inflate()).thenReturn(vRoot); | ||
when(vRoot.findViewById(R.id.tvReason)).thenReturn(tvReason); | ||
} | ||
|
||
@Test | ||
public void inflateViewStub() throws Exception { | ||
when(mConfirmRequestBinder.getDialogBody()).thenReturn("dialog body"); | ||
mTextDialogStubView.inflateViewStub(mViewStub); | ||
mTextDialogStubView.bindViews(); | ||
|
||
verify(mViewStub).setLayoutResource(R.layout.dialog_text); | ||
verify(tvReason).setText("dialog body"); | ||
} | ||
} |