PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/src/test/java/com/wet/wired/jrc/frame/capture/ScreenGrabberTest.java

http://java-remote-control.googlecode.com/
Java | 44 lines | 33 code | 11 blank | 0 comment | 7 complexity | 0d0fa2ca6ac8e3acdf46b66677b26b15 MD5 | raw file
 1package com.wet.wired.jrc.frame.capture;
 2
 3import java.awt.Dimension;
 4
 5import junit.framework.TestCase;
 6
 7import com.wet.wired.jrc.frame.Frame;
 8
 9public class ScreenGrabberTest extends TestCase {
10
11	public void testScreenSizeReturned() throws FrameCaptureException {
12		Dimension screenSize = new ScreenGrabber().getFrameSize();
13		
14		assertNotNull(screenSize);
15		if(screenSize.width==0 || screenSize.height==0) {
16			fail( "Screen size must not be 0 width or height" );
17		}
18	}
19	
20	public void testFrameReturned() throws FrameCaptureException {
21		Frame frame = new ScreenGrabber().grabFrame();
22		
23		assertNotNull(frame);
24		
25		if(frame.getDataSize()==0) {
26			fail("Frame data size must not be 0");
27		}
28		Dimension frameSize = frame.getFrameSize();
29		if(frameSize.width==0 || frameSize.height==0) {
30			fail( "Frame size must not be 0 width or height" );
31		}
32	}
33	
34	public void testFrameSizeMatchesScreenSize() throws FrameCaptureException {
35		ScreenGrabber screenGrabber = new ScreenGrabber();
36		Frame frame = screenGrabber.grabFrame();
37		Dimension screenSize = screenGrabber.getFrameSize();
38		Dimension frameSize = frame.getFrameSize();
39		
40		if(frameSize.width!=screenSize.width || frameSize.height!=screenSize.height) {
41			fail( "Frame size must match Screen size" );
42		}
43	}
44}