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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/physicalweb/PwsResultTest.java

Issue 2722623003: Move PwsResultTest to junit (Closed)
Patch Set: Rebase Created 3 years, 9 months 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 | « chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/PwsResultTest.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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser.physicalweb; 5 package org.chromium.chrome.browser.physicalweb;
6 6
7 import android.support.test.filters.SmallTest; 7 import static org.junit.Assert.assertEquals;
8
9 import junit.framework.TestCase;
10 8
11 import org.json.JSONException; 9 import org.json.JSONException;
12 import org.json.JSONObject; 10 import org.json.JSONObject;
13 11
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.junit.runner.RunWith;
15 import org.junit.runners.BlockJUnit4ClassRunner;
16
14 /** 17 /**
15 * Tests for {@link PwsResult}. 18 * Tests for {@link PwsResult}.
16 */ 19 */
17 public class PwsResultTest extends TestCase { 20 @RunWith(BlockJUnit4ClassRunner.class)
21 public class PwsResultTest {
18 PwsResult mReferencePwsResult = null; 22 PwsResult mReferencePwsResult = null;
19 JSONObject mReferenceJsonObject = null; 23 JSONObject mReferenceJsonObject = null;
20 24
21 @Override 25 @Before
22 protected void setUp() throws Exception { 26 public void setUp() throws Exception {
23 super.setUp(); 27 mReferencePwsResult = new PwsResult("https://shorturl.com", "https://lon gurl.com",
24 mReferencePwsResult = new PwsResult( 28 "https://longurl.com/favicon.ico", "This is a page", "Pages are the best",
25 "https://shorturl.com",
26 "https://longurl.com",
27 "https://longurl.com/favicon.ico",
28 "This is a page",
29 "Pages are the best",
30 "group1"); 29 "group1");
31 // Because we can't print JSON sorted by keys, the order is important he re. 30 // Because we can't print JSON sorted by keys, the order is important he re.
32 mReferenceJsonObject = new JSONObject("{" 31 mReferenceJsonObject = new JSONObject("{"
33 + " \"scannedUrl\": \"https://shorturl.com\"," 32 + " \"scannedUrl\": \"https://shorturl.com\","
34 + " \"resolvedUrl\": \"https://longurl.com\"," 33 + " \"resolvedUrl\": \"https://longurl.com\","
35 + " \"icon\": \"https://longurl.com/favicon.ico\"," 34 + " \"pageInfo\": {"
36 + " \"title\": \"This is a page\"," 35 + " \"icon\": \"https://longurl.com/favicon.ico\","
37 + " \"description\": \"Pages are the best\"," 36 + " \"title\": \"This is a page\","
38 + " \"group\": \"group1\"" 37 + " \"description\": \"Pages are the best\","
38 + " \"groupId\": \"group1\""
39 + " }"
39 + "}"); 40 + "}");
40 } 41 }
41 42
42 @SmallTest 43 @Test
43 public void testJsonSerializeWorks() throws JSONException { 44 public void testJsonSerializeWorks() throws JSONException {
44 assertEquals(mReferenceJsonObject.toString(), 45 assertEquals(
45 mReferencePwsResult.jsonSerialize().toString()); 46 mReferenceJsonObject.toString(), mReferencePwsResult.jsonSeriali ze().toString());
46 } 47 }
47 48
48 @SmallTest 49 @Test
49 public void testJsonDeserializeWorks() throws JSONException { 50 public void testJsonDeserializeWorks() throws JSONException {
50 PwsResult pwsResult = PwsResult.jsonDeserialize(mReferenceJsonObject); 51 PwsResult pwsResult = PwsResult.jsonDeserialize(mReferenceJsonObject);
51 assertEquals(mReferencePwsResult.requestUrl, pwsResult.requestUrl); 52 assertEquals(mReferencePwsResult.requestUrl, pwsResult.requestUrl);
52 assertEquals(mReferencePwsResult.responseUrl, pwsResult.responseUrl); 53 assertEquals(mReferencePwsResult.siteUrl, pwsResult.siteUrl);
53 assertEquals(mReferencePwsResult.iconUrl, pwsResult.iconUrl); 54 assertEquals(mReferencePwsResult.iconUrl, pwsResult.iconUrl);
54 assertEquals(mReferencePwsResult.title, pwsResult.title); 55 assertEquals(mReferencePwsResult.title, pwsResult.title);
55 assertEquals(mReferencePwsResult.description, pwsResult.description); 56 assertEquals(mReferencePwsResult.description, pwsResult.description);
56 assertEquals(mReferencePwsResult.group, pwsResult.group); 57 assertEquals(mReferencePwsResult.groupId, pwsResult.groupId);
57 } 58 }
58 } 59 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/physicalweb/PwsResultTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698