Fix cube map rendertargets.

We were using the entire level parameter of the cube map, instead
of using the helper functions for cube map ImageIndexes, which
set the layer corresponding to the cube map face.

BUG=angle:849
BUG=440701

Change-Id: Id78db5c8281b6b644392bb961d69a7f869755a34
Reviewed-on: https://chromium-review.googlesource.com/234380
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Brandon Jones <bajones@chromium.org>
diff --git a/tests/angle_tests/TextureTest.cpp b/tests/angle_tests/TextureTest.cpp
index d2e08e0..20e514e 100644
--- a/tests/angle_tests/TextureTest.cpp
+++ b/tests/angle_tests/TextureTest.cpp
@@ -390,3 +390,21 @@
     EXPECT_GL_NO_ERROR();
     EXPECT_PIXEL_EQ(px, py, 0, 0, 255, 255);
 }
+
+// Test creating a FBO with a cube map render target, to test an ANGLE bug
+// https://code.google.com/p/angleproject/issues/detail?id=849
+TYPED_TEST(TextureTest, CubeMapFBO)
+{
+    GLuint fbo;
+    glGenFramebuffers(1, &fbo);
+    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    glBindTexture(GL_TEXTURE_CUBE_MAP, mTextureCube);
+    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_Y, mTextureCube, 0);
+
+    EXPECT_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
+
+    glDeleteFramebuffers(1, &fbo);
+
+    EXPECT_GL_NO_ERROR();
+}