Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: gpu/command_buffer/tests/es3_misc_functions_unittest.cc

Issue 1325433003: command_buffer: Add support for creating non-WebGL ES 3 contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing hunk Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <GLES2/gl2.h>
6 #include <GLES2/gl2ext.h>
7 #include <GLES2/gl2extchromium.h>
8 #include <GLES3/gl3.h>
9
10 #include "base/command_line.h"
11 #include "gpu/command_buffer/tests/gl_manager.h"
12 #include "gpu/command_buffer/tests/gl_test_utils.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gl/gl_switches.h"
16
17 #define SHADER_VERSION_300(Src) "#version 300 es\n" #Src
18
19 namespace gpu {
20
21 class OpenGLES3FunctionTest : public testing::Test {
22 protected:
23 void SetUp() override {
24 base::CommandLine command_line(*base::CommandLine::ForCurrentProcess());
25 command_line.AppendSwitch(switches::kEnableUnsafeES3APIs);
26 GLManager::Options options;
27 options.context_type = gles2::CONTEXT_TYPE_OPENGLES3;
28 gl_.InitializeWithCommandLine(options, &command_line);
29 }
30 void TearDown() override { gl_.Destroy(); }
31 bool IsApplicable() const { return gl_.IsInitialized(); }
32 GLManager gl_;
33 };
34
35 TEST_F(OpenGLES3FunctionTest, GetFragDataLocationInvalid) {
36 if (!IsApplicable()) {
37 return;
38 }
39 // clang-format off
40 static const char* kVertexShader =
41 SHADER_VERSION_300(
42 in vec4 position;
43 void main() {
44 gl_Position = position;
45 });
46 static const char* kFragColorShader =
47 SHADER_VERSION_300(
48 precision mediump float;
49 uniform vec4 src;
50 out vec4 FragColor;
51 void main() {
52 FragColor = src;
53 });
54 // clang-format on
55
56 GLuint vsid = GLTestHelper::LoadShader(GL_VERTEX_SHADER, kVertexShader);
57 GLuint fsid = GLTestHelper::LoadShader(GL_FRAGMENT_SHADER, kFragColorShader);
58 GLuint program = glCreateProgram();
59 glAttachShader(program, vsid);
60 glAttachShader(program, fsid);
61 glDeleteShader(vsid);
62 glDeleteShader(fsid);
63
64 GLint location = glGetFragDataLocation(program, "FragColor");
65 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
66 EXPECT_EQ(-1, location);
67 location = glGetFragDataLocation(program, "Unknown");
68 EXPECT_EQ(static_cast<GLenum>(GL_INVALID_OPERATION), glGetError());
69 EXPECT_EQ(-1, location);
70
71 glLinkProgram(program);
72
73 location = glGetFragDataLocation(program, "FragColor");
74 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
75 EXPECT_EQ(0, location);
76 location = glGetFragDataLocation(program, "Unknown");
77 EXPECT_EQ(static_cast<GLenum>(GL_NO_ERROR), glGetError());
78 EXPECT_EQ(-1, location);
79
80 glDeleteProgram(program);
81 }
82
83 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager_unittest.cc ('k') | gpu/command_buffer/tests/gl_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698