| 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); |
| 43 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; | 44 g_current_gl_context_tls = new base::ThreadLocalPointer<GLApi>; |
| 44 | 45 |
| 45 SetGLGetProcAddressProc( | 46 SetGLGetProcAddressProc( |
| 46 static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress)); | 47 static_cast<GLGetProcAddressProc>(&FakeGLGetProcAddress)); |
| 47 } | 48 } |
| 48 | 49 |
| 49 static void* GL_BINDING_CALL FakeGLGetProcAddress(const char *proc) { | 50 static void* GL_BINDING_CALL FakeGLGetProcAddress(const char *proc) { |
| 50 return reinterpret_cast<void*>(0x1); | 51 return reinterpret_cast<void*>(0x1); |
| 51 } | 52 } |
| 52 | 53 |
| 53 void TearDown() override { | 54 void TearDown() override { |
| 54 api_.reset(nullptr); | 55 api_.reset(nullptr); |
| 55 delete g_current_gl_context_tls; | 56 delete g_current_gl_context_tls; |
| 57 g_current_gl_context_tls = nullptr; |
| 56 | 58 |
| 57 SetGLImplementation(kGLImplementationNone); | 59 SetGLImplementation(kGLImplementationNone); |
| 58 fake_extension_string_ = ""; | 60 fake_extension_string_ = ""; |
| 59 fake_version_string_ = ""; | 61 fake_version_string_ = ""; |
| 60 num_fake_extension_strings_ = 0; | 62 num_fake_extension_strings_ = 0; |
| 61 fake_extension_strings_ = nullptr; | 63 fake_extension_strings_ = nullptr; |
| 62 } | 64 } |
| 63 | 65 |
| 64 void InitializeAPI(base::CommandLine* command_line) { | 66 void InitializeAPI(base::CommandLine* command_line) { |
| 65 api_.reset(new RealGLApi()); | 67 api_.reset(new RealGLApi()); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 kFakeDisabledExtensions); | 207 kFakeDisabledExtensions); |
| 206 InitializeAPI(&command_line); | 208 InitializeAPI(&command_line); |
| 207 | 209 |
| 208 EXPECT_EQ(arraysize(kFilteredExtensions), GetNumExtensions()); | 210 EXPECT_EQ(arraysize(kFilteredExtensions), GetNumExtensions()); |
| 209 for (uint32_t i = 0; i < arraysize(kFilteredExtensions); ++i) { | 211 for (uint32_t i = 0; i < arraysize(kFilteredExtensions); ++i) { |
| 210 EXPECT_STREQ(kFilteredExtensions[i], GetExtensioni(i)); | 212 EXPECT_STREQ(kFilteredExtensions[i], GetExtensioni(i)); |
| 211 } | 213 } |
| 212 } | 214 } |
| 213 | 215 |
| 214 } // namespace gfx | 216 } // namespace gfx |
| OLD | NEW |