Skip to content

Commit

Permalink
Add tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
littledot committed Apr 11, 2016
1 parent 6a8b532 commit 8c69ddd
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions app/src/test/java/com/permissionnanny/TextDialogStubViewTest.java
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");
}
}

0 comments on commit 8c69ddd

Please sign in to comment.