All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.thoughtworks.gauge.screenshot.CustomScreenshotScanner Maven / Gradle / Ivy

There is a newer version: 0.11.1
Show newest version
/*----------------------------------------------------------------
 *  Copyright (c) ThoughtWorks, Inc.
 *  Licensed under the Apache License, Version 2.0
 *  See LICENSE.txt in the project root for license information.
 *----------------------------------------------------------------*/
package com.thoughtworks.gauge.screenshot;

import com.thoughtworks.gauge.Logger;
import com.thoughtworks.gauge.scan.IScanner;
import org.reflections.Reflections;

import java.util.Set;

/**
 * Scans for a custom screenshot grabber.
 */
public class CustomScreenshotScanner implements IScanner {
    public void scan(Reflections reflections) {
        Set> customScreenshotGrabbers = reflections.getSubTypesOf(ICustomScreenshotGrabber.class);

        if (customScreenshotGrabbers.size() > 0) {
            Class customScreenGrabber = customScreenshotGrabbers.iterator().next();
            Logger.debug(String.format("Using %s as custom screenshot grabber", customScreenGrabber.getName()));
            ScreenshotFactory.setCustomScreenshotGrabber(customScreenGrabber);
        }

        Set> customScreenshotWriters = reflections.getSubTypesOf(CustomScreenshotWriter.class);

        if (customScreenshotWriters.size() > 0) {
            Class customScreenWriter = customScreenshotWriters.iterator().next();
            Logger.debug(String.format("Using %s as custom screenshot grabber", customScreenWriter.getName()));
            ScreenshotFactory.setCustomScreenshotGrabber(customScreenWriter);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy