From bc10e4145ea3d48b577ea3eed3675b2bf6546073 Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Fri, 20 Jan 2012 15:35:27 +0900 Subject: [PATCH] Enable DEBUG mode for logic tests. This enables a wealth of useful checks. We want to run unit tests with debug mode on. Change-Id: Ic45caaf43a889287f5aec203e7d1ba63136fc58e --- .../inputmethod/latin/InputLogicTests.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index 18afe1198..06ee5bffa 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -18,6 +18,8 @@ package com.android.inputmethod.latin; import android.content.Context; import android.content.Intent; +import android.content.SharedPreferences; +import android.preference.PreferenceManager; import android.test.ServiceTestCase; import android.text.InputType; import android.util.Log; @@ -35,6 +37,8 @@ import com.android.inputmethod.keyboard.KeyboardActionListener; public class InputLogicTests extends ServiceTestCase { + private static final String PREF_DEBUG_MODE = "debug_mode"; + private LatinIME mLatinIME; private TextView mTextView; @@ -42,6 +46,16 @@ public class InputLogicTests extends ServiceTestCase { super(LatinIME.class); } + // returns the previous setting value + private boolean setDebugMode(final boolean mode) { + final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); + final boolean previousDebugSetting = prefs.getBoolean(PREF_DEBUG_MODE, false); + final SharedPreferences.Editor editor = prefs.edit(); + editor.putBoolean(PREF_DEBUG_MODE, true); + editor.commit(); + return previousDebugSetting; + } + @Override protected void setUp() { try { @@ -54,7 +68,9 @@ public class InputLogicTests extends ServiceTestCase { mTextView.setEnabled(true); setupService(); mLatinIME = getService(); + final boolean previousDebugSetting = setDebugMode(true); mLatinIME.onCreate(); + setDebugMode(previousDebugSetting); final EditorInfo ei = new EditorInfo(); final InputConnection ic = mTextView.onCreateInputConnection(ei); final LayoutInflater inflater =