OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2ext.h> | 6 #include <GLES2/gl2ext.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "gpu/command_buffer/service/feature_info.h" | 9 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/tests/gl_manager.h" | 10 #include "gpu/command_buffer/tests/gl_manager.h" |
11 #include "gpu/command_buffer/tests/gl_test_utils.h" | 11 #include "gpu/command_buffer/tests/gl_test_utils.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace gpu { | 15 namespace gpu { |
16 | 16 |
17 class GLTest : public testing::Test { | 17 class GLTest : public testing::Test { |
18 protected: | 18 protected: |
19 void SetUp() override { gl_.Initialize(GLManager::Options()); } | 19 void SetUp() override { |
| 20 GpuDriverBugWorkarounds::Initialize(gpu_driver_bug_workarounds_); |
| 21 gl_.Initialize(GLManager::Options()); |
| 22 } |
20 | 23 |
21 void TearDown() override { gl_.Destroy(); } | 24 void TearDown() override { gl_.Destroy(); } |
22 | 25 |
| 26 GpuDriverBugWorkarounds gpu_driver_bug_workarounds_; |
23 GLManager gl_; | 27 GLManager gl_; |
24 }; | 28 }; |
25 | 29 |
26 // Test that GL is at least minimally working. | 30 // Test that GL is at least minimally working. |
27 TEST_F(GLTest, Basic) { | 31 TEST_F(GLTest, Basic) { |
28 glClearColor(0.0f, 1.0f, 0.0f, 1.0f); | 32 glClearColor(0.0f, 1.0f, 0.0f, 1.0f); |
29 glClear(GL_COLOR_BUFFER_BIT); | 33 glClear(GL_COLOR_BUFFER_BIT); |
30 uint8_t expected[] = { | 34 uint8_t expected[] = { |
31 0, 255, 0, 255, | 35 0, 255, 0, 255, |
32 }; | 36 }; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 glClear(GL_COLOR_BUFFER_BIT); | 96 glClear(GL_COLOR_BUFFER_BIT); |
93 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 1, expected_clear)); | 97 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 1, expected_clear)); |
94 uint8_t expected_draw[] = { | 98 uint8_t expected_draw[] = { |
95 0, 255, 0, 255, | 99 0, 255, 0, 255, |
96 }; | 100 }; |
97 glDrawArrays(GL_TRIANGLES, 0, 6); | 101 glDrawArrays(GL_TRIANGLES, 0, 6); |
98 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_draw)); | 102 EXPECT_TRUE(GLTestHelper::CheckPixels(0, 0, 1, 1, 0, expected_draw)); |
99 } | 103 } |
100 | 104 |
101 TEST_F(GLTest, FeatureFlagsMatchCapabilities) { | 105 TEST_F(GLTest, FeatureFlagsMatchCapabilities) { |
102 scoped_refptr<gles2::FeatureInfo> features = new gles2::FeatureInfo; | 106 scoped_refptr<gles2::FeatureInfo> features = |
| 107 new gles2::FeatureInfo(gpu_driver_bug_workarounds_); |
103 EXPECT_TRUE(features->InitializeForTesting()); | 108 EXPECT_TRUE(features->InitializeForTesting()); |
104 const auto& caps = gl_.GetCapabilities(); | 109 const auto& caps = gl_.GetCapabilities(); |
105 const auto& flags = features->feature_flags(); | 110 const auto& flags = features->feature_flags(); |
106 EXPECT_EQ(caps.egl_image_external, flags.oes_egl_image_external); | 111 EXPECT_EQ(caps.egl_image_external, flags.oes_egl_image_external); |
107 EXPECT_EQ(caps.texture_format_bgra8888, flags.ext_texture_format_bgra8888); | 112 EXPECT_EQ(caps.texture_format_bgra8888, flags.ext_texture_format_bgra8888); |
108 EXPECT_EQ(caps.texture_format_etc1, flags.oes_compressed_etc1_rgb8_texture); | 113 EXPECT_EQ(caps.texture_format_etc1, flags.oes_compressed_etc1_rgb8_texture); |
109 EXPECT_EQ(caps.texture_rectangle, flags.arb_texture_rectangle); | 114 EXPECT_EQ(caps.texture_rectangle, flags.arb_texture_rectangle); |
110 EXPECT_EQ(caps.texture_usage, flags.angle_texture_usage); | 115 EXPECT_EQ(caps.texture_usage, flags.angle_texture_usage); |
111 EXPECT_EQ(caps.texture_storage, flags.ext_texture_storage); | 116 EXPECT_EQ(caps.texture_storage, flags.ext_texture_storage); |
112 EXPECT_EQ(caps.discard_framebuffer, flags.ext_discard_framebuffer); | 117 EXPECT_EQ(caps.discard_framebuffer, flags.ext_discard_framebuffer); |
(...skipping 19 matching lines...) Expand all Loading... |
132 EXPECT_STREQ( | 137 EXPECT_STREQ( |
133 "Chromium", | 138 "Chromium", |
134 reinterpret_cast<const char*>(glGetString(GL_RENDERER))); | 139 reinterpret_cast<const char*>(glGetString(GL_RENDERER))); |
135 EXPECT_STREQ( | 140 EXPECT_STREQ( |
136 "Chromium", | 141 "Chromium", |
137 reinterpret_cast<const char*>(glGetString(GL_VENDOR))); | 142 reinterpret_cast<const char*>(glGetString(GL_VENDOR))); |
138 } | 143 } |
139 | 144 |
140 } // namespace gpu | 145 } // namespace gpu |
141 | 146 |
OLD | NEW |