OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gl/gl_context.h" | 8 #include "ui/gl/gl_context.h" |
9 #include "ui/gl/gl_gl_api_implementation.h" | 9 #include "ui/gl/gl_gl_api_implementation.h" |
10 #include "ui/gl/gl_implementation.h" | 10 #include "ui/gl/gl_implementation.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 }; | 33 }; |
34 | 34 |
35 class GLApiTest : public testing::Test { | 35 class GLApiTest : public testing::Test { |
36 public: | 36 public: |
37 void SetUp() override { | 37 void SetUp() override { |
38 fake_extension_string_ = ""; | 38 fake_extension_string_ = ""; |
39 fake_version_string_ = ""; | 39 fake_version_string_ = ""; |
40 num_fake_extension_strings_ = 0; | 40 num_fake_extension_strings_ = 0; |
41 fake_extension_strings_ = nullptr; | 41 fake_extension_strings_ = nullptr; |
42 | 42 |
43 DCHECK(!g_current_gl_context_tls); | |
44 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; | 43 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; |
45 | 44 |
46 SetGLGetProcAddressProc( | 45 SetGLGetProcAddressProc( |
47 static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress)); | 46 static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress)); |
48 } | 47 } |
49 | 48 |
50 static void* GL_BINDING_CALL FakeGLGetProcAddress(const char *proc) { | 49 static void* GL_BINDING_CALL FakeGLGetProcAddress(const char *proc) { |
51 return reinterpret_cast<void*>(0x1); | 50 return reinterpret_cast<void*>(0x1); |
52 } | 51 } |
53 | 52 |
54 void TearDown() override { | 53 void TearDown() override { |
55 api_.reset(nullptr); | 54 api_.reset(nullptr); |
56 delete g_current_gl_context_tls; | 55 delete g_current_gl_context_tls; |
57 g_current_gl_context_tls = nullptr; | |
58 | 56 |
59 SetGLImplementation(kGLImplementationNone); | 57 SetGLImplementation(kGLImplementationNone); |
60 fake_extension_string_ = ""; | 58 fake_extension_string_ = ""; |
61 fake_version_string_ = ""; | 59 fake_version_string_ = ""; |
62 num_fake_extension_strings_ = 0; | 60 num_fake_extension_strings_ = 0; |
63 fake_extension_strings_ = nullptr; | 61 fake_extension_strings_ = nullptr; |
64 } | 62 } |
65 | 63 |
66 void InitializeAPI(base::CommandLine* command_line) { | 64 void InitializeAPI(base::CommandLine* command_line) { |
67 api_.reset(new RealGLApi()); | 65 api_.reset(new RealGLApi()); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 kFakeDisabledExtensions); | 205 kFakeDisabledExtensions); |
208 InitializeAPI(&command_line); | 206 InitializeAPI(&command_line); |
209 | 207 |
210 EXPECT_EQ(arraysize(kFilteredExtensions), GetNumExtensions()); | 208 EXPECT_EQ(arraysize(kFilteredExtensions), GetNumExtensions()); |
211 for (uint32_t i = 0; i < arraysize(kFilteredExtensions); ++i) { | 209 for (uint32_t i = 0; i < arraysize(kFilteredExtensions); ++i) { |
212 EXPECT_STREQ(kFilteredExtensions[i], GetExtensioni(i)); | 210 EXPECT_STREQ(kFilteredExtensions[i], GetExtensioni(i)); |
213 } | 211 } |
214 } | 212 } |
215 | 213 |
216 } // namespace gfx | 214 } // namespace gfx |
OLD | NEW |