Skip to content

Commit

Permalink
[java] Formatting files
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Jul 27, 2023
1 parent f03ba8c commit 60a054b
Show file tree
Hide file tree
Showing 16 changed files with 76 additions and 92 deletions.
1 change: 0 additions & 1 deletion java/src/org/openqa/selenium/edge/EdgeDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.openqa.selenium.chromium.ChromiumDriver;
import org.openqa.selenium.chromium.ChromiumDriverCommandExecutor;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.manager.SeleniumManagerOutput;
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
import org.openqa.selenium.remote.CommandInfo;
import org.openqa.selenium.remote.RemoteWebDriver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,21 @@ public class FederatedCredentialManagementAccount {
private final String name;
private final String givenName;
private final String pictureUrl;

/**
* The config URL of the identity provider that provided this account.
*
* This allows identifying the IDP in multi-IDP cases.
* <p>This allows identifying the IDP in multi-IDP cases.
*/
private final String idpConfigUrl;

/**
* The login state for this account.
*
* One of LOGIN_STATE_SIGNIN and LOGIN_STATE_SIGNUP.
* <p>One of LOGIN_STATE_SIGNIN and LOGIN_STATE_SIGNUP.
*/
private final String loginState;

private final String termsOfServiceUrl;
private final String privacyPolicyUrl;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,33 @@ public interface FederatedCredentialManagementDialog {
String DIALOG_TYPE_ACCOUNT_LIST = "AccountChooser";
String DIALOG_TYPE_AUTO_REAUTH = "AutoReauthn";

/**
* Closes the dialog as if the user had clicked X.
*/
/** Closes the dialog as if the user had clicked X. */
void cancelDialog();

/**
* Selects an account as if the user had clicked on it.
*
* @param index The index of the account to select from the list
* returned by getAccounts().
* @param index The index of the account to select from the list returned by getAccounts().
*/
void selectAccount(int index);

/**
* Returns the type of the open dialog.
*
* One of DIALOG_TYPE_ACCOUNT_LIST and DIALOG_TYPE_AUTO_REAUTH.
* <p>One of DIALOG_TYPE_ACCOUNT_LIST and DIALOG_TYPE_AUTO_REAUTH.
*/
String getDialogType();
String getDialogType();

/**
* Returns the title of the dialog.
*/
/** Returns the title of the dialog. */
String getTitle();

/**
* Returns the subtitle of the dialog or null if none.
*/
/** Returns the subtitle of the dialog or null if none. */
String getSubtitle();

/**
* Returns the accounts shown in the account chooser.
*
* If this is an auto reauth dialog, returns the single account
* that is being signed in.
* <p>If this is an auto reauth dialog, returns the single account that is being signed in.
*/
List<FederatedCredentialManagementAccount> getAccounts();
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,31 @@

import org.openqa.selenium.Beta;

/**
* Used by classes to indicate that they can interact with FedCM dialogs.
*/
/** Used by classes to indicate that they can interact with FedCM dialogs. */
@Beta
public interface HasFederatedCredentialManagement {
/**
* Disables the promise rejection delay.
*
* FedCM by default delays promise resolution in failure cases for privacy
* reasons (https://fedidcg.github.io/FedCM/#ref-for-setdelayenabled);
* this function allows turning it off to let tests run faster where this
* is not relevant.
* <p>FedCM by default delays promise resolution in failure cases for privacy reasons
* (https://fedidcg.github.io/FedCM/#ref-for-setdelayenabled); this function allows turning it off
* to let tests run faster where this is not relevant.
*/
void setDelayEnabled(boolean enabled);

/**
* Resets the FedCM dialog cooldown.
*
* If a user agent triggers a cooldown when the account chooser is dismissed,
* this function resets that cooldown so that the dialog can be triggered
* again immediately.
* <p>If a user agent triggers a cooldown when the account chooser is dismissed, this function
* resets that cooldown so that the dialog can be triggered again immediately.
*/
void resetCooldown();

/**
* Gets the currently open FedCM dialog, or null if there is no dialog.
*
* Can be used with WebDriverWait like:
* wait.until(driver -> ((HasFederatedCredentialManagement) driver).
* getFederatedCredentialManagementDialog() != null);
* <p>Can be used with WebDriverWait like: wait.until(driver ->
* ((HasFederatedCredentialManagement) driver). getFederatedCredentialManagementDialog() != null);
*/
FederatedCredentialManagementDialog getFederatedCredentialManagementDialog();
}

1 change: 0 additions & 1 deletion java/src/org/openqa/selenium/firefox/FirefoxDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.openqa.selenium.html5.SessionStorage;
import org.openqa.selenium.html5.WebStorage;
import org.openqa.selenium.internal.Require;
import org.openqa.selenium.manager.SeleniumManagerOutput;
import org.openqa.selenium.manager.SeleniumManagerOutput.Result;
import org.openqa.selenium.remote.CommandInfo;
import org.openqa.selenium.remote.FileDetector;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,21 +341,21 @@ private String getHost() {

private Capabilities setBrowserBinary(Capabilities options, String browserPath) {
List<String> vendorOptionsCapabilities =
Arrays.asList("moz:firefoxOptions", "goog:chromeOptions", "ms:edgeOptions");
Arrays.asList("moz:firefoxOptions", "goog:chromeOptions", "ms:edgeOptions");
for (String vendorOptionsCapability : vendorOptionsCapabilities) {
if (options.asMap().containsKey(vendorOptionsCapability)) {
try {
@SuppressWarnings("unchecked")
Map<String, Object> vendorOptions =
(Map<String, Object>) options.getCapability(vendorOptionsCapability);
(Map<String, Object>) options.getCapability(vendorOptionsCapability);
vendorOptions.put("binary", browserPath);
return new PersistentCapabilities(options)
.setCapability(vendorOptionsCapability, vendorOptions);
.setCapability(vendorOptionsCapability, vendorOptions);
} catch (Exception e) {
LOG.warning(
String.format(
"Exception while setting the browser binary path. %s: %s",
options, e.getMessage()));
String.format(
"Exception while setting the browser binary path. %s: %s",
options, e.getMessage()));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/grid/web/ResourceHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import static com.google.common.net.MediaType.GIF;
import static com.google.common.net.MediaType.HTML_UTF_8;
import static com.google.common.net.MediaType.JAVASCRIPT_UTF_8;
import static com.google.common.net.MediaType.JSON_UTF_8;
import static com.google.common.net.MediaType.JPEG;
import static com.google.common.net.MediaType.JSON_UTF_8;
import static com.google.common.net.MediaType.OCTET_STREAM;
import static com.google.common.net.MediaType.PLAIN_TEXT_UTF_8;
import static com.google.common.net.MediaType.PNG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
// under the License.
package org.openqa.selenium.manager;

import org.openqa.selenium.json.JsonInput;

import java.util.List;
import org.openqa.selenium.json.JsonInput;

public class SeleniumManagerOutput {

Expand Down
6 changes: 2 additions & 4 deletions java/src/org/openqa/selenium/remote/DriverCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,12 +412,10 @@ static CommandPayload SET_CURRENT_WINDOW_SIZE(Dimension targetSize) {
}

static CommandPayload SELECT_ACCOUNT(int index) {
return new CommandPayload(
SELECT_ACCOUNT, ImmutableMap.of("accountIndex", index));
return new CommandPayload(SELECT_ACCOUNT, ImmutableMap.of("accountIndex", index));
}

static CommandPayload SET_DELAY_ENABLED(boolean enabled) {
return new CommandPayload(
SET_DELAY_ENABLED, ImmutableMap.of("enabled", enabled));
return new CommandPayload(SET_DELAY_ENABLED, ImmutableMap.of("enabled", enabled));
}
}
17 changes: 9 additions & 8 deletions java/src/org/openqa/selenium/remote/FedCmDialogImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,12 @@

package org.openqa.selenium.remote;

import com.google.common.collect.ImmutableMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.federatedcredentialmanagement.FederatedCredentialManagementAccount;
import org.openqa.selenium.federatedcredentialmanagement.FederatedCredentialManagementDialog;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.ExecuteMethod;

class FedCmDialogImpl implements FederatedCredentialManagementDialog {
private final ExecuteMethod executeMethod;
Expand All @@ -51,20 +48,24 @@ public String getDialogType() {

@Override
public String getTitle() {
Map<String, Object> result = (Map<String, Object>) executeMethod.execute(DriverCommand.GET_FEDCM_TITLE, null);
Map<String, Object> result =
(Map<String, Object>) executeMethod.execute(DriverCommand.GET_FEDCM_TITLE, null);
return (String) result.getOrDefault("title", null);
}

@Override
public String getSubtitle() {
Map<String, Object> result = (Map<String, Object>) executeMethod.execute(DriverCommand.GET_FEDCM_TITLE, null);
Map<String, Object> result =
(Map<String, Object>) executeMethod.execute(DriverCommand.GET_FEDCM_TITLE, null);
return (String) result.getOrDefault("subtitle", null);
}

@Override
public List<FederatedCredentialManagementAccount> getAccounts() {
List<Map<String, String>> list = (List<Map<String, String>>) executeMethod.execute(DriverCommand.GET_ACCOUNTS, null);
ArrayList<FederatedCredentialManagementAccount> accounts = new ArrayList<FederatedCredentialManagementAccount>();
List<Map<String, String>> list =
(List<Map<String, String>>) executeMethod.execute(DriverCommand.GET_ACCOUNTS, null);
ArrayList<FederatedCredentialManagementAccount> accounts =
new ArrayList<FederatedCredentialManagementAccount>();
for (Map<String, String> map : list) {
accounts.add(new FederatedCredentialManagementAccount(map));
}
Expand Down
2 changes: 1 addition & 1 deletion java/src/org/openqa/selenium/remote/RemoteWebDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
import org.openqa.selenium.bidi.HasBiDi;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.HasDevTools;
import org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement;
import org.openqa.selenium.federatedcredentialmanagement.FederatedCredentialManagementDialog;
import org.openqa.selenium.federatedcredentialmanagement.HasFederatedCredentialManagement;
import org.openqa.selenium.interactions.Interactive;
import org.openqa.selenium.interactions.Sequence;
import org.openqa.selenium.internal.Debug;
Expand Down
8 changes: 6 additions & 2 deletions java/src/org/openqa/selenium/remote/service/DriverFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ public static Result getPath(DriverService service, Capabilities options, boolea
if (result.getDriverPath() == null) {
message = String.format("Unable to locate or obtain %s", service.getDriverName());
} else if (!new File(result.getDriverPath()).exists()) {
message = String.format("%s located at %s, but invalid", service.getDriverName(), result.getDriverPath());
message =
String.format(
"%s located at %s, but invalid", service.getDriverName(), result.getDriverPath());
} else if (!new File(result.getDriverPath()).canExecute()) {
message =
String.format("%s located at %s, cannot be executed", service.getDriverName(), result.getDriverPath());
String.format(
"%s located at %s, cannot be executed",
service.getDriverName(), result.getDriverPath());
} else {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@
/**
* Implements FedCM's ID assertion endpoint.
*
* https://fedidcg.github.io/FedCM/#idp-api-id-assertion-endpoint
* <p>https://fedidcg.github.io/FedCM/#idp-api-id-assertion-endpoint
*/
class FedCmIdAssertion implements HttpHandler {

private static final String RESPONSE_STRING =
"{\"token\": \"%s\"}";
private static final String RESPONSE_STRING = "{\"token\": \"%s\"}";

@Override
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
HttpResponse response = new HttpResponse();
response.setHeader("Content-Type", "application/json");
response.setHeader("Cache-Control", "no-store");

response.setContent(
Contents.string(String.format(RESPONSE_STRING, "a token"), UTF_8));
response.setContent(Contents.string(String.format(RESPONSE_STRING, "a token"), UTF_8));

return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@

class WellKnownWebIdentityHandler implements HttpHandler {

private static final String RESPONSE_STRING =
"{\"provider_urls\": [\"%s\"]}";
private static final String RESPONSE_STRING = "{\"provider_urls\": [\"%s\"]}";

@Override
public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
Expand All @@ -38,8 +37,7 @@ public HttpResponse execute(HttpRequest req) throws UncheckedIOException {
response.setHeader("Cache-Control", "no-store");
String targetLocation = UrlPath.relativeToContext(req, "/fedcm/fedcm.json");

response.setContent(
Contents.string(String.format(RESPONSE_STRING, targetLocation), UTF_8));
response.setContent(Contents.string(String.format(RESPONSE_STRING, targetLocation), UTF_8));

return response;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ java_selenium_test_suite(
"chrome",
],
deps = [
"//java/src/org/openqa/selenium/chrome",
"//java/src/org/openqa/selenium:core",
"//java/src/org/openqa/selenium/chrome",
"//java/src/org/openqa/selenium/remote",
"//java/src/org/openqa/selenium/support",
"//java/test/org/openqa/selenium/environment",
Expand Down
Loading

0 comments on commit 60a054b

Please sign in to comment.