Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: ui/compositor/test/fake_context_factory.cc

Issue 2752303002: views/mus: Install a mus-friend ContextFactory for tests. (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/test/fake_context_factory.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/compositor/test/fake_context_factory.cc
diff --git a/ui/compositor/test/fake_context_factory.cc b/ui/compositor/test/fake_context_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..43ba58af6aa5c04c9a249f765278d33674463e19
--- /dev/null
+++ b/ui/compositor/test/fake_context_factory.cc
@@ -0,0 +1,53 @@
+// Copyright 2017 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 "ui/compositor/test/fake_context_factory.h"
+
+#include "base/threading/thread_task_runner_handle.h"
+#include "cc/output/compositor_frame.h"
+#include "cc/output/compositor_frame_sink_client.h"
+#include "cc/scheduler/begin_frame_source.h"
+#include "cc/scheduler/delay_based_time_source.h"
+#include "cc/test/fake_compositor_frame_sink.h"
+
+namespace ui {
+
+const cc::CompositorFrame& FakeContextFactory::GetLastCompositorFrame() const {
+ return *frame_sink_->last_sent_frame();
+}
+
+void FakeContextFactory::CreateCompositorFrameSink(
+ base::WeakPtr<ui::Compositor> compositor) {
+ auto frame_sink = cc::FakeCompositorFrameSink::Create3d();
+ frame_sink_ = frame_sink.get();
+ compositor->SetCompositorFrameSink(std::move(frame_sink));
+}
+
+scoped_refptr<cc::ContextProvider>
+FakeContextFactory::SharedMainThreadContextProvider() {
+ return nullptr;
+}
+
+void FakeContextFactory::RemoveCompositor(ui::Compositor* compositor) {
+ frame_sink_ = nullptr;
+}
+
+bool FakeContextFactory::DoesCreateTestContexts() {
+ return true;
+}
+
+uint32_t FakeContextFactory::GetImageTextureTarget(gfx::BufferFormat format,
+ gfx::BufferUsage usage) {
+ return GL_TEXTURE_2D;
+}
+
+gpu::GpuMemoryBufferManager* FakeContextFactory::GetGpuMemoryBufferManager() {
+ return &gpu_memory_buffer_manager_;
+}
+
+cc::TaskGraphRunner* FakeContextFactory::GetTaskGraphRunner() {
+ return &task_graph_runner_;
+}
+
+} // namespace ui
« no previous file with comments | « ui/compositor/test/fake_context_factory.h ('k') | ui/views/mus/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698