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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/SuggestionAnswerTest.java

Issue 744453002: Fix a bunch of Java Checkstyle issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NeedsBraces to info Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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.omnibox; 5 package org.chromium.chrome.browser.omnibox;
6 6
7 import android.test.suitebuilder.annotation.SmallTest; 7 import android.test.suitebuilder.annotation.SmallTest;
8 8
9 import junit.framework.TestCase; 9 import junit.framework.TestCase;
10 10
11 public class SuggestionAnswerTest extends TestCase { 11 public class SuggestionAnswerTest extends TestCase {
12 @SmallTest 12 @SmallTest
13 public void testMalformedJsonReturnsNull() { 13 public void testMalformedJsonReturnsNull() {
14 String json = "} malformed json {"; 14 String json = "} malformed json {";
15 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 15 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
16 assertNull(answer); 16 assertNull(answer);
17 } 17 }
18 18
19 @SmallTest 19 @SmallTest
20 public void testEmpyJsonReturnsNull() { 20 public void testEmpyJsonReturnsNull() {
21 String json = ""; 21 String json = "";
22 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 22 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
23 assertNull(answer); 23 assertNull(answer);
24 } 24 }
25 25
26 @SmallTest 26 @SmallTest
27 public void testOneLineReturnsNull() { 27 public void testOneLineReturnsNull() {
28 String json = 28 String json = "{ 'l': ["
29 "{ 'l': [" + 29 + " { 'il': { 't': [{ 't': 'text', 'tt': 8 }] } }, "
30 " { 'il': { 't': [{ 't': 'text', 'tt': 8 }] } }, " + 30 + "] }";
31 "] }";
32 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 31 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
33 assertNull(answer); 32 assertNull(answer);
34 } 33 }
35 34
36 @SmallTest 35 @SmallTest
37 public void testTwoLinesDoesntReturnNull() { 36 public void testTwoLinesDoesntReturnNull() {
38 String json = 37 String json = "{ 'l': ["
39 "{ 'l': [" + 38 + " { 'il': { 't': [{ 't': 'text', 'tt': 8 }] } }, "
40 " { 'il': { 't': [{ 't': 'text', 'tt': 8 }] } }, " + 39 + " { 'il': { 't': [{ 't': 'other text', 'tt': 5 }] } }"
41 " { 'il': { 't': [{ 't': 'other text', 'tt': 5 }] } }" + 40 + "] }";
42 "] }";
43 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 41 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
44 assertNotNull(answer); 42 assertNotNull(answer);
45 } 43 }
46 44
47 @SmallTest 45 @SmallTest
48 public void testThreeLinesReturnsNull() { 46 public void testThreeLinesReturnsNull() {
49 String json = 47 String json = "{ 'l': ["
50 "{ 'l': [" + 48 + " { 'il': { 't': [{ 't': 'text', 'tt': 8 }] } }, "
51 " { 'il': { 't': [{ 't': 'text', 'tt': 8 }] } }, " + 49 + " { 'il': { 't': [{ 't': 'other text', 'tt': 5 }] } }"
52 " { 'il': { 't': [{ 't': 'other text', 'tt': 5 }] } }" + 50 + " { 'il': { 't': [{ 't': 'yet more text', 'tt': 13 }] } }"
53 " { 'il': { 't': [{ 't': 'yet more text', 'tt': 13 }] } }" + 51 + "] }";
54 "] }";
55 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 52 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
56 assertNull(answer); 53 assertNull(answer);
57 } 54 }
58 55
59 @SmallTest 56 @SmallTest
60 public void testFiveLinesReturnsNull() { 57 public void testFiveLinesReturnsNull() {
61 String json = 58 String json = "{ 'l': ["
62 "{ 'l': [" + 59 + " { 'il': { 't': [{ 't': 'line 1', 'tt': 0 }] } }, "
63 " { 'il': { 't': [{ 't': 'line 1', 'tt': 0 }] } }, " + 60 + " { 'il': { 't': [{ 't': 'line 2', 'tt': 5 }] } }"
64 " { 'il': { 't': [{ 't': 'line 2', 'tt': 5 }] } }" + 61 + " { 'il': { 't': [{ 't': 'line 3', 'tt': 13 }] } }"
65 " { 'il': { 't': [{ 't': 'line 3', 'tt': 13 }] } }" + 62 + " { 'il': { 't': [{ 't': 'line 4', 'tt': 14 }] } }"
66 " { 'il': { 't': [{ 't': 'line 4', 'tt': 14 }] } }" + 63 + " { 'il': { 't': [{ 't': 'line 5', 'tt': 5 }] } }"
67 " { 'il': { 't': [{ 't': 'line 5', 'tt': 5 }] } }" + 64 + "] }";
68 "] }";
69 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 65 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
70 assertNull(answer); 66 assertNull(answer);
71 } 67 }
72 68
73 @SmallTest 69 @SmallTest
74 public void testPropertyPresence() { 70 public void testPropertyPresence() {
75 String json = 71 String json = "{ 'l': ["
76 "{ 'l': [" + 72 + " { 'il': { 't': [{ 't': 'text', 'tt': 8 }, { 't': 'moar', 't t': 0 }], "
77 " { 'il': { 't': [{ 't': 'text', 'tt': 8 }, { 't': 'moar', 'tt' : 0 }], " + 73 + " 'i': { 'd': 'http://example.com/foo.jpg' } } }, "
78 " 'i': { 'd': 'http://example.com/foo.jpg' } } }, " + 74 + " { 'il': { 't': [{ 't': 'other text', 'tt': 5 }], "
79 " { 'il': { 't': [{ 't': 'other text', 'tt': 5 }], " + 75 + " 'at': { 't': 'slatfotf', 'tt': 42 }, "
80 " 'at': { 't': 'slatfotf', 'tt': 42 }, " + 76 + " 'st': { 't': 'oh hi, Mark', 'tt': 7666 } } } "
81 " 'st': { 't': 'oh hi, Mark', 'tt': 7666 } } } " + 77 + "] }";
82 "] }";
83 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 78 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
84 79
85 SuggestionAnswer.ImageLine firstLine = answer.getFirstLine(); 80 SuggestionAnswer.ImageLine firstLine = answer.getFirstLine();
86 assertEquals(2, firstLine.getTextFields().size()); 81 assertEquals(2, firstLine.getTextFields().size());
87 assertFalse(firstLine.hasAdditionalText()); 82 assertFalse(firstLine.hasAdditionalText());
88 assertFalse(firstLine.hasStatusText()); 83 assertFalse(firstLine.hasStatusText());
89 assertTrue(firstLine.hasImage()); 84 assertTrue(firstLine.hasImage());
90 85
91 SuggestionAnswer.ImageLine secondLine = answer.getSecondLine(); 86 SuggestionAnswer.ImageLine secondLine = answer.getSecondLine();
92 assertEquals(1, secondLine.getTextFields().size()); 87 assertEquals(1, secondLine.getTextFields().size());
93 assertTrue(secondLine.hasAdditionalText()); 88 assertTrue(secondLine.hasAdditionalText());
94 assertTrue(secondLine.hasStatusText()); 89 assertTrue(secondLine.hasStatusText());
95 assertFalse(secondLine.hasImage()); 90 assertFalse(secondLine.hasImage());
96 } 91 }
97 92
98 @SmallTest 93 @SmallTest
99 public void testContents() { 94 public void testContents() {
100 String json = 95 String json = "{ 'l': ["
101 "{ 'l': [" + 96 + " { 'il': { 't': [{ 't': 'text', 'tt': 8 }, { 't': 'moar', 't t': 0 }], "
102 " { 'il': { 't': [{ 't': 'text', 'tt': 8 }, { 't': 'moar', 'tt' : 0 }], " + 97 + " 'at': { 't': 'hi there', 'tt': 7 } } }, "
103 " 'at': { 't': 'hi there', 'tt': 7 } } }, " + 98 + " { 'il': { 't': [{ 't': 'ftw', 'tt': 6006 }], "
104 " { 'il': { 't': [{ 't': 'ftw', 'tt': 6006 }], " + 99 + " 'st': { 't': 'shop S-Mart', 'tt': 666 }, "
105 " 'st': { 't': 'shop S-Mart', 'tt': 666 }, " + 100 + " 'i': { 'd': 'Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aG lj' } } } "
106 " 'i': { 'd': 'Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGlj ' } } } " + 101 + "] }";
107 "] }";
108 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); 102 SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json);
109 103
110 SuggestionAnswer.ImageLine firstLine = answer.getFirstLine(); 104 SuggestionAnswer.ImageLine firstLine = answer.getFirstLine();
111 assertEquals("text", firstLine.getTextFields().get(0).getText()); 105 assertEquals("text", firstLine.getTextFields().get(0).getText());
112 assertEquals(8, firstLine.getTextFields().get(0).getType()); 106 assertEquals(8, firstLine.getTextFields().get(0).getType());
113 assertEquals("moar", firstLine.getTextFields().get(1).getText()); 107 assertEquals("moar", firstLine.getTextFields().get(1).getText());
114 assertEquals(0, firstLine.getTextFields().get(1).getType()); 108 assertEquals(0, firstLine.getTextFields().get(1).getType());
115 assertEquals("hi there", firstLine.getAdditionalText().getText()); 109 assertEquals("hi there", firstLine.getAdditionalText().getText());
116 assertEquals(7, firstLine.getAdditionalText().getType()); 110 assertEquals(7, firstLine.getAdditionalText().getType());
117 111
118 SuggestionAnswer.ImageLine secondLine = answer.getSecondLine(); 112 SuggestionAnswer.ImageLine secondLine = answer.getSecondLine();
119 assertEquals("ftw", secondLine.getTextFields().get(0).getText()); 113 assertEquals("ftw", secondLine.getTextFields().get(0).getText());
120 assertEquals(6006, secondLine.getTextFields().get(0).getType()); 114 assertEquals(6006, secondLine.getTextFields().get(0).getType());
121 assertEquals("shop S-Mart", secondLine.getStatusText().getText()); 115 assertEquals("shop S-Mart", secondLine.getStatusText().getText());
122 assertEquals(666, secondLine.getStatusText().getType()); 116 assertEquals(666, secondLine.getStatusText().getType());
123 assertEquals("Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGlj", secondLine.getIma ge()); 117 assertEquals("Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGlj", secondLine.getIma ge());
124 } 118 }
125 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698