OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 "platform/graphics/gpu/SharedGpuContext.h" |
| 6 |
| 7 #include "gpu/command_buffer/client/gles2_interface.h" |
| 8 #include "platform/graphics/test/FakeGLES2Interface.h" |
| 9 #include "platform/graphics/test/FakeWebGraphicsContext3DProvider.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "third_party/khronos/GLES2/gl2ext.h" |
| 12 |
| 13 using testing::Test; |
| 14 |
| 15 namespace blink { |
| 16 |
| 17 namespace { |
| 18 |
| 19 class SharedGpuContextTest : public Test { |
| 20 public: |
| 21 void SetUp() override |
| 22 { |
| 23 SharedGpuContext::setContextProviderFactoryForTesting([this] { |
| 24 m_gl.setIsContextLost(false); |
| 25 return std::unique_ptr<WebGraphicsContext3DProvider>(new FakeWebGrap
hicsContext3DProvider(&m_gl)); |
| 26 }); |
| 27 } |
| 28 |
| 29 void TearDown() override |
| 30 { |
| 31 SharedGpuContext::setContextProviderFactoryForTesting(nullptr); |
| 32 } |
| 33 |
| 34 FakeGLES2Interface m_gl; |
| 35 }; |
| 36 |
| 37 TEST_F(SharedGpuContextTest, contextLossAutoRecovery) |
| 38 { |
| 39 EXPECT_TRUE(SharedGpuContext::isValid()); |
| 40 unsigned contextId = SharedGpuContext::contextId(); |
| 41 m_gl.setIsContextLost(true); |
| 42 EXPECT_FALSE(SharedGpuContext::isValidWithoutRestoring()); |
| 43 EXPECT_TRUE(SharedGpuContext::isValid()); |
| 44 EXPECT_NE(contextId, SharedGpuContext::contextId()); |
| 45 } |
| 46 |
| 47 |
| 48 } // unnamed namespace |
| 49 |
| 50 } // blink |
OLD | NEW |