use of java.awt.Rectangle in project screenbird by adamhub.
the class PreviewPlayerTest method generateTestImageFile.
/**
* Generates screenshot for JUnit testing
* @return
* File pointer to screen shot
*/
private File generateTestImageFile(Rectangle captureArea) {
Robot awtRobot;
String currentCaptureDir = Settings.SCREEN_CAPTURE_DIR;
if (captureArea == null) {
//Get full screen if no defined area of screen capture is defined
captureArea = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
}
try {
BufferedImage bufferedImage = generateTestImage(captureArea);
Iterator iter = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = (ImageWriter) iter.next();
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(1.0F);
File imageFile = new File(currentCaptureDir, "test.jpeg");
FileImageOutputStream stream = new FileImageOutputStream(imageFile);
//Set up file access
writer.setOutput(stream);
//Create image
IIOImage image = new IIOImage(bufferedImage, null, null);
//write image
writer.write(null, image, iwp);
//Close image stream
stream.close();
return imageFile;
} catch (IOException e) {
System.err.println(e);
}
return null;
}
use of java.awt.Rectangle in project screenbird by adamhub.
the class PreviewPlayerTest method testSetScreenshot_BufferedImage.
/**
* Test of setScreenshot method, of class PreviewPlayer.
*/
@Test
public void testSetScreenshot_BufferedImage() {
System.out.println("setScreenshot");
BufferedImage screenshot = generateTestImage(null);
instance.setScreenshot(screenshot);
instance.setScreenshot(screenshot);
instance.updateRecordNowButtonPosition();
TimeUtil.skipToMyLou(2);
screenshot = generateTestImage(new Rectangle(0, 0, 600, 400));
instance.setScreenshot(screenshot);
instance.setScreenshot(screenshot);
instance.updateRecordNowButtonPosition();
TimeUtil.skipToMyLou(2);
screenshot = generateTestImage(new Rectangle(100, 100, 600, 400));
instance.setScreenshot(screenshot);
instance.setScreenshot(screenshot);
instance.updateRecordNowButtonPosition();
TimeUtil.skipToMyLou(2);
screenshot = generateTestImage(null);
instance.setScreenshot(screenshot);
instance.setScreenshot(screenshot);
instance.updateRecordNowButtonPosition();
TimeUtil.skipToMyLou(2);
}
use of java.awt.Rectangle in project screenbird by adamhub.
the class VideoCacheTest method generateTestImage.
/**
* Generates screenshot for JUnit testing
* @return
* File pointer to screen shot
*/
private File generateTestImage() {
Robot awtRobot;
String currentCaptureDir = Settings.SCREEN_CAPTURE_DIR;
try {
awtRobot = new Robot();
BufferedImage bufferedImage = awtRobot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
Iterator iter = ImageIO.getImageWritersByFormatName("jpeg");
ImageWriter writer = (ImageWriter) iter.next();
ImageWriteParam iwp = writer.getDefaultWriteParam();
iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
iwp.setCompressionQuality(1.0F);
File imageFile = new File(currentCaptureDir, "test.jpeg");
FileImageOutputStream stream = new FileImageOutputStream(imageFile);
//Set up file access
writer.setOutput(stream);
//Create image
IIOImage image = new IIOImage(bufferedImage, null, null);
//write image
writer.write(null, image, iwp);
//Close image stream
stream.close();
return imageFile;
} catch (AWTException e) {
System.err.println(e);
} catch (IOException e) {
System.err.println(e);
}
return null;
}
use of java.awt.Rectangle in project screenbird by adamhub.
the class RecorderTest method testCompileVideo.
/**
* Test of compileVideo method, of class Recorder.
*/
//@Test
@Test
public void testCompileVideo() throws Exception {
log("compileVideo");
Recorder instance = new Recorder(new TestMeasurable());
instance.cleanAndCreateFiles();
instance.setCaptureRectangle(new Rectangle(200, 100));
instance.recordVideo();
while (instance.getSecondsTime() < 10) {
}
instance.stopVideo();
Boolean expResult = true;
Boolean result = instance.compileVideo();
assertEquals(expResult, result);
}
use of java.awt.Rectangle in project screenbird by adamhub.
the class RecorderTest method testPauseVideo.
/**
* Test of pauseVideo method, of class Recorder.
*/
//@Test
@Test
public void testPauseVideo() {
log("pauseVideo");
Recorder instance = new Recorder(new TestMeasurable());
instance.setCaptureRectangle(new Rectangle(200, 100));
instance.recordVideo();
assertEquals(instance.getStatus(), RecorderStatus.RECORDING);
instance.pauseVideo();
assertEquals(instance.getStatus(), RecorderStatus.PAUSED);
instance.stopVideo();
}
Aggregations