Merge "add taskswitching / install time measurement" into jb-mr1-dev
diff --git a/tests/res/drawable/icon_black.jpg b/tests/res/drawable/icon_black.jpg
new file mode 100644
index 0000000..4c9062a
--- /dev/null
+++ b/tests/res/drawable/icon_black.jpg
Binary files differ
diff --git a/tests/res/drawable/icon_blue.jpg b/tests/res/drawable/icon_blue.jpg
new file mode 100644
index 0000000..9e6c1c8
--- /dev/null
+++ b/tests/res/drawable/icon_blue.jpg
Binary files differ
diff --git a/tests/res/drawable/icon_green.jpg b/tests/res/drawable/icon_green.jpg
new file mode 100644
index 0000000..55a78f2
--- /dev/null
+++ b/tests/res/drawable/icon_green.jpg
Binary files differ
diff --git a/tests/res/drawable/icon_red.jpg b/tests/res/drawable/icon_red.jpg
new file mode 100644
index 0000000..6bc9e1f
--- /dev/null
+++ b/tests/res/drawable/icon_red.jpg
Binary files differ
diff --git a/tests/res/drawable/icon_yellow.jpg b/tests/res/drawable/icon_yellow.jpg
new file mode 100644
index 0000000..e748059
--- /dev/null
+++ b/tests/res/drawable/icon_yellow.jpg
Binary files differ
diff --git a/tests/res/layout/textview_layout.xml b/tests/res/layout/textview_layout.xml
index 512184f..5aea538 100644
--- a/tests/res/layout/textview_layout.xml
+++ b/tests/res/layout/textview_layout.xml
@@ -96,4 +96,120 @@
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
+ <TextView android:id="@+id/textview_drawable_1_1"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableLeft="@drawable/icon_blue"
+ android:drawableRight="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ <TextView android:id="@+id/textview_drawable_1_2"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableLeft="@drawable/icon_blue"
+ android:drawableRight="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ android:layoutDirection="rtl"
+ />
+
+ <TextView android:id="@+id/textview_drawable_2_1"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ <TextView android:id="@+id/textview_drawable_2_2"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ android:layoutDirection="rtl"
+ />
+
+ <TextView android:id="@+id/textview_drawable_3_1"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableLeft="@drawable/icon_black"
+ android:drawableRight="@drawable/icon_black"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ <TextView android:id="@+id/textview_drawable_3_2"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableLeft="@drawable/icon_black"
+ android:drawableRight="@drawable/icon_black"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ android:layoutDirection="rtl"
+ />
+
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layoutDirection="ltr">
+
+ <TextView android:id="@+id/textview_drawable_4_1"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ <TextView android:id="@+id/textview_drawable_5_1"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableLeft="@drawable/icon_black"
+ android:drawableRight="@drawable/icon_black"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ </LinearLayout>
+
+ <LinearLayout android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layoutDirection="rtl">
+
+ <TextView android:id="@+id/textview_drawable_4_2"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ <TextView android:id="@+id/textview_drawable_5_2"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:drawableLeft="@drawable/icon_black"
+ android:drawableRight="@drawable/icon_black"
+ android:drawableStart="@drawable/icon_blue"
+ android:drawableEnd="@drawable/icon_red"
+ android:drawableTop="@drawable/icon_green"
+ android:drawableBottom="@drawable/icon_yellow"
+ />
+
+ </LinearLayout>
+
</LinearLayout>
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteFtsTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteFtsTest.java
new file mode 100644
index 0000000..d291dd7
--- /dev/null
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteFtsTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright (C) 2009 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.database.sqlite.cts;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.content.res.Resources;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+import android.test.AndroidTestCase;
+
+import java.io.File;
+
+/**
+ * Tests to verify FTS3/4 SQLite support.
+ */
+public class SQLiteFtsTest extends AndroidTestCase {
+
+ private static final String TEST_TABLE = "cts_fts";
+
+ private static final String[] TEST_CONTENT = {
+ "Any sufficiently advanced TECHnology is indistinguishable from magic.",
+ "Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety.",
+ "It is poor civic hygiene to install technologies that could someday facilitate a police state.",
+ };
+
+ private SQLiteDatabase mDatabase;
+
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ mDatabase = getContext().openOrCreateDatabase("CTS_FTS", Context.MODE_PRIVATE, null);
+ }
+
+ @Override
+ public void tearDown() throws Exception {
+ try {
+ final String path = mDatabase.getPath();
+ mDatabase.close();
+ SQLiteDatabase.deleteDatabase(new File(path));
+ } finally {
+ super.tearDown();
+ }
+ }
+
+ public void testFts3Porter() throws Exception {
+ prepareFtsTable(TEST_TABLE, "fts3", "tokenize=porter");
+
+ // Porter should include stemmed words
+ final Cursor cursor = queryFtsTable(TEST_TABLE, "technology");
+ try {
+ assertEquals(2, cursor.getCount());
+ cursor.moveToPosition(0);
+ assertTrue(cursor.getString(0).contains(">TECHnology<"));
+ cursor.moveToPosition(1);
+ assertTrue(cursor.getString(0).contains(">technologies<"));
+ } finally {
+ cursor.close();
+ }
+ }
+
+ public void testFts3Simple() throws Exception {
+ prepareFtsTable(TEST_TABLE, "fts3", "tokenize=simple");
+
+ // Simple shouldn't include stemmed words
+ final Cursor cursor = queryFtsTable(TEST_TABLE, "technology");
+ try {
+ assertEquals(1, cursor.getCount());
+ cursor.moveToPosition(0);
+ assertTrue(cursor.getString(0).contains(">TECHnology<"));
+ } finally {
+ cursor.close();
+ }
+ }
+
+ public void testFts4Simple() throws Exception {
+ prepareFtsTable(TEST_TABLE, "fts4", "tokenize=simple");
+
+ // Simple shouldn't include stemmed words
+ final Cursor cursor = queryFtsTable(TEST_TABLE, "technology");
+ try {
+ assertEquals(1, cursor.getCount());
+ cursor.moveToPosition(0);
+ assertTrue(cursor.getString(0).contains(">TECHnology<"));
+ } finally {
+ cursor.close();
+ }
+ }
+
+ private void prepareFtsTable(String table, String ftsType, String options)
+ throws Exception {
+ mDatabase.execSQL(
+ "CREATE VIRTUAL TABLE " + table + " USING " + ftsType
+ + "(content TEXT, " + options + ");");
+
+ final Resources res = getContext().getResources();
+ final ContentValues values = new ContentValues();
+ for (String content : TEST_CONTENT) {
+ values.clear();
+ values.put("content", content);
+ mDatabase.insert(table, null, values);
+ }
+ }
+
+ private Cursor queryFtsTable(String table, String match) {
+ return mDatabase.query(table, new String[] { "snippet(" + table + ")" },
+ "content MATCH ?", new String[] { match },
+ null, null, "rowid ASC");
+ }
+}
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index f31f552..8b1c741 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -44,7 +44,10 @@
private final String OUTPUT_PATH;
private final String OUTPUT_PATH2;
private static final float TOLERANCE = 0.0002f;
- private static final int RECORD_TIME = 3000;
+ private static final int RECORD_TIME_MS = 3000;
+ private static final int RECORD_TIME_LAPSE_MS = 4000;
+ private static final int RECORD_TIME_LONG_MS = 20000;
+ private static final int RECORDED_DUR_TOLERANCE_MS = 1000;
private static final int THREE_MINUTES = 180000;
private static final int VIDEO_WIDTH = 176;
private static final int VIDEO_HEIGHT = 144;
@@ -165,7 +168,7 @@
mMediaRecorder.setPreviewDisplay(mActivity.getSurfaceHolder().getSurface());
mMediaRecorder.prepare();
mMediaRecorder.start();
- Thread.sleep(1000);
+ Thread.sleep(RECORD_TIME_MS);
mMediaRecorder.stop();
checkOutputExist();
}
@@ -181,7 +184,7 @@
private void recordVideoUsingCamera(boolean timelapse) throws Exception {
int nCamera = Camera.getNumberOfCameras();
- int durMs = timelapse? 4000: 1000;
+ int durMs = timelapse? RECORD_TIME_LAPSE_MS: RECORD_TIME_MS;
for (int cameraId = 0; cameraId < nCamera; cameraId++) {
mCamera = Camera.open(cameraId);
recordVideoUsingCamera(mCamera, OUTPUT_PATH, durMs, timelapse);
@@ -366,7 +369,7 @@
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.prepare();
mMediaRecorder.start();
- Thread.sleep(RECORD_TIME);
+ Thread.sleep(RECORD_TIME_MS);
assertTrue(mOnInfoCalled);
}
@@ -374,7 +377,7 @@
if (!hasMicrophone()) {
return;
}
- testSetMaxDuration(20000, 1000);
+ testSetMaxDuration(RECORD_TIME_LONG_MS, RECORDED_DUR_TOLERANCE_MS);
}
private void testSetMaxDuration(long durationMs, long toleranceMs) throws Exception {
@@ -461,7 +464,7 @@
mMediaRecorder.setMaxFileSize(maxFileSize);
mMediaRecorder.prepare();
mMediaRecorder.start();
- Thread.sleep(RECORD_TIME);
+ Thread.sleep(RECORD_TIME_MS);
mMediaRecorder.stop();
assertTrue(outFile.exists());
diff --git a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
index 7408301..283f63b 100644
--- a/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/tests/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -55,9 +55,10 @@
private static final int STATE_NULL = 0;
private static final int STATE_WIFI_CHANGING = 1;
- private static final int STATE_WIFI_CHANGED = 2;
- private static final int STATE_SCANING = 3;
- private static final int STATE_SCAN_RESULTS_AVAILABLE = 4;
+ private static final int STATE_WIFI_ENABLED = 2;
+ private static final int STATE_WIFI_DISABLED = 3;
+ private static final int STATE_SCANNING = 4;
+ private static final int STATE_SCAN_RESULTS_AVAILABLE = 5;
private static final String TAG = "WifiManagerTest";
private static final String SSID1 = "\"WifiManagerTest\"";
@@ -76,20 +77,29 @@
mScanResult = mWifiManager.getScanResults();
mMySync.expectedState = STATE_SCAN_RESULTS_AVAILABLE;
mScanResult = mWifiManager.getScanResults();
- mMySync.notify();
+ mMySync.notifyAll();
}
}
- } else if (action.equals(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION)) {
+ } else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
+ int newState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
+ WifiManager.WIFI_STATE_UNKNOWN);
synchronized (mMySync) {
- mMySync.expectedState = STATE_WIFI_CHANGED;
- mMySync.notify();
+ if (newState == WifiManager.WIFI_STATE_ENABLED) {
+ Log.d(TAG, "*** New WiFi state is ENABLED ***");
+ mMySync.expectedState = STATE_WIFI_ENABLED;
+ mMySync.notifyAll();
+ } else if (newState == WifiManager.WIFI_STATE_DISABLED) {
+ Log.d(TAG, "*** New WiFi state is DISABLED ***");
+ mMySync.expectedState = STATE_WIFI_DISABLED;
+ mMySync.notifyAll();
+ }
}
} else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
synchronized (mMySync) {
mNetworkInfo =
(NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
if (mNetworkInfo.getState() == NetworkInfo.State.CONNECTED)
- mMySync.notify();
+ mMySync.notifyAll();
}
}
}
@@ -122,7 +132,9 @@
setWifiEnabled(true);
Thread.sleep(DURATION);
assertTrue(mWifiManager.isWifiEnabled());
- mMySync.expectedState = STATE_NULL;
+ synchronized (mMySync) {
+ mMySync.expectedState = STATE_NULL;
+ }
}
@Override
@@ -132,31 +144,34 @@
super.tearDown();
return;
}
- mWifiLock.release();
- mContext.unregisterReceiver(mReceiver);
if (!mWifiManager.isWifiEnabled())
setWifiEnabled(true);
+ mWifiLock.release();
+ mContext.unregisterReceiver(mReceiver);
Thread.sleep(DURATION);
super.tearDown();
}
private void setWifiEnabled(boolean enable) throws Exception {
synchronized (mMySync) {
- mMySync.expectedState = STATE_WIFI_CHANGING;
assertTrue(mWifiManager.setWifiEnabled(enable));
- long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
- while (System.currentTimeMillis() < timeout
- && mMySync.expectedState == STATE_WIFI_CHANGING)
- mMySync.wait(WAIT_MSEC);
+ if (mWifiManager.isWifiEnabled() != enable) {
+ mMySync.expectedState = STATE_WIFI_CHANGING;
+ long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
+ int expectedState = (enable ? STATE_WIFI_ENABLED : STATE_WIFI_DISABLED);
+ while (System.currentTimeMillis() < timeout
+ && mMySync.expectedState != expectedState)
+ mMySync.wait(WAIT_MSEC);
+ }
}
}
private void startScan() throws Exception {
synchronized (mMySync) {
- mMySync.expectedState = STATE_SCANING;
+ mMySync.expectedState = STATE_SCANNING;
assertTrue(mWifiManager.startScan());
long timeout = System.currentTimeMillis() + TIMEOUT_MSEC;
- while (System.currentTimeMillis() < timeout && mMySync.expectedState == STATE_SCANING)
+ while (System.currentTimeMillis() < timeout && mMySync.expectedState == STATE_SCANNING)
mMySync.wait(WAIT_MSEC);
}
}
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index b4279f2..9080320 100755
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -3279,6 +3279,150 @@
assertEquals(View.TEXT_ALIGNMENT_GRAVITY, tv.getTextAlignment());
}
+ @UiThreadTest
+ public void testDrawableResolution() {
+ final int LEFT = 0;
+ final int TOP = 1;
+ final int RIGHT = 2;
+ final int BOTTOM = 3;
+
+ TextViewStubActivity activity = getActivity();
+
+ // Case 1.1: left / right drawable defined in default LTR mode
+ TextView tv = (TextView) activity.findViewById(R.id.textview_drawable_1_1);
+ Drawable[] drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 1.2: left / right drawable defined in default RTL mode
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_1_2);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 2.1: start / end drawable defined in LTR mode
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_2_1);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 2.2: start / end drawable defined in RTL mode
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_2_2);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 3.1: left / right / start / end drawable defined in LTR mode
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_3_1);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 3.2: left / right / start / end drawable defined in RTL mode
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_3_2);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 4.1: start / end drawable defined in LTR mode inside a layout
+ // that defines the layout direction
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_4_1);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 4.2: start / end drawable defined in RTL mode inside a layout
+ // that defines the layout direction
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_4_2);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 5.1: left / right / start / end drawable defined in LTR mode inside a layout
+ // that defines the layout direction
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_3_1);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+
+ // Case 5.2: left / right / start / end drawable defined in RTL mode inside a layout
+ // that defines the layout direction
+ tv = (TextView) activity.findViewById(R.id.textview_drawable_3_2);
+ drawables = tv.getCompoundDrawables();
+
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_red),
+ ((BitmapDrawable) drawables[LEFT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_blue),
+ ((BitmapDrawable) drawables[RIGHT]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_green),
+ ((BitmapDrawable) drawables[TOP]).getBitmap());
+ WidgetTestUtils.assertEquals(getBitmap(R.drawable.icon_yellow),
+ ((BitmapDrawable) drawables[BOTTOM]).getBitmap());
+ }
+
private static class MockOnEditorActionListener implements OnEditorActionListener {
private boolean isOnEditorActionCalled;