-
Notifications
You must be signed in to change notification settings - Fork 15
[java] support for Browser on EmuSim #170
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
Draft
titusfortner
wants to merge
1
commit into
main
Choose a base branch
from
browser_emusim
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
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 hidden or 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
36 changes: 36 additions & 0 deletions
36
java/src/main/java/com/saucelabs/saucebindings/DeviceOrientation.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.saucelabs.saucebindings; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| public enum DeviceOrientation { | ||
| LANDSCAPE("landscape"), | ||
| PORTRAIT("portrait"); | ||
|
|
||
| @Getter | ||
| private final String value; | ||
|
|
||
| private static final class DeviceOrientationLookup { | ||
| private static final Map<String, String> lookup = new HashMap<String, String>(); | ||
| } | ||
|
|
||
| public static Set keys() { | ||
| return DeviceOrientationLookup.lookup.keySet(); | ||
| } | ||
|
|
||
| DeviceOrientation(String value) { | ||
| this.value = value; | ||
| DeviceOrientationLookup.lookup.put(value, this.name()); | ||
| } | ||
|
|
||
| public static String fromString(String value) { | ||
| return DeviceOrientationLookup.lookup.get(value); | ||
|
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.
|
||
| } | ||
|
|
||
| public String toString() { | ||
| return this.value; | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
java/src/main/java/com/saucelabs/saucebindings/DeviceType.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.saucelabs.saucebindings; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| public enum DeviceType { | ||
| PHONE("phone"), | ||
| TABLET("tablet"); | ||
|
|
||
| @Getter | ||
| private final String value; | ||
|
|
||
| private static final class DeviceTypeLookup { | ||
| private static final Map<String, String> lookup = new HashMap<String, String>(); | ||
| } | ||
|
|
||
| public static Set keys() { | ||
| return DeviceTypeLookup.lookup.keySet(); | ||
| } | ||
|
|
||
| DeviceType(String value) { | ||
| this.value = value; | ||
| DeviceTypeLookup.lookup.put(value, this.name()); | ||
| } | ||
|
|
||
| public static String fromString(String value) { | ||
| return DeviceTypeLookup.lookup.get(value); | ||
| } | ||
|
|
||
| public String toString() { | ||
| return this.value; | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
java/src/main/java/com/saucelabs/saucebindings/SauceAndroidSession.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.saucelabs.saucebindings; | ||
|
|
||
| import io.appium.java_client.android.AndroidDriver; | ||
| import lombok.Getter; | ||
| import org.openqa.selenium.MutableCapabilities; | ||
|
|
||
| import java.net.URL; | ||
|
|
||
| public class SauceAndroidSession extends SauceSession<AndroidDriver> { | ||
| @Getter private AndroidDriver driver; | ||
|
|
||
| public SauceAndroidSession() { | ||
| this(SauceOptions.android()); | ||
| } | ||
|
|
||
| public SauceAndroidSession(SauceOptions options) { | ||
| setSauceOptions(options); | ||
| } | ||
|
|
||
| protected AndroidDriver createDriver(URL url, MutableCapabilities capabilities) { | ||
| this.driver = new AndroidDriver(url, capabilities); | ||
| return driver; | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
java/src/main/java/com/saucelabs/saucebindings/SauceAutomationName.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.saucelabs.saucebindings; | ||
|
|
||
| import lombok.Getter; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| public enum SauceAutomationName { | ||
| UIAUTOMATOR2("UiAutomator2"), | ||
| APPIUM("Appium"); | ||
|
|
||
| @Getter | ||
| private final String value; | ||
|
|
||
| private static final class AutomationNameLookup { | ||
| private static final Map<String, String> lookup = new HashMap<String, String>(); | ||
| } | ||
|
|
||
| public static Set keys() { | ||
| return AutomationNameLookup.lookup.keySet(); | ||
| } | ||
|
|
||
| SauceAutomationName(String value) { | ||
| this.value = value; | ||
| AutomationNameLookup.lookup.put(value, this.name()); | ||
| } | ||
|
|
||
| public static String fromString(String value) { | ||
| return AutomationNameLookup.lookup.get(value); | ||
| } | ||
|
|
||
| public String toString() { | ||
| return this.value; | ||
| } | ||
| } |
24 changes: 24 additions & 0 deletions
24
java/src/main/java/com/saucelabs/saucebindings/SauceIOSSession.java
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.saucelabs.saucebindings; | ||
|
|
||
| import io.appium.java_client.ios.IOSDriver; | ||
| import lombok.Getter; | ||
| import org.openqa.selenium.MutableCapabilities; | ||
|
|
||
| import java.net.URL; | ||
|
|
||
| public class SauceIOSSession extends SauceSession<IOSDriver> { | ||
| @Getter private IOSDriver driver; | ||
|
|
||
| public SauceIOSSession() { | ||
| this(SauceOptions.ios()); | ||
| } | ||
|
|
||
| public SauceIOSSession(SauceOptions options) { | ||
| setSauceOptions(options); | ||
| } | ||
|
|
||
| protected IOSDriver createDriver(URL url, MutableCapabilities capabilities) { | ||
| this.driver = new IOSDriver(url, capabilities); | ||
| return driver; | ||
| } | ||
| } |
Oops, something went wrong.
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.
Could also be
return Stream.of(this.values()).map((x) -> x.name()).collect(toList())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.
Yeah, it took me a while to find an approach that worked for what I needed. This code matches what I'm doing in all the other enums. Is the an advantage to replacing the code in all of them?
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 say it makes sense since we get rid of the redundant data structure. All operations could be done using native methods of the Enum class itself