Class ScreenLock

java.lang.Object
org.fest.swing.lock.ScreenLock

@ThreadSafe public final class ScreenLock extends Object
Understands a lock that each GUI test should acquire before being executed, to guarantee sequential execution of GUI tests and to prevent GUI tests from blocking each other.
  • Field Details

    • lock

      private final Lock lock
    • released

      private final Condition released
    • owner

      private Object owner
    • acquired

      private boolean acquired
  • Constructor Details

    • ScreenLock

      ScreenLock()
  • Method Details

    • acquire

      public void acquire(Object newOwner)
      Acquires this lock. If this lock was already acquired by another object, this method will block until the lock is released.
      Parameters:
      newOwner - the new owner of the lock.
    • release

      public void release(Object currentOwner)
      Releases this lock.
      Parameters:
      currentOwner - the current owner of the lock.
      Throws:
      ScreenLockException - if the lock has not been previously acquired.
      ScreenLockException - if the given owner is not the same as the current owner of the lock.
    • acquiredBy

      public boolean acquiredBy(Object possibleOwner)
      Indicates whether this lock was acquired by the given object.
      Parameters:
      possibleOwner - the given object, which could be owning the lock.
      Returns:
      true if the given object is owning the lock; false otherwise.
    • alreadyAcquiredBy

      private boolean alreadyAcquiredBy(Object possibleOwner)
    • acquired

      public boolean acquired()
      Indicates whether this lock is already acquired.
      Returns:
      true if the lock is already acquired; false otherwise.
      Since:
      1.2
      See Also:
    • instance

      public static ScreenLock instance()
      Returns the singleton instance of this class.
      Returns:
      the singleton instance of this class.