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

com.objogate.wl.swing.driver.JProgressBarDriver Maven / Gradle / Ivy

The newest version!
package com.objogate.wl.swing.driver;

import javax.swing.JProgressBar;
import java.awt.Component;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;
import com.objogate.wl.Prober;
import com.objogate.wl.swing.ComponentSelector;
import com.objogate.wl.swing.gesture.GesturePerformer;

public class JProgressBarDriver extends JComponentDriver {
    public JProgressBarDriver(GesturePerformer gesturePerformer, ComponentSelector jProgressBarComponentSelector, Prober prober) {
        super(gesturePerformer, jProgressBarComponentSelector, prober);
    }

    public JProgressBarDriver(ComponentDriver parentOrOwner, ComponentSelector jProgressBarComponentSelector) {
        super(parentOrOwner, jProgressBarComponentSelector);
    }

    public JProgressBarDriver(ComponentDriver parentOrOwner, Class componentType, Matcher... matchers) {
        super(parentOrOwner, componentType, matchers);
    }

    public void hasMinimum(final Matcher matcher) {
        is(new TypeSafeMatcher() {
            @Override
            public boolean matchesSafely(JProgressBar jProgressBar) {
                return matcher.matches(jProgressBar.getMinimum());
            }

            public void describeTo(Description description) {
                description.appendText("minimumvalue matches");
                description.appendDescriptionOf(matcher);
            }
        });
    }

    public void hasMaximum(final Matcher matcher) {
        is(new TypeSafeMatcher() {
            @Override
            public boolean matchesSafely(JProgressBar jProgressBar) {
                return matcher.matches(jProgressBar.getMaximum());
            }

            public void describeTo(Description description) {
                description.appendText("maximumvalue matches");
                description.appendDescriptionOf(matcher);
            }
        });
    }

    public void hasValue(final Matcher matcher) {
        is(new TypeSafeMatcher() {
            @Override
            public boolean matchesSafely(JProgressBar jProgressBar) {
                return matcher.matches(jProgressBar.getValue());
            }

            public void describeTo(Description description) {
                description.appendText("value matches");
                description.appendDescriptionOf(matcher);
            }
        });
    }

    public void hasString(final Matcher matcher) {
        is(new TypeSafeMatcher() {
            @Override
            public boolean matchesSafely(JProgressBar jProgressBar) {
                return matcher.matches(jProgressBar.getString());
            }

            public void describeTo(Description description) {
                description.appendText("string matches");
                description.appendDescriptionOf(matcher);
            }
        });
    }

    public void hasPercentComplete(final Matcher matcher) {
        is(new TypeSafeMatcher() {
            @Override
            public boolean matchesSafely(JProgressBar jProgressBar) {
                return matcher.matches(jProgressBar.getPercentComplete());
            }

            public void describeTo(Description description) {
                description.appendText("percentage matches");
                description.appendDescriptionOf(matcher);
            }
        });
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy