Class UploadLocator

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

@Generated("com.vaadin.browserless.locator.processor.LocatorProcessor") public class UploadLocator extends Locator<Upload,UploadLocator> implements Clickable<Upload>, HasThemeFilter<Upload,UploadLocator>
Generated locator for Upload, derived from UploadTester. 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

    • UploadLocator

      public UploadLocator()
    • UploadLocator

      public UploadLocator(Upload component)
  • Method Details

    • getComponent

      public Upload getComponent()
      Description copied from interface: Clickable
      Gets the component being tested.
      Specified by:
      getComponent in interface Clickable<Upload>
      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<Upload>
    • upload

      public void upload(String fileName, String contentType, InputStream contents)
      Send the file data to the Upload component as if it is uploaded in the browser.

      The file is rejected with a FileRejectedEvent, and never reaches the upload handler, if it violates one of the client-side constraints of the component. Javadoc copied from UploadTester.upload(java.lang.String,java.lang.String,java.io.InputStream).

      Parameters:
      fileName - name of the file to upload
      contentType - content type of the file to upload
      contents - file contents as an array of bytes
    • upload

      public void upload(String fileName, String contentType, byte[] contents)
      Send the file data to the Upload component as if it is uploaded in the browser.

      The file is rejected with a FileRejectedEvent, and never reaches the upload handler, if it violates one of the client-side constraints of the component. Javadoc copied from UploadTester.upload(java.lang.String,java.lang.String,byte[]).

      Parameters:
      fileName - name of the file to upload
      contentType - content type of the file to upload
      contents - file contents as an array of bytes
    • upload

      public void upload(File file)
      Send the file data to the Upload component as if it is uploaded in the browser. The content type is detected from file name.

      The file is rejected with a FileRejectedEvent, and never reaches the upload handler, if it violates one of the client-side constraints of the component. Javadoc copied from UploadTester.upload(java.io.File).

      Parameters:
      file - the file to upload
    • uploadAll

      public void uploadAll(File... files)
      Simulates uploading multiple files at once.

      Files violating one of the client-side constraints of the component are rejected with a FileRejectedEvent and never reach the upload handler; the remaining files are uploaded. Javadoc copied from UploadTester.uploadAll(java.io.File[]).

      Parameters:
      files - files to upload
      Throws:
      IllegalStateException - if the component is not usable
    • uploadAll

      public void uploadAll(Collection<File> files)
      Simulates uploading multiple files at once.

      Files violating one of the client-side constraints of the component are rejected with a FileRejectedEvent and never reach the upload handler; the remaining files are uploaded. Javadoc copied from UploadTester.uploadAll(java.util.Collection).

      Parameters:
      files - files to upload
      Throws:
      IllegalStateException - if the component is not usable
    • uploadAborted

      public void uploadAborted(String fileName, String contentType)
      Simulates upload interruption by user on browser.

      As in the browser, the interrupted file is dropped from the file list and a FileRemovedEvent is fired, freeing a slot when Upload.setMaxFiles(int) is in use. Javadoc copied from UploadTester.uploadAborted(java.lang.String,java.lang.String).

      Parameters:
      fileName - name of uploading file
      contentType - content type of the uploading file
    • uploadAborted

      public void uploadAborted(File file)
      Simulates upload interruption by user on browser.

      As in the browser, the interrupted file is dropped from the file list and a FileRemovedEvent is fired, freeing a slot when Upload.setMaxFiles(int) is in use. Javadoc copied from UploadTester.uploadAborted(java.io.File).

      Parameters:
      file - uploading file
    • uploadFailed

      public void uploadFailed(File file)
      Simulates a failure during file upload.

      As in the browser, a file whose upload failed stays in the file list. Javadoc copied from UploadTester.uploadFailed(java.io.File).

      Parameters:
      file - uploading file
    • uploadFailed

      public void uploadFailed(String fileName, String contentType)
      Simulates a failure during file upload.

      As in the browser, a file whose upload failed stays in the file list. Javadoc copied from UploadTester.uploadFailed(java.lang.String,java.lang.String).

      Parameters:
      fileName - name of uploading file
      contentType - content type of the uploading file
    • removeFile

      public void removeFile(String fileName)
      Simulates the user removing a file from the upload file list, as if clicking the remove button on the file entry.

      A FileRemovedEvent is fired and the file stops counting towards Upload.setMaxFiles(int). Javadoc copied from UploadTester.removeFile(java.lang.String).

      Parameters:
      fileName - name of the file to remove, as given when it was uploaded
      Throws:
      IllegalArgumentException - if the file is not in the upload file list
    • removeFile

      public void removeFile(File file)
      Simulates the user removing a file from the upload file list, as if clicking the remove button on the file entry.

      A FileRemovedEvent is fired and the file stops counting towards Upload.setMaxFiles(int). Javadoc copied from UploadTester.removeFile(java.io.File).

      Parameters:
      file - the file to remove
      Throws:
      IllegalArgumentException - if the file is not in the upload file list
    • getLastUploadStatus

      public List<UploadTester.FileStatus> getLastUploadStatus()
      Returns what happened to each file of the upload last simulated on this component, in the order the files were given, so that a test can check the outcome the same way a user reads the upload file list in the browser.

      Files are reported as

      invalid reference
      UploadStatus#UPLOADED
      once the upload handler or receiver has consumed them, and as
      invalid reference
      UploadStatus#REJECTED
      both when the client-side gate refused them and when Flow's server-side accepted type validation did, in which case neither shows up as a thrown exception. Javadoc copied from UploadTester.getLastUploadStatus().
      Returns:
      the outcome of the last simulated upload, one entry per file, or an empty list if no upload has been simulated yet
    • ensureUploaded

      public void ensureUploaded()
      Checks that the upload last simulated on this component delivered every one of its files, and fails otherwise.

      Convenience for the common case where a test only wants to be sure the files went through: an upload the browser or the server refused is silent, so without this check it would be noticed only later, as a missing side effect. Javadoc copied from UploadTester.ensureUploaded().

      Throws:
      IllegalStateException - if no upload has been simulated on the component, or if any file of the last upload was not uploaded
      See Also: