FEST

JProgressBar has no Fixture

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: FEST-Swing 1.2a3
  • Fix Version/s: FEST-Swing 1.2a4
  • Component/s: Swing
  • Labels:
    None
  • Number of attachments :
    0

Description

There is no Fixture defined for JProgressBar. This would be nice to have when you want the gui test to wait for a determinate progress bar to complete or a indeterminate progress bar to become determinate.

Activity

Hide
Alex Ruiz added a comment -

Hi Jacob,

I'm working on this issue now and I have a question: can you please share some more details about "you want the gui test to wait for a determinate progress bar to complete or a indeterminate progress bar to become determinate"?

How would you like to fixture to behave in this case?

Thanks,
-Alex

Show
Alex Ruiz added a comment - Hi Jacob, I'm working on this issue now and I have a question: can you please share some more details about "you want the gui test to wait for a determinate progress bar to complete or a indeterminate progress bar to become determinate"? How would you like to fixture to behave in this case? Thanks, -Alex
Hide
Alex Ruiz added a comment -

What do you think about something like:

fixture.waitUntilValueIs(50);
fixture.waitUntilIsComplete();
fixture.waitUntilIsInDeterminateMode();

I'll be adding this methods shortly. Let me know if there is anything else you'd like to see in JProgressBarFixture.

Thanks,
-Alex

Show
Alex Ruiz added a comment - What do you think about something like:
fixture.waitUntilValueIs(50);
fixture.waitUntilIsComplete();
fixture.waitUntilIsInDeterminateMode();
I'll be adding this methods shortly. Let me know if there is anything else you'd like to see in JProgressBarFixture. Thanks, -Alex
Hide
Jacob Qvortrup added a comment -

Hi.

The first and the last methods are usefull (i use something like the last method in my tests).
I dont think you will be able to use the second method for anything, since a JProgressBar is in the same state when it is completed as it is when it is about to start. its value is simply 0.

Show
Jacob Qvortrup added a comment - Hi. The first and the last methods are usefull (i use something like the last method in my tests). I dont think you will be able to use the second method for anything, since a JProgressBar is in the same state when it is completed as it is when it is about to start. its value is simply 0.
Hide
Jacob Qvortrup added a comment - - edited

Here are a snip of the code i use right now to wait until a progressbar is determinate:

Conditions.java
/**
 * This class holds static factory methods for custom conditions.
 * All return types must be of type Condition, and the implementating 
 * class hidden by declaring then non-public.
 * Methods from this class should be statically imported in tests that need them.
 * Method names should be chosen to fit into a fluent interface, and 
 * start with the word <code>until</code>.   
 * @author Stephen Gade Esven, IBM Danmark A/S, esven@dk.ibm.com
 */
public final class Conditions {

	/**
	 * Return a Condition Builder for {@link JProgressBar}
	 * @param progressBar the {@link JProgressBar}
	 * @return a {@link ProgressBarConditionBuilder}
	 */
	public static ProgressBarConditionBuilder until(JProgressBar progressBar) {
		return new ProgressBarConditionBuilder(progressBar);
	}
	
	
	/**
	 * Condition builder for JProgressBar.
	 * Holds methods for creating JProgressBar related conditions.
	 * @author Jacob Qvortrup, IBM Denmark A/S, jfq@dk.ibm.com
	 */
	public static class ProgressBarConditionBuilder {

		/**
		 * This is the progress bar attribute
		 */
		private JProgressBar progressBar;

		/**
		 * Constructs an instance for the progress bar
		 * @param progressBar the JProgressBar
		 */
		public ProgressBarConditionBuilder(JProgressBar progressBar) {
			this.progressBar = progressBar;
		}

		/**
		 * <p>Return a condition that is fulfilled when the progress bar is in
		 * determinate state. A progress bar that is <code>indeterminate</code>
		 * is one that shows the user that an operation of unknown length is
		 * running. The progress bar becomes <code>determinate</code> when the
		 * operation is complete.</p>
		 * 
		 * @return a {@link ProgressBarDeterminateConditionBuilder}
		 */
		public Condition isDeterminate() {
			return new ProgressBarDeterminateConditionBuilder(progressBar);
		}
		
	}

}
ProgressBarDeterminateConditionBuilder.java
/**
 * @author Jacob Qvortrup, IBM Denmark A/S, jfq@dk.ibm.com
 *
 */
public class ProgressBarDeterminateConditionBuilder extends ComponentCondition<JProgressBar> {

	public ProgressBarDeterminateConditionBuilder(JProgressBar progressBar) {
		super(progressBar, "progress bar " + progressBar.getName() + " to be determinate");
	}
	
	@Override
	public boolean test() {
		return execute(new GuiQuery<Boolean>() {
			public Boolean executeInEDT() {
				return !getComponent().isIndeterminate();
			}
		});
	}

}
Show
Jacob Qvortrup added a comment - - edited Here are a snip of the code i use right now to wait until a progressbar is determinate:
Conditions.java
/**
 * This class holds static factory methods for custom conditions.
 * All return types must be of type Condition, and the implementating 
 * class hidden by declaring then non-public.
 * Methods from this class should be statically imported in tests that need them.
 * Method names should be chosen to fit into a fluent interface, and 
 * start with the word <code>until</code>.   
 * @author Stephen Gade Esven, IBM Danmark A/S, esven@dk.ibm.com
 */
public final class Conditions {

	/**
	 * Return a Condition Builder for {@link JProgressBar}
	 * @param progressBar the {@link JProgressBar}
	 * @return a {@link ProgressBarConditionBuilder}
	 */
	public static ProgressBarConditionBuilder until(JProgressBar progressBar) {
		return new ProgressBarConditionBuilder(progressBar);
	}
	
	
	/**
	 * Condition builder for JProgressBar.
	 * Holds methods for creating JProgressBar related conditions.
	 * @author Jacob Qvortrup, IBM Denmark A/S, jfq@dk.ibm.com
	 */
	public static class ProgressBarConditionBuilder {

		/**
		 * This is the progress bar attribute
		 */
		private JProgressBar progressBar;

		/**
		 * Constructs an instance for the progress bar
		 * @param progressBar the JProgressBar
		 */
		public ProgressBarConditionBuilder(JProgressBar progressBar) {
			this.progressBar = progressBar;
		}

		/**
		 * <p>Return a condition that is fulfilled when the progress bar is in
		 * determinate state. A progress bar that is <code>indeterminate</code>
		 * is one that shows the user that an operation of unknown length is
		 * running. The progress bar becomes <code>determinate</code> when the
		 * operation is complete.</p>
		 * 
		 * @return a {@link ProgressBarDeterminateConditionBuilder}
		 */
		public Condition isDeterminate() {
			return new ProgressBarDeterminateConditionBuilder(progressBar);
		}
		
	}

}
ProgressBarDeterminateConditionBuilder.java
/**
 * @author Jacob Qvortrup, IBM Denmark A/S, jfq@dk.ibm.com
 *
 */
public class ProgressBarDeterminateConditionBuilder extends ComponentCondition<JProgressBar> {

	public ProgressBarDeterminateConditionBuilder(JProgressBar progressBar) {
		super(progressBar, "progress bar " + progressBar.getName() + " to be determinate");
	}
	
	@Override
	public boolean test() {
		return execute(new GuiQuery<Boolean>() {
			public Boolean executeInEDT() {
				return !getComponent().isIndeterminate();
			}
		});
	}

}
Hide
Alex Ruiz added a comment -

Thanks Jacob for the feedback.

Show
Alex Ruiz added a comment - Thanks Jacob for the feedback.
Hide
Alex Ruiz added a comment -

Uploaded new snapshot to our Maven repo.

Show
Alex Ruiz added a comment - Uploaded new snapshot to our Maven repo.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: