-
Notifications
You must be signed in to change notification settings - Fork 84
Cronvoy: Map EM Errors to Cronet API Errors II (#1594) #2633
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
560265e
cronvoy: add network_disconnected error and tests
colibie 7bf274c
add quic exception and delete tests
colibie 558cf94
[cronvoy] fix flaky malloc error
colibie 8ee1279
cronvoy: move mockurlrequest test deletions to another PR
colibie 3dfd37a
cronvoy: switch the croneturlrequesttest to use a single engine
colibie fb9fa84
cronvoy: remove commented code
colibie d88b165
cronvoy: remove code
colibie 3f7b8d4
cronvoy: format
colibie 6b627b6
address comments
colibie 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
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
20 changes: 20 additions & 0 deletions
20
library/java/io/envoyproxy/envoymobile/engine/UpstreamHttpProtocol.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,20 @@ | ||
| package io.envoyproxy.envoymobile.engine; | ||
|
|
||
| import androidx.annotation.LongDef; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
|
|
||
| /** | ||
| * The upstream protocol, if an upstream connection was established. Field | ||
| * entries are based off of Envoy's Http::Protocol | ||
| * https://github.com/envoyproxy/envoy/blob/main/envoy/http/protocol.h | ||
| */ | ||
| @LongDef({UpstreamHttpProtocol.HTTP10, UpstreamHttpProtocol.HTTP11, UpstreamHttpProtocol.HTTP2, | ||
| UpstreamHttpProtocol.HTTP3}) | ||
| @Retention(RetentionPolicy.SOURCE) | ||
| public @interface UpstreamHttpProtocol { | ||
| long HTTP10 = 0; | ||
| long HTTP11 = 1; | ||
| long HTTP2 = 2; | ||
| long HTTP3 = 3; | ||
| } |
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
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
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
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
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
68 changes: 68 additions & 0 deletions
68
test/java/io/envoyproxy/envoymobile/engine/AndroidNetworkMonitorTest.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,68 @@ | ||
| package io.envoyproxy.envoymobile.engine; | ||
|
|
||
| import static org.robolectric.Shadows.shadowOf; | ||
|
|
||
| import android.content.Context; | ||
| import android.content.Intent; | ||
| import android.Manifest; | ||
| import android.net.ConnectivityManager; | ||
| import android.net.NetworkInfo; | ||
| import androidx.test.filters.MediumTest; | ||
| import androidx.test.platform.app.InstrumentationRegistry; | ||
| import androidx.test.rule.GrantPermissionRule; | ||
| import androidx.test.annotation.UiThreadTest; | ||
| import io.envoyproxy.envoymobile.MockEnvoyEngine; | ||
| import org.junit.After; | ||
| import org.junit.Assert; | ||
| import org.junit.Before; | ||
| import org.junit.Rule; | ||
| import org.junit.Test; | ||
| import org.junit.runner.RunWith; | ||
| import org.robolectric.RobolectricTestRunner; | ||
| import org.robolectric.shadows.ShadowConnectivityManager; | ||
|
|
||
| /** | ||
| * Tests functionality of AndroidNetworkMonitor | ||
| */ | ||
| @RunWith(RobolectricTestRunner.class) | ||
| public class AndroidNetworkMonitorTest { | ||
|
|
||
| @Rule | ||
| public GrantPermissionRule mRuntimePermissionRule = | ||
| GrantPermissionRule.grant(Manifest.permission.ACCESS_NETWORK_STATE); | ||
|
|
||
| private AndroidNetworkMonitor androidNetworkMonitor; | ||
| private ShadowConnectivityManager connectivityManager; | ||
| private Context context; | ||
|
|
||
| @Before | ||
| public void setUp() { | ||
| context = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
| AndroidNetworkMonitor.load(context, new MockEnvoyEngine()); | ||
| androidNetworkMonitor = AndroidNetworkMonitor.getInstance(); | ||
| connectivityManager = shadowOf(androidNetworkMonitor.getConnectivityManager()); | ||
| } | ||
|
|
||
| /** | ||
| * Tests that isOnline() returns the correct result. | ||
| */ | ||
| @Test | ||
| @MediumTest | ||
| @UiThreadTest | ||
| public void testAndroidNetworkMonitorIsOnline() { | ||
| Intent intent = new Intent(ConnectivityManager.CONNECTIVITY_ACTION); | ||
| // Set up network change | ||
| androidNetworkMonitor.onReceive(context, intent); | ||
| Assert.assertTrue(androidNetworkMonitor.isOnline()); | ||
|
|
||
| // Save old networkInfo and simulate a no network scenerio | ||
| NetworkInfo networkInfo = androidNetworkMonitor.getConnectivityManager().getActiveNetworkInfo(); | ||
| connectivityManager.setActiveNetworkInfo(null); | ||
| androidNetworkMonitor.onReceive(context, intent); | ||
| Assert.assertFalse(androidNetworkMonitor.isOnline()); | ||
|
|
||
| // Bring back online since the AndroidNetworkMonitor class is a singleton | ||
| connectivityManager.setActiveNetworkInfo(networkInfo); | ||
| androidNetworkMonitor.onReceive(context, intent); | ||
| } | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.