Index: gpu/command_buffer/tests/gl_gpu_fence_unittest.cc |
diff --git a/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc b/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1a93547e6a7ccba44899bf67f93444d60601a778 |
--- /dev/null |
+++ b/gpu/command_buffer/tests/gl_gpu_fence_unittest.cc |
@@ -0,0 +1,67 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include <GLES2/gl2.h> |
+#include <GLES2/gl2chromium.h> |
+#include <GLES2/gl2ext.h> |
+#include <GLES2/gl2extchromium.h> |
+#include <stdint.h> |
+ |
+#include <memory> |
+ |
+#include "base/bind.h" |
+#include "base/process/process_handle.h" |
+#include "gpu/command_buffer/client/gles2_implementation.h" |
+#include "gpu/command_buffer/service/command_buffer_service.h" |
+#include "gpu/command_buffer/service/fence_manager.h" |
+#include "gpu/command_buffer/tests/gl_manager.h" |
+#include "gpu/command_buffer/tests/gl_test_utils.h" |
+#include "testing/gmock/include/gmock/gmock.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+#include "ui/gfx/gpu_fence.h" |
+#include "ui/gl/gl_fence.h" |
+ |
+using testing::_; |
+using testing::IgnoreResult; |
+using testing::InvokeWithoutArgs; |
+using testing::Invoke; |
+using testing::Return; |
+using testing::SetArgPointee; |
+using testing::StrictMock; |
+ |
+namespace gpu { |
+namespace gles2 { |
+ |
+class GpuFenceTest : public testing::Test { |
+ protected: |
+ void SetUp() override { gl_.Initialize(GLManager::Options()); } |
+ void TearDown() override { gl_.Destroy(); } |
+ |
+ GLManager gl_; |
+}; |
+ |
+// An end to end test that tests the whole GpuFence lifecycle. |
+TEST_F(GpuFenceTest, Lifecycle) { |
+ // Create the gpu fence. |
+ std::unique_ptr<gfx::GpuFence> fence(gl_.CreateGpuFence()); |
+ |
+ // Check fence. |
+ bool rv = fence->Wait(base::TimeDelta()); |
+ DCHECK(!rv); |
+ |
+ // Create the GL fence. This should add the fence ID to the FenceManager. |
+ GLuint fence_id = glCreateFenceCHROMIUM(fence->AsClientFence()); |
+ ASSERT_NE(0u, fence_id); |
+ ASSERT_TRUE(gl_.decoder()->GetFenceManager()->LookupFence(fence_id) != NULL); |
+ |
+ // Wait for 1us on fence. |
+ rv = fence->Wait(base::TimeDelta::FromMicroseconds(1)); |
+ DCHECK(!rv); |
+ |
+ // Clean up. |
+ glDestroyFenceCHROMIUM(fence_id); |
+} |
+ |
+} // namespace gles2 |
+} // namespace gpu |