/*
 * Copyright 2010-2011, Sikuli.org
 * Released under the MIT License.
 *
 */
package org.sikuli.script;

import org.junit.* ;
import static org.junit.Assert.* ;
import static org.mockito.Mockito.*;
import org.mockito.stubbing.Answer;
import org.mockito.invocation.InvocationOnMock;


import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.Rectangle;
import java.io.File;

public class RegionFastTest 
{
   static protected int DESKTOP_X = 0, DESKTOP_Y = 0, DESKTOP_W = 1680, DESKTOP_H = 1050;
   static protected Rectangle DESKTOP_RECT = new Rectangle(DESKTOP_X, DESKTOP_Y, DESKTOP_W, DESKTOP_H);

   static protected Screen _mockScr;

   @BeforeClass static public void setupMockScreen() throws Exception{
      BufferedImage desktop_img = ImageIO.read(new File("test-res/mac-desktop.png"));
      ScreenImage desktop_simg = new ScreenImage(DESKTOP_RECT, desktop_img);

      _mockScr = spy(new Screen());
      doReturn(_mockScr).when(_mockScr).getScreen();
      doReturn(desktop_simg).when(_mockScr).capture(anyInt(), anyInt(), anyInt(), anyInt());
   }

   @Test
   public void test_doFind() throws Exception {
      Match m = _mockScr.doFind("test-res/network.png");
      assertEquals(m.x, 792);
      assertEquals(m.y, 391);
      assertEquals(m.w, 52);
      assertEquals(m.h, 54);
   }
}


@@ -394,16 +394,43 @@
 io.File;
+%0Aimport java.util.Iterator;
 %0A%0Apublic
@@ -648,17 +648,94 @@
 TOP_H);%0A
+   static protected Rectangle NETWORK_ICON = new Rectangle(792, 391, 52, 54);
 %0A
-
    stati
@@ -1325,19 +1325,30 @@
 ls(m.x, 
-792
+NETWORK_ICON.x
 );%0A     
@@ -1370,76 +1370,631 @@
 .y, 
-391);%0A      assertEquals(m.w, 52);%0A      assertEquals(m.h, 54
+NETWORK_ICON.y);%0A      assertEquals(m.w, NETWORK_ICON.width);%0A      assertEquals(m.h, NETWORK_ICON.height);%0A      assertEquals(m.score, 1.0, 0.01);%0A   %7D%0A%0A   @Test%0A   public void test_doFindAll() throws Exception %7B%0A      Iterator%3CMatch%3E matches = _mockScr.doFindAll(%22test-res/network.png%22);%0A      int count = 0;%0A      while(matches.hasNext())%7B%0A         count++;%0A         Match m = matches.next();%0A         assertEquals(m.x, NETWORK_ICON.x);%0A         assertEquals(m.y, NETWORK_ICON.y);%0A         assertEquals(m.w, NETWORK_ICON.width);%0A         assertEquals(m.h, NETWORK_ICON.height);%0A      %7D%0A      assertEquals(count, 1
 );%0A   %7D%0A
 %7D%0A%0A
@@ -1990,11 +1990,13 @@
 );%0A   %7D%0A
+%0A%0A
 %7D%0A%0A

add test_doFindAll