am df20ad8e: am b7377cc8: (-s ours) am 6fb729dd: Merge "blacklist android.provider.cts.CalendarTest#testEventColors DO NOT MERGE" into jb-dev

* commit 'df20ad8efe6c045bf5655ab60dc0470701e80d7b':
  blacklist android.provider.cts.CalendarTest#testEventColors DO NOT MERGE
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/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());
     }