This source file includes following definitions.
- Feature
- testLoadUrl
- Feature
- testInvalidUrl
- Feature
- testPostData
package org.chromium.cronet_sample_apk;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.test.util.Feature;
public class CronetSampleUrlTest extends CronetSampleTestBase {
private static final String URL = "http://127.0.0.1:8000";
@SmallTest
@Feature({"Cronet"})
public void testLoadUrl() throws Exception {
CronetSampleActivity activity = launchCronetSampleWithUrl(URL);
assertNotNull(activity);
waitForActiveShellToBeDoneLoading();
assertEquals(URL, activity.getUrl());
assertEquals(200, activity.getHttpStatusCode());
}
@SmallTest
@Feature({"Cronet"})
public void testInvalidUrl() throws Exception {
CronetSampleActivity activity = launchCronetSampleWithUrl(
"127.0.0.1:8000");
assertNotNull(activity);
waitForActiveShellToBeDoneLoading();
assertEquals(0, activity.getHttpStatusCode());
}
@SmallTest
@Feature({"Cronet"})
public void testPostData() throws Exception {
String[] commandLineArgs = {
CronetSampleActivity.POST_DATA_KEY, "test" };
CronetSampleActivity activity =
launchCronetSampleWithUrlAndCommandLineArgs(URL,
commandLineArgs);
assertNotNull(activity);
waitForActiveShellToBeDoneLoading();
assertEquals(URL, activity.getUrl());
assertEquals(200, activity.getHttpStatusCode());
}
}