-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Jeremy Silver
committed
Nov 7, 2016
1 parent
bd16bb0
commit 7ae90e9
Showing
4 changed files
with
46 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
/.idea | ||
.DS_Store | ||
/build |
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
52 changes: 21 additions & 31 deletions
52
...g/solution/app/src/androidTest/java/com/example/android/clickcounter/ButtonClickTest.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,42 +1,32 @@ | ||
package com.example.android.clickcounter; | ||
|
||
import android.test.ActivityInstrumentationTestCase2; | ||
import android.test.TouchUtils; | ||
import android.test.suitebuilder.annotation.MediumTest; | ||
import android.widget.Button; | ||
import android.widget.TextView; | ||
import android.support.test.filters.LargeTest; | ||
import android.support.test.rule.ActivityTestRule; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
public class ButtonClickTest extends ActivityInstrumentationTestCase2<ClickActivity> { | ||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
private ClickActivity mClickActvity; | ||
private Button mButton; | ||
private TextView mTextView; | ||
import static android.support.test.espresso.Espresso.onView; | ||
import static android.support.test.espresso.action.ViewActions.click; | ||
import static android.support.test.espresso.assertion.ViewAssertions.matches; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withId; | ||
import static android.support.test.espresso.matcher.ViewMatchers.withText; | ||
|
||
public ButtonClickTest() { | ||
super(ClickActivity.class); | ||
} | ||
|
||
@Override | ||
protected void setUp() throws Exception { | ||
super.setUp(); | ||
|
||
setActivityInitialTouchMode(true); | ||
mClickActvity = getActivity(); | ||
mButton = (Button) mClickActvity.findViewById(R.id.click_button); | ||
mTextView = (TextView) mClickActvity.findViewById(R.id.click_count_text_view); | ||
} | ||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class ButtonClickTest { | ||
|
||
@MediumTest | ||
public void testInitialValue() { | ||
int initialNumber = Integer.parseInt(mTextView.getText().toString()); | ||
assertEquals(0, initialNumber); | ||
} | ||
@Rule | ||
public ActivityTestRule<ClickActivity> mActivityRule = new ActivityTestRule<>( | ||
ClickActivity.class); | ||
|
||
@MediumTest | ||
@Test | ||
public void testClick() { | ||
int priorNumber = Integer.parseInt(mTextView.getText().toString()); | ||
TouchUtils.clickView(this, mButton); | ||
int newNumber = Integer.parseInt(mTextView.getText().toString()); | ||
assertEquals(priorNumber + 1, newNumber); | ||
onView(withId(R.id.click_count_text_view)).check(matches(withText("0"))); | ||
onView(withId(R.id.click_button)).perform(click()); | ||
onView(withId(R.id.click_count_text_view)).check(matches(withText("1"))); | ||
} | ||
} |
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