Skip to content

Testing nav drawer #661

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ dependencies {

testCompile 'junit:junit:4.12'
androidTestCompile "com.android.support:support-annotations:${project.supportLibVersion}"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
// androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'

Copy link
Collaborator

@whym whym May 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would you comment it out? It can probably be removed (if it is a dependency to espresso-contrib).

androidTestCompile ('com.android.support.test.espresso:espresso-contrib:2.2.2'){
exclude module: 'support-annotations'
exclude module: 'support-v4'
exclude module: 'support-v13'
exclude module: 'recyclerview-v7'
exclude module: 'design'
}

debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package fr.free.nrw.commons;


import android.support.test.filters.LargeTest;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;
import android.view.Gravity;

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

import fr.free.nrw.commons.contributions.ContributionsActivity;

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.contrib.DrawerActions.open;
import static android.support.test.espresso.contrib.DrawerActions.close;
import static android.support.test.espresso.contrib.DrawerMatchers.isClosed;
import static android.support.test.espresso.matcher.ViewMatchers.isDisplayed;
import static android.support.test.espresso.matcher.ViewMatchers.withId;

@RunWith(AndroidJUnit4.class)
@LargeTest
public class NavigationDrawerTest {

@Rule
public ActivityTestRule<ContributionsActivity> mActivityRule = new ActivityTestRule<>(
ContributionsActivity.class);


@Test
public void testNavigationDrawer(){
onView(withId(R.id.drawer_layout))
.check(matches(isClosed(Gravity.LEFT)))
.perform(open());

//test the settings fragment is displayed
onView(withId(R.id.settings_item)).perform(click());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes "Error:(40, 27) error: cannot find symbol variable settings_item", if you rebase master. After some recent changes around the drawer, this patch seems to need some revision.

onView(withId(R.id.settingsFragment)).check(matches(isDisplayed()));

onView(withId(R.id.drawer_layout))
.perform(close());

//test the nearby item fragment is displayed
onView(withId(R.id.drawer_layout))
.perform(open());
onView(withId(R.id.nearby_item)).perform(click());
onView(withId(R.id.listView)).check(matches(isDisplayed()));

onView(withId(R.id.drawer_layout))
.perform(close());


}

}