Class UploadDropZoneLocator

java.lang.Object
com.vaadin.browserless.locator.Locator<com.vaadin.flow.component.upload.UploadDropZone,UploadDropZoneLocator>
com.vaadin.flow.component.upload.UploadDropZoneLocator
All Implemented Interfaces:
Clickable<com.vaadin.flow.component.upload.UploadDropZone>

@Generated("com.vaadin.browserless.locator.processor.LocatorProcessor") public class UploadDropZoneLocator extends Locator<com.vaadin.flow.component.upload.UploadDropZone,UploadDropZoneLocator> implements Clickable<com.vaadin.flow.component.upload.UploadDropZone>
Generated locator for UploadDropZone, derived from UploadDropZoneTester. Filter steps are inherited from Locator; action methods delegate to a fresh tester around the resolved component, so behavioral changes belong on the tester, not here.
  • Constructor Details

    • UploadDropZoneLocator

      public UploadDropZoneLocator()
      Creates a locator that searches for a UploadDropZone.
    • UploadDropZoneLocator

      public UploadDropZoneLocator(com.vaadin.flow.component.upload.UploadDropZone component)
      Creates a locator already bound to the given component, so that the action methods run against it instead of against a lookup.
      Parameters:
      component - the component the locator resolves to
  • Method Details

    • getComponent

      public com.vaadin.flow.component.upload.UploadDropZone getComponent()
      Description copied from interface: Clickable
      Gets the component being tested.
      Specified by:
      getComponent in interface Clickable<com.vaadin.flow.component.upload.UploadDropZone>
      Returns:
      the component under test
    • ensureComponentIsUsable

      public void ensureComponentIsUsable()
      Description copied from interface: Clickable
      Ensures the component is in a usable state before interaction.
      Specified by:
      ensureComponentIsUsable in interface Clickable<com.vaadin.flow.component.upload.UploadDropZone>
    • drop

      public void drop(File... files)
      Simulates the user dropping the given files on the drop zone.

      The content types are detected from the file names. Javadoc copied from UploadDropZoneTester.drop(java.io.File[]).

      Parameters:
      files - the files to drop
      Throws:
      UncheckedIOException - if the upload handler fails to handle the file contents
      IllegalArgumentException - if no file is given
      IllegalStateException - if the component is not usable
    • drop

      public void drop(Collection<File> files)
      Simulates the user dropping the given files on the drop zone.

      The content types are detected from the file names. Javadoc copied from UploadDropZoneTester.drop(java.util.Collection).

      Parameters:
      files - the files to drop
      Throws:
      UncheckedIOException - if the upload handler fails to handle the file contents
      IllegalArgumentException - if no file is given
      IllegalStateException - if the component is not usable
    • drop

      public void drop(String fileName, String contentType, byte[] contents)
      Simulates the user dropping a file with the given name, content type and contents on the drop zone. Javadoc copied from UploadDropZoneTester.drop(java.lang.String,java.lang.String,byte[]).
      Parameters:
      fileName - name of the file to drop
      contentType - content type of the file to drop
      contents - file contents as an array of bytes
      Throws:
      UncheckedIOException - if the upload handler fails to handle the file contents
      IllegalStateException - if the component is not usable
    • uploadAborted

      public void uploadAborted(File file)
      Simulates the user dropping the given file on the drop zone and then aborting its upload.

      As in the browser, the aborted file is dropped from the file list and a UploadManager.FileRemovedEvent is fired, freeing a slot when UploadManager.setMaxFiles(int) is in use.

      The file is added and its transfer started in one go, whether or not auto upload is turned off. The content type is detected from the file name, and the file is not read. Javadoc copied from UploadDropZoneTester.uploadAborted(java.io.File).

      Parameters:
      file - the file to drop
      Throws:
      IllegalStateException - if the component is not usable
    • uploadAborted

      public void uploadAborted(String fileName, String contentType)
      Simulates the user dropping a file with the given name and content type on the drop zone and then aborting its upload.

      As in the browser, the aborted file is dropped from the file list and a UploadManager.FileRemovedEvent is fired, freeing a slot when UploadManager.setMaxFiles(int) is in use.

      The file is added and its transfer started in one go, whether or not auto upload is turned off. Javadoc copied from UploadDropZoneTester.uploadAborted(java.lang.String,java.lang.String).

      Parameters:
      fileName - name of the file to drop
      contentType - content type of the file to drop
      Throws:
      IllegalStateException - if the component is not usable
    • uploadFailed

      public void uploadFailed(File file)
      Simulates the user dropping the given file on the drop zone and its upload then failing.

      As in the browser, a file whose upload failed stays in the file list.

      The file is added and its transfer started in one go, whether or not auto upload is turned off. The content type is detected from the file name, and the file is not read. Javadoc copied from UploadDropZoneTester.uploadFailed(java.io.File).

      Parameters:
      file - the file to drop
      Throws:
      IllegalStateException - if the component is not usable
    • uploadFailed

      public void uploadFailed(String fileName, String contentType)
      Simulates the user dropping a file with the given name and content type on the drop zone and its upload then failing.

      As in the browser, a file whose upload failed stays in the file list.

      The file is added and its transfer started in one go, whether or not auto upload is turned off. Javadoc copied from UploadDropZoneTester.uploadFailed(java.lang.String,java.lang.String).

      Parameters:
      fileName - name of the file to drop
      contentType - content type of the file to drop
      Throws:
      IllegalStateException - if the component is not usable
    • getLastUploadStatus

      public List<UploadTester.FileStatus> getLastUploadStatus()
      Returns what happened to each file the user last selected, dropped or started through the UploadManager the drop zone is linked to, in the order the files were given.

      Files are reported as UploadTester.UploadStatus.UPLOADED once the upload handler has consumed them, as UploadTester.UploadStatus.REJECTED when the manager or Flow's server-side accepted type validation refused them, as UploadTester.UploadStatus.FAILED when the handler threw, and as UploadTester.UploadStatus.PENDING while they wait in the file list for auto upload being turned off. The error message of a file the manager refused is the client-side error code: tooManyFiles, fileIsTooBig or incorrectFileType. Javadoc copied from UploadDropZoneTester.getLastUploadStatus().

      Returns:
      the outcome of the last upload, one entry per file, or an empty list if nothing has been uploaded yet or the drop zone is not linked to a manager
    • ensureUploaded

      public void ensureUploaded()
      Checks that the last upload through the UploadManager the drop zone is linked to delivered every one of its files, and fails otherwise. Javadoc copied from UploadDropZoneTester.ensureUploaded().
      Throws:
      IllegalStateException - if no upload has been simulated, or if any file of the last upload was not uploaded
      See Also:
    • ensureUploadFailed

      public void ensureUploadFailed()
      Checks that at least one file of the last upload through the UploadManager the drop zone is linked to failed or was rejected, and fails otherwise.

      Counterpart of UploadDropZoneTester.ensureUploaded() for a test about the failure case, such as an upload handler that throws or a file the manager refuses. Use UploadDropZoneTester.getLastUploadStatus() to check which file failed and why.

      A file left UploadTester.UploadStatus.PENDING does not count as failed: it was neither delivered nor refused, such as a file waiting because auto upload is turned off. Javadoc copied from UploadDropZoneTester.ensureUploadFailed().

      Throws:
      IllegalStateException - if no upload has been simulated, or if no file of the last upload failed or was rejected
      See Also: