Class UploadLocator
- All Implemented Interfaces:
Clickable<Upload>,HasThemeFilter<Upload,UploadLocator>
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidEnsures the component is in a usable state before interaction.voidChecks that the upload last simulated on this component delivered every one of its files, and fails otherwise.voidChecks that at least one file of the upload last simulated on this component failed or was rejected, and fails otherwise.Gets the component being tested.getFiles()Gets the files the upload file list shows, in the order the browser shows them: the most recently added file first.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.voidremoveFile(int index) Simulates the user removing the file at the given position of the upload file list, as if clicking the remove button on that entry.voidremoveFile(File file) Simulates the user removing a file from the upload file list, as if clicking the remove button on the file entry.voidremoveFile(String fileName) Simulates the user removing a file from the upload file list, as if clicking the remove button on the file entry.voidstartUpload(int index) Simulates the user clicking the start button of the file at the given position of the upload file list, which waits becauseauto uploadis turned off, uploading it.voidstartUpload(File file) Simulates the user clicking the start button of a file that waits in the upload file list becauseauto uploadis turned off, uploading it.voidstartUpload(String fileName) Simulates the user clicking the start button of a file that waits in the upload file list becauseauto uploadis turned off, uploading it.voidSend the file data to the Upload component as if it is uploaded in the browser.voidSend the file data to the Upload component as if it is uploaded in the browser.voidupload(String fileName, String contentType, InputStream contents) Send the file data to the Upload component as if it is uploaded in the browser.voiduploadAborted(File file) Simulates upload interruption by user on browser.voiduploadAborted(String fileName, String contentType) Simulates upload interruption by user on browser.voidSimulates uploading multiple files at once.voiduploadAll(Collection<File> files) Simulates uploading multiple files at once.voiduploadFailed(File file) Simulates a failure during file upload.voiduploadFailed(String fileName, String contentType) Simulates a failure during file upload.Methods inherited from class com.vaadin.browserless.locator.Locator
atIndex, component, components, exists, inside, inside, invalidate, self, with, withAttribute, withAttribute, withClassName, withCondition, withCondition, withId, withinSlot, withoutAttribute, withoutAttribute, withoutClassName, withTestIdMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.browserless.Clickable
click, click, click, middleClick, middleClick, rightClick, rightClickMethods inherited from interface com.vaadin.browserless.locator.HasThemeFilter
withoutTheme, withoutTheme, withTheme, withTheme
-
Constructor Details
-
UploadLocator
public UploadLocator() -
UploadLocator
-
-
Method Details
-
getComponent
Description copied from interface:ClickableGets the component being tested.- Specified by:
getComponentin interfaceClickable<Upload>- Returns:
- the component under test
-
ensureComponentIsUsable
public void ensureComponentIsUsable()Description copied from interface:ClickableEnsures the component is in a usable state before interaction.- Specified by:
ensureComponentIsUsablein interfaceClickable<Upload>
-
upload
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. Withauto uploadturned off, an accepted file waits in the file list untilstartUpload(String)is called. Javadoc copied fromUploadTester.upload(java.lang.String,java.lang.String,java.io.InputStream).- Parameters:
fileName- name of the file to uploadcontentType- content type of the file to uploadcontents- file contents as an array of bytes
-
upload
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. Withauto uploadturned off, an accepted file waits in the file list untilstartUpload(String)is called. Javadoc copied fromUploadTester.upload(java.lang.String,java.lang.String,byte[]).- Parameters:
fileName- name of the file to uploadcontentType- content type of the file to uploadcontents- file contents as an array of bytes
-
upload
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. Withauto uploadturned off, an accepted file waits in the file list untilstartUpload(String)is called. Javadoc copied fromUploadTester.upload(java.io.File).- Parameters:
file- the file to upload
-
uploadAll
Simulates uploading multiple files at once.Files violating one of the client-side constraints of the component are rejected with a
FileRejectedEventand never reach the upload handler; the remaining files are uploaded, or wait in the file list whenauto uploadis turned off. Javadoc copied fromUploadTester.uploadAll(java.io.File[]).- Parameters:
files- files to upload- Throws:
IllegalStateException- if the component is not usable
-
uploadAll
Simulates uploading multiple files at once.Files violating one of the client-side constraints of the component are rejected with a
FileRejectedEventand never reach the upload handler; the remaining files are uploaded, or wait in the file list whenauto uploadis turned off. Javadoc copied fromUploadTester.uploadAll(java.util.Collection).- Parameters:
files- files to upload- Throws:
IllegalStateException- if the component is not usable
-
uploadAborted
Simulates upload interruption by user on browser.As in the browser, the interrupted file is dropped from the file list and a
FileRemovedEventis fired, freeing a slot whenUpload.setMaxFiles(int)is in use.The file is added and its transfer started in one go, whether or not
auto uploadis turned off. Javadoc copied fromUploadTester.uploadAborted(java.lang.String,java.lang.String).- Parameters:
fileName- name of uploading filecontentType- content type of the uploading file
-
uploadAborted
Simulates upload interruption by user on browser.As in the browser, the interrupted file is dropped from the file list and a
FileRemovedEventis fired, freeing a slot whenUpload.setMaxFiles(int)is in use.The file is added and its transfer started in one go, whether or not
auto uploadis turned off. Javadoc copied fromUploadTester.uploadAborted(java.io.File).- Parameters:
file- uploading file
-
uploadFailed
Simulates a failure during file upload.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 uploadis turned off. Javadoc copied fromUploadTester.uploadFailed(java.io.File).- Parameters:
file- uploading file
-
uploadFailed
Simulates a failure during file upload.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 uploadis turned off. Javadoc copied fromUploadTester.uploadFailed(java.lang.String,java.lang.String).- Parameters:
fileName- name of uploading filecontentType- content type of the uploading file
-
removeFile
Simulates the user removing a file from the upload file list, as if clicking the remove button on the file entry.A
FileRemovedEventis fired and the file stops counting towardsUpload.setMaxFiles(int).When several entries have the given name, the most recently added one is removed. 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 listIllegalStateException- if the component is not usable- Since:
- 25.3
-
removeFile
Simulates the user removing a file from the upload file list, as if clicking the remove button on the file entry.A
FileRemovedEventis fired and the file stops counting towardsUpload.setMaxFiles(int).When several entries have the name of the given file, the most recently added one is removed. 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 listIllegalStateException- if the component is not usable- Since:
- 25.3
-
removeFile
public void removeFile(int index) Simulates the user removing the file at the given position of the upload file list, as if clicking the remove button on that entry. This reaches one entry when several share a name.A
FileRemovedEventis fired and the file stops counting towardsUpload.setMaxFiles(int). Javadoc copied fromUploadTester.removeFile(int).- Parameters:
index- the position of the file in the list, in the ordergetFiles()returns them: the most recently added file first- Throws:
IllegalArgumentException- if there is no file at the positionIllegalStateException- if the component is not usable
-
startUpload
Simulates the user clicking the start button of a file that waits in the upload file list becauseauto uploadis turned off, uploading it.When several waiting entries have the given name, the most recently added one is started. Javadoc copied from
UploadTester.startUpload(java.lang.String).- Parameters:
fileName- name of the file to start, as given when it was added
-
startUpload
Simulates the user clicking the start button of a file that waits in the upload file list becauseauto uploadis turned off, uploading it.When several waiting entries have the name of the given file, the most recently added one is started. Javadoc copied from
UploadTester.startUpload(java.io.File).- Parameters:
file- the file to start
-
startUpload
public void startUpload(int index) Simulates the user clicking the start button of the file at the given position of the upload file list, which waits becauseauto uploadis turned off, uploading it. This reaches one entry when several share a name. Javadoc copied fromUploadTester.startUpload(int).- Parameters:
index- the position of the file in the list, in the ordergetFiles()returns them: the most recently added file first
-
getFiles
Gets the files the upload file list shows, in the order the browser shows them: the most recently added file first.A file is
once the upload handler or receiver has consumed it,invalid reference
UploadStatus#UPLOADEDorinvalid reference
UploadStatus#FAILEDwhen its transfer failed or the server refused it, andinvalid reference
UploadStatus#REJECTEDwhile it waits to be started because auto upload is turned off. Files the client-side constraints refused never enter the list. Javadoc copied frominvalid reference
UploadStatus#PENDINGUploadTester.getFiles().- Returns:
- the files in the upload file list
-
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
once the upload handler or receiver has consumed them, and asinvalid reference
UploadStatus#UPLOADEDboth 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. A file waiting forinvalid reference
UploadStatus#REJECTEDstartUpload(String)because auto upload is turned off is; once started, the last upload is that file. Javadoc copied frominvalid reference
UploadStatus#PENDINGUploadTester.getLastUploadStatus().- Returns:
- the outcome of the last simulated upload, one entry per file, or an empty list if no upload has been simulated yet
- Since:
- 25.3
-
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- Since:
- 25.3
- See Also:
-
ensureUploadFailed
public void ensureUploadFailed()Checks that at least one file of the upload last simulated on this component failed or was rejected, and fails otherwise.Counterpart of
ensureUploaded()for a test about the failure case, such as an upload handler that throws or a file the component refuses. UsegetLastUploadStatus()to check which file failed and why.A file left
UploadTester.UploadStatus.PENDINGdoes not count as failed: it was neither delivered nor refused, such as a file following one whose upload threw or a file waiting because auto upload is turned off. Javadoc copied fromUploadTester.ensureUploadFailed().- Throws:
IllegalStateException- if no upload has been simulated on the component, or if no file of the last upload failed or was rejected- See Also:
-