Six Test cases for AttachShader - Written in opengl es c apis

Change-Id: I9359587d9cf4c9ccd7b80397ee18c0f666cedae3
diff --git a/tests/tests/opengl/Android.mk b/tests/tests/opengl/Android.mk
index fbb3b2a..6c533a0 100644
--- a/tests/tests/opengl/Android.mk
+++ b/tests/tests/opengl/Android.mk
@@ -26,9 +26,15 @@
 
 # All tests should include android.test.runner.
 LOCAL_JAVA_LIBRARIES := android.test.runner
-
+LOCAL_JNI_SHARED_LIBRARIES := libopengltest
 LOCAL_SRC_FILES := $(call all-java-files-under, src)
 
 LOCAL_SDK_VERSION := current
 
 include $(BUILD_CTS_PACKAGE)
+
+# Include the associated library's makefile.
+include $(LOCAL_PATH)/libopengltest/Android.mk
+
+
+
diff --git a/tests/tests/opengl/AndroidManifest.xml b/tests/tests/opengl/AndroidManifest.xml
index c2f6078..ef1af51 100644
--- a/tests/tests/opengl/AndroidManifest.xml
+++ b/tests/tests/opengl/AndroidManifest.xml
@@ -19,6 +19,7 @@
     android:versionName="1.0" >
 
     <uses-sdk android:minSdkVersion="14" />
+    <uses-feature android:glEsVersion="0x00020000"/>
     <instrumentation
         android:name="android.test.InstrumentationTestRunner"
         android:targetPackage="com.android.cts.opengl" />
@@ -36,6 +37,9 @@
             </intent-filter>
          </activity> 
          <uses-library  android:name="android.test.runner" />
+         <activity
+            android:name="android.opengl.cts.OpenGLES20NativeActivity"
+            android:label="@string/app_name" />
     </application>
 
 </manifest>
diff --git a/tests/tests/opengl/libopengltest/Android.mk b/tests/tests/opengl/libopengltest/Android.mk
new file mode 100755
index 0000000..a54816e
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/Android.mk
@@ -0,0 +1,37 @@
+# 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.
+
+#
+# This is the shared library included by the JNI test app.
+#
+LOCAL_PATH := $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_MODULE := libopengltest
+LOCAL_MODULE_TAGS := optional
+LOCAL_SRC_FILES := common.cpp \
+                   gl2_jni_libone.cpp \
+                   attach_shader_one.cpp \
+                   attach_shader_two.cpp \
+                   attach_shader_three.cpp \
+                   attach_shader_four.cpp \
+                   attach_shader_five.cpp \
+                   attach_shader_six.cpp \
+
+LOCAL_C_INCLUDES := $(JNI_H_INCLUDE)
+
+LOCAL_SHARED_LIBRARIES := libGLESv2 liblog
+include $(BUILD_SHARED_LIBRARY)
+
+
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_five.cpp b/tests/tests/opengl/libopengltest/attach_shader_five.cpp
new file mode 100755
index 0000000..dcfd1b2
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_five.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "attach_shader_five.h"
+
+#define  LOG_TAG    "attach_shader_five"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+Data attachShaderFive(){
+    GLuint fragmentShaderOne = glCreateShader(GL_FRAGMENT_SHADER);
+    GLuint fragmentShaderTwo = glCreateShader(GL_FRAGMENT_SHADER);
+    GLuint program = glCreateProgram();
+    glAttachShader(program, fragmentShaderOne);
+    glAttachShader(program, fragmentShaderTwo);
+    GLsizei maxCount = 10;
+    GLsizei count;
+    GLuint shaders[maxCount];
+
+    glGetAttachedShaders(program, maxCount,
+         &count,
+         shaders);
+    LOGI("Attached Shader First element :  %d\n", *shaders);
+    LOGI("ShaderCount %d\n", count);
+    GLint error = glGetError();
+    Data data = {error, count, -1};
+
+    glDeleteProgram(program);
+    return data;
+}
+
+
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_five.h b/tests/tests/opengl/libopengltest/attach_shader_five.h
new file mode 100755
index 0000000..67015b9
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_five.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef _ATTACH_SHADER_FIVE_H_
+#define _ATTACH_SHADER_FIVE_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <android/log.h>
+#include "types.h"
+
+Data attachShaderFive();
+
+#endif
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_four.cpp b/tests/tests/opengl/libopengltest/attach_shader_four.cpp
new file mode 100755
index 0000000..d047cf4
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_four.cpp
@@ -0,0 +1,44 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "attach_shader_four.h"
+
+#define  LOG_TAG    "attach_shader_four"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+Data attachShaderFour(){
+    GLuint program = glCreateProgram();
+    GLsizei maxCount = 10;
+    GLsizei count;
+    GLuint shaders[maxCount];
+
+    glGetAttachedShaders(program, maxCount,
+         &count,
+         shaders);
+    LOGI("Attached Shader First element :  %d\n", *shaders);
+    LOGI("ShaderCount %d\n", count);
+    GLint error = glGetError();
+    Data data = {error, count, -1};
+
+    glDeleteProgram(program);
+    return data;
+}
+
+
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_four.h b/tests/tests/opengl/libopengltest/attach_shader_four.h
new file mode 100755
index 0000000..f170cb0
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_four.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef _ATTACH_SHADER_FOUR_H_
+#define _ATTACH_SHADER_FOUR_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <android/log.h>
+#include "types.h"
+
+Data attachShaderFour();
+
+#endif
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_one.cpp b/tests/tests/opengl/libopengltest/attach_shader_one.cpp
new file mode 100755
index 0000000..b8c8575
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_one.cpp
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "attach_shader_one.h"
+#include "common.h"
+
+#define  LOG_TAG    "attach_shader_one"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+static const char gVertexShader[] =
+    "attribute vec4 vPosition;\n"
+    "void main() {\n"
+    "  gl_Position = vPosition;\n"
+    "}\n";
+
+static const char gFragmentShader[] =
+    "precision mediump float;\n"
+    "void main() {\n"
+    "  gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n"
+    "}\n";
+
+
+Data attachShaderOne(){
+    GLuint vertexShader = loadShader(GL_VERTEX_SHADER, gVertexShader);
+    GLuint pixelShader = loadShader(GL_FRAGMENT_SHADER, gFragmentShader);
+    GLuint program = glCreateProgram();
+
+    glAttachShader(program, vertexShader);
+    glAttachShader(program, pixelShader);
+    int e1 = -1;
+    GLsizei maxCount = 10;
+    GLsizei count;
+    GLuint shaders[maxCount];
+
+    glGetAttachedShaders(program, maxCount,
+         &count,
+         shaders);
+    LOGI("Attached Shader First elemt :  %d\n", *shaders);
+    LOGI("ShaderCount %d\n", count);
+    GLint error = glGetError();
+    Data data = {error, count, -1};
+    glDeleteShader(vertexShader);
+    glDeleteShader(pixelShader);
+    glDeleteProgram(program);
+    return data;
+}
+
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_one.h b/tests/tests/opengl/libopengltest/attach_shader_one.h
new file mode 100755
index 0000000..bceadbc
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_one.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef _ATTACH_SHADER_ONE_H_
+#define _ATTACH_SHADER_ONE_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <android/log.h>
+#include "types.h"
+
+Data attachShaderOne();
+
+#endif
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_six.cpp b/tests/tests/opengl/libopengltest/attach_shader_six.cpp
new file mode 100755
index 0000000..8e987f7
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_six.cpp
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "attach_shader_six.h"
+
+#define  LOG_TAG    "attach_shader_six"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+Data attachShaderSix(){
+    GLuint fragmentShader = glCreateShader(GL_FRAGMENT_SHADER);
+    GLuint vertexShader = glCreateShader(GL_VERTEX_SHADER);
+
+    GLuint program = glCreateProgram();
+    glAttachShader(program, fragmentShader);
+    glAttachShader(program, vertexShader);
+
+
+    GLint error = glGetError();
+    Data data = {error, -9 , -1};
+
+    glDeleteProgram(program);
+    return data;
+}
diff --git a/tests/tests/opengl/libopengltest/attach_shader_six.h b/tests/tests/opengl/libopengltest/attach_shader_six.h
new file mode 100755
index 0000000..05030cf
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_six.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef _ATTACH_SHADER_SIX_H_
+#define _ATTACH_SHADER_SIX_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <android/log.h>
+#include "types.h"
+
+Data attachShaderSix();
+
+#endif
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_three.cpp b/tests/tests/opengl/libopengltest/attach_shader_three.cpp
new file mode 100755
index 0000000..2364a6d
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_three.cpp
@@ -0,0 +1,48 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "attach_shader_three.h"
+#include "common.h"
+
+#define  LOG_TAG    "attach_shader_three"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+static const char gVertexShader[] =
+    "attribute vec4 vPosition;\n"
+    "void main() {\n"
+    "  gl_Position = vPosition;\n"
+    "}\n";
+
+Data attachShaderThree(){
+    GLuint vertexShader = loadShader(GL_VERTEX_SHADER, gVertexShader);
+    GLuint program = glCreateProgram();
+    glAttachShader(program, vertexShader);
+    glAttachShader(program, vertexShader);
+
+
+    GLint error = glGetError();
+    Data data = {error, -9, -1};
+    glDeleteShader(vertexShader);
+    glDeleteProgram(program);
+    return data;
+}
+
+
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_three.h b/tests/tests/opengl/libopengltest/attach_shader_three.h
new file mode 100755
index 0000000..fb236e4
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_three.h
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+#ifndef _ATTACH_SHADER_THREE_H_
+#define _ATTACH_SHADER_THREE_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <android/log.h>
+#include "types.h"
+
+Data attachShaderThree();
+
+#endif
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_two.cpp b/tests/tests/opengl/libopengltest/attach_shader_two.cpp
new file mode 100755
index 0000000..d2affa3
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_two.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <android/log.h>
+#include "attach_shader_two.h"
+#include "common.h"
+
+#define  LOG_TAG    "attach_shader_two"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+
+Data attachShaderTwo(){
+    GLuint vertexShader = -99;
+    GLuint program = glCreateProgram();
+
+    glAttachShader(program, vertexShader);
+
+    GLsizei maxCount = 10;
+    GLsizei count;
+    GLuint shaders[maxCount];
+
+    glGetAttachedShaders(program, maxCount,
+         &count,
+         shaders);
+    LOGI("Attached Shader First element :  %d\n", *shaders);
+    LOGI("ShaderCount %d\n", count);
+    GLint error = glGetError();
+    LOGI("Error %d\n", error);
+    Data data = {error, count, -1};
+
+    glDeleteProgram(program);
+    return data;
+}
+
+
diff --git a/tests/tests/opengl/libopengltest/attach_shader_two.h b/tests/tests/opengl/libopengltest/attach_shader_two.h
new file mode 100755
index 0000000..1e8ca8e
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/attach_shader_two.h
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+
+#ifndef _ATTACH_SHADER_TWO_H_
+#define _ATTACH_SHADER_TWO_H_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "types.h"
+
+
+
+Data attachShaderTwo();
+
+#endif
+
diff --git a/tests/tests/opengl/libopengltest/common.cpp b/tests/tests/opengl/libopengltest/common.cpp
new file mode 100755
index 0000000..5a85a1e
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/common.cpp
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "common.h"
+
+GLuint loadShader(GLenum shaderType, const char* pSource) {
+    GLuint shader = glCreateShader(shaderType);
+    glShaderSource(shader, 1, &pSource, NULL);
+    glCompileShader(shader);
+    return shader;
+}
+
+
diff --git a/tests/tests/opengl/libopengltest/common.h b/tests/tests/opengl/libopengltest/common.h
new file mode 100755
index 0000000..4527565
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/common.h
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+#ifndef _TYPE_COMMON_
+#define _TYPE_COMMON_
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+GLuint loadShader(GLenum shaderType, const char* pSource);
+
+#endif
diff --git a/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp b/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
new file mode 100755
index 0000000..9433702
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/gl2_jni_libone.cpp
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+
+
+#include <jni.h>
+#include <android/log.h>
+
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include "attach_shader_one.h"
+#include "attach_shader_two.h"
+#include "attach_shader_three.h"
+#include "attach_shader_four.h"
+#include "attach_shader_five.h"
+#include "attach_shader_six.h"
+
+#define  LOG_TAG    "gl2_jni_libone"
+#define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
+#define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
+static GLint errorAttachShader = -1;
+static GLint shaderCount = -1;
+
+
+extern "C" JNIEXPORT void JNICALL Java_android_opengl_cts_GL2JniLibOne_init
+  (JNIEnv *, jclass pClass, jint pCategory, jint pSubCategory)  {
+    LOGI("Category :  %d\n", pCategory);
+
+    if(pCategory == 1) {
+        if(pSubCategory == 1) {
+            Data data = attachShaderOne();
+            LOGI("Attach Shader Error :  %d\n", data.mShaderError);
+            LOGI("Shader Count :  %d\n", data.mShaderCount);
+            errorAttachShader = data.mShaderError;
+            shaderCount = data.mShaderCount;
+        }else if(pSubCategory == 2) {
+            Data data = attachShaderTwo();
+            LOGI("Attach Shader Error :  %d\n", data.mShaderError);
+            errorAttachShader = data.mShaderError;
+        }else if(pSubCategory == 3) {
+            Data data = attachShaderThree();
+            LOGI("Attach Shader Error :  %d\n", data.mShaderError);
+            errorAttachShader = data.mShaderError;
+        }else if(pSubCategory == 4) {
+            Data data = attachShaderFour();
+            LOGI("Attach Shader Error :  %d\n", data.mShaderError);
+            LOGI("Shader Count :  %d\n", data.mShaderCount);
+            errorAttachShader = data.mShaderError;
+            shaderCount = data.mShaderCount;
+        }else if(pSubCategory == 5) {
+            Data data = attachShaderFive();
+            LOGI("Attach Shader Error :  %d\n", data.mShaderError);
+            errorAttachShader = data.mShaderError;
+        }else if(pSubCategory == 6) {
+            Data data = attachShaderSix();
+            LOGI("Attach Shader Error :  %d\n", data.mShaderError);
+            errorAttachShader = data.mShaderError;
+        }
+    }
+}
+
+extern "C" JNIEXPORT void JNICALL Java_android_opengl_cts_GL2JniLibOne_step(JNIEnv * env, jclass obj)
+{
+    //implement later
+}
+
+extern "C" JNIEXPORT jint JNICALL Java_android_opengl_cts_GL2JniLibOne_getAttachShaderError(JNIEnv * env, jclass obj){
+    return errorAttachShader;
+}
+
+extern "C" JNIEXPORT jint JNICALL Java_android_opengl_cts_GL2JniLibOne_getLoadShaderError(JNIEnv * env, jclass obj){
+     return -1;
+}
+
+extern "C" JNIEXPORT jint JNICALL Java_android_opengl_cts_GL2JniLibOne_getProgramError(JNIEnv * env, jclass obj){
+     return -2;
+}
+
+extern "C" JNIEXPORT jint JNICALL Java_android_opengl_cts_GL2JniLibOne_getAttachedShaderCount(JNIEnv * env, jclass obj){
+    return shaderCount;
+}
+
+
diff --git a/tests/tests/opengl/libopengltest/types.h b/tests/tests/opengl/libopengltest/types.h
new file mode 100755
index 0000000..0faa3fa
--- /dev/null
+++ b/tests/tests/opengl/libopengltest/types.h
@@ -0,0 +1,24 @@
+/*
+ * 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.
+ */
+#ifndef _TYPES_H_
+#define _TYPES_H_
+typedef struct {
+    int32_t mShaderError;
+    int32_t mShaderCount;
+    int32_t mProgramError;
+} Data;
+
+#endif
diff --git a/tests/tests/opengl/src/android/opengl/cts/Constants.java b/tests/tests/opengl/src/android/opengl/cts/Constants.java
index bdc8de1..9bd1acc 100644
--- a/tests/tests/opengl/src/android/opengl/cts/Constants.java
+++ b/tests/tests/opengl/src/android/opengl/cts/Constants.java
@@ -16,6 +16,6 @@
 package android.opengl.cts;
 
 public class Constants {
-    public static final String SHADER = "shader";
-    public static final String PROGRAM = "program";
+    public static final int SHADER = 1;
+    public static final int PROGRAM = 2;
 }
diff --git a/tests/tests/opengl/src/android/opengl/cts/GL2JniLibOne.java b/tests/tests/opengl/src/android/opengl/cts/GL2JniLibOne.java
new file mode 100755
index 0000000..26de6ff
--- /dev/null
+++ b/tests/tests/opengl/src/android/opengl/cts/GL2JniLibOne.java
@@ -0,0 +1,31 @@
+/*
+ * 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 android.opengl.cts;
+
+public class GL2JniLibOne {
+     static {
+         System.loadLibrary("opengltest");
+     }
+
+     public static native void init(int category, int subcategory);
+     public static native void step();
+
+     public static native int getAttachShaderError();
+     public static native int getLoadShaderError();
+     public static native int getProgramError();
+     public static native int getAttachedShaderCount();
+}
diff --git a/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java b/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java
new file mode 100755
index 0000000..e6707da
--- /dev/null
+++ b/tests/tests/opengl/src/android/opengl/cts/NativeAttachShaderTest.java
@@ -0,0 +1,156 @@
+/*
+ * 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 android.opengl.cts;
+
+import android.opengl.GLES20;
+import android.test.ActivityInstrumentationTestCase2;
+
+public class NativeAttachShaderTest 
+        extends ActivityInstrumentationTestCase2<OpenGLES20NativeActivity> {
+
+    private static final long SLEEP_TIME = 1000l;
+
+    public NativeAttachShaderTest(Class<OpenGLES20NativeActivity> activityClass) {
+        super(activityClass);
+    }
+
+    private OpenGLES20NativeActivity mActivity;
+
+    public NativeAttachShaderTest() {
+        super(OpenGLES20NativeActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mActivity = getActivity();
+    }
+
+    /**
+     *Test: Attach an two valid shaders to a program
+     * <pre>
+     * shader count : 2
+     * 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);
+        int shaderCount = mActivity.mRenderer.mShaderCount;
+        assertEquals(2,shaderCount);
+        int error = mActivity.mRenderer.mAttachShaderError;
+        assertEquals(GLES20.GL_NO_ERROR, error);
+    }
+
+    /**
+     * Test: Attach an invalid vertex shader  to the program handle
+     * <pre>
+     * shader count : 1
+     * error        : GLES20.GL_INVALID_VALUE
+     * </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);
+
+        int error = mActivity.mRenderer.mAttachShaderError;
+
+        assertEquals(GLES20.GL_INVALID_VALUE, error);
+    }
+
+    /**
+     * Test: Attach two shaders of the same type to the program
+     * <pre>
+     * shader count : 1
+     * error        : GLES20.GL_INVALID_OPERATION
+     * </pre>
+     * @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);
+        int error = mActivity.mRenderer.mAttachShaderError;
+        assertEquals(GLES20.GL_INVALID_OPERATION, error);
+    }
+
+    /**
+     * Test: No shader is attached to a program, glGetAttachedShaders returns
+     * <pre>
+     * shader count : 0
+     * error        : GLES20.GL_NO_ERROR
+     * </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);
+        int shaderCount = GL2JniLibOne.getAttachedShaderCount();
+        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;;
+        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);
+
+        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 d7530c9..809b640 100644
--- a/tests/tests/opengl/src/android/opengl/cts/OpenGLES20ActivityOne.java
+++ b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20ActivityOne.java
@@ -32,7 +32,7 @@
 
     }
 
-    public void setView(String type, int i ) {
+    public void setView(int type, int i ) {
         view = new OpenGLES20View(this,type,i);
         setContentView(view);
     }
@@ -61,10 +61,10 @@
 
     class OpenGLES20View extends GLSurfaceView {
 
-        public OpenGLES20View(Context context, String type, int index) {
+        public OpenGLES20View(Context context, int type, int index) {
             super(context);
             setEGLContextClientVersion(2);
-            if(type.equals(Constants.SHADER)) {
+            if(type == Constants.SHADER) {
                 if(index == 1) {
                     mRenderer = new RendererOneShaderTest();
                 }else if(index == 2) {
@@ -88,7 +88,7 @@
                 }else {
                     throw new RuntimeException();
                 }
-            }else if(type.equals(Constants.PROGRAM)) {
+            }else if(type == Constants.PROGRAM) {
                 if(index == 1) {
                     mRenderer = new RendererOneProgramTest();
                 }
diff --git a/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java
new file mode 100755
index 0000000..d642e7a
--- /dev/null
+++ b/tests/tests/opengl/src/android/opengl/cts/OpenGLES20NativeActivity.java
@@ -0,0 +1,122 @@
+/*
+ * 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 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.widget.Button;
+import android.widget.EditText;
+import android.widget.TextView;
+
+public class OpenGLES20NativeActivity extends Activity {
+    /** Called when the activity is first created. */
+
+    int mValue;
+
+    OpenGLES20View view;
+    GL2Renderer mRenderer;
+    int mRendererType;
+
+    /**
+     * Called when the activity is first created.
+     */
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+    }
+
+    public void setView(int type, int i ) {
+        view = new OpenGLES20View(this,type,i);
+        setContentView(view);
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        view.onPause();
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        if(view != null) {
+            view.onResume();
+        }
+    }
+
+    class OpenGLES20View extends GLSurfaceView {
+        public OpenGLES20View(Context context, int category, int testCase) {
+            super(context);
+            setEGLContextClientVersion(2);
+            mRenderer = new GL2Renderer(category, testCase);
+            setRenderer(mRenderer);
+        }
+
+        @Override
+        public void setEGLContextClientVersion(int version) {
+            super.setEGLContextClientVersion(version);
+        }
+
+        public GL2Renderer getRenderer() {
+            return mRenderer;
+        }
+    }
+}
+class GL2Renderer implements GLSurfaceView.Renderer {
+    private String TAG = "GL2Renderer";
+    private int mCategory = -1;
+    private int mTestCase = -1;
+    int mAttachShaderError = -1;
+    int mShaderCount = -1;
+
+    public GL2Renderer(int category, int testcase) {
+        this.mCategory = category;
+        this.mTestCase = testcase;
+    }
+
+    public void onDrawFrame(GL10 gl) {
+        
+    }
+
+    public void onSurfaceChanged(GL10 gl, int width, int height) {
+        
+    }
+
+    public void onSurfaceCreated(GL10 gl, EGLConfig config) {
+        Log.i(TAG ,"onSurfaceCreated");
+        GL2JniLibOne.init(mCategory, mTestCase);
+        this.mAttachShaderError = GL2JniLibOne.getAttachShaderError();
+        Log.i(TAG,"error:" + mAttachShaderError);
+        this.mShaderCount = GL2JniLibOne.getAttachedShaderCount();
+        Log.i(TAG,"ShaderCount:" + mShaderCount);
+    }
+}