-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Browser#openAndWait for convenience(Fixes #28) #30
Merged
alechenninger
merged 4 commits into
darcy-framework:master
from
abocz:add-openandwait-to-browser
Apr 17, 2015
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,10 @@ | |
import com.redhat.darcy.ui.api.View; | ||
import com.redhat.darcy.ui.api.elements.Findable; | ||
import com.redhat.synq.Event; | ||
|
||
import java.time.Duration; | ||
import java.time.temporal.ChronoUnit; | ||
|
||
/** | ||
* Abstracts all of the interactions a user might make with a browser. | ||
*/ | ||
|
@@ -67,6 +71,34 @@ default <T extends View> Event<T> open(ViewUrl<T> viewUrl) { | |
*/ | ||
<T extends View> Event<T> open(String url, T destination); | ||
|
||
/** | ||
* Opens the URL and immediately blocks the thread for a maximum of the specified | ||
* duration, after which a {@link com.redhat.synq.TimeoutException} will be thrown. | ||
* @param viewUrl If you don't have a {@link com.redhat.darcy.web.api.ViewUrl} instance, but you | ||
* know the url and the resulting {@link com.redhat.darcy.ui.api.View}, see | ||
* {@link #open(String, com.redhat.darcy.ui.api.View)}. | ||
* @param duration Maximum specified duration of the view loading | ||
* @return The awaited view once it has met all criteria for loading | ||
*/ | ||
default <T extends View> T openAndWaitUpTo(ViewUrl<T> viewUrl, Duration duration) { | ||
return open(viewUrl).waitUpTo(duration); | ||
} | ||
|
||
/** | ||
* Opens the URL and immediately blocks the thread for a maximum of the duration of the | ||
* specified amount of units, after which a {@link com.redhat.synq.TimeoutException} will be | ||
* thrown. | ||
* @param viewUrl If you don't have a {@link com.redhat.darcy.web.api.ViewUrl} instance, but you | ||
* know the url and the resulting {@link com.redhat.darcy.ui.api.View}, see | ||
* {@link #open(String, com.redhat.darcy.ui.api.View)}. | ||
* @param amount The amount of the duration, expressed in units | ||
* @param unit The unit the duration is measured in | ||
* @return The awaited view once it has met all criteria for loading | ||
*/ | ||
default <T extends View> T openAndWaitUpTo(ViewUrl<T> viewUrl, Long amount, ChronoUnit unit) { | ||
return open(viewUrl).waitUpTo(Duration.of(amount, unit)); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would remove this override -- I don't like the hard coded 2 minute wait time here. We can address default times in |
||
|
||
/** | ||
* @return the current URL string this Browser window is pointing to. | ||
*/ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would also add an override that accepts a
Long
and aChronoUnit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.