Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / components / cronet / android / sample / javatests / src / org / chromium / cronet_sample_apk / HttpUrlRequestFactoryTest.java
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.
4
5 package org.chromium.cronet_sample_apk;
6
7 import android.test.InstrumentationTestCase;
8 import android.test.suitebuilder.annotation.SmallTest;
9
10 import org.chromium.base.test.util.Feature;
11 import org.chromium.net.HttpUrlRequestFactory;
12 import org.chromium.net.HttpUrlRequestFactoryConfig;
13
14 import java.util.regex.Pattern;
15
16 /**
17  * Tests for {@link ChunkedWritableByteChannel}
18  */
19 public class HttpUrlRequestFactoryTest extends InstrumentationTestCase {
20     @SmallTest
21     @Feature({"Cronet"})
22     public void testCreateFactory() {
23         HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig();
24         HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
25                 getInstrumentation().getContext(), config);
26         assertNotNull("Factory should be created", factory);
27         assertTrue("Factory should be Chromium/n.n.n.n/r",
28                    Pattern.matches("Chromium/\\d+\\.\\d+\\.\\d+\\.\\d+@\\d+",
29                    factory.getName()));
30     }
31
32     @SmallTest
33     @Feature({"Cronet"})
34     public void testCreateLegacyFactory() {
35         HttpUrlRequestFactoryConfig config = new HttpUrlRequestFactoryConfig();
36         config.enableLegacyMode(true);
37
38         HttpUrlRequestFactory factory = HttpUrlRequestFactory.createFactory(
39                 getInstrumentation().getContext(), config);
40         assertNotNull("Factory should be created", factory);
41         assertTrue("Factory should be HttpUrlConnection/n.n.n.n@r",
42                    Pattern.matches("HttpUrlConnection/\\d+\\.\\d+\\.\\d+\\.\\d+@\\d+",
43                    factory.getName()));
44     }
45 }