OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.content.browser.input; |
| 6 |
| 7 import android.util.StringBuilderPrinter; |
| 8 import android.view.inputmethod.CorrectionInfo; |
| 9 import android.view.inputmethod.EditorInfo; |
| 10 |
| 11 import org.chromium.base.ThreadUtils; |
| 12 |
| 13 /** |
| 14 * Utilities for IME-related classes. |
| 15 */ |
| 16 public class ImeUtils { |
| 17 /** |
| 18 * Dump the given {@EditorInfo} into class. |
| 19 * @param editorInfo |
| 20 * @return User-readable {@EditorInfo}. |
| 21 */ |
| 22 static String dumpEditorInfo(EditorInfo editorInfo) { |
| 23 StringBuilder builder = new StringBuilder(); |
| 24 StringBuilderPrinter printer = new StringBuilderPrinter(builder); |
| 25 editorInfo.dump(printer, ""); |
| 26 return builder.toString(); |
| 27 } |
| 28 |
| 29 /** |
| 30 * Dump the given {@CorrectionInfo} into class. |
| 31 * @param correctionInfo |
| 32 * @return User-readable {@CorrectionInfo}. |
| 33 */ |
| 34 static String dumpCorrectionInfo(CorrectionInfo correctionInfo) { |
| 35 // TODO(changwan): implement it properly if needed. |
| 36 return correctionInfo.toString(); |
| 37 } |
| 38 |
| 39 // TODO(changwan): remove these once implementation becomes stable. |
| 40 static void assertReally(boolean value) { |
| 41 if (!value) { |
| 42 throw new AssertionError(); |
| 43 } |
| 44 } |
| 45 |
| 46 static void assertReally(String msg, boolean value) { |
| 47 if (!value) { |
| 48 throw new AssertionError(msg); |
| 49 } |
| 50 } |
| 51 |
| 52 static void assertNotOnUiThread() { |
| 53 assertReally("Should not be on UI thread.", !ThreadUtils.runningOnUiThre
ad()); |
| 54 } |
| 55 |
| 56 static void assertOnUiThread() { |
| 57 assertReally("Should be on UI thread.", ThreadUtils.runningOnUiThread())
; |
| 58 } |
| 59 } |
OLD | NEW |