am 8ae96707: Adding a widget to perform a few basic tests of the widget framework
* commit '8ae96707415b1739c8e05cfdcc77809f36f9a7c6':
Adding a widget to perform a few basic tests of the widget framework
diff --git a/tests/src/android/view/inputmethod/cts/InputMethodSettingsActivityStub.java b/tests/src/android/view/inputmethod/cts/InputMethodInfoStub.java
similarity index 84%
rename from tests/src/android/view/inputmethod/cts/InputMethodSettingsActivityStub.java
rename to tests/src/android/view/inputmethod/cts/InputMethodInfoStub.java
index 58aa364..0eeefbe 100644
--- a/tests/src/android/view/inputmethod/cts/InputMethodSettingsActivityStub.java
+++ b/tests/src/android/view/inputmethod/cts/InputMethodInfoStub.java
@@ -16,8 +16,8 @@
package android.view.inputmethod.cts;
-import android.preference.PreferenceActivity;
+import android.inputmethodservice.InputMethodService;
-public class InputMethodSettingsActivityStub extends PreferenceActivity {
+public class InputMethodInfoStub extends InputMethodService {
}
diff --git a/tests/tests/media/src/android/media/cts/RingtoneTest.java b/tests/tests/media/src/android/media/cts/RingtoneTest.java
index 024f44d..6e3a1e9 100644
--- a/tests/tests/media/src/android/media/cts/RingtoneTest.java
+++ b/tests/tests/media/src/android/media/cts/RingtoneTest.java
@@ -21,6 +21,7 @@
import android.media.AudioManager;
import android.media.Ringtone;
import android.media.RingtoneManager;
+import android.net.Uri;
import android.provider.Settings;
import android.test.AndroidTestCase;
@@ -32,6 +33,7 @@
private int mOriginalVolume;
private int mOriginalRingerMode;
private int mOriginalStreamType;
+ private Uri mDefaultRingUri;
@Override
protected void setUp() throws Exception {
@@ -49,6 +51,9 @@
AudioManager.FLAG_ALLOW_RINGER_MODES);
// make sure that we are not in silent mode
mAudioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
+
+ mDefaultRingUri = RingtoneManager.getActualDefaultRingtoneUri(mContext,
+ RingtoneManager.TYPE_RINGTONE);
}
@Override
@@ -63,6 +68,8 @@
mAudioManager.setStreamVolume(AudioManager.STREAM_RING, mOriginalVolume,
AudioManager.FLAG_ALLOW_RINGER_MODES);
}
+ RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_RINGTONE,
+ mDefaultRingUri);
super.tearDown();
}
@@ -79,8 +86,20 @@
mRingtone.setStreamType(AudioManager.STREAM_RING);
assertEquals(AudioManager.STREAM_RING, mRingtone.getStreamType());
+ // test both the "None" ringtone and an actual ringtone
+ RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_RINGTONE, null);
+ mRingtone = RingtoneManager.getRingtone(mContext, Settings.System.DEFAULT_RINGTONE_URI);
+ assertTrue(mRingtone.getStreamType() == AudioManager.STREAM_RING);
mRingtone.play();
- assertTrue(mRingtone.isPlaying());
+ assertFalse(mRingtone.isPlaying());
+
+ Uri uri = RingtoneManager.getValidRingtoneUri(mContext);
+ assertNotNull("ringtone was unexpectedly null", uri);
+ RingtoneManager.setActualDefaultRingtoneUri(mContext, RingtoneManager.TYPE_RINGTONE, uri);
+ mRingtone = RingtoneManager.getRingtone(mContext, Settings.System.DEFAULT_RINGTONE_URI);
+ assertTrue(mRingtone.getStreamType() == AudioManager.STREAM_RING);
+ mRingtone.play();
+ assertTrue("couldn't play ringtone " + uri, mRingtone.isPlaying());
mRingtone.stop();
assertFalse(mRingtone.isPlaying());
}
diff --git a/tests/tests/mediastress/src/android/mediastress/cts/CodecTest.java b/tests/tests/mediastress/src/android/mediastress/cts/CodecTest.java
index c349ac0..1b4ed62 100644
--- a/tests/tests/mediastress/src/android/mediastress/cts/CodecTest.java
+++ b/tests/tests/mediastress/src/android/mediastress/cts/CodecTest.java
@@ -808,6 +808,9 @@
return false;
}
}
+ if (!mOnCompleteSuccess && !mPlaybackError) {
+ Log.e(TAG, "wait timed-out without onCompletion notification");
+ }
terminateMessageLooper();
} catch (Exception e) {
Log.v(TAG, "playMediaSample Exception:" + e.getMessage());
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 0167364..dfa8301 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -29,7 +29,7 @@
private static final String LOG_TAG = "BuildVersionTest";
private static final Set<String> EXPECTED_RELEASES =
- new HashSet<String>(Arrays.asList("4.2", "4.2.1"));
+ new HashSet<String>(Arrays.asList("4.2", "4.2.1", "4.2.2"));
private static final int EXPECTED_SDK = 17;
@SuppressWarnings("deprecation")
diff --git a/tests/tests/view/src/android/view/cts/ViewGroupTest.java b/tests/tests/view/src/android/view/cts/ViewGroupTest.java
index 1fc9a88..b46c031 100644
--- a/tests/tests/view/src/android/view/cts/ViewGroupTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewGroupTest.java
@@ -1661,6 +1661,63 @@
assertFalse(vg.isGetChildStaticTransformationCalled);
}
+ static public int resetRtlPropertiesCount;
+ static public int resetResolvedLayoutDirectionCount;
+ static public int resetResolvedTextDirectionCount;
+ static public int resetResolvedTextAlignmentCount;
+ static public int resetResolvedPaddingCount;
+ static public int resetResolvedDrawablesCount;
+
+
+ private static void clearRtlCounters() {
+ resetRtlPropertiesCount = 0;
+ resetResolvedLayoutDirectionCount = 0;
+ resetResolvedTextDirectionCount = 0;
+ resetResolvedTextAlignmentCount = 0;
+ resetResolvedPaddingCount = 0;
+ resetResolvedDrawablesCount = 0;
+ }
+
+ public void testResetRtlProperties() {
+ clearRtlCounters();
+
+ MockViewGroup vg = new MockViewGroup(mContext);
+ MockView2 v1 = new MockView2(mContext);
+ MockView2 v2 = new MockView2(mContext);
+
+ MockViewGroup v3 = new MockViewGroup(mContext);
+ MockView2 v4 = new MockView2(mContext);
+
+ v3.addView(v4);
+ assertEquals(1, resetRtlPropertiesCount);
+ assertEquals(1, resetResolvedLayoutDirectionCount);
+ assertEquals(1, resetResolvedTextDirectionCount);
+ assertEquals(1, resetResolvedTextAlignmentCount);
+ assertEquals(1, resetResolvedPaddingCount);
+ assertEquals(1, resetResolvedDrawablesCount);
+
+ clearRtlCounters();
+ vg.addView(v1);
+ vg.addView(v2);
+ vg.addView(v3);
+
+ assertEquals(3, resetRtlPropertiesCount); // for v1 / v2 / v3 only
+ assertEquals(4, resetResolvedLayoutDirectionCount); // for v1 / v2 / v3 / v4
+ assertEquals(4, resetResolvedTextDirectionCount);
+ assertEquals(3, resetResolvedTextAlignmentCount); // for v1 / v2 / v3 only
+ assertEquals(4, resetResolvedPaddingCount);
+ assertEquals(4, resetResolvedDrawablesCount);
+
+ clearRtlCounters();
+ vg.resetRtlProperties();
+ assertEquals(1, resetRtlPropertiesCount); // for vg only
+ assertEquals(5, resetResolvedLayoutDirectionCount); // for all
+ assertEquals(5, resetResolvedTextDirectionCount);
+ assertEquals(1, resetResolvedTextAlignmentCount); // for vg only as TextAlignment is not inherited (default is Gravity)
+ assertEquals(5, resetResolvedPaddingCount);
+ assertEquals(5, resetResolvedDrawablesCount);
+ }
+
static class MockTextView extends TextView {
public boolean isClearFocusCalled;
@@ -2071,6 +2128,93 @@
public void setStaticTransformationsEnabled(boolean enabled) {
super.setStaticTransformationsEnabled(enabled);
}
+
+ @Override
+ public void resetRtlProperties() {
+ super.resetRtlProperties();
+ resetRtlPropertiesCount++;
+ }
+
+ @Override
+ public void resetResolvedLayoutDirection() {
+ super.resetResolvedLayoutDirection();
+ resetResolvedLayoutDirectionCount++;
+ }
+
+ @Override
+ public void resetResolvedTextDirection() {
+ super.resetResolvedTextDirection();
+ resetResolvedTextDirectionCount++;
+ }
+
+ @Override
+ public void resetResolvedTextAlignment() {
+ super.resetResolvedTextAlignment();
+ resetResolvedTextAlignmentCount++;
+ }
+
+ @Override
+ public void resetResolvedPadding() {
+ super.resetResolvedPadding();
+ resetResolvedPaddingCount++;
+ }
+
+ @Override
+ protected void resetResolvedDrawables() {
+ super.resetResolvedDrawables();
+ resetResolvedDrawablesCount++;
+ }
+ }
+
+ static class MockView2 extends View {
+
+ public MockView2(Context context) {
+ super(context);
+ }
+
+ public MockView2(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MockView2(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ public void resetRtlProperties() {
+ super.resetRtlProperties();
+ resetRtlPropertiesCount++;
+ }
+
+ @Override
+ public void resetResolvedLayoutDirection() {
+ super.resetResolvedLayoutDirection();
+ resetResolvedLayoutDirectionCount++;
+ }
+
+ @Override
+ public void resetResolvedTextDirection() {
+ super.resetResolvedTextDirection();
+ resetResolvedTextDirectionCount++;
+ }
+
+ @Override
+ public void resetResolvedTextAlignment() {
+ super.resetResolvedTextAlignment();
+ resetResolvedTextAlignmentCount++;
+ }
+
+ @Override
+ public void resetResolvedPadding() {
+ super.resetResolvedPadding();
+ resetResolvedPaddingCount++;
+ }
+
+ @Override
+ protected void resetResolvedDrawables() {
+ super.resetResolvedDrawables();
+ resetResolvedDrawablesCount++;
+ }
}
public void setResult(int resultCode) {
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java
index 722c1b3..00a8dea 100644
--- a/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java
@@ -16,6 +16,7 @@
package android.view.inputmethod.cts;
+
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -26,7 +27,6 @@
import android.util.Printer;
import android.view.inputmethod.InputMethod;
import android.view.inputmethod.InputMethodInfo;
-import android.view.inputmethod.InputMethodSubtype;
import org.xmlpull.v1.XmlPullParserException;
@@ -40,40 +40,14 @@
private CharSequence mLabel;
private String mSettingsActivity;
- private int mSubtypeNameResId;
- private int mSubtypeIconResId;
- private String mSubtypeLocale;
- private String mSubtypeMode;
- private String mSubtypeExtraValue_key;
- private String mSubtypeExtraValue_value;
- private String mSubtypeExtraValue;
- private boolean mSubtypeIsAuxiliary;
- private boolean mSubtypeOverridesImplicitlyEnabledSubtype;
- private int mSubtypeId;
- private InputMethodSubtype mInputMethodSubtype;
-
@Override
protected void setUp() throws Exception {
super.setUp();
mPackageName = mContext.getPackageName();
- mClassName = InputMethodSettingsActivityStub.class.getName();
+ mClassName = InputMethodInfoStub.class.getName();
mLabel = "test";
- mSettingsActivity = "android.view.inputmethod.cts.InputMethodSettingsActivityStub";
+ mSettingsActivity = "android.view.inputmethod.cts.InputMethodInfoStub";
mInputMethodInfo = new InputMethodInfo(mPackageName, mClassName, mLabel, mSettingsActivity);
-
- mSubtypeNameResId = 0;
- mSubtypeIconResId = 0;
- mSubtypeLocale = "en_US";
- mSubtypeMode = "keyboard";
- mSubtypeExtraValue_key = "key1";
- mSubtypeExtraValue_value = "value1";
- mSubtypeExtraValue = "tag," + mSubtypeExtraValue_key + "=" + mSubtypeExtraValue_value;
- mSubtypeIsAuxiliary = false;
- mSubtypeOverridesImplicitlyEnabledSubtype = false;
- mSubtypeId = 99;
- mInputMethodSubtype = new InputMethodSubtype(mSubtypeNameResId, mSubtypeIconResId,
- mSubtypeLocale, mSubtypeMode, mSubtypeExtraValue, mSubtypeIsAuxiliary,
- mSubtypeOverridesImplicitlyEnabledSubtype, mSubtypeId);
}
public void testInputMethodInfoProperties() throws XmlPullParserException, IOException {
@@ -84,7 +58,7 @@
assertEquals(0, mInputMethodInfo.getIsDefaultResourceId());
Intent intent = new Intent(InputMethod.SERVICE_INTERFACE);
- intent.setClass(mContext, InputMethodSettingsActivityStub.class);
+ intent.setClass(mContext, InputMethodInfoStub.class);
PackageManager pm = mContext.getPackageManager();
List<ResolveInfo> ris = pm.queryIntentServices(intent, PackageManager.GET_META_DATA);
for (int i = 0; i < ris.size(); i++) {
@@ -95,22 +69,6 @@
}
}
- public void testInputMethodSubtypeProperties() {
- // TODO: Test InputMethodSubtype.getDisplayName()
- assertEquals(mSubtypeNameResId, mInputMethodSubtype.getNameResId());
- assertEquals(mSubtypeIconResId, mInputMethodSubtype.getIconResId());
- assertEquals(mSubtypeLocale, mInputMethodSubtype.getLocale());
- assertEquals(mSubtypeMode, mInputMethodSubtype.getMode());
- assertEquals(mSubtypeExtraValue, mInputMethodSubtype.getExtraValue());
- assertTrue(mInputMethodSubtype.containsExtraValueKey(mSubtypeExtraValue_key));
- assertEquals(mSubtypeExtraValue_value,
- mInputMethodSubtype.getExtraValueOf(mSubtypeExtraValue_key));
- assertEquals(mSubtypeIsAuxiliary, mInputMethodSubtype.isAuxiliary());
- assertEquals(mSubtypeOverridesImplicitlyEnabledSubtype,
- mInputMethodSubtype.overridesImplicitlyEnabledSubtype());
- assertEquals(mSubtypeId, mInputMethodSubtype.hashCode());
- }
-
private void assertService(ServiceInfo expected, ServiceInfo actual) {
assertEquals(expected.getIconResource(), actual.getIconResource());
assertEquals(expected.labelRes, actual.labelRes);
@@ -152,39 +110,19 @@
assertEquals(expected.toString(), mInputMethodInfo.loadLabel(pm).toString());
}
- public void testInputMethodInfoWriteToParcel() {
- final Parcel p = Parcel.obtain();
+ public void testWriteToParcel() {
+ Parcel p = Parcel.obtain();
mInputMethodInfo.writeToParcel(p, 0);
p.setDataPosition(0);
- final InputMethodInfo imi = InputMethodInfo.CREATOR.createFromParcel(p);
+ InputMethodInfo inputMethodInfo = InputMethodInfo.CREATOR.createFromParcel(p);
- assertEquals(mInputMethodInfo.getPackageName(), imi.getPackageName());
- assertEquals(mInputMethodInfo.getServiceName(), imi.getServiceName());
- assertEquals(mInputMethodInfo.getSettingsActivity(), imi.getSettingsActivity());
- assertEquals(mInputMethodInfo.getId(), imi.getId());
- assertEquals(mInputMethodInfo.getIsDefaultResourceId(), imi.getIsDefaultResourceId());
- assertService(mInputMethodInfo.getServiceInfo(), imi.getServiceInfo());
- }
-
- public void testInputMethodSubtypeWriteToParcel() {
- final Parcel p = Parcel.obtain();
- mInputMethodSubtype.writeToParcel(p, 0);
- p.setDataPosition(0);
- final InputMethodSubtype subtype = InputMethodSubtype.CREATOR.createFromParcel(p);
-
- assertEquals(mInputMethodSubtype.containsExtraValueKey(mSubtypeExtraValue_key),
- subtype.containsExtraValueKey(mSubtypeExtraValue_key));
- assertEquals(mInputMethodSubtype.getExtraValue(), subtype.getExtraValue());
- assertEquals(mInputMethodSubtype.getExtraValueOf(mSubtypeExtraValue_key),
- subtype.getExtraValueOf(mSubtypeExtraValue_key));
- assertEquals(mInputMethodSubtype.getIconResId(), subtype.getIconResId());
- assertEquals(mInputMethodSubtype.getLocale(), subtype.getLocale());
- assertEquals(mInputMethodSubtype.getMode(), subtype.getMode());
- assertEquals(mInputMethodSubtype.getNameResId(), subtype.getNameResId());
- assertEquals(mInputMethodSubtype.hashCode(), subtype.hashCode());
- assertEquals(mInputMethodSubtype.isAuxiliary(), subtype.isAuxiliary());
- assertEquals(mInputMethodSubtype.overridesImplicitlyEnabledSubtype(),
- subtype.overridesImplicitlyEnabledSubtype());
+ assertEquals(mInputMethodInfo.getPackageName(), inputMethodInfo.getPackageName());
+ assertEquals(mInputMethodInfo.getServiceName(), inputMethodInfo.getServiceName());
+ assertEquals(mInputMethodInfo.getSettingsActivity(), inputMethodInfo.getSettingsActivity());
+ assertEquals(mInputMethodInfo.getId(), inputMethodInfo.getId());
+ assertEquals(mInputMethodInfo.getIsDefaultResourceId(), inputMethodInfo
+ .getIsDefaultResourceId());
+ assertService(mInputMethodInfo.getServiceInfo(), inputMethodInfo.getServiceInfo());
}
class MockPrinter implements Printer {
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index 9080320..533e8a8 100755
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -3151,7 +3151,12 @@
tv.setTextDirection(View.TEXT_DIRECTION_INHERIT);
assertEquals(View.TEXT_DIRECTION_RTL, tv.getTextDirection());
+ // No reset when we remove the view
ll.removeView(tv);
+ assertEquals(View.TEXT_DIRECTION_RTL, tv.getTextDirection());
+
+ // Reset is done when we add the view
+ ll.addView(tv);
assertEquals(View.TEXT_DIRECTION_FIRST_STRONG, tv.getTextDirection());
}
@@ -3274,8 +3279,13 @@
tv.setTextAlignment(View.TEXT_ALIGNMENT_INHERIT);
assertEquals(View.TEXT_ALIGNMENT_CENTER, tv.getTextAlignment());
+ // No reset when we remove the view
ll.removeView(tv);
- // default text alignment is GRAVITY
+ assertEquals(View.TEXT_ALIGNMENT_CENTER, tv.getTextAlignment());
+
+ // Reset is done when we add the view
+ // Default text alignment is GRAVITY
+ ll.addView(tv);
assertEquals(View.TEXT_ALIGNMENT_GRAVITY, tv.getTextAlignment());
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
index 8fb2f15..6674bdf 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/build/CtsBuildProvider.java
@@ -31,7 +31,7 @@
@Option(name="cts-install-path", description="the path to the cts installation to use")
private String mCtsRootDirPath = System.getProperty("CTS_ROOT");
- public static final String CTS_BUILD_VERSION = "4.2_r2";
+ public static final String CTS_BUILD_VERSION = "4.2_r1";
/**
* {@inheritDoc}