Chromium Code Reviews| Index: chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/SuggestionAnswerTest.java |
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/SuggestionAnswerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/SuggestionAnswerTest.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d021164b107611d7368b377d054aa82fbd6121ec |
| --- /dev/null |
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/omnibox/SuggestionAnswerTest.java |
| @@ -0,0 +1,41 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +package org.chromium.chrome.browser.omnibox; |
| + |
| +import android.test.suitebuilder.annotation.SmallTest; |
| + |
| +import junit.framework.TestCase; |
| + |
| +public class SuggestionAnswerTest extends TestCase { |
| + @SmallTest |
| + public void testMalformedJsonReturnsNull() { |
| + String json = "} malformed json {"; |
| + SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); |
| + assertNull(answer); |
| + } |
| + |
| + @SmallTest |
| + public void testEmpyJsonReturnsNull() { |
| + String json = ""; |
| + SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); |
| + assertNull(answer); |
| + } |
| + |
| + @SmallTest |
| + public void testOneLineReturnsNull() { |
| + String json = "{ \"l\": [ { \"il\": { \"t\": [{\"t\": \"text\", \"tt\": 8 }] }} ] }"; |
|
groby-ooo-7-16
2014/06/12 23:10:49
That's rather hard to read - I'd prefer using sing
Justin Donnelly
2014/06/17 21:34:03
No need to replace, I should've just used single q
|
| + SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); |
| + assertNull(answer); |
| + } |
| + |
| + @SmallTest |
| + public void testTwoLinesDoesntReturnNull() { |
| + String json = |
| + "{ \"l\": [ { \"il\": { \"t\": [{\"t\": \"text\", \"tt\": 8 }] }}, " + |
| + "{ \"il\": { \"t\": [{\"t\": \"other text\", \"tt\": 5 }] }} ] }"; |
| + SuggestionAnswer answer = SuggestionAnswer.parseAnswerContents(json); |
| + assertNotNull(answer); |
| + } |
| +} |