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 <GLES2/gl2.h> |
| 6 #include <GLES2/gl2chromium.h> |
| 7 #include <GLES2/gl2ext.h> |
| 8 #include <GLES2/gl2extchromium.h> |
| 9 #include <stdint.h> |
| 10 |
| 11 #include <memory> |
| 12 |
| 13 #include "base/bind.h" |
| 14 #include "base/process/process_handle.h" |
| 15 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 16 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 17 #include "gpu/command_buffer/service/fence_manager.h" |
| 18 #include "gpu/command_buffer/tests/gl_manager.h" |
| 19 #include "gpu/command_buffer/tests/gl_test_utils.h" |
| 20 #include "testing/gmock/include/gmock/gmock.h" |
| 21 #include "testing/gtest/include/gtest/gtest.h" |
| 22 #include "ui/gfx/gpu_fence.h" |
| 23 #include "ui/gl/gl_fence.h" |
| 24 |
| 25 using testing::_; |
| 26 using testing::IgnoreResult; |
| 27 using testing::InvokeWithoutArgs; |
| 28 using testing::Invoke; |
| 29 using testing::Return; |
| 30 using testing::SetArgPointee; |
| 31 using testing::StrictMock; |
| 32 |
| 33 namespace gpu { |
| 34 namespace gles2 { |
| 35 |
| 36 class GpuFenceTest : public testing::Test { |
| 37 protected: |
| 38 void SetUp() override { gl_.Initialize(GLManager::Options()); } |
| 39 void TearDown() override { gl_.Destroy(); } |
| 40 |
| 41 GLManager gl_; |
| 42 }; |
| 43 |
| 44 // An end to end test that tests the whole GpuFence lifecycle. |
| 45 TEST_F(GpuFenceTest, Lifecycle) { |
| 46 // Create the gpu fence. |
| 47 std::unique_ptr<gfx::GpuFence> fence(gl_.CreateGpuFence()); |
| 48 |
| 49 // Check fence. |
| 50 bool rv = fence->Wait(base::TimeDelta()); |
| 51 DCHECK(!rv); |
| 52 |
| 53 // Create the GL fence. This should add the fence ID to the FenceManager. |
| 54 GLuint fence_id = glCreateFenceCHROMIUM(fence->AsClientFence()); |
| 55 ASSERT_NE(0u, fence_id); |
| 56 ASSERT_TRUE(gl_.decoder()->GetFenceManager()->LookupFence(fence_id) != NULL); |
| 57 |
| 58 // Wait for 1us on fence. |
| 59 rv = fence->Wait(base::TimeDelta::FromMicroseconds(1)); |
| 60 DCHECK(!rv); |
| 61 |
| 62 // Clean up. |
| 63 glDestroyFenceCHROMIUM(fence_id); |
| 64 } |
| 65 |
| 66 } // namespace gles2 |
| 67 } // namespace gpu |
OLD | NEW |