Android Open Source - filmster Movie List Item Holder Spec






From Project

Back to project page filmster.

License

The source code is released under:

Apache License

If you think the Android project filmster 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.doodeec.filmster.MovieList;
//from www  . j  a  va  2 s .  c  om
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.test.AndroidTestCase;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.doodeec.filmster.R;

/**
 * Created by Dusan Doodeec Bartos on 1.11.2014.
 *
 * @see com.doodeec.filmster.MovieList.MovieListItemHolder
 */
public class MovieListItemHolderSpec extends AndroidTestCase {

    private View view;
    private MovieListItemHolder holder;

    @SuppressWarnings("InflateParams")
    @Override
    protected void setUp() throws Exception {
        super.setUp();

        view = LayoutInflater.from(getContext()).inflate(R.layout.movie_list_item, null);
        holder = new MovieListItemHolder(view);
    }

    public void testSetTitle() throws Exception {
        holder.setTitle("firstMovieTitle");
        assertEquals("firstMovieTitle", ((TextView) view.findViewById(R.id.movie_title)).getText());

        holder.setTitle("secondMovieTitle");
        assertEquals("secondMovieTitle", ((TextView) view.findViewById(R.id.movie_title)).getText());
    }

    public void testSetYear() throws Exception {
        holder.setYear(2014);
        assertEquals("2014", ((TextView) view.findViewById(R.id.movie_year)).getText());

        holder.setYear(1990);
        assertEquals("1990", ((TextView) view.findViewById(R.id.movie_year)).getText());

        holder.setYear(null);
        assertEquals("", ((TextView) view.findViewById(R.id.movie_year)).getText());
    }

    public void testSetRating() throws Exception {
        holder.setRating(80);
        assertEquals("80 %", ((TextView) view.findViewById(R.id.movie_rating)).getText());

        holder.setRating(100);
        assertEquals("100 %", ((TextView) view.findViewById(R.id.movie_rating)).getText());

        holder.setRating(null);
        assertEquals("", ((TextView) view.findViewById(R.id.movie_rating)).getText());
    }

    public void testRatingColor() throws Exception {
        holder.setRating(0);
        assertEquals(getContext().getResources().getColor(R.color.ruby_deep),
                ((TextView) view.findViewById(R.id.movie_rating)).getCurrentTextColor());

        holder.setRating(21);
        assertEquals(getContext().getResources().getColor(R.color.amber_deep),
                ((TextView) view.findViewById(R.id.movie_rating)).getCurrentTextColor());

        holder.setRating(60);
        assertEquals(getContext().getResources().getColor(R.color.azure_deep),
                ((TextView) view.findViewById(R.id.movie_rating)).getCurrentTextColor());

        holder.setRating(80);
        assertEquals(getContext().getResources().getColor(R.color.emerald_deep),
                ((TextView) view.findViewById(R.id.movie_rating)).getCurrentTextColor());

        holder.setRating(100);
        assertEquals(getContext().getResources().getColor(R.color.emerald),
                ((TextView) view.findViewById(R.id.movie_rating)).getCurrentTextColor());
    }

    public void testSetThumbnail() throws Exception {
        Bitmap bitmap = Bitmap.createBitmap(50,100, Bitmap.Config.ARGB_8888);
        Drawable oldDrawable = ((ImageView) view.findViewById(R.id.movie_poster)).getDrawable();


        holder.setThumbnail(bitmap);
        assertNotSame(oldDrawable.getConstantState(),
                ((ImageView) view.findViewById(R.id.movie_poster)).getDrawable().getConstantState());
    }
}




Java Source Code List

com.doodeec.filmster.HelperSpec.java
com.doodeec.filmster.Helper.java
com.doodeec.filmster.ImageCacheSpec.java
com.doodeec.filmster.ImageCache.java
com.doodeec.filmster.MainActivity.java
com.doodeec.filmster.Mock.java
com.doodeec.filmster.ApplicationState.AppStateSpec.java
com.doodeec.filmster.ApplicationState.AppState.java
com.doodeec.filmster.ApplicationState.ConnectionStateChange.java
com.doodeec.filmster.Model.JSONParserSpec.java
com.doodeec.filmster.Model.JSONParser.java
com.doodeec.filmster.Model.MovieDefinitionKeys.java
com.doodeec.filmster.Model.MovieSpec.java
com.doodeec.filmster.Model.Movie.java
com.doodeec.filmster.MovieDetail.MovieDetailFragmentSpec.java
com.doodeec.filmster.MovieDetail.MovieDetailFragment.java
com.doodeec.filmster.MovieList.MovieListActivityInterface.java
com.doodeec.filmster.MovieList.MovieListAdapterSpec.java
com.doodeec.filmster.MovieList.MovieListAdapter.java
com.doodeec.filmster.MovieList.MovieListFragmentSpec.java
com.doodeec.filmster.MovieList.MovieListFragment.java
com.doodeec.filmster.MovieList.MovieListItemHolderSpec.java
com.doodeec.filmster.MovieList.MovieListItemHolder.java
com.doodeec.filmster.Provider.DbHelperSpec.java
com.doodeec.filmster.Provider.DbHelper.java
com.doodeec.filmster.Provider.MovieEntry.java
com.doodeec.filmster.Provider.MovieProviderSpec.java
com.doodeec.filmster.Provider.MovieProvider.java
com.doodeec.filmster.ServerCommunicator.ResourceServiceSpec.java
com.doodeec.filmster.ServerCommunicator.ResourceService.java
com.doodeec.filmster.ServerCommunicator.ResponseListener.BitmapServerResponseListener.java
com.doodeec.filmster.ServerCommunicator.ResponseListener.JSONServerResponseListener.java
com.doodeec.filmster.ServerCommunicator.ResponseListener.ServerResponseListener.java
com.doodeec.filmster.ServerCommunicator.ServerRequest.ErrorResponseSpec.java
com.doodeec.filmster.ServerCommunicator.ServerRequest.ErrorResponse.java
com.doodeec.filmster.ServerCommunicator.ServerRequest.ServerRequestInterface.java
com.doodeec.filmster.ServerCommunicator.ServerRequest.ServerRequestSpec.java
com.doodeec.filmster.ServerCommunicator.ServerRequest.ServerRequest.java