// Path: nox/src/test/java/com/github/pedrovgs/nox/doubles/FakeImageLoader.java
// public class FakeImageLoader implements ImageLoader {
// 
//   private String url;
//   private Integer resourceId;
//   private Integer placeholderId;
//   private Listener listener;
//   private boolean loadOnDemand;
// 
//   public FakeImageLoader() {
// 
//   }
// 
//   public FakeImageLoader(boolean loadOnDemand) {
//     this.loadOnDemand = loadOnDemand;
//   }
// 
//   @Override public ImageLoader load(String url) {
//     this.url = url;
//     return this;
//   }
// 
//   @Override public ImageLoader load(Integer resourceId) {
//     this.resourceId = resourceId;
//     return this;
//   }
// 
//   @Override public ImageLoader withPlaceholder(Integer placeholderId) {
//     this.placeholderId = placeholderId;
//     return this;
//   }
// 
//   @Override public ImageLoader useCircularTransformation(boolean useCircularTransformation) {
//     return this;
//   }
// 
//   @Override public ImageLoader size(int size) {
//     return this;
//   }
// 
//   @Override public void notify(Listener listener) {
//     this.listener = listener;
//     if (loadOnDemand) {
//       return;
//     }
//     Drawable fakeDrawable = placeholderId != null ? new ColorDrawable() : null;
//     listener.onPlaceholderLoaded(fakeDrawable);
// 
//     boolean hasResourceToLoad = url != null || resourceId != null;
//     Bitmap fakeBitmap = hasResourceToLoad ? Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8) : null;
//     listener.onImageLoaded(fakeBitmap);
//   }
// 
//   @Override public void pause() {
// 
//   }
// 
//   @Override public void resume() {
// 
//   }
// 
//   @Override public void cancelPendingRequests() {
// 
//   }
// 
//   public void forceLoad() {
//     loadOnDemand = false;
//     notify(listener);
//   }
// 
//   public void forceError() {
//     listener.onError();
//   }
// }
// 
// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/ImageLoader.java
// public interface ImageLoader {
// 
//   /**
//    * Configures an url to be downloaded.
//    */
//   ImageLoader load(String url);
// 
//   /**
//    * Configures a resource id to be loaded.
//    */
//   ImageLoader load(Integer resourceId);
// 
//   /**
//    * Loads a placeholder using a resource id to be shown while the external resource is being
//    * downloaded.
//    */
//   ImageLoader withPlaceholder(Integer placeholderId);
// 
//   /**
//    * Applies a circular transformation to transform the source bitmap into a circular one.
//    */
//   ImageLoader useCircularTransformation(boolean useCircularTransformation);
// 
//   /**
//    * Changes the external resource size once it downloaded and before to notify the listener.
//    */
//   ImageLoader size(int size);
// 
//   /**
//    * Configures a listener where the ImageLoader will notify once the resource be loaded. This
//    * method has to be called to start the resource download. The listener used can't be null.
//    */
//   void notify(Listener listener);
// 
//   /**
//    * Pauses all the resource downloads associated to this library.
//    */
//   void pause();
// 
//   /**
//    * Resumes all the resource downloads associated to this library.
//    */
//   void resume();
// 
//   /**
//    * Cancels all the pending requests to download a resource.
//    */
//   void cancelPendingRequests();
// 
//   /**
//    * Declares some methods which will be called during the resource download process implemented by
//    * the ImageLoader. Use this interface to be notified when the placeholder and the final resource
//    * be ready to be used.
//    */
//   interface Listener {
// 
//     void onPlaceholderLoaded(Drawable placeholder);
// 
//     void onImageLoaded(Bitmap image);
// 
//     void onError();
// 
//     void onDrawableLoaded(Drawable drawable);
//   }
// }


import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import com.github.pedrovgs.nox.doubles.FakeImageLoader;
import com.github.pedrovgs.nox.imageloader.ImageLoader;
import java.util.LinkedList;
import java.util.List;
import java.util.Observer;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
/*
 * Copyright (C) 2015 Pedro Vicente Gomez Sanchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.pedrovgs.nox;



/**
 * @author Pedro Vicente Gómez Sánchez.
 */
@Config(emulateSdk = 18) @RunWith(RobolectricTestRunner.class) public class NoxItemCatalogTest {

  private static final int ANY_NOX_ITEM_SIZE = 100;
  private static final String ANY_URL = "http://anyimage.com/1";
  private static final String ANY_URL_2 = "http://anyimage.com/2";
  private static final NoxItem ANY_NOX_ITEM = new NoxItem(ANY_URL);
  private static final Drawable ANY_PLACEHOLDER = new ColorDrawable();
  private static final int ANY_PLACEHOLDER_ID = 2;
  private static final int ANY_RESOURCE_ID = 1;
  private static final boolean USE_CIRCULAR_TRANSFORMATION = true;

// Path: nox/src/test/java/com/github/pedrovgs/nox/doubles/FakeImageLoader.java
// public class FakeImageLoader implements ImageLoader {
// 
//   private String url;
//   private Integer resourceId;
//   private Integer placeholderId;
//   private Listener listener;
//   private boolean loadOnDemand;
// 
//   public FakeImageLoader() {
// 
//   }
// 
//   public FakeImageLoader(boolean loadOnDemand) {
//     this.loadOnDemand = loadOnDemand;
//   }
// 
//   @Override public ImageLoader load(String url) {
//     this.url = url;
//     return this;
//   }
// 
//   @Override public ImageLoader load(Integer resourceId) {
//     this.resourceId = resourceId;
//     return this;
//   }
// 
//   @Override public ImageLoader withPlaceholder(Integer placeholderId) {
//     this.placeholderId = placeholderId;
//     return this;
//   }
// 
//   @Override public ImageLoader useCircularTransformation(boolean useCircularTransformation) {
//     return this;
//   }
// 
//   @Override public ImageLoader size(int size) {
//     return this;
//   }
// 
//   @Override public void notify(Listener listener) {
//     this.listener = listener;
//     if (loadOnDemand) {
//       return;
//     }
//     Drawable fakeDrawable = placeholderId != null ? new ColorDrawable() : null;
//     listener.onPlaceholderLoaded(fakeDrawable);
// 
//     boolean hasResourceToLoad = url != null || resourceId != null;
//     Bitmap fakeBitmap = hasResourceToLoad ? Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8) : null;
//     listener.onImageLoaded(fakeBitmap);
//   }
// 
//   @Override public void pause() {
// 
//   }
// 
//   @Override public void resume() {
// 
//   }
// 
//   @Override public void cancelPendingRequests() {
// 
//   }
// 
//   public void forceLoad() {
//     loadOnDemand = false;
//     notify(listener);
//   }
// 
//   public void forceError() {
//     listener.onError();
//   }
// }
// 
// Path: nox/src/main/java/com/github/pedrovgs/nox/imageloader/ImageLoader.java
// public interface ImageLoader {
// 
//   /**
//    * Configures an url to be downloaded.
//    */
//   ImageLoader load(String url);
// 
//   /**
//    * Configures a resource id to be loaded.
//    */
//   ImageLoader load(Integer resourceId);
// 
//   /**
//    * Loads a placeholder using a resource id to be shown while the external resource is being
//    * downloaded.
//    */
//   ImageLoader withPlaceholder(Integer placeholderId);
// 
//   /**
//    * Applies a circular transformation to transform the source bitmap into a circular one.
//    */
//   ImageLoader useCircularTransformation(boolean useCircularTransformation);
// 
//   /**
//    * Changes the external resource size once it downloaded and before to notify the listener.
//    */
//   ImageLoader size(int size);
// 
//   /**
//    * Configures a listener where the ImageLoader will notify once the resource be loaded. This
//    * method has to be called to start the resource download. The listener used can't be null.
//    */
//   void notify(Listener listener);
// 
//   /**
//    * Pauses all the resource downloads associated to this library.
//    */
//   void pause();
// 
//   /**
//    * Resumes all the resource downloads associated to this library.
//    */
//   void resume();
// 
//   /**
//    * Cancels all the pending requests to download a resource.
//    */
//   void cancelPendingRequests();
// 
//   /**
//    * Declares some methods which will be called during the resource download process implemented by
//    * the ImageLoader. Use this interface to be notified when the placeholder and the final resource
//    * be ready to be used.
//    */
//   interface Listener {
// 
//     void onPlaceholderLoaded(Drawable placeholder);
// 
//     void onImageLoaded(Bitmap image);
// 
//     void onError();
// 
//     void onDrawableLoaded(Drawable drawable);
//   }
// }


// Path: nox/src/test/java/com/github/pedrovgs/nox/NoxItemCatalogTest.java
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import com.github.pedrovgs.nox.doubles.FakeImageLoader;
import com.github.pedrovgs.nox.imageloader.ImageLoader;
import java.util.LinkedList;
import java.util.List;
import java.util.Observer;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

/*
 * Copyright (C) 2015 Pedro Vicente Gomez Sanchez.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.github.pedrovgs.nox;



/**
 * @author Pedro Vicente Gómez Sánchez.
 */
@Config(emulateSdk = 18) @RunWith(RobolectricTestRunner.class) public class NoxItemCatalogTest {

  private static final int ANY_NOX_ITEM_SIZE = 100;
  private static final String ANY_URL = "http://anyimage.com/1";
  private static final String ANY_URL_2 = "http://anyimage.com/2";
  private static final NoxItem ANY_NOX_ITEM = new NoxItem(ANY_URL);
  private static final Drawable ANY_PLACEHOLDER = new ColorDrawable();
  private static final int ANY_PLACEHOLDER_ID = 2;
  private static final int ANY_RESOURCE_ID = 1;
  private static final boolean USE_CIRCULAR_TRANSFORMATION = true;

  @Spy private ImageLoader imageLoader = new FakeImageLoader();