Android Open Source - droidcon-android-espresso Visitor Activity Test






From Project

Back to project page droidcon-android-espresso.

License

The source code is released under:

Apache License

If you think the Android project droidcon-android-espresso listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.xrigau.droidcon.espresso.presentation;
//from w  w  w.  ja  v  a2  s . com
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;

import com.xrigau.droidcon.espresso.R;

import static com.google.android.apps.common.testing.ui.espresso.Espresso.onView;
import static com.google.android.apps.common.testing.ui.espresso.Espresso.openActionBarOverflowOrOptionsMenu;
import static com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions.matches;
import static com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers.*;
import static com.xrigau.droidcon.espresso.helper.EspressoTestsMatchers.overflowMenu;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.containsString;

public class VisitorActivityTest extends ActivityInstrumentationTestCase2<VisitorActivity> {

    private static final int EXPECTED_VISITOR_ID = 123;

    public VisitorActivityTest() {
        super(VisitorActivity.class);
    }

    @Override
    protected void setUp() throws Exception {
        super.setUp();
        setActivityIntent(new Intent().putExtra(VisitorActivity.VISITOR_ID, EXPECTED_VISITOR_ID));
        getActivity();
    }

    public void testShowsCorrectVisitorId() {
        onView(withId(R.id.visitor_text)).check(matches(allOf(isDisplayed(), withText(containsString(Integer.toString(EXPECTED_VISITOR_ID))))));
    }

    public void testActionBarMenuIsCorrect() {
        onView(overflowMenu()).check(matches(isDisplayed()));
        onView(withId(R.id.toast)).check(matches(isDisplayed()));
//        onView(withId(R.id.toast)).perform(click());
//        onView(withText(R.string.toasted_message)).check(matches(isDisplayed())); // FAIL: Toast is showing in a different window?
    }

    public void testExitMenuIsInOverflow() {
        openActionBarOverflowOrOptionsMenu(getActivity());
        onView(withText(R.string.menu_exit)).check(matches(isDisplayed()));
    }
}




Java Source Code List

com.xrigau.droidcon.core.debug.MockClient.java
com.xrigau.droidcon.core.model.PostList.java
com.xrigau.droidcon.core.model.PostShould.java
com.xrigau.droidcon.core.model.Post.java
com.xrigau.droidcon.core.service.Services.java
com.xrigau.droidcon.core.task.NewsTask.java
com.xrigau.droidcon.core.task.TaskExecutorShould.java
com.xrigau.droidcon.core.task.TaskExecutor.java
com.xrigau.droidcon.core.task.Task.java
com.xrigau.droidcon.espresso.AndroidUnitTest.java
com.xrigau.droidcon.espresso.helper.DrawableMatcher.java
com.xrigau.droidcon.espresso.helper.EspressoTestsMatchers.java
com.xrigau.droidcon.espresso.loader.LoaderListener.java
com.xrigau.droidcon.espresso.loader.PostsTaskLoaderCallbacks.java
com.xrigau.droidcon.espresso.loader.PostsTaskLoader.java
com.xrigau.droidcon.espresso.presentation.IdlingResourceActivityTest.java
com.xrigau.droidcon.espresso.presentation.IdlingResourceActivity.java
com.xrigau.droidcon.espresso.presentation.MainActivityTest.java
com.xrigau.droidcon.espresso.presentation.MainActivity.java
com.xrigau.droidcon.espresso.presentation.PostListActivityTest.java
com.xrigau.droidcon.espresso.presentation.PostListActivity.java
com.xrigau.droidcon.espresso.presentation.VisitorActivityTest.java
com.xrigau.droidcon.espresso.presentation.VisitorActivity.java
com.xrigau.droidcon.espresso.presentation.WorldDestructionCountdown.java
com.xrigau.droidcon.espresso.presentation.adapter.EmptyAdapter.java
com.xrigau.droidcon.espresso.presentation.adapter.PostsAdapter.java
com.xrigau.droidcon.espresso.util.DeveloperError.java