Add more unit tests for RTL layouts

- update LinearLayout tests with default case (no horizontalDirection specified)
- add TableLayout tests

Change-Id: I9ad2239fca96b896c5aae4dfe67b8113faf2f96e
This commit is contained in:
Fabrice Di Meglio
2011-06-02 10:55:58 -07:00
parent 52ae3f345b
commit 88f9fd2316
9 changed files with 612 additions and 40 deletions

View File

@@ -99,6 +99,20 @@
</intent-filter>
</activity>
<activity android:name=".BiDiTestTableLayoutLtrActivity"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity android:name=".BiDiTestTableLayoutRtlActivity"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@@ -24,26 +24,52 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:horizontalDirection="inherit">
android:layout_height="wrap_content">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:horizontalDirection="inherit">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
/>
</LinearLayout>
@@ -57,20 +83,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -84,20 +110,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -111,20 +137,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -138,20 +164,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -165,20 +191,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>

View File

@@ -24,26 +24,52 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:horizontalDirection="inherit">
android:layout_height="wrap_content">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:horizontalDirection="inherit">
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
/>
</LinearLayout>
@@ -57,20 +83,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -84,20 +110,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -111,20 +137,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -138,20 +164,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>
@@ -165,20 +191,20 @@
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="32dip"
android:textSize="24dip"
/>
<TextView android:id="@+id/textview"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:textSize="32dip"
android:textSize="24dip"
android:text="@string/textview_text"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="32dip"
android:textSize="24dip"
/>
</LinearLayout>

View File

@@ -0,0 +1,215 @@
<?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/linear_layout_ltr"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:horizontalDirection="ltr">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
android:horizontalDirection="inherit">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
android:horizontalDirection="ltr">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
android:horizontalDirection="rtl">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
</LinearLayout>

View File

@@ -0,0 +1,215 @@
<?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/linear_layout_ltr"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:horizontalDirection="rtl">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
android:horizontalDirection="inherit">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
android:horizontalDirection="ltr">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:stretchColumns="1,2"
android:horizontalDirection="rtl">
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button1_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button2_text"
android:textSize="24dip"
android:gravity="right"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button3_text"
android:textSize="24dip"
android:gravity="after"
/>
</TableRow>
<TableRow>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button4_text"
android:textSize="24dip"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button5_text"
android:textSize="24dip"
android:gravity="left"
/>
<Button android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/button6_text"
android:textSize="24dip"
android:gravity="before"
/>
</TableRow>
</TableLayout>
</LinearLayout>

View File

@@ -16,6 +16,10 @@
<string name="button_text">Button</string>
<string name="button1_text">Button1</string>
<string name="button2_text">Button2</string>
<string name="button3_text">Button3</string>
<string name="button4_text">Button4</string>
<string name="button5_text">Button5</string>
<string name="button6_text">Button6</string>
<string name="button_requestlayout_text">Request Layout</string>
<string name="textview_text">This is a text for a TextView</string>
<string name="edittext_text">mmmmmmmmmmmmmmmmmmmmmmmm</string>

View File

@@ -87,6 +87,16 @@ public class BiDiTestActivity extends TabActivity {
setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, BiDiTestTableLayoutLtrActivity.class);
spec = tabHost.newTabSpec("table-layout-ltr").setIndicator("Table LTR").
setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, BiDiTestTableLayoutRtlActivity.class);
spec = tabHost.newTabSpec("table-layout-rtl").setIndicator("Table RTL").
setContent(intent);
tabHost.addTab(spec);
tabHost.setCurrentTab(0);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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 com.android.bidi;
import android.app.Activity;
import android.os.Bundle;
public class BiDiTestTableLayoutLtrActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table_layout_ltr);
}
}

View File

@@ -0,0 +1,31 @@
/*
* 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 com.android.bidi;
import android.app.Activity;
import android.os.Bundle;
public class BiDiTestTableLayoutRtlActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.table_layout_rtl);
}
}