Merge "Camera: Add cancelAutofocus test case." into jb-dev
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
index c074195..92e13638 100644
--- a/development/ide/eclipse/.classpath
+++ b/development/ide/eclipse/.classpath
@@ -25,6 +25,7 @@
     <classpathentry kind="src" path="cts/tests/tests/accessibilityservice/src"/>
     <classpathentry kind="src" path="cts/tests/tests/accounts/src"/>
     <classpathentry kind="src" path="cts/tests/tests/admin/src"/>
+    <classpathentry kind="src" path="cts/tests/tests/animation/src"/>
     <classpathentry kind="src" path="cts/tests/tests/app/src"/>
     <classpathentry kind="src" path="cts/tests/tests/bluetooth/src"/>
     <classpathentry kind="src" path="cts/tests/tests/content/src"/>
@@ -43,6 +44,7 @@
     <classpathentry kind="src" path="cts/tests/tests/media/src"/>
     <classpathentry kind="src" path="cts/tests/tests/mediastress/src"/>
     <classpathentry kind="src" path="cts/tests/tests/net/src"/>
+    <classpathentry kind="src" path="cts/tests/tests/opengl/src"/>
     <classpathentry kind="src" path="cts/tests/tests/openglperf/src"/>
     <classpathentry kind="src" path="cts/tests/tests/os/src"/>
     <classpathentry kind="src" path="cts/tests/tests/performance/src"/>
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index 868db72..378b46e 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -43,14 +43,12 @@
   {
     description: "flakey libcore tests",
     names: [
-      "libcore.java.net.ConcurrentCloseTest#test_connect_timeout",
-      "libcore.java.net.ConcurrentCloseTest#test_read",
+      "libcore.java.net.ConcurrentCloseTest",
       "libcore.java.net.SocketTest#testAvailable",
-      "libcore.java.net.URLConnectionTest#testServerClosesSocket",
-      "libcore.java.net.URLConnectionTest#testServerShutdownInput",
-      "libcore.java.net.URLConnectionTest#testServerShutdownOutput",
+      "libcore.java.net.URLConnectionTest",
       "libcore.java.util.prefs.OldPreferencesTest#testAddNodeChangeListener",
-      "libcore.net.http.HttpResponseCacheTest#testClientPrematureDisconnectWithChunkedEncoding"
+      "libcore.net.http.HttpResponseCacheTest#testClientPrematureDisconnectWithChunkedEncoding",
+      "org.apache.harmony.luni.tests.java.net.URLConnectionTest"
     ]
   }
 ]
diff --git a/tests/src/android/view/animation/cts/AnimationTestUtils.java b/tests/src/android/view/animation/cts/AnimationTestUtils.java
index a2b786d..f9675c7 100644
--- a/tests/src/android/view/animation/cts/AnimationTestUtils.java
+++ b/tests/src/android/view/animation/cts/AnimationTestUtils.java
@@ -81,6 +81,8 @@
                 return animation.hasEnded();
             }
         }.run();
+
+        instrumentation.waitForIdleSync();
     }
 
     /**
diff --git a/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java b/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java
index c1cbfcc..71945ac 100644
--- a/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java
+++ b/tests/tests/animation/src/android/animation/cts/ObjectAnimatorTest.java
@@ -20,8 +20,8 @@
 import android.animation.ObjectAnimator;
 import android.animation.PropertyValuesHolder;
 import android.animation.ValueAnimator;
+import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
-import android.util.Property;
 import android.view.animation.AccelerateInterpolator;
 import android.view.animation.Interpolator;
 
@@ -133,7 +133,7 @@
         int values[] = {startColor, endColor};
         ArgbEvaluator evaluator = new ArgbEvaluator();
         PropertyValuesHolder propertyValuesHolder = PropertyValuesHolder.ofInt(propertyName, values);
-        ObjectAnimator colorAnimator = ObjectAnimator.ofPropertyValuesHolder(object, 
+        ObjectAnimator colorAnimator = ObjectAnimator.ofPropertyValuesHolder(object,
             propertyValuesHolder);
         colorAnimator.setDuration(1000);
         colorAnimator.setRepeatCount(1);
@@ -160,21 +160,6 @@
         assertEquals(propertyName, actualPropertyName);
     }
 
-    public void testSetCurrentPlayTime() throws Throwable {
-        Object object = mActivity.view.newBall;
-        String propertyName = "backgroundColor";
-        int startColor = mActivity.view.RED;
-        int endColor = mActivity.view.BLUE;
-        long playTime = 10000l;
-        Object[] values = {new Integer(startColor), new Integer(endColor)};
-        ArgbEvaluator evaluator = new ArgbEvaluator();
-        ObjectAnimator colorAnimator = ObjectAnimator.ofObject(object, propertyName,
-                evaluator, values);
-        colorAnimator.setCurrentPlayTime(playTime);
-        long actualPlayTime = colorAnimator.getCurrentPlayTime();
-        assertEquals(playTime, actualPlayTime);
-    }
-
     public void testSetFloatValues() throws Throwable {
         Object object = mActivity.view.newBall;
         String property = "y";
diff --git a/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java b/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java
index 1bfe737..dd73475 100644
--- a/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java
+++ b/tests/tests/animation/src/android/animation/cts/ValueAnimatorTest.java
@@ -24,7 +24,7 @@
         ActivityInstrumentationTestCase2<AnimationActivity> {
     private AnimationActivity mActivity;
     private ValueAnimator mValueAnimator;
-    private long mDuration = 1000;
+    private long mDuration = 2000;
 
     public ValueAnimatorTest() {
         super(AnimationActivity.class);
@@ -133,7 +133,7 @@
         ValueAnimator objAnimator = getAnimator();
         startAnimation(objAnimator);
         assertNotNull(objAnimator);
-        float[] fractions = getValue(objAnimator, 10, "getAnimatedFraction()", 100l, null);
+        float[] fractions = getValue(objAnimator, 10, "getAnimatedFraction()", 200l, null);
         for(int j = 0; j < 9; j++){
             assertTrue(fractions[j] >= 0.0);
             assertTrue(fractions[j] <= 1.0);
@@ -145,7 +145,7 @@
         ValueAnimator objAnimator = getAnimator();
         startAnimation(objAnimator);
         assertNotNull(objAnimator);
-        float[] animatedValues = getValue(objAnimator, 10, "getAnimatedValue()", 100l, null);
+        float[] animatedValues = getValue(objAnimator, 10, "getAnimatedValue()", 200l, null);
 
         for(int j = 0; j < 9; j++){
             assertTrue(animatedValues[j + 1] != animatedValues[j]);
@@ -157,7 +157,7 @@
         ValueAnimator objAnimator = getAnimator();
         startAnimation(objAnimator);
         assertNotNull(objAnimator);
-        float[] animatedValues = getValue(objAnimator, 10, "getAnimatedValue(property)", 100l,
+        float[] animatedValues = getValue(objAnimator, 10, "getAnimatedValue(property)", 200l,
             property);
         for(int j = 0; j < 9; j++){
             assertTrue(animatedValues[j + 1] != animatedValues[j]);
@@ -225,7 +225,7 @@
         return objAnimator;
     }
 
-    private float[] getValue(ValueAnimator animator, int n, String methodName, 
+    private float[] getValue(ValueAnimator animator, int n, String methodName,
             long sleepTime, String property) throws InterruptedException {
         float[] values = new float[n];
         for(int i = 0; i < (n-1); i++){
diff --git a/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java b/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java
index 3173e6c..034a77a 100644
--- a/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java
+++ b/tests/tests/opengl/src/android/opengl/cts/AttachShaderTest.java
@@ -15,14 +15,11 @@
  */
 package android.opengl.cts;
 
+import android.content.Intent;
 import android.opengl.GLES20;
 import android.test.ActivityInstrumentationTestCase2;
 
 public class AttachShaderTest extends ActivityInstrumentationTestCase2<OpenGLES20ActivityOne> {
-    private static final long SLEEP_TIME = 1000l;
-    public AttachShaderTest(Class<OpenGLES20ActivityOne> activityClass) {
-        super(activityClass);
-    }
 
     private OpenGLES20ActivityOne mActivity;
 
@@ -30,11 +27,14 @@
         super(OpenGLES20ActivityOne.class);
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mActivity = getActivity();
+    private OpenGLES20ActivityOne getShaderActivity(int viewType, int viewIndex) {
+        Intent intent = new Intent();
+        intent.putExtra(OpenGLES20NativeActivity.EXTRA_VIEW_TYPE, viewType);
+        intent.putExtra(OpenGLES20NativeActivity.EXTRA_VIEW_INDEX, viewIndex);
+        setActivityIntent(intent);
+        return getActivity();
     }
+
     /**
      *Test: Attach an two valid shaders to a program
      * <pre>
@@ -43,14 +43,7 @@
      * </pre>
      */
     public void test_glAttachedShaders_validshader() throws Throwable {
-
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 1);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 1);
         int shaderCount = mActivity.getNoOfAttachedShaders();
         assertEquals(2,shaderCount);
         int error = mActivity.glGetError();
@@ -67,13 +60,7 @@
      */
 
     public void test_glAttachedShaders_invalidshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 2);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 2);
         int shaderCount = mActivity.getNoOfAttachedShaders();
         assertEquals(1, shaderCount);
         int error = mActivity.glGetError();
@@ -89,13 +76,7 @@
      * @throws Throwable
      */
     public void test_glAttachedShaders_attach_same_shader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 3);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 3);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_INVALID_OPERATION, error);
     }
@@ -110,13 +91,7 @@
      */
 
     public void test_glAttachedShaders_noshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 4);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 4);
         int shaderCount = mActivity.getNoOfAttachedShaders();
         assertEquals(0, shaderCount);
         int error = mActivity.glGetError();
@@ -124,79 +99,37 @@
     }
 
     public void test_glAttachShaders_emptyfragshader_emptyfragshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 5);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 5);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_INVALID_OPERATION, error);
     }
 
     public void test_glAttachShaders_emptyfragshader_emptyvertexshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 6);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 6);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_NO_ERROR, error);
     }
 
     public void test_glAttachShaders_emptyvertexshader_emptyvertexshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 7);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 7);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_INVALID_OPERATION, error);
     }
 
     public void test_glAttachShaders_programobject_attach_fragshaderobject() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 8);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 8);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_INVALID_VALUE, error);
     }
 
     public void test_glAttachShaders_invalidshader_attach_valid_handle() throws Throwable{
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 9);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 9);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_INVALID_VALUE, error);
     }
 
     public void test_glAttachShaders_successfulcompile_attach_frag() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 10);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 10);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_NO_ERROR, error);
     }
diff --git a/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java b/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java
index e6707da..1a51b6e 100755
--- a/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java
+++ b/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java
@@ -15,14 +15,13 @@
  */
 package android.opengl.cts;
 
+import android.content.Intent;
 import android.opengl.GLES20;
 import android.test.ActivityInstrumentationTestCase2;
 
-public class NativeAttachShaderTest 
+public class NativeAttachShaderTest
         extends ActivityInstrumentationTestCase2<OpenGLES20NativeActivity> {
 
-    private static final long SLEEP_TIME = 1000l;
-
     public NativeAttachShaderTest(Class<OpenGLES20NativeActivity> activityClass) {
         super(activityClass);
     }
@@ -33,10 +32,12 @@
         super(OpenGLES20NativeActivity.class);
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mActivity = getActivity();
+    private OpenGLES20NativeActivity getShaderActivity(int viewType, int viewIndex) {
+        Intent intent = new Intent();
+        intent.putExtra(OpenGLES20NativeActivity.EXTRA_VIEW_TYPE, viewType);
+        intent.putExtra(OpenGLES20NativeActivity.EXTRA_VIEW_INDEX, viewIndex);
+        setActivityIntent(intent);
+        return getActivity();
     }
 
     /**
@@ -46,17 +47,10 @@
      * error        : GLES20.GL_NO_ERROR
      * </pre>
      */
-
     public void test_glAttachedShaders_validshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 1);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 1);
         int shaderCount = mActivity.mRenderer.mShaderCount;
-        assertEquals(2,shaderCount);
+        assertEquals(2, shaderCount);
         int error = mActivity.mRenderer.mAttachShaderError;
         assertEquals(GLES20.GL_NO_ERROR, error);
     }
@@ -69,18 +63,9 @@
      * </pre>
      * @throws Throwable
      */
-
     public void test_glAttachedShaders_invalidshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 2);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 2);
         int error = mActivity.mRenderer.mAttachShaderError;
-
         assertEquals(GLES20.GL_INVALID_VALUE, error);
     }
 
@@ -93,13 +78,7 @@
      * @throws Throwable
      */
     public void test_glAttachedShaders_attach_same_shader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 3);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 3);
         int error = mActivity.mRenderer.mAttachShaderError;
         assertEquals(GLES20.GL_INVALID_OPERATION, error);
     }
@@ -112,44 +91,23 @@
      * </pre>
      * @throws Throwable
      */
-
     public void test_glAttachedShaders_noshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 4);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
+        mActivity = getShaderActivity(Constants.SHADER, 4);
         int shaderCount = GL2JniLibOne.getAttachedShaderCount();
-        assertEquals(0,shaderCount);
+        assertEquals(0, shaderCount);
 
         int error = mActivity.mRenderer.mAttachShaderError;
         assertEquals(GLES20.GL_NO_ERROR, error);
     }
 
     public void test_glAttachShaders_emptyfragshader_emptyfragshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 5);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
-        int error = mActivity.mRenderer.mAttachShaderError;;
+        mActivity = getShaderActivity(Constants.SHADER, 5);
+        int error = mActivity.mRenderer.mAttachShaderError;
         assertEquals(GLES20.GL_INVALID_OPERATION, error);
     }
 
     public void test_glAttachShaders_emptyfragshader_emptyvertexshader() throws Throwable {
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.SHADER, 6);
-            }
-        });
-        Thread.sleep(SLEEP_TIME);
-
+        mActivity = getShaderActivity(Constants.SHADER, 6);
         int error = mActivity.mRenderer.mAttachShaderError;;
         assertEquals(GLES20.GL_NO_ERROR, error);
     }
diff --git a/tests/tests/opengl/src/android/opengl/cts/OpenGLES20ActivityOne.java b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20ActivityOne.java
index a3b7503..4a4e4ca 100644
--- a/tests/tests/opengl/src/android/opengl/cts/OpenGLES20ActivityOne.java
+++ b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20ActivityOne.java
@@ -24,19 +24,24 @@
 import android.view.WindowManager;
 
 public class OpenGLES20ActivityOne extends Activity {
+
+    public static final String EXTRA_VIEW_TYPE = "viewType";
+    public static final String EXTRA_VIEW_INDEX = "viewIndex";
+
     OpenGLES20View view;
     Renderer mRenderer;
     int mRendererType;
-    /** Called when the activity is first created. */
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         Window window = getWindow();
         window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
-    }
 
-    public void setView(int type, int i ) {
-        view = new OpenGLES20View(this,type,i);
+        int viewType = getIntent().getIntExtra(EXTRA_VIEW_TYPE, -1);
+        int viewIndex = getIntent().getIntExtra(EXTRA_VIEW_INDEX, -1);
+
+        view = new OpenGLES20View(this, viewType, viewIndex);
         setContentView(view);
     }
 
diff --git a/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java
index 7028db2..4579ebf 100755
--- a/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java
+++ b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java
@@ -15,26 +15,21 @@
  */
 package android.opengl.cts;
 
-import javax.microedition.khronos.egl.EGLConfig;
-import javax.microedition.khronos.opengles.GL10;
-
-import com.android.cts.opengl.R;
-
 import android.app.Activity;
 import android.content.Context;
 import android.opengl.GLSurfaceView;
 import android.os.Bundle;
 import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
 import android.view.Window;
 import android.view.WindowManager;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.TextView;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
 
 public class OpenGLES20NativeActivity extends Activity {
-    /** Called when the activity is first created. */
+
+    public static final String EXTRA_VIEW_TYPE = "viewType";
+    public static final String EXTRA_VIEW_INDEX = "viewIndex";
 
     int mValue;
 
@@ -48,21 +43,18 @@
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
+
         Window window = getWindow();
         window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
-    }
 
-    public void setView(int type, int i ) {
-        view = new OpenGLES20View(this,type,i);
+        int viewType = getIntent().getIntExtra(EXTRA_VIEW_TYPE, -1);
+        int viewIndex = getIntent().getIntExtra(EXTRA_VIEW_INDEX, -1);
+
+        view = new OpenGLES20View(this, viewType, viewIndex);
         setContentView(view);
     }
 
     @Override
-    protected void onDestroy() {
-        super.onDestroy();
-    }
-
-    @Override
     protected void onPause() {
         super.onPause();
         view.onPause();
@@ -107,11 +99,11 @@
     }
 
     public void onDrawFrame(GL10 gl) {
-        
+
     }
 
     public void onSurfaceChanged(GL10 gl, int width, int height) {
-        
+
     }
 
     public void onSurfaceCreated(GL10 gl, EGLConfig config) {
diff --git a/tests/tests/opengl/src/android/opengl/cts/ProgramTest.java b/tests/tests/opengl/src/android/opengl/cts/ProgramTest.java
index ee9a835..4c59070 100644
--- a/tests/tests/opengl/src/android/opengl/cts/ProgramTest.java
+++ b/tests/tests/opengl/src/android/opengl/cts/ProgramTest.java
@@ -15,14 +15,11 @@
  */
 package android.opengl.cts;
 
+import android.content.Intent;
 import android.opengl.GLES20;
 import android.test.ActivityInstrumentationTestCase2;
 
 public class ProgramTest extends ActivityInstrumentationTestCase2<OpenGLES20ActivityOne> {
-    public ProgramTest(Class<OpenGLES20ActivityOne> activityClass) {
-        super(activityClass);
-
-    }
 
     private OpenGLES20ActivityOne mActivity;
 
@@ -30,23 +27,17 @@
         super(OpenGLES20ActivityOne.class);
     }
 
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        mActivity = getActivity();
+    private OpenGLES20ActivityOne getShaderActivity(int viewType, int viewIndex) {
+        Intent intent = new Intent();
+        intent.putExtra(OpenGLES20NativeActivity.EXTRA_VIEW_TYPE, viewType);
+        intent.putExtra(OpenGLES20NativeActivity.EXTRA_VIEW_INDEX, viewIndex);
+        setActivityIntent(intent);
+        return getActivity();
     }
 
     public void test_glAttachShader_program() throws Throwable {
-
-        mActivity = getActivity();
-        this.runTestOnUiThread(new Runnable() {
-            public void run() {
-                mActivity.setView(Constants.PROGRAM,1);
-            }
-        });
-        Thread.sleep(1000);
+        mActivity = getShaderActivity(Constants.PROGRAM, 1);
         int error = mActivity.glGetError();
         assertEquals(GLES20.GL_INVALID_OPERATION, error);
     }
-
 }