Stop the GLPrograms unit test from generating out of range attrib indices for effects.

R=jvanverth@google.com

Author: bsalomon@google.com

Reviewed By: jvanverth@google.com

Review URL: https://chromiumcodereview.appspot.com/12834013

git-svn-id: http://skia.googlecode.com/svn/trunk@8298 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index aeb7ecc..68db27a 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -134,7 +134,16 @@
                                                                                 &random,
                                                                                 this->getContext(),
                                                                                 dummyTextures));
-                for (int i = 0; i < effect.get()->get()->numVertexAttribs(); ++i) {
+                int numAttribs = (*effect)->numVertexAttribs();
+
+                // If adding this effect would cause to exceed the max attrib count then generate a
+                // new random effect. The explanation for why this check is correct is a bit
+                // convoluted and this code will be removed soon.
+                if (currAttribIndex + numAttribs > GrDrawState::kCoverageOverrideAttribIndexValue) {
+                    --s;
+                    continue;
+                }
+                for (int i = 0; i < numAttribs; ++i) {
                     attribIndices[i] = currAttribIndex++;
                 }
                 stages[s].setEffect(effect.get(), attribIndices[0], attribIndices[1]);