diff options
author | Fabrice Di Meglio <fdimeglio@google.com> | 2012-03-05 16:09:08 -0800 |
---|---|---|
committer | Fabrice Di Meglio <fdimeglio@google.com> | 2012-03-05 16:22:22 -0800 |
commit | e9c0d1495b1ac85048e19fd7cbf232a0cd10df12 (patch) | |
tree | 0474a7f1c743b6f98d455257697817c8cfcb7b7c /core/tests | |
parent | 7d3c690e723e3fb82775baad5942234cd30f8d2d (diff) | |
download | frameworks_base-e9c0d1495b1ac85048e19fd7cbf232a0cd10df12.zip frameworks_base-e9c0d1495b1ac85048e19fd7cbf232a0cd10df12.tar.gz frameworks_base-e9c0d1495b1ac85048e19fd7cbf232a0cd10df12.tar.bz2 |
Fix bug #4972463 Update CTS tests for TextView textDirection
- move unit tests from Frameworks to CTS
Change-Id: I4598d8e99850f49e660c5bb3fb6025e71c635635
Diffstat (limited to 'core/tests')
3 files changed, 3 insertions, 244 deletions
diff --git a/core/tests/coretests/res/layout/textview_test.xml b/core/tests/coretests/res/layout/textview_test.xml deleted file mode 100644 index f0c7b9e..0000000 --- a/core/tests/coretests/res/layout/textview_test.xml +++ /dev/null @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<!-- Copyright (C) 2011 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. ---> - -<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" - android:id="@+id/textviewtest_layout" - android:layout_width="fill_parent" - android:layout_height="fill_parent"> - - <TextView android:id="@+id/textviewtest_textview" - android:layout_height="wrap_content" - android:layout_width="wrap_content" - android:text="@string/textview_hebrew_text"/> - -</LinearLayout>
\ No newline at end of file diff --git a/core/tests/coretests/src/android/widget/TextViewTest.java b/core/tests/coretests/src/android/widget/TextViewTest.java index d4dbced..af6df1a 100644 --- a/core/tests/coretests/src/android/widget/TextViewTest.java +++ b/core/tests/coretests/src/android/widget/TextViewTest.java @@ -16,25 +16,18 @@ package android.widget; -import android.test.ActivityInstrumentationTestCase2; +import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.SmallTest; import android.text.GetChars; -import android.view.View; - -import com.android.frameworks.coretests.R; /** * TextViewTest tests {@link TextView}. */ -public class TextViewTest extends ActivityInstrumentationTestCase2<TextViewTestActivity> { - - public TextViewTest() { - super(TextViewTestActivity.class); - } +public class TextViewTest extends AndroidTestCase { @SmallTest public void testArray() throws Exception { - TextView tv = new TextView(getActivity()); + TextView tv = new TextView(mContext); char[] c = new char[] { 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd', '!' }; @@ -61,181 +54,4 @@ public class TextViewTest extends ActivityInstrumentationTestCase2<TextViewTestA assertEquals('o', c2[4]); assertEquals('\0', c2[5]); } - - @SmallTest - public void testTextDirectionDefault() { - TextView tv = new TextView(getActivity()); - assertEquals(View.TEXT_DIRECTION_INHERIT, tv.getTextDirection()); - } - - @SmallTest - public void testSetGetTextDirection() { - TextView tv = new TextView(getActivity()); - - tv.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_INHERIT, tv.getTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LTR); - assertEquals(View.TEXT_DIRECTION_LTR, tv.getTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_RTL); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LOCALE); - assertEquals(View.TEXT_DIRECTION_LOCALE, tv.getTextDirection()); - } - - @SmallTest - public void testGetResolvedTextDirectionLtr() { - TextView tv = new TextView(getActivity()); - tv.setText("this is a test"); - - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LTR); - assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_RTL); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LOCALE); - assertEquals(View.TEXT_DIRECTION_LOCALE, tv.getResolvedTextDirection()); - } - - @SmallTest - public void testGetResolvedTextDirectionLtrWithInheritance() { - LinearLayout ll = new LinearLayout(getActivity()); - ll.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - - TextView tv = new TextView(getActivity()); - tv.setText("this is a test"); - ll.addView(tv); - - tv.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LTR); - assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_RTL); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LOCALE); - assertEquals(View.TEXT_DIRECTION_LOCALE, tv.getResolvedTextDirection()); - } - - @SmallTest - public void testGetResolvedTextDirectionRtl() { - TextView tv = new TextView(getActivity()); - tv.setText("\u05DD\u05DE"); // hebrew - - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LTR); - assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_RTL); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LOCALE); - assertEquals(View.TEXT_DIRECTION_LOCALE, tv.getResolvedTextDirection()); - } - - @SmallTest - public void testGetResolvedTextDirectionRtlWithInheritance() { - LinearLayout ll = new LinearLayout(getActivity()); - ll.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - - TextView tv = new TextView(getActivity()); - tv.setText("\u05DD\u05DE"); // hebrew - ll.addView(tv); - - tv.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LTR); - assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_RTL); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LOCALE); - assertEquals(View.TEXT_DIRECTION_LOCALE, tv.getResolvedTextDirection()); - - // Force to RTL text direction on the layout - ll.setTextDirection(View.TEXT_DIRECTION_RTL); - - tv.setTextDirection(View.TEXT_DIRECTION_FIRST_STRONG); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_ANY_RTL); - assertEquals(View.TEXT_DIRECTION_ANY_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LTR); - assertEquals(View.TEXT_DIRECTION_LTR, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_RTL); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - tv.setTextDirection(View.TEXT_DIRECTION_LOCALE); - assertEquals(View.TEXT_DIRECTION_LOCALE, tv.getResolvedTextDirection()); - } - - @SmallTest - public void testResetTextDirection() { - final TextViewTestActivity activity = getActivity(); - - final LinearLayout ll = (LinearLayout) activity.findViewById(R.id.textviewtest_layout); - final TextView tv = (TextView) activity.findViewById(R.id.textviewtest_textview); - - getActivity().runOnUiThread(new Runnable() { - public void run() { - ll.setTextDirection(View.TEXT_DIRECTION_RTL); - tv.setTextDirection(View.TEXT_DIRECTION_INHERIT); - assertEquals(View.TEXT_DIRECTION_RTL, tv.getResolvedTextDirection()); - - ll.removeView(tv); - assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getResolvedTextDirection()); - } - }); - } } diff --git a/core/tests/coretests/src/android/widget/TextViewTestActivity.java b/core/tests/coretests/src/android/widget/TextViewTestActivity.java deleted file mode 100644 index 1bb4d24..0000000 --- a/core/tests/coretests/src/android/widget/TextViewTestActivity.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2011 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 android.widget; - -import android.app.Activity; -import android.os.Bundle; - -import com.android.frameworks.coretests.R; - -public class TextViewTestActivity extends Activity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.textview_test); - } -} |