Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(263)

Side by Side Diff: components/cronet/android/test/javatests/src/org/chromium/net/UrlResponseInfoTest.java

Issue 1419033006: [Cronet] Make UrlResponseInfo constuctor public for testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address nits Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/cronet/android/api/src/org/chromium/net/UrlResponseInfo.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 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.net;
6
7 import static junit.framework.Assert.assertEquals;
8
9 import android.test.AndroidTestCase;
10 import android.test.suitebuilder.annotation.SmallTest;
11
12 import org.chromium.base.test.util.Feature;
13
14 import java.util.AbstractMap;
15 import java.util.ArrayList;
16 import java.util.List;
17 import java.util.Map;
18
19 /**
20 * Tests for {@link UrlResponseInfo}.
21 */
22 public class UrlResponseInfoTest extends AndroidTestCase {
23 /**
24 * Test for public API of {@link UrlResponseInfo}.
25 */
26 @SmallTest
27 @Feature({"Cronet"})
28 public void testPublicAPI() throws Exception {
29 final List<String> urlChain = new ArrayList<String>();
30 urlChain.add("chromium.org");
31 final int httpStatusCode = 200;
32 final String httpStatusText = "OK";
33 final List<Map.Entry<String, String>> allHeadersList =
34 new ArrayList<Map.Entry<String, String>>();
35 allHeadersList.add(new AbstractMap.SimpleImmutableEntry<String, String>(
36 "Date", "Fri, 30 Oct 2015 14:26:41 GMT"));
37 final boolean wasCached = true;
38 final String negotiatedProtocol = "quic/1+spdy/3";
39 final String proxyServer = "example.com";
40
41 final UrlResponseInfo info = new UrlResponseInfo(urlChain, httpStatusCod e, httpStatusText,
42 allHeadersList, wasCached, negotiatedProtocol, proxyServer);
43 assertEquals(info.getUrlChain(), urlChain);
44 try {
45 info.getUrlChain().add("example.com");
46 fail("getUrlChain() returned modifyable list.");
47 } catch (UnsupportedOperationException e) {
48 // Expected.
49 }
50 assertEquals(info.getHttpStatusCode(), httpStatusCode);
51 assertEquals(info.getHttpStatusText(), httpStatusText);
52 assertEquals(info.getAllHeadersAsList(), allHeadersList);
53 try {
54 info.getAllHeadersAsList().add(
55 new AbstractMap.SimpleImmutableEntry<String, String>("X", "Y "));
56 fail("getAllHeadersAsList() returned modifyable list.");
57 } catch (UnsupportedOperationException e) {
58 // Expected.
59 }
60 assertEquals(info.getAllHeaders().size(), allHeadersList.size());
61 assertEquals(info.getAllHeaders().get(allHeadersList.get(0).getKey()).si ze(), 1);
62 assertEquals(info.getAllHeaders().get(allHeadersList.get(0).getKey()).ge t(0),
63 allHeadersList.get(0).getValue());
64 assertEquals(info.wasCached(), wasCached);
65 assertEquals(info.getNegotiatedProtocol(), negotiatedProtocol);
66 assertEquals(info.getProxyServer(), proxyServer);
67 }
68 }
OLDNEW
« no previous file with comments | « components/cronet/android/api/src/org/chromium/net/UrlResponseInfo.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698