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

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

Issue 332943002: [AiS] Add a structured representation of Answer JSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
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);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698