Android Open Source - soas Photos List Activity Espresso Test






From Project

Back to project page soas.

License

The source code is released under:

Apache License

If you think the Android project soas 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.meg7.soas.espresso;
/* w  ww  . jav a2s  .c  om*/
import android.app.Activity;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.MediumTest;

import com.google.android.apps.common.testing.ui.espresso.Espresso;
import com.google.android.apps.common.testing.ui.espresso.action.ViewActions;
import com.google.android.apps.common.testing.ui.espresso.assertion.ViewAssertions;
import com.google.android.apps.common.testing.ui.espresso.contrib.DrawerActions;
import com.google.android.apps.common.testing.ui.espresso.contrib.DrawerMatchers;
import com.google.android.apps.common.testing.ui.espresso.matcher.ViewMatchers;
import com.meg7.soas.R;
import com.meg7.soas.ui.PhotosListActivity;

public class PhotosListActivityEspressoTest extends ActivityInstrumentationTestCase2<PhotosListActivity> {

    private Activity mActivity;

    public PhotosListActivityEspressoTest() {
        super(PhotosListActivity.class);
    }

    public void setUp() throws Exception {
        super.setUp();

        mActivity = getActivity();
    }

    @MediumTest
    public void testLoadingPhotos() throws InterruptedException {
        VolleyIdlingResource volleyResources;
        try {
            volleyResources = new VolleyIdlingResource(mActivity, "VolleyCalls");
            Espresso.registerIdlingResources(volleyResources);
        } catch (SecurityException | NoSuchFieldException e) {
            fail(e.getMessage());
        }

        Espresso.onView(ViewMatchers.withId(android.R.id.list))
                .check(ViewAssertions.matches(ViewMatchers.isDisplayed()));
    }

    @MediumTest
    public void testOnPhotoItemClick() {
        // NOTE :: Re-enable this test.
//        Espresso.onData(LongListMatchers.withItemContent("item: 5"))
//                .perform(ViewActions.click());
    }

    @MediumTest
    public void testOpenAndCloseDrawer() {
        // Drawer should not be open to start.
        Espresso.onView(ViewMatchers.withId(R.id.drawer)).check(ViewAssertions.matches(DrawerMatchers.isClosed()));

        DrawerActions.openDrawer(R.id.drawer);

        // The drawer should now be open.
        Espresso.onView(ViewMatchers.withId(R.id.drawer)).check(ViewAssertions.matches(DrawerMatchers.isOpen()));

        DrawerActions.closeDrawer(R.id.drawer);

        // Drawer should be closed again.
        Espresso.onView(ViewMatchers.withId(R.id.drawer)).check(ViewAssertions.matches(DrawerMatchers.isClosed()));
    }

}




Java Source Code List

com.meg7.soas.ApplicationTest.java
com.meg7.soas.SoasApplication.java
com.meg7.soas.data.Location.java
com.meg7.soas.data.OfflineNote.java
com.meg7.soas.data.Photo.java
com.meg7.soas.data.Photos.java
com.meg7.soas.database.DatabaseHelper.java
com.meg7.soas.database.OfflineNotesDataSource.java
com.meg7.soas.database.provider.OfflineNotesProvider.java
com.meg7.soas.database.provider.ProviderConstants.java
com.meg7.soas.database.provider.ProviderConstants.java
com.meg7.soas.espresso.LongListMatchers.java
com.meg7.soas.espresso.PhotosListActivityEspressoTest.java
com.meg7.soas.espresso.VolleyIdlingResource.java
com.meg7.soas.http.HttpConstants.java
com.meg7.soas.http.HttpHeaderParser.java
com.meg7.soas.http.request.GsonGetRequest.java
com.meg7.soas.http.util.UrlBuilder.java
com.meg7.soas.ui.BaseActivity.java
com.meg7.soas.ui.PhotoDetailActivity.java
com.meg7.soas.ui.PhotosListActivity.java
com.meg7.soas.ui.adapter.BaseEndlessAdapter.java
com.meg7.soas.ui.adapter.BaseEndlessScrollListener.java
com.meg7.soas.ui.adapter.PhotosAdapter.java
com.meg7.soas.ui.fragment.PhotoDetailFragment.java
com.meg7.soas.ui.fragment.PhotosListFragment.java
com.meg7.soas.ui.fragment.SwipeRefreshListFragment.java
com.meg7.soas.ui.fragment.retained.PhotosListTaskFragment.java
com.meg7.soas.ui.view.PhotoView.java
com.meg7.soas.ui.widget.BaseFadeInNetworkImageView.java
com.meg7.soas.ui.widget.RectangleFadeInNetworkImageView.java
com.meg7.soas.ui.widget.RoundedFadeInNetworkImageView.java
com.meg7.soas.unit.PhotosListActivityUnitTest.java
com.meg7.soas.util.BitmapLruCache.java
com.meg7.soas.util.SdkUtils.java
com.meg7.widget.RecyclingBitmapDrawable.java
com.meg7.widget.RecyclingImageView.java