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

Side by Side Diff: chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java

Issue 2735133003: [Cleanup] Run git cl format on minidump uploader files. (Closed)
Patch Set: Manually revert questionable changes 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
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.crash; 5 package org.chromium.chrome.browser.crash;
6 6
7 import static org.junit.Assert.assertArrayEquals; 7 import static org.junit.Assert.assertArrayEquals;
8 import static org.junit.Assert.assertEquals; 8 import static org.junit.Assert.assertEquals;
9 9
10 import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.BEGIN_M ICRODUMP; 10 import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.BEGIN_M ICRODUMP;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 @Test 127 @Test
128 public void testLogcatEmpty() { 128 public void testLogcatEmpty() {
129 final List<String> original = new LinkedList<>(); 129 final List<String> original = new LinkedList<>();
130 assertLogcatLists(original, original); 130 assertLogcatLists(original, original);
131 } 131 }
132 132
133 @Test 133 @Test
134 public void testLogcatWithoutBeginOrEnd_smallLogcat() { 134 public void testLogcatWithoutBeginOrEnd_smallLogcat() {
135 final List<String> original = Arrays.asList("Line 1", "Line 2", "Line 3" , "Line 4", 135 final List<String> original =
136 "Line 5"); 136 Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4", "Line 5");
137 assertLogcatLists(original, original); 137 assertLogcatLists(original, original);
138 } 138 }
139 139
140 @Test 140 @Test
141 public void testLogcatWithoutBeginOrEnd_largeLogcat() { 141 public void testLogcatWithoutBeginOrEnd_largeLogcat() {
142 final List<String> original = Arrays.asList("Trimmed Line 1", "Trimmed L ine 2", "Line 3", 142 final List<String> original = Arrays.asList("Trimmed Line 1", "Trimmed L ine 2", "Line 3",
143 "Line 4", "Line 5", "Line 6", "Line 7"); 143 "Line 4", "Line 5", "Line 6", "Line 7");
144 final List<String> expected = 144 final List<String> expected =
145 Arrays.asList("Line 3", "Line 4", "Line 5", "Line 6", "Line 7"); 145 Arrays.asList("Line 3", "Line 4", "Line 5", "Line 6", "Line 7");
146 assertLogcatLists(expected, original); 146 assertLogcatLists(expected, original);
147 } 147 }
148 148
149 @Test 149 @Test
150 public void testLogcatBeginsWithBegin() { 150 public void testLogcatBeginsWithBegin() {
151 final List<String> original = Arrays.asList(BEGIN_MICRODUMP, "a", "b", " c", "d", "e"); 151 final List<String> original = Arrays.asList(BEGIN_MICRODUMP, "a", "b", " c", "d", "e");
152 final List<String> expected = Arrays.asList(SNIPPED_MICRODUMP); 152 final List<String> expected = Arrays.asList(SNIPPED_MICRODUMP);
153 assertLogcatLists(expected, original); 153 assertLogcatLists(expected, original);
154 } 154 }
155 155
156 @Test 156 @Test
157 public void testLogcatWithBegin() { 157 public void testLogcatWithBegin() {
158 final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MI CRODUMP, "a", 158 final List<String> original =
159 "b", "c", "d", "e"); 159 Arrays.asList("Line 1", "Line 2", BEGIN_MICRODUMP, "a", "b", "c" , "d", "e");
160 final List<String> expected = Arrays.asList("Line 1", "Line 2", SNIPPED_ MICRODUMP); 160 final List<String> expected = Arrays.asList("Line 1", "Line 2", SNIPPED_ MICRODUMP);
161 assertLogcatLists(expected, original); 161 assertLogcatLists(expected, original);
162 } 162 }
163 163
164 @Test 164 @Test
165 public void testLogcatWithEnd() { 165 public void testLogcatWithEnd() {
166 final List<String> original = Arrays.asList("Line 1", "Line 2", END_MICR ODUMP); 166 final List<String> original = Arrays.asList("Line 1", "Line 2", END_MICR ODUMP);
167 assertLogcatLists(original, original); 167 assertLogcatLists(original, original);
168 } 168 }
169 169
170 @Test 170 @Test
171 public void testLogcatWithBeginAndEnd_smallLogcat() { 171 public void testLogcatWithBeginAndEnd_smallLogcat() {
172 final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MI CRODUMP, "a", "b", 172 final List<String> original = Arrays.asList(
173 "c", "d", "e", END_MICRODUMP); 173 "Line 1", "Line 2", BEGIN_MICRODUMP, "a", "b", "c", "d", "e", EN D_MICRODUMP);
174 final List<String> expected = Arrays.asList("Line 1", "Line 2", SNIPPED_ MICRODUMP); 174 final List<String> expected = Arrays.asList("Line 1", "Line 2", SNIPPED_ MICRODUMP);
175 assertLogcatLists(expected, original); 175 assertLogcatLists(expected, original);
176 } 176 }
177 177
178 @Test 178 @Test
179 public void testLogcatWithBeginAndEnd_splitLogcat() { 179 public void testLogcatWithBeginAndEnd_splitLogcat() {
180 final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MI CRODUMP, "a", "b", 180 final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MI CRODUMP, "a", "b",
181 "c", "d", "e", END_MICRODUMP, "Trimmed Line 3", "Trimmed Line 4" ); 181 "c", "d", "e", END_MICRODUMP, "Trimmed Line 3", "Trimmed Line 4" );
182 final List<String> expected = Arrays.asList("Line 1", "Line 2", SNIPPED_ MICRODUMP); 182 final List<String> expected = Arrays.asList("Line 1", "Line 2", SNIPPED_ MICRODUMP);
183 assertLogcatLists(expected, original); 183 assertLogcatLists(expected, original);
184 } 184 }
185 185
186 @Test 186 @Test
187 public void testLogcatWithBeginAndEnd_largeLogcat() { 187 public void testLogcatWithBeginAndEnd_largeLogcat() {
188 final List<String> original = Arrays.asList("Trimmed Line 1", "Trimmed L ine 2", "Line 3", 188 final List<String> original = Arrays.asList("Trimmed Line 1", "Trimmed L ine 2", "Line 3",
189 "Line 4", "Line 5", "Line 6", BEGIN_MICRODUMP, "a", "b", "c", "d ", "e", 189 "Line 4", "Line 5", "Line 6", BEGIN_MICRODUMP, "a", "b", "c", "d ", "e",
190 END_MICRODUMP, "Trimmed Line 7", "Trimmed Line 8"); 190 END_MICRODUMP, "Trimmed Line 7", "Trimmed Line 8");
191 final List<String> expected = 191 final List<String> expected =
192 Arrays.asList("Line 3", "Line 4", "Line 5", "Line 6", SNIPPED_MI CRODUMP); 192 Arrays.asList("Line 3", "Line 4", "Line 5", "Line 6", SNIPPED_MI CRODUMP);
193 assertLogcatLists(expected, original); 193 assertLogcatLists(expected, original);
194 } 194 }
195 195
196 @Test 196 @Test
197 public void testLogcatWithEndAndBegin_smallLogcat() { 197 public void testLogcatWithEndAndBegin_smallLogcat() {
198 final List<String> original = Arrays.asList(END_MICRODUMP, "Line 1", "Li ne 2", 198 final List<String> original = Arrays.asList(
199 BEGIN_MICRODUMP, "a", "b", "c", "d", "e"); 199 END_MICRODUMP, "Line 1", "Line 2", BEGIN_MICRODUMP, "a", "b", "c ", "d", "e");
200 final List<String> expected = 200 final List<String> expected =
201 Arrays.asList(END_MICRODUMP, "Line 1", "Line 2", SNIPPED_MICRODU MP); 201 Arrays.asList(END_MICRODUMP, "Line 1", "Line 2", SNIPPED_MICRODU MP);
202 assertLogcatLists(expected, original); 202 assertLogcatLists(expected, original);
203 } 203 }
204 204
205 @Test 205 @Test
206 public void testLogcatWithEndAndBegin_largeLogcat() { 206 public void testLogcatWithEndAndBegin_largeLogcat() {
207 final List<String> original = 207 final List<String> original =
208 Arrays.asList(END_MICRODUMP, "Line 1", "Line 2", BEGIN_MICRODUMP , "a", "b", "c", 208 Arrays.asList(END_MICRODUMP, "Line 1", "Line 2", BEGIN_MICRODUMP , "a", "b", "c",
209 "d", "e", END_MICRODUMP, "Trimmed Line 3", "Trimmed Line 4"); 209 "d", "e", END_MICRODUMP, "Trimmed Line 3", "Trimmed Line 4");
210 final List<String> expected = 210 final List<String> expected =
211 Arrays.asList(END_MICRODUMP, "Line 1", "Line 2", SNIPPED_MICRODU MP); 211 Arrays.asList(END_MICRODUMP, "Line 1", "Line 2", SNIPPED_MICRODU MP);
212 assertLogcatLists(expected, original); 212 assertLogcatLists(expected, original);
213 } 213 }
214 214
215 private void assertLogcatLists(List<String> expected, List<String> original) { 215 private void assertLogcatLists(List<String> expected, List<String> original) {
216 // trimLogcat() expects a modifiable list as input. 216 // trimLogcat() expects a modifiable list as input.
217 LinkedList<String> rawLogcat = new LinkedList<String>(original); 217 LinkedList<String> rawLogcat = new LinkedList<String>(original);
218 List<String> actualLogcat = LogcatExtractionCallable.trimLogcat(rawLogca t, MAX_LINES); 218 List<String> actualLogcat = LogcatExtractionCallable.trimLogcat(rawLogca t, MAX_LINES);
219 assertArrayEquals(expected.toArray(), actualLogcat.toArray()); 219 assertArrayEquals(expected.toArray(), actualLogcat.toArray());
220 } 220 }
221 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698