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

Unified Diff: cc/surfaces/display_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/surfaces/display.cc ('k') | cc/test/fake_output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/display_unittest.cc
diff --git a/cc/surfaces/display_unittest.cc b/cc/surfaces/display_unittest.cc
index b8b814e145e4045adf05b1df78409406a3503801..a59565da689c2a26371adb2e85944be82e9c568d 100644
--- a/cc/surfaces/display_unittest.cc
+++ b/cc/surfaces/display_unittest.cc
@@ -25,6 +25,7 @@
#include "cc/test/fake_output_surface.h"
#include "cc/test/scheduler_test_common.h"
#include "cc/test/test_shared_bitmap_manager.h"
+#include "gpu/GLES2/gl2extchromium.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -115,7 +116,9 @@ class DisplayTest : public testing::Test {
std::unique_ptr<FakeOutputSurface> output_surface;
if (context) {
- output_surface = FakeOutputSurface::Create3d(std::move(context));
+ auto provider = TestContextProvider::Create(std::move(context));
+ provider->BindToCurrentThread();
+ output_surface = FakeOutputSurface::Create3d(std::move(provider));
} else {
std::unique_ptr<TestSoftwareOutputDevice> device(
new TestSoftwareOutputDevice);
@@ -499,5 +502,31 @@ TEST_F(DisplayTest, Finish) {
factory_.Destroy(local_frame_id);
}
+class CountLossDisplayClient : public StubDisplayClient {
+ public:
+ CountLossDisplayClient() = default;
+
+ void DisplayOutputSurfaceLost() override { ++loss_count_; }
+
+ int loss_count() const { return loss_count_; }
+
+ private:
+ int loss_count_ = 0;
+};
+
+TEST_F(DisplayTest, ContextLossInformsClient) {
+ SetUpDisplay(RendererSettings(), TestWebGraphicsContext3D::Create());
+
+ CountLossDisplayClient client;
+ display_->Initialize(&client, &manager_, kArbitraryFrameSinkId);
+
+ // Verify DidLoseOutputSurface callback is hooked up correctly.
+ EXPECT_EQ(0, client.loss_count());
+ output_surface_->context_provider()->ContextGL()->LoseContextCHROMIUM(
+ GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
+ output_surface_->context_provider()->ContextGL()->Flush();
+ EXPECT_EQ(1, client.loss_count());
+}
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/surfaces/display.cc ('k') | cc/test/fake_output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698