Skip to content

Commit

Permalink
Convert most cronet tests to JUnit4
Browse files Browse the repository at this point in the history
This CL converts most instrumentation tests in cronet to JUnit4, with
exceptions to some flaky tests. For more on JUnit4 migration, please
check src/testing/android/docs/junit4.md

Bug: 640116
Cq-Include-Trybots: master.tryserver.chromium.android:android_cronet_tester
Change-Id: Ieed3201370234ad05f34aa1e5a4e4b4660441f08
Reviewed-on: https://chromium-review.googlesource.com/605048
Commit-Queue: Yoland Yan <yolandyan@chromium.org>
Reviewed-by: Paul Jensen <pauljensen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#495585}
  • Loading branch information
Yoland Yan authored and Commit Bot committed Aug 18, 2017
1 parent ed864a4 commit 3381ca9
Show file tree
Hide file tree
Showing 23 changed files with 645 additions and 189 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,25 @@

package org.chromium.net;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

import static org.chromium.base.CollectionUtil.newHashSet;
import static org.chromium.net.CronetTestRule.getContext;

import android.support.test.filters.SmallTest;

import org.json.JSONObject;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;
import org.chromium.net.CronetTestRule.OnlyRunNativeCronet;
import org.chromium.net.MetricsTestUtil.TestRequestFinishedListener;
Expand All @@ -21,7 +34,12 @@
/**
* Tests functionality of BidirectionalStream's QUIC implementation.
*/
public class BidirectionalStreamQuicTest extends CronetTestBase {
@RunWith(BaseJUnit4ClassRunner.class)
public class BidirectionalStreamQuicTest {
@SuppressFBWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
@Rule
public final CronetTestRule mTestRule = new CronetTestRule();

private ExperimentalCronetEngine mCronetEngine;
private enum QuicBidirectionalStreams {
ENABLED,
Expand Down Expand Up @@ -56,12 +74,12 @@ private void setUp(QuicBidirectionalStreams enabled) throws Exception {
mCronetEngine = builder.build();
}

@Override
protected void tearDown() throws Exception {
@After
public void tearDown() throws Exception {
QuicTestServer.shutdownQuicTestServer();
super.tearDown();
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand All @@ -84,6 +102,7 @@ public void testSimpleGet() throws Exception {
assertEquals("quic/1+spdy/3", callback.mResponseInfo.getNegotiatedProtocol());
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down Expand Up @@ -125,6 +144,7 @@ public void testSimplePost() throws Exception {
assertEquals("quic/1+spdy/3", callback.mResponseInfo.getNegotiatedProtocol());
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down Expand Up @@ -158,6 +178,7 @@ public void testSimplePostWithFlush() throws Exception {
}
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down Expand Up @@ -194,6 +215,7 @@ public void testSimplePostWithFlushTwice() throws Exception {
}
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down Expand Up @@ -238,6 +260,7 @@ public void onStreamReady(BidirectionalStream stream) {
}
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down Expand Up @@ -269,6 +292,7 @@ public void testSimplePostWithFlushAfterOneWrite() throws Exception {
}
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand All @@ -290,6 +314,7 @@ public void testQuicBidirectionalStreamDisabled() throws Exception {
assertNull(callback.mResponseInfo);
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down Expand Up @@ -339,6 +364,7 @@ public void onWriteCompleted(BidirectionalStream stream, UrlResponseInfo info,
assertTrue(callback.mError instanceof QuicException);
}

@Test
@SmallTest
@Feature({"Cronet"})
@OnlyRunNativeCronet
Expand Down
Loading

0 comments on commit 3381ca9

Please sign in to comment.