summaryrefslogtreecommitdiffstats
path: root/core/tests
diff options
context:
space:
mode:
Diffstat (limited to 'core/tests')
-rw-r--r--core/tests/coretests/apks/install/Android.mk8
-rw-r--r--core/tests/coretests/apks/install/AndroidManifest.xml21
-rw-r--r--core/tests/coretests/apks/install/res/values/strings.xml6
-rw-r--r--core/tests/coretests/res/drawable/abe.jpgbin0 -> 3622 bytes
-rw-r--r--core/tests/coretests/res/drawable/gettysburg.pngbin0 -> 118370 bytes
-rw-r--r--core/tests/coretests/res/layout/size_adaptive.xml40
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_color.xml41
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_four_u.xml68
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_four_u_text.xml59
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_gappy.xml40
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_large_only.xml31
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_one_u.xml66
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_one_u_text.xml54
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_overlapping.xml40
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_singleton.xml31
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_text.xml40
-rw-r--r--core/tests/coretests/res/layout/size_adaptive_three_way.xml48
-rw-r--r--core/tests/coretests/res/raw/installbin3078 -> 0 bytes
-rw-r--r--core/tests/coretests/res/values/strings.xml4
-rwxr-xr-xcore/tests/coretests/src/android/content/pm/PackageManagerTests.java42
-rw-r--r--core/tests/coretests/src/android/widget/focus/ListOfButtonsTest.java7
-rw-r--r--core/tests/coretests/src/com/android/internal/os/DebugTest.java67
-rw-r--r--core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java446
23 files changed, 1139 insertions, 20 deletions
diff --git a/core/tests/coretests/apks/install/Android.mk b/core/tests/coretests/apks/install/Android.mk
new file mode 100644
index 0000000..b38dc20
--- /dev/null
+++ b/core/tests/coretests/apks/install/Android.mk
@@ -0,0 +1,8 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(call all-subdir-java-files)
+
+LOCAL_PACKAGE_NAME := install
+
+include $(FrameworkCoreTests_BUILD_PACKAGE)
diff --git a/core/tests/coretests/apks/install/AndroidManifest.xml b/core/tests/coretests/apks/install/AndroidManifest.xml
new file mode 100644
index 0000000..60f1ba0
--- /dev/null
+++ b/core/tests/coretests/apks/install/AndroidManifest.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.frameworks.coretests.install_loc">
+
+ <application android:hasCode="false">
+ </application>
+</manifest>
diff --git a/core/tests/coretests/apks/install/res/values/strings.xml b/core/tests/coretests/apks/install/res/values/strings.xml
new file mode 100644
index 0000000..3b8b3b1
--- /dev/null
+++ b/core/tests/coretests/apks/install/res/values/strings.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Just need this dummy file to have something to build. -->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <string name="dummy">dummy</string>
+</resources>
diff --git a/core/tests/coretests/res/drawable/abe.jpg b/core/tests/coretests/res/drawable/abe.jpg
new file mode 100644
index 0000000..1f978a9
--- /dev/null
+++ b/core/tests/coretests/res/drawable/abe.jpg
Binary files differ
diff --git a/core/tests/coretests/res/drawable/gettysburg.png b/core/tests/coretests/res/drawable/gettysburg.png
new file mode 100644
index 0000000..7a2d596
--- /dev/null
+++ b/core/tests/coretests/res/drawable/gettysburg.png
Binary files differ
diff --git a/core/tests/coretests/res/layout/size_adaptive.xml b/core/tests/coretests/res/layout/size_adaptive.xml
new file mode 100644
index 0000000..03d0574
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/multi1"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ internal:layout_minHeight="65dp"
+ internal:layout_maxHeight="unbounded"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_color.xml b/core/tests/coretests/res/layout/size_adaptive_color.xml
new file mode 100644
index 0000000..cdb7a59
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_color.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:background="#ffffff"
+ android:id="@+id/multi1"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ internal:layout_minHeight="65dp"
+ internal:layout_maxHeight="unbounded"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_four_u.xml b/core/tests/coretests/res/layout/size_adaptive_four_u.xml
new file mode 100644
index 0000000..232b921
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_four_u.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridLayout4"
+ android:layout_width="match_parent"
+ android:layout_height="256dp"
+ android:background="#000000"
+ android:columnCount="2"
+ android:padding="1dp" >
+
+ <ImageView
+ android:id="@+id/actor"
+ android:layout_width="62dp"
+ android:layout_height="62dp"
+ android:layout_row="0"
+ android:layout_column="0"
+ android:layout_rowSpan="2"
+ android:contentDescription="@string/actor"
+ android:src="@drawable/abe" />
+
+ <TextView
+ android:layout_width="0dp"
+ android:id="@+id/name"
+ android:layout_row="0"
+ android:layout_column="1"
+ android:layout_gravity="fill_horizontal"
+ android:padding="3dp"
+ android:text="@string/actor"
+ android:textColor="#ffffff"
+ android:textStyle="bold" />
+
+ <ImageView
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_row="1"
+ android:layout_column="1"
+ android:layout_gravity="fill_horizontal"
+ android:padding="5dp"
+ android:adjustViewBounds="true"
+ android:background="#555555"
+ android:scaleType="centerCrop"
+ android:src="@drawable/gettysburg"
+ android:contentDescription="@string/caption" />
+
+ <TextView
+ android:layout_width="0dp"
+ android:id="@+id/note"
+ android:layout_row="2"
+ android:layout_column="1"
+ android:layout_gravity="fill_horizontal"
+ android:padding="3dp"
+ android:singleLine="true"
+ android:text="@string/first"
+ android:textColor="#ffffff" />
+</GridLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_four_u_text.xml b/core/tests/coretests/res/layout/size_adaptive_four_u_text.xml
new file mode 100644
index 0000000..93a10de
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_four_u_text.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridLayout4"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:background="#000000"
+ android:columnCount="2"
+ android:padding="1dp"
+ android:orientation="horizontal" >
+
+ <ImageView
+ android:id="@+id/actor"
+ android:layout_width="62dp"
+ android:layout_height="62dp"
+ android:layout_row="0"
+ android:layout_column="0"
+ android:layout_rowSpan="2"
+ android:contentDescription="@string/actor"
+ android:src="@drawable/abe" />
+
+ <TextView
+ android:layout_width="0dp"
+ android:id="@+id/name"
+ android:layout_row="0"
+ android:layout_column="1"
+ android:layout_gravity="fill_horizontal"
+ android:padding="3dp"
+ android:text="@string/actor"
+ android:textColor="#ffffff"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/note"
+ android:layout_width="0dp"
+ android:layout_height="wrap_content"
+ android:layout_column="1"
+ android:layout_gravity="fill_horizontal"
+ android:layout_marginTop="5dp"
+ android:layout_row="1"
+ android:padding="3dp"
+ android:singleLine="false"
+ android:text="@string/first"
+ android:textColor="#ffffff" />
+
+ </GridLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_gappy.xml b/core/tests/coretests/res/layout/size_adaptive_gappy.xml
new file mode 100644
index 0000000..d5e3b41
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_gappy.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/multi_with_gap"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="256dp"
+ internal:layout_minHeight="128dp"
+ internal:layout_maxHeight="unbounded"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_large_only.xml b/core/tests/coretests/res/layout/size_adaptive_large_only.xml
new file mode 100644
index 0000000..cf58265
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_large_only.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/large_only_multi"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="256dp"
+ internal:layout_minHeight="65dp"
+ internal:layout_maxHeight="unbounded"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_one_u.xml b/core/tests/coretests/res/layout/size_adaptive_one_u.xml
new file mode 100644
index 0000000..b6fe4a0
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_one_u.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="64dp"
+ android:background="#000000"
+ android:columnCount="3"
+ android:padding="1dp"
+ android:rowCount="2" >
+
+ <ImageView
+ android:id="@+id/actor"
+ android:layout_width="62dp"
+ android:layout_height="62dp"
+ android:layout_column="0"
+ android:layout_row="0"
+ android:layout_rowSpan="2"
+ android:contentDescription="@string/actor"
+ android:src="@drawable/abe" />
+
+ <TextView
+ android:id="@+id/name"
+ android:layout_gravity="fill"
+ android:padding="3dp"
+ android:text="@string/actor"
+ android:textColor="#ffffff"
+ android:textStyle="bold" />
+
+ <ImageView
+ android:layout_width="62dp"
+ android:layout_height="62dp"
+ android:layout_gravity="fill_vertical"
+ android:layout_rowSpan="2"
+ android:adjustViewBounds="true"
+ android:background="#555555"
+ android:padding="2dp"
+ android:scaleType="fitXY"
+ android:src="@drawable/gettysburg"
+ android:contentDescription="@string/caption" />
+
+ <TextView
+ android:id="@+id/note"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_gravity="fill"
+ android:layout_marginTop="5dp"
+ android:padding="3dp"
+ android:singleLine="true"
+ android:text="@string/first"
+ android:textColor="#ffffff" />
+
+</GridLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_one_u_text.xml b/core/tests/coretests/res/layout/size_adaptive_one_u_text.xml
new file mode 100644
index 0000000..df54eb6
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_one_u_text.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/gridLayout1"
+ android:layout_width="match_parent"
+ android:layout_height="64dp"
+ android:background="#000000"
+ android:columnCount="2"
+ android:padding="1dp"
+ android:rowCount="2" >
+
+ <ImageView
+ android:id="@+id/actor"
+ android:layout_width="62dp"
+ android:layout_height="62dp"
+ android:layout_column="0"
+ android:layout_row="0"
+ android:layout_rowSpan="2"
+ android:contentDescription="@string/actor"
+ android:src="@drawable/abe" />
+
+ <TextView
+ android:id="@+id/name"
+ android:layout_gravity="fill"
+ android:padding="3dp"
+ android:text="@string/actor"
+ android:textColor="#ffffff"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/note"
+ android:layout_width="0dp"
+ android:layout_height="0dp"
+ android:layout_gravity="fill"
+ android:layout_marginTop="5dp"
+ android:padding="3dp"
+ android:singleLine="true"
+ android:text="@string/first"
+ android:textColor="#ffffff" />
+
+</GridLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_overlapping.xml b/core/tests/coretests/res/layout/size_adaptive_overlapping.xml
new file mode 100644
index 0000000..4abe8b0
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_overlapping.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/multi_with_overlap"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="256dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="256dp"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_singleton.xml b/core/tests/coretests/res/layout/size_adaptive_singleton.xml
new file mode 100644
index 0000000..eba387f
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_singleton.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u_text"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_text.xml b/core/tests/coretests/res/layout/size_adaptive_text.xml
new file mode 100644
index 0000000..a9f0ba9
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_text.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/multi1"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u_text"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u_text"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ internal:layout_minHeight="65dp"
+ internal:layout_maxHeight="unbounded"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/layout/size_adaptive_three_way.xml b/core/tests/coretests/res/layout/size_adaptive_three_way.xml
new file mode 100644
index 0000000..1eb5396
--- /dev/null
+++ b/core/tests/coretests/res/layout/size_adaptive_three_way.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 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.
+-->
+<com.android.internal.widget.SizeAdaptiveLayout
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:internal="http://schemas.android.com/apk/prv/res/android"
+ android:id="@+id/three_way_multi"
+ android:layout_width="match_parent"
+ android:layout_height="64dp" >
+
+ <include
+ android:id="@+id/one_u"
+ layout="@layout/size_adaptive_one_u"
+ android:layout_width="fill_parent"
+ android:layout_height="64dp"
+ internal:layout_minHeight="64dp"
+ internal:layout_maxHeight="64dp"
+ />
+
+ <include
+ android:id="@+id/two_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="128dp"
+ internal:layout_minHeight="65dp"
+ internal:layout_maxHeight="128dp"/>
+
+ <include
+ android:id="@+id/four_u"
+ layout="@layout/size_adaptive_four_u"
+ android:layout_width="fill_parent"
+ android:layout_height="256dp"
+ internal:layout_minHeight="129dp"
+ internal:layout_maxHeight="unbounded"/>
+
+</com.android.internal.widget.SizeAdaptiveLayout>
diff --git a/core/tests/coretests/res/raw/install b/core/tests/coretests/res/raw/install
deleted file mode 100644
index 06981f4..0000000
--- a/core/tests/coretests/res/raw/install
+++ /dev/null
Binary files differ
diff --git a/core/tests/coretests/res/values/strings.xml b/core/tests/coretests/res/values/strings.xml
index 71f3520..ce0d9a2 100644
--- a/core/tests/coretests/res/values/strings.xml
+++ b/core/tests/coretests/res/values/strings.xml
@@ -131,4 +131,8 @@
<string name="textview_hebrew_text">&#x05DD;&#x05DE;ab?!</string>
+ <!-- SizeAdaptiveLayout -->
+ <string name="first">Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.</string>
+ <string name="actor">Abe Lincoln</string>
+ <string name="caption">Lincoln adressing the crowd at Gettysburgh</string>
</resources>
diff --git a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
index 9575ced..580b4da 100755
--- a/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
+++ b/core/tests/coretests/src/android/content/pm/PackageManagerTests.java
@@ -170,11 +170,10 @@ public class PackageManagerTests extends AndroidTestCase {
return ipm;
}
- public boolean invokeInstallPackage(Uri packageURI, int flags, GenericReceiver receiver) {
+ public void invokeInstallPackage(Uri packageURI, int flags, GenericReceiver receiver,
+ boolean shouldSucceed) {
PackageInstallObserver observer = new PackageInstallObserver();
- final boolean received = false;
mContext.registerReceiver(receiver, receiver.filter);
- final boolean DEBUG = true;
try {
// Wait on observer
synchronized(observer) {
@@ -192,10 +191,24 @@ public class PackageManagerTests extends AndroidTestCase {
if(!observer.isDone()) {
fail("Timed out waiting for packageInstalled callback");
}
- if (observer.returnCode != PackageManager.INSTALL_SUCCEEDED) {
- Log.i(TAG, "Failed to install with error code = " + observer.returnCode);
- return false;
+
+ if (shouldSucceed) {
+ if (observer.returnCode != PackageManager.INSTALL_SUCCEEDED) {
+ fail("Package installation should have succeeded, but got code "
+ + observer.returnCode);
+ }
+ } else {
+ if (observer.returnCode == PackageManager.INSTALL_SUCCEEDED) {
+ fail("Package installation should fail");
+ }
+
+ /*
+ * We'll never expect get a notification since we
+ * shouldn't succeed.
+ */
+ return;
}
+
// Verify we received the broadcast
waitTime = 0;
while((!receiver.isDone()) && (waitTime < MAX_WAIT_TIME) ) {
@@ -209,7 +222,6 @@ public class PackageManagerTests extends AndroidTestCase {
if(!receiver.isDone()) {
fail("Timed out waiting for PACKAGE_ADDED notification");
}
- return receiver.received;
}
}
} finally {
@@ -588,7 +600,7 @@ public class PackageManagerTests extends AndroidTestCase {
}
} else {
InstallReceiver receiver = new InstallReceiver(pkg.packageName);
- assertTrue(invokeInstallPackage(packageURI, flags, receiver));
+ invokeInstallPackage(packageURI, flags, receiver, true);
// Verify installed information
assertInstall(pkg, flags, expInstallLocation);
}
@@ -705,13 +717,9 @@ public class PackageManagerTests extends AndroidTestCase {
receiver = new InstallReceiver(ip.pkg.packageName);
}
try {
- try {
- assertEquals(invokeInstallPackage(ip.packageURI, flags, receiver), replace);
- if (replace) {
- assertInstall(ip.pkg, flags, ip.pkg.installLocation);
- }
- } catch (Exception e) {
- failStr("Failed with exception : " + e);
+ invokeInstallPackage(ip.packageURI, flags, receiver, replace);
+ if (replace) {
+ assertInstall(ip.pkg, flags, ip.pkg.installLocation);
}
} finally {
cleanUpInstall(ip);
@@ -1244,7 +1252,7 @@ public class PackageManagerTests extends AndroidTestCase {
GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName);
int replaceFlags = rFlags | PackageManager.INSTALL_REPLACE_EXISTING;
try {
- assertEquals(invokeInstallPackage(ip.packageURI, replaceFlags, receiver), true);
+ invokeInstallPackage(ip.packageURI, replaceFlags, receiver, true);
assertInstall(ip.pkg, rFlags, ip.pkg.installLocation);
} catch (Exception e) {
failStr("Failed with exception : " + e);
@@ -1271,7 +1279,7 @@ public class PackageManagerTests extends AndroidTestCase {
GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName);
int replaceFlags = rFlags | PackageManager.INSTALL_REPLACE_EXISTING;
try {
- assertEquals(invokeInstallPackage(ip.packageURI, replaceFlags, receiver), true);
+ invokeInstallPackage(ip.packageURI, replaceFlags, receiver, true);
assertInstall(ip.pkg, iFlags, ip.pkg.installLocation);
} catch (Exception e) {
failStr("Failed with exception : " + e);
diff --git a/core/tests/coretests/src/android/widget/focus/ListOfButtonsTest.java b/core/tests/coretests/src/android/widget/focus/ListOfButtonsTest.java
index 3dba4e5..1968a32 100644
--- a/core/tests/coretests/src/android/widget/focus/ListOfButtonsTest.java
+++ b/core/tests/coretests/src/android/widget/focus/ListOfButtonsTest.java
@@ -19,7 +19,7 @@ package android.widget.focus;
import android.widget.focus.ListOfButtons;
import com.android.frameworks.coretests.R;
-import android.test.ActivityInstrumentationTestCase;
+import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.MediumTest;
import android.widget.ListAdapter;
import android.widget.Button;
@@ -31,7 +31,7 @@ import android.view.View;
* Tests that focus works as expected when navigating into and out of
* a {@link ListView} that has buttons in it.
*/
-public class ListOfButtonsTest extends ActivityInstrumentationTestCase<ListOfButtons> {
+public class ListOfButtonsTest extends ActivityInstrumentationTestCase2<ListOfButtons> {
private ListAdapter mListAdapter;
private Button mButtonAtTop;
@@ -39,7 +39,7 @@ public class ListOfButtonsTest extends ActivityInstrumentationTestCase<ListOfBut
private ListView mListView;
public ListOfButtonsTest() {
- super("com.android.frameworks.coretests", ListOfButtons.class);
+ super(ListOfButtons.class);
}
@Override
@@ -47,6 +47,7 @@ public class ListOfButtonsTest extends ActivityInstrumentationTestCase<ListOfBut
super.setUp();
ListOfButtons a = getActivity();
+ getInstrumentation().waitForIdleSync();
mListAdapter = a.getListAdapter();
mButtonAtTop = (Button) a.findViewById(R.id.button);
mListView = a.getListView();
diff --git a/core/tests/coretests/src/com/android/internal/os/DebugTest.java b/core/tests/coretests/src/com/android/internal/os/DebugTest.java
new file mode 100644
index 0000000..88c7d1b
--- /dev/null
+++ b/core/tests/coretests/src/com/android/internal/os/DebugTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2012 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.internal.os;
+
+import android.os.Debug;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import junit.framework.TestCase;
+
+@SmallTest
+public class DebugTest extends TestCase {
+
+ private final static String EXPECTED_GET_CALLER =
+ "com\\.android\\.internal\\.os\\.DebugTest\\.testGetCaller:\\d\\d";
+ private final static String EXPECTED_GET_CALLERS =
+ "com\\.android\\.internal\\.os\\.DebugTest.callDepth3:\\d\\d " +
+ "com\\.android\\.internal\\.os\\.DebugTest.callDepth2:\\d\\d " +
+ "com\\.android\\.internal\\.os\\.DebugTest.callDepth1:\\d\\d ";
+
+ /**
+ * @return String consisting of the caller to this method.
+ */
+ private String callDepth0() {
+ return Debug.getCaller();
+ }
+
+ public void testGetCaller() {
+ assertTrue(callDepth0().matches(EXPECTED_GET_CALLER));
+ }
+
+ /**
+ * @return String consisting of the callers to this method.
+ */
+ private String callDepth4() {
+ return Debug.getCallers(3);
+ }
+
+ private String callDepth3() {
+ return callDepth4();
+ }
+
+ private String callDepth2() {
+ return callDepth3();
+ }
+
+ private String callDepth1() {
+ return callDepth2();
+ }
+
+ public void testGetCallers() {
+ assertTrue(callDepth1().matches(EXPECTED_GET_CALLERS));
+ }
+}
diff --git a/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java b/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java
new file mode 100644
index 0000000..fc83e4a
--- /dev/null
+++ b/core/tests/coretests/src/com/android/internal/widget/SizeAdaptiveLayoutTest.java
@@ -0,0 +1,446 @@
+/*
+ * Copyright (C) 2012 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.internal.widget;
+
+import com.android.frameworks.coretests.R;
+
+import android.content.Context;
+import android.graphics.drawable.ColorDrawable;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.LayoutInflater;
+import android.view.View;
+
+import com.android.internal.widget.SizeAdaptiveLayout;
+
+
+public class SizeAdaptiveLayoutTest extends AndroidTestCase {
+
+ private LayoutInflater mInflater;
+ private int mOneU;
+ private int mFourU;
+ private SizeAdaptiveLayout mSizeAdaptiveLayout;
+ private View mSmallView;
+ private View mMediumView;
+ private View mLargeView;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // inflate the layout
+ final Context context = getContext();
+ mInflater = LayoutInflater.from(context);
+ mOneU = 64;
+ mFourU = 4 * mOneU;
+ }
+
+ private void inflate(int resource){
+ mSizeAdaptiveLayout = (SizeAdaptiveLayout) mInflater.inflate(resource, null);
+ mSizeAdaptiveLayout.onAttachedToWindow();
+
+ mSmallView = mSizeAdaptiveLayout.findViewById(R.id.one_u);
+ mMediumView = mSizeAdaptiveLayout.findViewById(R.id.two_u);
+ mLargeView = mSizeAdaptiveLayout.findViewById(R.id.four_u);
+ }
+
+ /**
+ * The name 'test preconditions' is a convention to signal that if this
+ * test doesn't pass, the test case was not set up properly and it might
+ * explain any and all failures in other tests. This is not guaranteed
+ * to run before other tests, as junit uses reflection to find the tests.
+ */
+ @SmallTest
+ public void testPreconditions() {
+ assertNotNull(mInflater);
+
+ inflate(R.layout.size_adaptive);
+ assertNotNull(mSizeAdaptiveLayout);
+ assertNotNull(mSmallView);
+ assertNotNull(mLargeView);
+ }
+
+ @SmallTest
+ public void testOpenLarge() {
+ inflate(R.layout.size_adaptive);
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int height = (int) lp.minHeight + 10;
+
+ measureAndLayout(height);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ assertEquals("1U should be gone",
+ View.GONE,
+ mSmallView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenSmall() {
+ inflate(R.layout.size_adaptive);
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ int height = (int) lp.minHeight;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ assertEquals("4U should be gone",
+ View.GONE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenTooSmall() {
+ inflate(R.layout.size_adaptive);
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ int height = (int) lp.minHeight - 10;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ assertEquals("4U should be gone",
+ View.GONE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenTooBig() {
+ inflate(R.layout.size_adaptive);
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ lp.maxHeight = 500;
+ mLargeView.setLayoutParams(lp);
+ int height = (int) (lp.minHeight + 10);
+
+ measureAndLayout(height);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ assertEquals("1U should be gone",
+ View.GONE,
+ mSmallView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenWrapContent() {
+ inflate(R.layout.size_adaptive_text);
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int height = (int) lp.minHeight + 10;
+
+ // manually measure it, and lay it out
+ int measureSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST);
+ mSizeAdaptiveLayout.measure(500, measureSpec);
+ assertTrue("should not be forced to 4U",
+ mSizeAdaptiveLayout.getMeasuredHeight() < mFourU);
+ }
+
+ @SmallTest
+ public void testOpenOneUOnlySmall() {
+ inflate(R.layout.size_adaptive_singleton);
+ assertNull("largeView should be NULL in the singleton layout", mLargeView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ int height = (int) lp.minHeight - 10;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenOneUOnlyLarge() {
+ inflate(R.layout.size_adaptive_singleton);
+ assertNull("largeView should be NULL in the singleton layout", mLargeView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ int height = (int) lp.maxHeight + 10;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenOneUOnlyJustRight() {
+ inflate(R.layout.size_adaptive_singleton);
+ assertNull("largeView should be NULL in the singleton layout", mLargeView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ int height = (int) lp.minHeight;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenFourUOnlySmall() {
+ inflate(R.layout.size_adaptive_large_only);
+ assertNull("smallView should be NULL in the singleton layout", mSmallView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int height = (int) lp.minHeight - 10;
+
+ measureAndLayout(height);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenFourUOnlyLarge() {
+ inflate(R.layout.size_adaptive_large_only);
+ assertNull("smallView should be NULL in the singleton layout", mSmallView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int height = (int) lp.maxHeight + 10;
+
+ measureAndLayout(height);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenFourUOnlyJustRight() {
+ inflate(R.layout.size_adaptive_large_only);
+ assertNull("smallView should be NULL in the singleton layout", mSmallView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int height = (int) lp.minHeight;
+
+ measureAndLayout(height);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenIntoAGap() {
+ inflate(R.layout.size_adaptive_gappy);
+
+ SizeAdaptiveLayout.LayoutParams smallParams =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ SizeAdaptiveLayout.LayoutParams largeParams =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ assertTrue("gappy layout should have a gap",
+ smallParams.maxHeight + 10 < largeParams.minHeight);
+ int height = (int) smallParams.maxHeight + 10;
+
+ measureAndLayout(height);
+
+ assertTrue("one and only one view should be visible",
+ mLargeView.getVisibility() != mSmallView.getVisibility());
+ // behavior is undefined in this case.
+ }
+
+ @SmallTest
+ public void testOpenIntoAnOverlap() {
+ inflate(R.layout.size_adaptive_overlapping);
+
+ SizeAdaptiveLayout.LayoutParams smallParams =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ SizeAdaptiveLayout.LayoutParams largeParams =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ assertEquals("overlapping layout should overlap",
+ smallParams.minHeight,
+ largeParams.minHeight);
+ int height = (int) smallParams.maxHeight;
+
+ measureAndLayout(height);
+
+ assertTrue("one and only one view should be visible",
+ mLargeView.getVisibility() != mSmallView.getVisibility());
+ assertEquals("1U should get priority in an overlap because it is first",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenThreeWayViewSmall() {
+ inflate(R.layout.size_adaptive_three_way);
+ assertNotNull("mMediumView should not be NULL in the three view layout", mMediumView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ int height = (int) lp.minHeight;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ assertEquals("2U should be gone",
+ View.GONE,
+ mMediumView.getVisibility());
+ assertEquals("4U should be gone",
+ View.GONE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenThreeWayViewMedium() {
+ inflate(R.layout.size_adaptive_three_way);
+ assertNotNull("mMediumView should not be NULL in the three view layout", mMediumView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mMediumView.getLayoutParams();
+ int height = (int) lp.minHeight;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be gone",
+ View.GONE,
+ mSmallView.getVisibility());
+ assertEquals("2U should be visible",
+ View.VISIBLE,
+ mMediumView.getVisibility());
+ assertEquals("4U should be gone",
+ View.GONE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testOpenThreeWayViewLarge() {
+ inflate(R.layout.size_adaptive_three_way);
+ assertNotNull("mMediumView should not be NULL in the three view layout", mMediumView);
+
+ SizeAdaptiveLayout.LayoutParams lp =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int height = (int) lp.minHeight;
+
+ measureAndLayout(height);
+
+ assertEquals("1U should be gone",
+ View.GONE,
+ mSmallView.getVisibility());
+ assertEquals("2U should be gone",
+ View.GONE,
+ mMediumView.getVisibility());
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ }
+
+ @SmallTest
+ public void testResizeWithoutAnimation() {
+ inflate(R.layout.size_adaptive);
+
+ SizeAdaptiveLayout.LayoutParams largeParams =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int startHeight = (int) largeParams.minHeight + 10;
+ int endHeight = (int) largeParams.minHeight + 10;
+
+ measureAndLayout(startHeight);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ assertFalse("There should be no animation on initial rendering.",
+ mSizeAdaptiveLayout.getTransitionAnimation().isRunning());
+
+ measureAndLayout(endHeight);
+
+ assertEquals("4U should still be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ assertFalse("There should be no animation on scale within a view.",
+ mSizeAdaptiveLayout.getTransitionAnimation().isRunning());
+ }
+
+ @SmallTest
+ public void testResizeWithAnimation() {
+ inflate(R.layout.size_adaptive);
+
+ SizeAdaptiveLayout.LayoutParams smallParams =
+ (SizeAdaptiveLayout.LayoutParams) mSmallView.getLayoutParams();
+ SizeAdaptiveLayout.LayoutParams largeParams =
+ (SizeAdaptiveLayout.LayoutParams) mLargeView.getLayoutParams();
+ int startHeight = (int) largeParams.minHeight + 10;
+ int endHeight = (int) smallParams.maxHeight;
+
+ measureAndLayout(startHeight);
+
+ assertEquals("4U should be visible",
+ View.VISIBLE,
+ mLargeView.getVisibility());
+ assertFalse("There should be no animation on initial rendering.",
+ mSizeAdaptiveLayout.getTransitionAnimation().isRunning());
+
+ measureAndLayout(endHeight);
+
+ assertEquals("1U should now be visible",
+ View.VISIBLE,
+ mSmallView.getVisibility());
+ assertTrue("There should be an animation on scale between views.",
+ mSizeAdaptiveLayout.getTransitionAnimation().isRunning());
+ }
+
+ @SmallTest
+ public void testModestyPanelChangesColorWhite() {
+ inflate(R.layout.size_adaptive_color);
+ View panel = mSizeAdaptiveLayout.getModestyPanel();
+ assertTrue("ModestyPanel should have a ColorDrawable background",
+ panel.getBackground() instanceof ColorDrawable);
+ ColorDrawable panelColor = (ColorDrawable) panel.getBackground();
+ ColorDrawable salColor = (ColorDrawable) mSizeAdaptiveLayout.getBackground();
+ assertEquals("ModestyPanel color should match the SizeAdaptiveLayout",
+ panelColor.getColor(), salColor.getColor());
+ }
+
+ @SmallTest
+ public void testModestyPanelHasDefault() {
+ inflate(R.layout.size_adaptive);
+ View panel = mSizeAdaptiveLayout.getModestyPanel();
+ assertNull("SizeAdaptiveLayout should have no background for this test",
+ mSizeAdaptiveLayout.getBackground());
+ assertTrue("ModestyPanel should have a ColorDrawable background",
+ panel.getBackground() instanceof ColorDrawable);
+ }
+
+ private void measureAndLayout(int height) {
+ // manually measure it, and lay it out
+ int measureSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST);
+ mSizeAdaptiveLayout.measure(500, measureSpec);
+ mSizeAdaptiveLayout.layout(0, 0, 500, height);
+ }
+}