Upstream version 11.40.271.0
[platform/framework/web/crosswalk.git] / src / components / devtools_bridge / test / android / javatests / src / org / chromium / components / devtools_bridge / util / TestSource.java
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
3 // found in the LICENSE file.
4
5 package org.chromium.components.devtools_bridge.util;
6
7 import android.util.JsonReader;
8 import android.util.JsonWriter;
9
10 import java.io.StringReader;
11 import java.io.StringWriter;
12
13 /**
14  * Helper class for testing JSON-based readers.
15  */
16 public class TestSource {
17     private final StringWriter mSource;
18     private final JsonWriter mSourceWriter;
19
20     public TestSource() {
21         mSource = new StringWriter();
22         mSourceWriter = new JsonWriter(mSource);
23     }
24
25     public JsonReader read() {
26         return new JsonReader(new StringReader(mSource.toString()));
27     }
28
29     public JsonWriter write() {
30         return mSourceWriter;
31     }
32 }