Commit d607f73d authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

weblayer: ignore version checks in some code paths

This allows calling these functions when running under roboelectric.
This is necessary as when running under roboelectric the implementation
is not loaded and it doesn't run on a device.

BUG=1128312
TEST=none

Change-Id: Ib96cd68b8ff22f0046d6a96f8b1ca6ba203f418c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414775Reviewed-by: default avatarBo <boliu@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807964}
parent 82523b39
...@@ -59,7 +59,8 @@ public class NavigateParams { ...@@ -59,7 +59,8 @@ public class NavigateParams {
*/ */
@NonNull @NonNull
public Builder disableIntentProcessing() { public Builder disableIntentProcessing() {
if (WebLayer.getSupportedMajorVersionInternal() < 86) { if (WebLayer.shouldPerformVersionChecks()
&& WebLayer.getSupportedMajorVersionInternal() < 86) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
mParams.mIntentProcessingDisabled = true; mParams.mIntentProcessingDisabled = true;
...@@ -74,7 +75,8 @@ public class NavigateParams { ...@@ -74,7 +75,8 @@ public class NavigateParams {
*/ */
@NonNull @NonNull
public Builder disableNetworkErrorAutoReload() { public Builder disableNetworkErrorAutoReload() {
if (WebLayer.getSupportedMajorVersionInternal() < 86) { if (WebLayer.shouldPerformVersionChecks()
&& WebLayer.getSupportedMajorVersionInternal() < 86) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
mParams.mNetworkErrorAutoReloadDisabled = true; mParams.mNetworkErrorAutoReloadDisabled = true;
...@@ -103,7 +105,8 @@ public class NavigateParams { ...@@ -103,7 +105,8 @@ public class NavigateParams {
* @since 86 * @since 86
*/ */
public boolean isIntentProcessingDisabled() { public boolean isIntentProcessingDisabled() {
if (WebLayer.getSupportedMajorVersionInternal() < 86) { if (WebLayer.shouldPerformVersionChecks()
&& WebLayer.getSupportedMajorVersionInternal() < 86) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
return mIntentProcessingDisabled; return mIntentProcessingDisabled;
...@@ -117,7 +120,8 @@ public class NavigateParams { ...@@ -117,7 +120,8 @@ public class NavigateParams {
* @since 86 * @since 86
*/ */
public boolean isNetworkErrorAutoReloadDisabled() { public boolean isNetworkErrorAutoReloadDisabled() {
if (WebLayer.getSupportedMajorVersionInternal() < 86) { if (WebLayer.shouldPerformVersionChecks()
&& WebLayer.getSupportedMajorVersionInternal() < 86) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
return mNetworkErrorAutoReloadDisabled; return mNetworkErrorAutoReloadDisabled;
......
...@@ -191,6 +191,14 @@ public class WebLayer { ...@@ -191,6 +191,14 @@ public class WebLayer {
return getWebLayerLoader(context).getMajorVersion(); return getWebLayerLoader(context).getMajorVersion();
} }
// Returns true if version checks should be done. This is provided solely for testing, and
// specifically testing that does not run on device and load the implementation. It is only
// necessary to check this in code paths that don't require WebLayer to load the implementation
// and need to be callable in tests.
static boolean shouldPerformVersionChecks() {
return !"robolectric".equals(Build.FINGERPRINT);
}
// Internal version of getSupportedMajorVersion(). This should only be used when you know // Internal version of getSupportedMajorVersion(). This should only be used when you know
// WebLayer has been initialized. Generally that means calling this from any non-static method. // WebLayer has been initialized. Generally that means calling this from any non-static method.
static int getSupportedMajorVersionInternal() { static int getSupportedMajorVersionInternal() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment