Fix shader support of OVR_multiview

Fix up incorrect capitalization of gl_ViewID_OVR in a few places.

Also add extension macro test to compiler unit tests.

BUG=angleproject:1669
TEST=angle_unittests

Change-Id: Ia7fdd747ad08355cdc149db9e2e7911c2e673af5
Reviewed-on: https://chromium-review.googlesource.com/425851
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/compiler/translator/OutputGLSLBase.cpp b/src/compiler/translator/OutputGLSLBase.cpp
index e7684ed..18afc83 100644
--- a/src/compiler/translator/OutputGLSLBase.cpp
+++ b/src/compiler/translator/OutputGLSLBase.cpp
@@ -1143,7 +1143,7 @@
         if (mCompileOptions & SH_TRANSLATE_VIEWID_OVR_TO_UNIFORM &&
             name.getString() == "gl_ViewID_OVR")
         {
-            TName uniformName(TString("ViewId_OVR"));
+            TName uniformName(TString("ViewID_OVR"));
             uniformName.setInternal(true);
             return hashName(uniformName);
         }
diff --git a/src/compiler/translator/TranslatorESSL.cpp b/src/compiler/translator/TranslatorESSL.cpp
index 1e2f182..5447879 100644
--- a/src/compiler/translator/TranslatorESSL.cpp
+++ b/src/compiler/translator/TranslatorESSL.cpp
@@ -97,7 +97,7 @@
 
     if (compileOptions & SH_TRANSLATE_VIEWID_OVR_TO_UNIFORM)
     {
-        TName uniformName(TString("ViewId_OVR"));
+        TName uniformName(TString("ViewID_OVR"));
         uniformName.setInternal(true);
         sink << "highp uniform int " << outputESSL.hashName(uniformName) << ";\n";
     }
diff --git a/src/compiler/translator/TranslatorGLSL.cpp b/src/compiler/translator/TranslatorGLSL.cpp
index cfb8538..1946149 100644
--- a/src/compiler/translator/TranslatorGLSL.cpp
+++ b/src/compiler/translator/TranslatorGLSL.cpp
@@ -207,7 +207,7 @@
 
     if (compileOptions & SH_TRANSLATE_VIEWID_OVR_TO_UNIFORM)
     {
-        TName uniformName(TString("ViewId_OVR"));
+        TName uniformName(TString("ViewID_OVR"));
         uniformName.setInternal(true);
         sink << "uniform int " << outputGLSL.hashName(uniformName) << ";\n";
     }
diff --git a/src/tests/compiler_tests/WEBGL_multiview_test.cpp b/src/tests/compiler_tests/WEBGL_multiview_test.cpp
index f1e3774..9eadae2 100644
--- a/src/tests/compiler_tests/WEBGL_multiview_test.cpp
+++ b/src/tests/compiler_tests/WEBGL_multiview_test.cpp
@@ -360,3 +360,24 @@
         FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
     }
 }
+
+// Correct use of GL_OVR_multiview macros.
+TEST_F(WEBGLMultiviewVertexShaderTest, ValidUseOfExtensionMacros)
+{
+    const std::string &shaderString =
+        "#version 300 es\n"
+        "#ifdef GL_OVR_multiview\n"
+        "#ifdef GL_OVR_multiview2\n"
+        "#if (GL_OVR_multiview == 1) && (GL_OVR_multiview2 == 1)\n"
+        "void main()\n"
+        "{\n"
+        "    gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n"
+        "}\n"
+        "#endif\n"
+        "#endif\n"
+        "#endif\n";
+    if (!compile(shaderString))
+    {
+        FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
+    }
+}