diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java | 70 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/utils/EditDistanceTests.java | 99 |
2 files changed, 0 insertions, 169 deletions
diff --git a/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java b/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java index 273d7faf7..2ef8b548f 100644 --- a/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java +++ b/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java @@ -16,21 +16,14 @@ package com.android.inputmethod.latin.settings; -import static com.android.inputmethod.latin.settings.AccountsSettingsFragment.AUTHORITY; - -import android.accounts.Account; import android.app.AlertDialog; import android.app.Dialog; -import android.content.ContentResolver; import android.content.Intent; import android.test.ActivityInstrumentationTestCase2; import android.test.suitebuilder.annotation.MediumTest; import android.view.View; import android.widget.ListView; -import com.android.inputmethod.latin.accounts.LoginAccountUtils; -import com.android.inputmethod.latin.define.ProductionFlags; - import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -39,9 +32,6 @@ public class AccountsSettingsFragmentTests extends ActivityInstrumentationTestCase2<TestFragmentActivity> { private static final String FRAG_NAME = AccountsSettingsFragment.class.getName(); private static final long TEST_TIMEOUT_MILLIS = 5000; - private static final String TEST_ACCOUNT_NAME = "AccountsSettingsFragmentTests"; - private static final Account TEST_ACCOUNT = - new Account(TEST_ACCOUNT_NAME, LoginAccountUtils.ACCOUNT_TYPE); private AlertDialog mDialog; @@ -57,13 +47,6 @@ public class AccountsSettingsFragmentTests setActivityIntent(intent); } - @Override - protected void tearDown() throws Exception { - super.tearDown(); - // reset the syncable state to unknown - ContentResolver.setIsSyncable(TEST_ACCOUNT, AUTHORITY, -1); - } - public void testEmptyAccounts() { final AccountsSettingsFragment fragment = (AccountsSettingsFragment) getActivity().mFragment; @@ -146,57 +129,4 @@ public class AccountsSettingsFragmentTests assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_NEGATIVE).getVisibility()); assertEquals(View.VISIBLE, mDialog.getButton(Dialog.BUTTON_POSITIVE).getVisibility()); } - - public void testUpdateSyncPolicy_enable() { - // This test is a no-op when ENABLE_PERSONAL_DICTIONARY_SYNC is not enabled - if (!ProductionFlags.ENABLE_PERSONAL_DICTIONARY_SYNC) { - return; - } - // Should be unknown by default. - assertTrue(ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY) < 0); - - final AccountsSettingsFragment fragment = - (AccountsSettingsFragment) getActivity().mFragment; - fragment.updateSyncPolicy(true, TEST_ACCOUNT_NAME); - - // Should be syncable now. - assertEquals(1, ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY)); - } - - public void testUpdateSyncPolicy_disable() { - // This test is a no-op when ENABLE_PERSONAL_DICTIONARY_SYNC is not enabled - if (!ProductionFlags.ENABLE_PERSONAL_DICTIONARY_SYNC) { - return; - } - // Should be unknown by default. - assertTrue(ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY) < 0); - - final AccountsSettingsFragment fragment = - (AccountsSettingsFragment) getActivity().mFragment; - fragment.updateSyncPolicy(false, TEST_ACCOUNT_NAME); - - // Should not be syncable now. - assertEquals(0, ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY)); - } - - public void testUpdateSyncPolicy_enableDisable() { - // This test is a no-op when ENABLE_PERSONAL_DICTIONARY_SYNC is not enabled - if (!ProductionFlags.ENABLE_PERSONAL_DICTIONARY_SYNC) { - return; - } - // Should be unknown by default. - assertTrue(ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY) < 0); - - final AccountsSettingsFragment fragment = - (AccountsSettingsFragment) getActivity().mFragment; - fragment.updateSyncPolicy(true, TEST_ACCOUNT_NAME); - - // Should be syncable now. - assertEquals(1, ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY)); - - fragment.updateSyncPolicy(false, TEST_ACCOUNT_NAME); - - // Should not be syncable now. - assertEquals(0, ContentResolver.getIsSyncable(TEST_ACCOUNT, AUTHORITY)); - } } diff --git a/tests/src/com/android/inputmethod/latin/utils/EditDistanceTests.java b/tests/src/com/android/inputmethod/latin/utils/EditDistanceTests.java deleted file mode 100644 index 58312264b..000000000 --- a/tests/src/com/android/inputmethod/latin/utils/EditDistanceTests.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.inputmethod.latin.utils; - -import android.test.AndroidTestCase; -import android.test.suitebuilder.annotation.SmallTest; - -@SmallTest -public class EditDistanceTests extends AndroidTestCase { - /* - * dist(kitten, sitting) == 3 - * - * kitten- - * .|||.| - * sitting - */ - public void testExample1() { - final int dist = BinaryDictionaryUtils.editDistance("kitten", "sitting"); - assertEquals("edit distance between 'kitten' and 'sitting' is 3", - 3, dist); - } - - /* - * dist(Sunday, Saturday) == 3 - * - * Saturday - * | |.||| - * S--unday - */ - public void testExample2() { - final int dist = BinaryDictionaryUtils.editDistance("Saturday", "Sunday"); - assertEquals("edit distance between 'Saturday' and 'Sunday' is 3", - 3, dist); - } - - public void testBothEmpty() { - final int dist = BinaryDictionaryUtils.editDistance("", ""); - assertEquals("when both string are empty, no edits are needed", - 0, dist); - } - - public void testFirstArgIsEmpty() { - final int dist = BinaryDictionaryUtils.editDistance("", "aaaa"); - assertEquals("when only one string of the arguments is empty," - + " the edit distance is the length of the other.", - 4, dist); - } - - public void testSecoondArgIsEmpty() { - final int dist = BinaryDictionaryUtils.editDistance("aaaa", ""); - assertEquals("when only one string of the arguments is empty," - + " the edit distance is the length of the other.", - 4, dist); - } - - public void testSameStrings() { - final String arg1 = "The quick brown fox jumps over the lazy dog."; - final String arg2 = "The quick brown fox jumps over the lazy dog."; - final int dist = BinaryDictionaryUtils.editDistance(arg1, arg2); - assertEquals("when same strings are passed, distance equals 0.", - 0, dist); - } - - public void testSameReference() { - final String arg = "The quick brown fox jumps over the lazy dog."; - final int dist = BinaryDictionaryUtils.editDistance(arg, arg); - assertEquals("when same string references are passed, the distance equals 0.", - 0, dist); - } - - public void testNullArg() { - try { - BinaryDictionaryUtils.editDistance(null, "aaa"); - fail("IllegalArgumentException should be thrown."); - } catch (Exception e) { - assertTrue(e instanceof IllegalArgumentException); - } - try { - BinaryDictionaryUtils.editDistance("aaa", null); - fail("IllegalArgumentException should be thrown."); - } catch (Exception e) { - assertTrue(e instanceof IllegalArgumentException); - } - } -} |