diff options
Diffstat (limited to 'components/cronet/android/test/javatests/src')
11 files changed, 130 insertions, 226 deletions
diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/BrotliTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/BrotliTest.java index 81b88c03b..d172a433f 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/BrotliTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/BrotliTest.java @@ -15,7 +15,6 @@ import androidx.test.filters.SmallTest; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -51,15 +50,13 @@ public class BrotliTest { builder, QuicTestServer.createMockCertVerifier()); }); } - assertThat(NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext())).isTrue(); + assertThat(Http2TestServer.startHttp2TestServer(mTestRule.getTestFramework().getContext())) + .isTrue(); } @After public void tearDown() throws Exception { - NativeTestServer.shutdownNativeTestServer(); - if (mCronetEngine != null) { - mCronetEngine.shutdown(); - } + assertThat(Http2TestServer.shutdownHttp2TestServer()).isTrue(); } @Test @@ -73,17 +70,17 @@ public class BrotliTest { }); mCronetEngine = mTestRule.getTestFramework().startEngine(); - String url = NativeTestServer.getEchoAllHeadersURL(); + String url = Http2TestServer.getEchoAllHeadersUrl(); TestUrlRequestCallback callback = startAndWaitForComplete(url); assertThat(callback.getResponseInfoWithChecks()).hasHttpStatusCodeThat().isEqualTo(200); - assertThat(callback.mResponseAsString).contains("Accept-Encoding: gzip, deflate, br"); + assertThat(callback.mResponseAsString).contains("accept-encoding: gzip, deflate, br"); } @Test @SmallTest public void testBrotliNotAdvertised() throws Exception { mCronetEngine = mTestRule.getTestFramework().startEngine(); - String url = NativeTestServer.getEchoAllHeadersURL(); + String url = Http2TestServer.getEchoAllHeadersUrl(); TestUrlRequestCallback callback = startAndWaitForComplete(url); assertThat(callback.getResponseInfoWithChecks()).hasHttpStatusCodeThat().isEqualTo(200); assertThat(callback.mResponseAsString).doesNotContain("br"); @@ -91,7 +88,6 @@ public class BrotliTest { @Test @SmallTest - @Ignore // TODO(danstahr): Add test server support for setting the Brotli header public void testBrotliDecoded() throws Exception { mTestRule .getTestFramework() diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetStressTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetStressTest.java index a5b3968c7..a23705034 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetStressTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetStressTest.java @@ -11,8 +11,6 @@ import static org.chromium.net.truth.UrlResponseInfoSubject.assertThat; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; -import org.chromium.base.test.util.Batch; -import org.chromium.net.apihelpers.UploadDataProviders; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestRuleTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestRuleTest.java index 8190ab7f8..3fa22d155 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestRuleTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetTestRuleTest.java @@ -26,6 +26,7 @@ import org.chromium.net.CronetTestRule.IgnoreFor; import org.chromium.net.CronetTestRule.RequiresMinAndroidApi; import org.chromium.net.CronetTestRule.RequiresMinApi; import org.chromium.net.impl.CronetUrlRequestContext; +import org.chromium.net.impl.JavaCronetEngine; /** Tests features of CronetTestRule. */ @RunWith(AndroidJUnit4.class) @@ -84,6 +85,34 @@ public class CronetTestRuleTest { */ @Test @SmallTest + public void testAllImplsMustRun() { + assertThat(mTestWasRun).isFalse(); + mTestWasRun = true; + mNumberOfReruns++; + assertThat(mNumberOfReruns).isLessThan(4); + switch (mTestRule.implementationUnderTest()) { + case STATICALLY_LINKED: + assertThat(mNativeImplWasRun).isFalse(); + mNativeImplWasRun = true; + break; + case FALLBACK: + assertThat(mFallbackImplWasRun).isFalse(); + mFallbackImplWasRun = true; + break; + case AOSP_PLATFORM: + assertThat(mPlatformImplWasRun).isFalse(); + mPlatformImplWasRun = true; + break; + } + if (mNumberOfReruns == 3) { + assertThat(mFallbackImplWasRun).isTrue(); + assertThat(mPlatformImplWasRun).isTrue(); + assertThat(mNativeImplWasRun).isTrue(); + } + } + + @Test + @SmallTest @IgnoreFor( implementations = {CronetImplementation.FALLBACK, CronetImplementation.AOSP_PLATFORM}, reason = "Testing the rule") @@ -96,4 +125,41 @@ public class CronetTestRuleTest { assertThat(mTestRule.getTestFramework().getEngine()) .isInstanceOf(CronetUrlRequestContext.class); } + + @Test + @SmallTest + @IgnoreFor( + implementations = { + CronetImplementation.STATICALLY_LINKED, + CronetImplementation.AOSP_PLATFORM + }, + reason = "Testing the rule") + public void testRunOnlyJavaMustRun() { + assertThat(mTestRule.testingJavaImpl()).isTrue(); + assertThat(mTestRule.implementationUnderTest()).isEqualTo(CronetImplementation.FALLBACK); + assertThat(mTestWasRun).isFalse(); + mTestWasRun = true; + assertThat(mTestRule.getTestFramework().getEngine()).isInstanceOf(JavaCronetEngine.class); + } + + @Test + @SmallTest + @IgnoreFor( + implementations = { + CronetImplementation.STATICALLY_LINKED, + CronetImplementation.FALLBACK + }, + reason = "Testing the rule") + @RequiresMinAndroidApi(Build.VERSION_CODES.UPSIDE_DOWN_CAKE) + public void testRunOnlyAospPlatformMustRun() { + assertThat(mTestRule.testingJavaImpl()).isFalse(); + assertThat(mTestRule.implementationUnderTest()) + .isEqualTo(CronetImplementation.AOSP_PLATFORM); + assertThat(mTestWasRun).isFalse(); + mTestWasRun = true; + assertThat(mTestRule.getTestFramework().getEngine()) + .isNotInstanceOf(JavaCronetEngine.class); + assertThat(mTestRule.getTestFramework().getEngine()) + .isNotInstanceOf(CronetUrlRequestContext.class); + } } diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java index 5110bbb9d..f4cb0bb96 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestContextTest.java @@ -5,11 +5,13 @@ package org.chromium.net; import static com.google.common.truth.Truth.assertThat; + +import static org.junit.Assert.assertThrows; +import static org.junit.Assume.assumeTrue; + import static org.chromium.net.CronetEngine.Builder.HTTP_CACHE_IN_MEMORY; import static org.chromium.net.CronetTestRule.getTestStorage; import static org.chromium.net.truth.UrlResponseInfoSubject.assertThat; -import static org.junit.Assert.assertThrows; -import static org.junit.Assume.assumeTrue; import android.net.Network; import android.os.Build; @@ -18,9 +20,11 @@ import android.os.ConditionVariable; import android.os.Handler; import android.os.Looper; import android.os.Process; + import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; import com.android.testutils.SkipPresubmit; + import org.jni_zero.JNINamespace; import org.jni_zero.NativeMethods; import org.json.JSONObject; @@ -31,7 +35,6 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.chromium.base.Log; -import org.chromium.base.FileUtils; import org.chromium.base.PathUtils; import org.chromium.base.test.util.DoNotBatch; import org.chromium.net.CronetTestRule.CronetImplementation; @@ -51,7 +54,6 @@ import org.chromium.net.impl.CronetUrlRequestContext; import org.chromium.net.impl.ImplVersion; import org.chromium.net.impl.NativeCronetEngineBuilderImpl; import org.chromium.net.impl.NetworkExceptionImpl; -import org.chromium.net.test.EmbeddedTestServer; import java.io.BufferedReader; import java.io.File; @@ -82,11 +84,11 @@ public class CronetUrlRequestContextTest { private String mUrl404; private String mUrl500; - @Before - public void setUp() throws Exception { - assertThat(NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext())).isTrue(); - mUrl = NativeTestServer.getSuccessURL(); - mUrl404 = NativeTestServer.getNotFoundURL(); + @Before + public void setUp() throws Exception { + NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext()); + mUrl = NativeTestServer.getSuccessURL(); + mUrl404 = NativeTestServer.getNotFoundURL(); mUrl500 = NativeTestServer.getServerErrorURL(); } @@ -784,7 +786,7 @@ public class CronetUrlRequestContextTest { assertThat(logFile.exists()).isTrue(); assertThat(logFile.length()).isNotEqualTo(0); assertThat(hasBytesInNetLog(logFile)).isFalse(); - FileUtils.recursivelyDeleteFile(netLogDir, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir); assertThat(netLogDir.exists()).isFalse(); } @@ -845,12 +847,13 @@ public class CronetUrlRequestContextTest { assertThat(logFile.exists()).isTrue(); assertThat(logFile.length()).isNotEqualTo(0); - FileUtils.recursivelyDeleteFile(netLogDir, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir); assertThat(netLogDir.exists()).isFalse(); } @Test @SmallTest + @SkipPresubmit(reason = "b/293141085 flaky test") @IgnoreFor( implementations = {CronetImplementation.AOSP_PLATFORM}, reason = "ActiveRequestCount is not available in AOSP") @@ -1270,9 +1273,9 @@ public class CronetUrlRequestContextTest { assertThat(containsStringInNetLog(logFile2, mUrl404)).isTrue(); assertThat(containsStringInNetLog(logFile2, mUrl500)).isTrue(); - FileUtils.recursivelyDeleteFile(netLogDir1, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir1); assertThat(netLogDir1.exists()).isFalse(); - FileUtils.recursivelyDeleteFile(netLogDir2, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir2); assertThat(netLogDir2.exists()).isFalse(); } @@ -1295,7 +1298,10 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @SkipPresubmit(reason = "b/293141085 flaky test") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "Fallback implementation does not have a network thread.") // Tests that if CronetEngine is shut down on the network thread, an appropriate exception // is thrown. public void testShutDownEngineOnNetworkThread() throws Exception { @@ -1353,7 +1359,10 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @SkipPresubmit(reason = "b/293141085 flaky test") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "Fallback implementation has no support for caches") // Tests that if CronetEngine is shut down when reading from disk cache, // there isn't a crash. See crbug.com/486120. public void testShutDownEngineWhenReadingFromDiskCache() throws Exception { @@ -1452,7 +1461,7 @@ public class CronetUrlRequestContextTest { netLogDir.getPath(), false, MAX_FILE_SIZE)); assertThat(e).hasMessageThat().isEqualTo("Engine is shut down."); assertThat(logFile.exists()).isFalse(); - FileUtils.recursivelyDeleteFile(netLogDir, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir); assertThat(netLogDir.exists()).isFalse(); } @@ -1514,7 +1523,7 @@ public class CronetUrlRequestContextTest { assertThat(logFile.exists()).isTrue(); assertThat(logFile.length()).isNotEqualTo(0); assertThat(hasBytesInNetLog(logFile)).isFalse(); - FileUtils.recursivelyDeleteFile(netLogDir, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir); assertThat(netLogDir.exists()).isFalse(); } @@ -1578,7 +1587,7 @@ public class CronetUrlRequestContextTest { assertThat(logFile.exists()).isTrue(); assertThat(logFile.length()).isNotEqualTo(0); assertThat(hasBytesInNetLog(logFile)).isFalse(); - FileUtils.recursivelyDeleteFile(netLogDir, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir); assertThat(netLogDir.exists()).isFalse(); } @@ -1634,7 +1643,7 @@ public class CronetUrlRequestContextTest { assertThat(logFile.exists()).isTrue(); assertThat(logFile.length()).isNotEqualTo(0); assertThat(hasBytesInNetLog(logFile)).isTrue(); - FileUtils.recursivelyDeleteFile(netLogDir, FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(netLogDir); assertThat(netLogDir.exists()).isFalse(); } @@ -1724,7 +1733,9 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "No caches support for fallback implementation") public void testEnableHttpCacheDisk() throws Exception { CronetEngine cronetEngine = createCronetEngineWithCache(CronetEngine.Builder.HTTP_CACHE_DISK); @@ -1738,7 +1749,10 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @SkipPresubmit(reason = "b/293141085 flaky test") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "No caches support for fallback implementation") public void testNoConcurrentDiskUsage() throws Exception { CronetEngine cronetEngine = createCronetEngineWithCache(CronetEngine.Builder.HTTP_CACHE_DISK); @@ -1759,7 +1773,10 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @SkipPresubmit(reason = "b/293141085 flaky test") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "No caches support for fallback implementation") public void testEnableHttpCacheDiskNoHttp() throws Exception { CronetEngine cronetEngine = createCronetEngineWithCache(CronetEngine.Builder.HTTP_CACHE_DISK_NO_HTTP); @@ -1780,7 +1797,9 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "No caches support for fallback implementation") public void testDisableCache() throws Exception { CronetEngine cronetEngine = createCronetEngineWithCache(CronetEngine.Builder.HTTP_CACHE_DISK); @@ -1819,7 +1838,9 @@ public class CronetUrlRequestContextTest { @Test @SmallTest - @SkipPresubmit(reason = "b/293141085 Tests that enable disk cache are flaky") + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK}, + reason = "No caches support for fallback implementation") public void testEnableHttpCacheDiskNewEngine() throws Exception { CronetEngine cronetEngine = createCronetEngineWithCache(CronetEngine.Builder.HTTP_CACHE_DISK); @@ -2041,6 +2062,9 @@ public class CronetUrlRequestContextTest { @Test @SmallTest + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK, CronetImplementation.AOSP_PLATFORM}, + reason = "LibraryLoader is supported only by the native implementation") public void testSetLibraryLoaderIsEnforcedByDefaultEmbeddedProvider() throws Exception { CronetEngine.Builder builder = new CronetEngine.Builder(mTestRule.getTestFramework().getContext()); @@ -2061,6 +2085,9 @@ public class CronetUrlRequestContextTest { @Test @SmallTest + @IgnoreFor( + implementations = {CronetImplementation.FALLBACK, CronetImplementation.AOSP_PLATFORM}, + reason = "LibraryLoader is supported only by the native implementation") public void testSetLibraryLoaderIsIgnoredInNativeCronetEngineBuilderImpl() throws Exception { CronetEngine.Builder builder = new CronetEngine.Builder( diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestTest.java index 876921d02..c32681ab4 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/CronetUrlRequestTest.java @@ -25,7 +25,6 @@ import androidx.test.filters.SmallTest; import org.jni_zero.NativeMethods; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -1016,47 +1015,6 @@ public class CronetUrlRequestTest { assertThat(callback.mResponseStep).isEqualTo(ResponseStep.ON_FAILED); } - /** - * Tests that an SSL cert error with upload will be reported via {@link - * UrlRequest.Callback#onFailed}. - */ - @Test - @SmallTest - @Ignore ("b/267353182 " - + "Figure out why EmbeddedTestServer was used instead of MockUrlForSSLCertificateError" - + "since this is similar test to one above") - @IgnoreFor( - implementations = {CronetImplementation.FALLBACK}, - reason = "crbug.com/1495320: Refactor error checking") - public void testSSLCertificateError() throws Exception { - // EmbeddedTestServer sslServer = EmbeddedTestServer.createAndStartHTTPSServer( - // mTestRule.getTestFramework().getContext(), ServerCertificate.CERT_EXPIRED); - - TestUrlRequestCallback callback = new TestUrlRequestCallback(); - UrlRequest.Builder builder = mTestRule.getTestFramework().getEngine().newUrlRequestBuilder( - /* sslServer.getURL("/") */ null, callback, callback.getExecutor()); - - TestUploadDataProvider dataProvider = - new TestUploadDataProvider( - TestUploadDataProvider.SuccessCallbackMode.SYNC, callback.getExecutor()); - dataProvider.addRead("test".getBytes()); - builder.setUploadDataProvider(dataProvider, callback.getExecutor()); - builder.addHeader("Content-Type", "useless/string"); - builder.build().start(); - callback.blockForDone(); - dataProvider.assertClosed(); - - assertThat(callback.getResponseInfo()).isNull(); - assertThat(callback.mOnErrorCalled).isTrue(); - assertThat(callback.mError) - .hasMessageThat() - .contains("Exception in CronetUrlRequest: net::ERR_CERT_DATE_INVALID"); - mTestRule.assertCronetInternalErrorCode((NetworkException) callback.mError, -201); - assertThat(callback.mResponseStep).isEqualTo(ResponseStep.ON_FAILED); - - // sslServer.stopAndDestroyServer(); - } - /** Checks that the buffer is updated correctly, when starting at an offset. */ @Test @SmallTest diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/DiskStorageTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/DiskStorageTest.java index d971d4f22..98dde3a68 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/DiskStorageTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/DiskStorageTest.java @@ -13,7 +13,6 @@ import static org.chromium.net.truth.UrlResponseInfoSubject.assertThat; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.SmallTest; - import com.android.testutils.SkipPresubmit; import org.junit.After; @@ -22,7 +21,6 @@ import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.chromium.base.FileUtils; import org.chromium.base.PathUtils; import org.chromium.base.test.util.DoNotBatch; import org.chromium.net.CronetTestRule.CronetImplementation; @@ -57,7 +55,7 @@ public class DiskStorageTest { @After public void tearDown() throws Exception { if (mReadOnlyStoragePath != null) { - FileUtils.recursivelyDeleteFile(new File(mReadOnlyStoragePath), FileUtils.DELETE_ALL); + FileUtils.recursivelyDeleteFile(new File(mReadOnlyStoragePath)); } NativeTestServer.shutdownNativeTestServer(); } diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/ExperimentalOptionsTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/ExperimentalOptionsTest.java index 01a63a591..1dc8ad69f 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/ExperimentalOptionsTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/ExperimentalOptionsTest.java @@ -21,13 +21,11 @@ import androidx.test.filters.MediumTest; import com.android.testutils.SkipPresubmit; -import org.json.JSONException; import org.jni_zero.JNINamespace; import org.jni_zero.NativeMethods; import org.json.JSONObject; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -96,7 +94,6 @@ public class ExperimentalOptionsTest { @Test @MediumTest - @Ignore("b/275345637 Needs HTTP2 Server") @DisableAutomaticNetLog(reason = "Test is targeting NetLog") // Tests that NetLog writes effective experimental options to NetLog. public void testNetLog() throws Exception { @@ -158,7 +155,6 @@ public class ExperimentalOptionsTest { @Test @MediumTest - @Ignore("b/275345637 Needs HTTP2 Server") public void testSetSSLKeyLogFile() throws Exception { String url = Http2TestServer.getEchoMethodUrl(); File dir = new File(PathUtils.getDataDirectory()); @@ -234,9 +230,9 @@ public class ExperimentalOptionsTest { // Tests that basic Cronet functionality works when host cache persistence is enabled, and that // persistence works. public void testHostCachePersistence() throws Exception { - assertThat(NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext())).isTrue(); + NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext()); - String realUrl = NativeTestServer.getSuccessURL(); + String realUrl = NativeTestServer.getFileURL("/echo?status=200"); URL javaUrl = new URL(realUrl); String realHost = javaUrl.getHost(); int realPort = javaUrl.getPort(); @@ -316,7 +312,6 @@ public class ExperimentalOptionsTest { @Test @MediumTest - @Ignore("b/275345637 Needs HTTP2 Server") public void testDetectBrokenConnection() throws Exception { String url = Http2TestServer.getEchoMethodUrl(); mTestRule @@ -348,7 +343,6 @@ public class ExperimentalOptionsTest { @DisabledTest(message = "crbug.com/1320725") @Test @LargeTest - @Ignore("b/275345637 Needs HTTP2 Server") public void testDetectBrokenConnectionOnNetworkFailure() throws Exception { // HangingRequestUrl stops the server from replying until mHangingUrlLatch is opened, // simulating a network failure between client and server. diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/Http2TestServer.java b/components/cronet/android/test/javatests/src/org/chromium/net/Http2TestServer.java deleted file mode 100644 index 55c36010a..000000000 --- a/components/cronet/android/test/javatests/src/org/chromium/net/Http2TestServer.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (C) 2023 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.chromium.net; - -import android.content.Context; - -import java.io.File; -import java.util.concurrent.CountDownLatch; - - -/** - * This is a STUB AOSP-only version of org.chromium.net.test.Http2TestServer. This will allow us - * to not have comment out the tests but rather simply @Ignore them till we figure out what the - * plan for a H2 server is. - */ -public final class Http2TestServer { - - public static boolean shutdownHttp2TestServer() throws Exception { - return true; - } - - public static String getServerHost() { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static int getServerPort() { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static String getServerUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static ReportingCollector getReportingCollector() { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static String getEchoAllHeadersUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static String getEchoHeaderUrl(String headerName) { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static String getEchoMethodUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * When using this you must provide a CountDownLatch in the call to startHttp2TestServer. - * The request handler will continue to hang until the provided CountDownLatch reaches 0. - * - * @return url of the server resource which will hang indefinitely. - */ - public static String getHangingRequestUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * @return url of the server resource which will echo every received stream data frame. - */ - public static String getEchoStreamUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * @return url of the server resource which will echo request headers as response trailers. - */ - public static String getEchoTrailersUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * @return url of a brotli-encoded server resource. - */ - public static String getServeSimpleBrotliResponse() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * @return url of the reporting collector - */ - public static String getReportingCollectorUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * @return url of a resource that includes Reporting and NEL policy headers in its response - */ - public static String getSuccessWithNELHeadersUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - /** - * @return url of a resource that sends response headers with the same key - */ - public static String getCombinedHeadersUrl() { - throw new UnsupportedOperationException("This is a stub class"); - } - - public static boolean startHttp2TestServer(Context context) throws Exception { - return true; - } - - public static boolean startHttp2TestServer(Context context, CountDownLatch hangingUrlLatch) - throws Exception { - return true; - } - - private Http2TestServer() { - } - - private static class ReportingCollector { - } -} diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/NQETest.java b/components/cronet/android/test/javatests/src/org/chromium/net/NQETest.java index 1e490a7cb..2407da5f2 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/NQETest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/NQETest.java @@ -18,7 +18,6 @@ import androidx.test.filters.SmallTest; import org.json.JSONObject; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -57,8 +56,8 @@ public class NQETest { @Before public void setUp() throws Exception { - assertThat(NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext())).isTrue(); - mUrl = NativeTestServer.getSuccessURL(); + NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext()); + mUrl = NativeTestServer.getFileURL("/echo?status=200"); } @After @@ -277,7 +276,6 @@ public class NQETest { @Test @SmallTest - @Ignore("b/267353182 Permission denied error") public void testPrefsWriteRead() throws Exception { // When the loop is run for the first time, network quality is written to the disk. The // test verifies that in the next loop, the network quality is read back. diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java index b8d7442a7..2f2959e63 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/QuicTest.java @@ -13,7 +13,6 @@ import static org.chromium.net.truth.UrlResponseInfoSubject.assertThat; import androidx.test.ext.junit.runners.AndroidJUnit4; import androidx.test.filters.LargeTest; import androidx.test.filters.SmallTest; - import com.android.testutils.SkipPresubmit; import org.json.JSONObject; diff --git a/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java b/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java index 1b0b0fd77..b0b4f6aea 100644 --- a/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java +++ b/components/cronet/android/test/javatests/src/org/chromium/net/RequestFinishedInfoTest.java @@ -68,8 +68,8 @@ public class RequestFinishedInfoTest { @Before public void setUp() throws Exception { - assertThat(NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext())).isTrue(); - mUrl = NativeTestServer.getSuccessURL(); + NativeTestServer.startNativeTestServer(mTestRule.getTestFramework().getContext()); + mUrl = NativeTestServer.getFileURL("/echo?status=200"); } @After |