Add default VAO vertexAttrbDivisor GLES3/GLES31 behavior change tests.

- Add positive test for default VAO divisor in GLES3.
- Add negative test for default VAO divisor in GLES31.
- Use VAO in vertex_attrib_binding divisor state query tests.

Bug: 20154392
Change-Id: Iac43c4484bf7c5eff2409c964778e3dc304649f9
diff --git a/Android.mk b/Android.mk
index 69c5058..619175f 100644
--- a/Android.mk
+++ b/Android.mk
@@ -407,6 +407,7 @@
 	modules/gles3/functional/es3fClippingTests.cpp \
 	modules/gles3/functional/es3fColorClearTest.cpp \
 	modules/gles3/functional/es3fCompressedTextureTests.cpp \
+	modules/gles3/functional/es3fDefaultVertexArrayObjectTests.cpp \
 	modules/gles3/functional/es3fDefaultVertexAttributeTests.cpp \
 	modules/gles3/functional/es3fDepthStencilClearTests.cpp \
 	modules/gles3/functional/es3fDepthStencilTests.cpp \
@@ -535,6 +536,7 @@
 	modules/gles31/functional/es31fBuiltinPrecisionTests.cpp \
 	modules/gles31/functional/es31fComputeShaderBuiltinVarTests.cpp \
 	modules/gles31/functional/es31fDebugTests.cpp \
+	modules/gles31/functional/es31fDefaultVertexArrayObjectTests.cpp \
 	modules/gles31/functional/es31fDrawTests.cpp \
 	modules/gles31/functional/es31fFboColorbufferTests.cpp \
 	modules/gles31/functional/es31fFboNoAttachmentTests.cpp \
diff --git a/android/cts/master/com.drawelements.deqp.gles3.xml b/android/cts/master/com.drawelements.deqp.gles3.xml
index 8d6bf93..bf19bcf 100644
--- a/android/cts/master/com.drawelements.deqp.gles3.xml
+++ b/android/cts/master/com.drawelements.deqp.gles3.xml
@@ -141581,6 +141581,11 @@
 					</Test>
 				</TestCase>
 			</TestSuite>
+			<TestCase name="default_vertex_array_object">
+				<Test name="vertex_attrib_divisor">
+					<TestInstance glconfig="rgba8888d24s8ms0" rotation="unspecified" surfacetype="window"/>
+				</Test>
+			</TestCase>
 		</TestSuite>
 	</TestSuite>
 </TestPackage>
diff --git a/android/cts/master/gles3-master.txt b/android/cts/master/gles3-master.txt
index 00c302c..bc30f95 100644
--- a/android/cts/master/gles3-master.txt
+++ b/android/cts/master/gles3-master.txt
@@ -41962,3 +41962,4 @@
 dEQP-GLES3.functional.lifetime.attach.deleted_output.renderbuffer_framebuffer
 dEQP-GLES3.functional.lifetime.attach.deleted_output.buffer_transform_feedback
 dEQP-GLES3.functional.lifetime.delete_active.transform_feedback
+dEQP-GLES3.functional.default_vertex_array_object.vertex_attrib_divisor
diff --git a/android/cts/master/src/gles31-spec-issues.txt b/android/cts/master/src/gles31-spec-issues.txt
new file mode 100644
index 0000000..884b49c
--- /dev/null
+++ b/android/cts/master/src/gles31-spec-issues.txt
@@ -0,0 +1,2 @@
+# Bug 13564
+dEQP-GLES31.functional.default_vertex_array_object.vertex_attrib_divisor
diff --git a/modules/gles3/functional/CMakeLists.txt b/modules/gles3/functional/CMakeLists.txt
index 7705dfb..1adc70e 100644
--- a/modules/gles3/functional/CMakeLists.txt
+++ b/modules/gles3/functional/CMakeLists.txt
@@ -13,6 +13,8 @@
 	es3fBufferWriteTests.hpp
 	es3fColorClearTest.cpp
 	es3fColorClearTest.hpp
+	es3fDefaultVertexArrayObjectTests.cpp
+	es3fDefaultVertexArrayObjectTests.hpp
 	es3fDefaultVertexAttributeTests.cpp
 	es3fDefaultVertexAttributeTests.hpp
 	es3fDepthStencilClearTests.cpp
diff --git a/modules/gles3/functional/es3fDefaultVertexArrayObjectTests.cpp b/modules/gles3/functional/es3fDefaultVertexArrayObjectTests.cpp
new file mode 100644
index 0000000..5ee8786
--- /dev/null
+++ b/modules/gles3/functional/es3fDefaultVertexArrayObjectTests.cpp
@@ -0,0 +1,85 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program OpenGL ES 3.0 Module
+ * -------------------------------------------------
+ *
+ * Copyright 2015 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.
+ *
+ *//*!
+ * \file
+ * \brief Default vertex array tests
+ *//*--------------------------------------------------------------------*/
+
+#include "es3fDefaultVertexArrayObjectTests.hpp"
+
+#include "gluCallLogWrapper.hpp"
+#include "gluRenderContext.hpp"
+
+namespace deqp
+{
+namespace gles3
+{
+namespace Functional
+{
+namespace
+{
+
+class VertexAttributeDivisorCase : public TestCase
+{
+public:
+					VertexAttributeDivisorCase	(Context& context, const char* name, const char* description);
+	IterateResult	iterate						(void);
+};
+
+VertexAttributeDivisorCase::VertexAttributeDivisorCase (Context& context, const char* name, const char* description)
+	: TestCase(context, name, description)
+{
+}
+
+VertexAttributeDivisorCase::IterateResult VertexAttributeDivisorCase::iterate (void)
+{
+	glu::CallLogWrapper gl(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
+
+	m_testCtx.getLog()	<< tcu::TestLog::Message
+						<< "Using VertexAttribDivisor with default VAO.\n"
+						<< "Expecting no error."
+						<< tcu::TestLog::EndMessage;
+
+	gl.enableLogging(true);
+	gl.glBindVertexArray(0);
+
+	// Using vertexAttribDivisor with default vao is an error in ES 3.1, but not
+	// in ES 3.0. See Khronos bug 13564 for details.
+	gl.glVertexAttribDivisor(0, 3);
+	GLU_EXPECT_NO_ERROR(gl.glGetError(), "VertexAttribDivisor");
+
+	m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
+	return STOP;
+}
+
+} // anonymous
+
+DefaultVertexArrayObjectTests::DefaultVertexArrayObjectTests (Context& context)
+	: TestCaseGroup(context, "default_vertex_array_object", "Default vertex array object")
+{
+}
+
+void DefaultVertexArrayObjectTests::init (void)
+{
+	addChild(new VertexAttributeDivisorCase(m_context, "vertex_attrib_divisor", "Use VertexAttribDivisor with default VAO"));
+}
+
+} // Functional
+} // gles3
+} // deqp
diff --git a/modules/gles3/functional/es3fDefaultVertexArrayObjectTests.hpp b/modules/gles3/functional/es3fDefaultVertexArrayObjectTests.hpp
new file mode 100644
index 0000000..ab3eeb2
--- /dev/null
+++ b/modules/gles3/functional/es3fDefaultVertexArrayObjectTests.hpp
@@ -0,0 +1,53 @@
+#ifndef _ES3FDEFAULTVERTEXARRAYOBJECTTESTS_HPP
+#define _ES3FDEFAULTVERTEXARRAYOBJECTTESTS_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program OpenGL ES 3.0 Module
+ * -------------------------------------------------
+ *
+ * Copyright 2015 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.
+ *
+ *//*!
+ * \file
+ * \brief Default vertex array tests
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tes3TestCase.hpp"
+
+namespace deqp
+{
+namespace gles3
+{
+namespace Functional
+{
+
+class DefaultVertexArrayObjectTests : public TestCaseGroup
+{
+public:
+										DefaultVertexArrayObjectTests	(Context& context);
+	virtual								~DefaultVertexArrayObjectTests	(void) {}
+
+	virtual void						init							(void);
+
+private:
+										DefaultVertexArrayObjectTests	(const DefaultVertexArrayObjectTests& other);
+	DefaultVertexArrayObjectTests&		operator=						(const DefaultVertexArrayObjectTests& other);
+};
+
+} // Functional
+} // gles3
+} // deqp
+
+#endif // _ES3FDEFAULTVERTEXARRAYOBJECTTESTS_HPP
diff --git a/modules/gles3/functional/es3fFunctionalTests.cpp b/modules/gles3/functional/es3fFunctionalTests.cpp
index e987fc4..6f6f308 100644
--- a/modules/gles3/functional/es3fFunctionalTests.cpp
+++ b/modules/gles3/functional/es3fFunctionalTests.cpp
@@ -58,6 +58,7 @@
 #include "es3fDefaultVertexAttributeTests.hpp"
 #include "es3fScissorTests.hpp"
 #include "es3fLifetimeTests.hpp"
+#include "es3fDefaultVertexArrayObjectTests.hpp"
 
 // Shader tests
 #include "es3fShaderApiTests.hpp"
@@ -369,42 +370,43 @@
 
 void FunctionalTests::init (void)
 {
-	addChild(new PrerequisiteTests			(m_context));
-	addChild(new ImplementationLimitTests	(m_context));
-	addChild(new ColorClearTest				(m_context));
-	addChild(new DepthStencilClearTests		(m_context));
-	addChild(new BufferTests				(m_context));
-	addChild(new ShaderTests				(m_context));
-	addChild(new TextureTests				(m_context));
-	addChild(new FragmentOpTests			(m_context));
-	addChild(new FboTests					(m_context));
-	addChild(new VertexArrayTestGroup		(m_context));
-	addChild(new UniformBlockTests			(m_context));
-	addChild(new UniformApiTests			(m_context));
-	addChild(createAttributeLocationTests	(m_context));
-	addChild(new FragmentOutputTests		(m_context));
-	addChild(new SamplerObjectTests			(m_context));
-	addChild(new PixelBufferObjectTests		(m_context));
-	addChild(new RasterizationTests			(m_context));
-	addChild(new OcclusionQueryTests		(m_context));
-	addChild(new VertexArrayObjectTestGroup	(m_context));
-	addChild(new PrimitiveRestartTests		(m_context));
-	addChild(new InstancedRenderingTests	(m_context));
-	addChild(new RasterizerDiscardTests		(m_context));
-	addChild(new TransformFeedbackTests		(m_context));
-	addChild(new SyncTests					(m_context));
-	addChild(new ShaderApiTests				(m_context));
-	addChild(new NegativeApiTestGroup		(m_context));
-	addChild(new MultisampleTests			(m_context));
-	addChild(new ReadPixelsTests			(m_context));
-	addChild(new DitheringTests				(m_context));
-	addChild(new StateQueryTests			(m_context));
-	addChild(new ClippingTests				(m_context));
-	addChild(new PolygonOffsetTests			(m_context));
-	addChild(new DrawTests					(m_context));
-	addChild(new FlushFinishTests			(m_context));
-	addChild(new DefaultVertexAttributeTests(m_context));
-	addChild(createLifetimeTests			(m_context));
+	addChild(new PrerequisiteTests				(m_context));
+	addChild(new ImplementationLimitTests		(m_context));
+	addChild(new ColorClearTest					(m_context));
+	addChild(new DepthStencilClearTests			(m_context));
+	addChild(new BufferTests					(m_context));
+	addChild(new ShaderTests					(m_context));
+	addChild(new TextureTests					(m_context));
+	addChild(new FragmentOpTests				(m_context));
+	addChild(new FboTests						(m_context));
+	addChild(new VertexArrayTestGroup			(m_context));
+	addChild(new UniformBlockTests				(m_context));
+	addChild(new UniformApiTests				(m_context));
+	addChild(createAttributeLocationTests		(m_context));
+	addChild(new FragmentOutputTests			(m_context));
+	addChild(new SamplerObjectTests				(m_context));
+	addChild(new PixelBufferObjectTests			(m_context));
+	addChild(new RasterizationTests				(m_context));
+	addChild(new OcclusionQueryTests			(m_context));
+	addChild(new VertexArrayObjectTestGroup		(m_context));
+	addChild(new PrimitiveRestartTests			(m_context));
+	addChild(new InstancedRenderingTests		(m_context));
+	addChild(new RasterizerDiscardTests			(m_context));
+	addChild(new TransformFeedbackTests			(m_context));
+	addChild(new SyncTests						(m_context));
+	addChild(new ShaderApiTests					(m_context));
+	addChild(new NegativeApiTestGroup			(m_context));
+	addChild(new MultisampleTests				(m_context));
+	addChild(new ReadPixelsTests				(m_context));
+	addChild(new DitheringTests					(m_context));
+	addChild(new StateQueryTests				(m_context));
+	addChild(new ClippingTests					(m_context));
+	addChild(new PolygonOffsetTests				(m_context));
+	addChild(new DrawTests						(m_context));
+	addChild(new FlushFinishTests				(m_context));
+	addChild(new DefaultVertexAttributeTests	(m_context));
+	addChild(createLifetimeTests				(m_context));
+	addChild(new DefaultVertexArrayObjectTests	(m_context));
 }
 
 } // Functional
diff --git a/modules/gles31/functional/CMakeLists.txt b/modules/gles31/functional/CMakeLists.txt
index a4240f1..699664a 100644
--- a/modules/gles31/functional/CMakeLists.txt
+++ b/modules/gles31/functional/CMakeLists.txt
@@ -11,6 +11,10 @@
 	es31fComputeShaderBuiltinVarTests.hpp
 	es31fFunctionalTests.cpp
 	es31fFunctionalTests.hpp
+	es31fDebugTests.cpp
+	es31fDebugTests.hpp
+	es31fDefaultVertexArrayObjectTests.cpp
+	es31fDefaultVertexArrayObjectTests.hpp
 	es31fDrawTests.cpp
 	es31fDrawTests.hpp
 	es31fGeometryShaderTests.cpp
@@ -123,8 +127,6 @@
 	es31fTessellationGeometryInteractionTests.hpp
 	es31fUniformBlockTests.cpp
 	es31fUniformBlockTests.hpp
-	es31fDebugTests.cpp
-	es31fDebugTests.hpp
 	es31fFboNoAttachmentTests.cpp
 	es31fFboNoAttachmentTests.hpp
 	es31fNegativeTestShared.cpp
diff --git a/modules/gles31/functional/es31fDefaultVertexArrayObjectTests.cpp b/modules/gles31/functional/es31fDefaultVertexArrayObjectTests.cpp
new file mode 100644
index 0000000..b9cf3b8
--- /dev/null
+++ b/modules/gles31/functional/es31fDefaultVertexArrayObjectTests.cpp
@@ -0,0 +1,92 @@
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program OpenGL ES 3.1 Module
+ * -------------------------------------------------
+ *
+ * Copyright 2015 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.
+ *
+ *//*!
+ * \file
+ * \brief Default vertex array tests
+ *//*--------------------------------------------------------------------*/
+
+#include "es31fDefaultVertexArrayObjectTests.hpp"
+
+#include "gluCallLogWrapper.hpp"
+#include "gluRenderContext.hpp"
+
+#include "glwEnums.hpp"
+
+namespace deqp
+{
+namespace gles31
+{
+namespace Functional
+{
+namespace
+{
+
+class VertexAttributeDivisorCase : public TestCase
+{
+public:
+					VertexAttributeDivisorCase	(Context& context, const char* name, const char* description);
+	IterateResult	iterate						(void);
+};
+
+VertexAttributeDivisorCase::VertexAttributeDivisorCase (Context& context, const char* name, const char* description)
+	: TestCase(context, name, description)
+{
+}
+
+VertexAttributeDivisorCase::IterateResult VertexAttributeDivisorCase::iterate (void)
+{
+	glu::CallLogWrapper gl		(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
+	deUint32			error;
+
+	m_testCtx.getLog()	<< tcu::TestLog::Message
+						<< "Using VertexAttribDivisor with default VAO.\n"
+						<< "Expecting INVALID_OPERATION."
+						<< tcu::TestLog::EndMessage;
+
+	gl.enableLogging(true);
+	gl.glBindVertexArray(0);
+
+	// Using vertexAttribDivisor with default vao is an error in ES 3.1, but not
+	// in ES 3.0. See Khronos bug 13564 for details.
+	gl.glVertexAttribDivisor(0, 3);
+	error = gl.glGetError();
+
+	if (error == GL_INVALID_OPERATION)
+		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
+	else
+		m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Incorrect error value");
+
+	return STOP;
+}
+
+} // anonymous
+
+DefaultVertexArrayObjectTests::DefaultVertexArrayObjectTests (Context& context)
+	: TestCaseGroup(context, "default_vertex_array_object", "Default vertex array object")
+{
+}
+
+void DefaultVertexArrayObjectTests::init (void)
+{
+	addChild(new VertexAttributeDivisorCase(m_context, "vertex_attrib_divisor", "Use VertexAttribDivisor with default VAO"));
+}
+
+} // Functional
+} // gles31
+} // deqp
diff --git a/modules/gles31/functional/es31fDefaultVertexArrayObjectTests.hpp b/modules/gles31/functional/es31fDefaultVertexArrayObjectTests.hpp
new file mode 100644
index 0000000..5d9872d
--- /dev/null
+++ b/modules/gles31/functional/es31fDefaultVertexArrayObjectTests.hpp
@@ -0,0 +1,53 @@
+#ifndef _ES31FDEFAULTVERTEXARRAYOBJECTTESTS_HPP
+#define _ES31FDEFAULTVERTEXARRAYOBJECTTESTS_HPP
+/*-------------------------------------------------------------------------
+ * drawElements Quality Program OpenGL ES 3.1 Module
+ * -------------------------------------------------
+ *
+ * Copyright 2015 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.
+ *
+ *//*!
+ * \file
+ * \brief Default vertex array tests
+ *//*--------------------------------------------------------------------*/
+
+#include "tcuDefs.hpp"
+#include "tes31TestCase.hpp"
+
+namespace deqp
+{
+namespace gles31
+{
+namespace Functional
+{
+
+class DefaultVertexArrayObjectTests : public TestCaseGroup
+{
+public:
+										DefaultVertexArrayObjectTests	(Context& context);
+	virtual								~DefaultVertexArrayObjectTests	(void) {}
+
+	virtual void						init							(void);
+
+private:
+										DefaultVertexArrayObjectTests	(const DefaultVertexArrayObjectTests& other);
+	DefaultVertexArrayObjectTests&		operator=						(const DefaultVertexArrayObjectTests& other);
+};
+
+} // Functional
+} // gles31
+} // deqp
+
+#endif // _ES31FDEFAULTVERTEXARRAYOBJECTTESTS_HPP
diff --git a/modules/gles31/functional/es31fFunctionalTests.cpp b/modules/gles31/functional/es31fFunctionalTests.cpp
index ad2251d..303415d 100644
--- a/modules/gles31/functional/es31fFunctionalTests.cpp
+++ b/modules/gles31/functional/es31fFunctionalTests.cpp
@@ -86,6 +86,7 @@
 #include "es31fAndroidExtensionPackES31ATests.hpp"
 #include "es31fCopyImageTests.hpp"
 #include "es31fDrawBuffersIndexedTests.hpp"
+#include "es31fDefaultVertexArrayObjectTests.hpp"
 
 namespace deqp
 {
@@ -332,6 +333,7 @@
 	addChild(new AndroidExtensionPackES31ATests			(m_context));
 	addChild(createCopyImageTests						(m_context));
 	addChild(createDrawBuffersIndexedTests				(m_context));
+	addChild(new DefaultVertexArrayObjectTests			(m_context));
 }
 
 } // Functional
diff --git a/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp b/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
index 21d5bf3..309123c 100644
--- a/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
+++ b/modules/gles31/functional/es31fVertexAttributeBindingStateQueryTests.cpp
@@ -578,9 +578,11 @@
 void MixedVertexBindingDivisorCase::test (tcu::ResultCollector& result)
 {
 	glu::CallLogWrapper gl					(m_context.getRenderContext().getFunctions(), m_testCtx.getLog());
+	glu::VertexArray	vao					(m_context.getRenderContext());
 
 	gl.enableLogging(true);
 
+	gl.glBindVertexArray(*vao);
 	gl.glVertexAttribDivisor(1, 4);
 	verifyStateIndexedInteger(result, gl, GL_VERTEX_BINDING_DIVISOR, 1, 4, m_verifier);
 }
diff --git a/scripts/build_android_mustpass.py b/scripts/build_android_mustpass.py
index 199502b..b39fd2e 100644
--- a/scripts/build_android_mustpass.py
+++ b/scripts/build_android_mustpass.py
@@ -482,6 +482,7 @@
 		include("gles31-master.txt"),
 		exclude("gles31-hw-issues.txt"),
 		exclude("gles31-test-issues.txt"),
+		exclude("gles31-spec-issues.txt"),
 	]
 MASTER_GLES31_PKG				= Package(module = GLES31_MODULE, configurations = [
 		# Master