1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.cronet_sample_apk;
7 import android.test.suitebuilder.annotation.SmallTest;
9 import org.chromium.base.test.util.Feature;
12 * Example test that just starts the cronet sample.
14 public class CronetSampleUrlTest extends CronetSampleTestBase {
15 // URL used for base tests.
16 private static final String URL = "http://127.0.0.1:8000";
20 public void testLoadUrl() throws Exception {
21 CronetSampleActivity activity = launchCronetSampleWithUrl(URL);
23 // Make sure the activity was created as expected.
24 assertNotNull(activity);
26 waitForActiveShellToBeDoneLoading();
28 // Make sure that the URL is set as expected.
29 assertEquals(URL, activity.getUrl());
30 assertEquals(200, activity.getHttpStatusCode());
35 public void testInvalidUrl() throws Exception {
36 CronetSampleActivity activity = launchCronetSampleWithUrl(
39 // Make sure the activity was created as expected.
40 assertNotNull(activity);
42 waitForActiveShellToBeDoneLoading();
44 // The load should fail.
45 assertEquals(0, activity.getHttpStatusCode());
50 public void testPostData() throws Exception {
51 String[] commandLineArgs = {
52 CronetSampleActivity.POST_DATA_KEY, "test" };
53 CronetSampleActivity activity =
54 launchCronetSampleWithUrlAndCommandLineArgs(URL,
57 // Make sure the activity was created as expected.
58 assertNotNull(activity);
60 waitForActiveShellToBeDoneLoading();
62 // Make sure that the URL is set as expected.
63 assertEquals(URL, activity.getUrl());
64 // TODO(mef): The test server doesn't seem to work with chunked uploads.
65 assertEquals(411, activity.getHttpStatusCode());