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

Unified Diff: cc/output/output_surface_unittest.cc

Issue 2443003004: cc: Make OutputSurface::BindToClient pure virtual and not return bool (Closed)
Patch Set: bindtoclient-pure-virtual: rebase Created 4 years, 2 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 | « cc/output/output_surface_client.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/output_surface_unittest.cc
diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc
deleted file mode 100644
index 2c40578117a2b27e0374bebb14f4f8142fad3027..0000000000000000000000000000000000000000
--- a/cc/output/output_surface_unittest.cc
+++ /dev/null
@@ -1,124 +0,0 @@
-// Copyright 2013 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 "cc/output/output_surface.h"
-
-#include <utility>
-
-#include "base/memory/ptr_util.h"
-#include "cc/output/output_surface_frame.h"
-#include "cc/output/software_output_device.h"
-#include "cc/test/fake_output_surface_client.h"
-#include "cc/test/test_context_provider.h"
-#include "cc/test/test_web_graphics_context_3d.h"
-#include "gpu/GLES2/gl2extchromium.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace cc {
-namespace {
-
-class TestOutputSurface : public OutputSurface {
- public:
- explicit TestOutputSurface(
- scoped_refptr<TestContextProvider> context_provider)
- : OutputSurface(std::move(context_provider)) {}
-
- explicit TestOutputSurface(
- std::unique_ptr<SoftwareOutputDevice> software_device)
- : OutputSurface(std::move(software_device)) {}
-
- void EnsureBackbuffer() override {}
- void DiscardBackbuffer() override {}
- void BindFramebuffer() override {}
- void Reshape(const gfx::Size& size,
- float device_scale_factor,
- const gfx::ColorSpace& color_space,
- bool has_alpha) override {}
- void SwapBuffers(OutputSurfaceFrame frame) override {
- client_->DidReceiveSwapBuffersAck();
- }
- uint32_t GetFramebufferCopyTextureFormat() override {
- // TestContextProvider has no real framebuffer, just use RGB.
- return GL_RGB;
- }
- OverlayCandidateValidator* GetOverlayCandidateValidator() const override {
- return nullptr;
- }
- bool IsDisplayedAsOverlayPlane() const override { return false; }
- unsigned GetOverlayTextureId() const override { return 0; }
- bool SurfaceIsSuspendForRecycle() const override { return false; }
- bool HasExternalStencilTest() const override { return false; }
- void ApplyExternalStencil() override {}
-
- void OnSwapBuffersCompleteForTesting() {
- client_->DidReceiveSwapBuffersAck();
- }
-
- protected:
-};
-
-class TestSoftwareOutputDevice : public SoftwareOutputDevice {
- public:
- TestSoftwareOutputDevice();
- ~TestSoftwareOutputDevice() override;
-
- // Overriden from cc:SoftwareOutputDevice
- void DiscardBackbuffer() override;
- void EnsureBackbuffer() override;
-
- int discard_backbuffer_count() { return discard_backbuffer_count_; }
- int ensure_backbuffer_count() { return ensure_backbuffer_count_; }
-
- private:
- int discard_backbuffer_count_;
- int ensure_backbuffer_count_;
-};
-
-TestSoftwareOutputDevice::TestSoftwareOutputDevice()
- : discard_backbuffer_count_(0), ensure_backbuffer_count_(0) {}
-
-TestSoftwareOutputDevice::~TestSoftwareOutputDevice() {}
-
-void TestSoftwareOutputDevice::DiscardBackbuffer() {
- SoftwareOutputDevice::DiscardBackbuffer();
- discard_backbuffer_count_++;
-}
-
-void TestSoftwareOutputDevice::EnsureBackbuffer() {
- SoftwareOutputDevice::EnsureBackbuffer();
- ensure_backbuffer_count_++;
-}
-
-TEST(OutputSurfaceTest, ContextLossInformsClient) {
- scoped_refptr<TestContextProvider> provider = TestContextProvider::Create();
- TestOutputSurface output_surface(provider);
-
- FakeOutputSurfaceClient client;
- EXPECT_TRUE(output_surface.BindToClient(&client));
-
- // Verify DidLoseOutputSurface callback is hooked up correctly.
- EXPECT_FALSE(client.did_lose_output_surface_called());
- output_surface.context_provider()->ContextGL()->LoseContextCHROMIUM(
- GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
- output_surface.context_provider()->ContextGL()->Flush();
- EXPECT_TRUE(client.did_lose_output_surface_called());
-}
-
-// TODO(danakj): Add a test for worker context failure as well when
-// OutputSurface creates/binds it.
-TEST(OutputSurfaceTest, ContextLossFailsBind) {
- scoped_refptr<TestContextProvider> context_provider =
- TestContextProvider::Create();
-
- // Lose the context so BindToClient fails.
- context_provider->UnboundTestContext3d()->set_context_lost(true);
-
- TestOutputSurface output_surface(context_provider);
-
- FakeOutputSurfaceClient client;
- EXPECT_FALSE(output_surface.BindToClient(&client));
-}
-
-} // namespace
-} // namespace cc
« no previous file with comments | « cc/output/output_surface_client.h ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698