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

Unified Diff: cc/surfaces/surface_factory_unittest.cc

Issue 2144733005: [WIP] cc: Plumb SurfaceId from clients Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ensure only SurfaceFactoy and tests can update hierarchy Created 4 years, 5 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/surface_factory.cc ('k') | cc/surfaces/surface_hittest_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_factory_unittest.cc
diff --git a/cc/surfaces/surface_factory_unittest.cc b/cc/surfaces/surface_factory_unittest.cc
index b5cfa1cc79798a517d4971f329aa4c4510ef7849..8bcd7e787b7d9e2ac7d03d53e91def7756128760 100644
--- a/cc/surfaces/surface_factory_unittest.cc
+++ b/cc/surfaces/surface_factory_unittest.cc
@@ -67,7 +67,7 @@ gpu::SyncToken GenTestSyncToken(int id) {
class SurfaceFactoryTest : public testing::Test, public SurfaceDamageObserver {
public:
SurfaceFactoryTest()
- : factory_(new SurfaceFactory(&manager_, &client_)),
+ : factory_(new SurfaceFactory(kArbitraryClientId, &manager_, &client_)),
surface_id_(kArbitraryClientId, 3, 0),
frame_sync_token_(GenTestSyncToken(4)),
consumer_sync_token_(GenTestSyncToken(5)) {
@@ -81,7 +81,7 @@ class SurfaceFactoryTest : public testing::Test, public SurfaceDamageObserver {
}
~SurfaceFactoryTest() override {
- if (!surface_id_.is_null())
+ if (factory_ && !surface_id_.is_null())
factory_->Destroy(surface_id_);
manager_.RemoveObserver(this);
}
@@ -499,8 +499,6 @@ TEST_F(SurfaceFactoryTest, DestroySequence) {
SurfaceId id2(kArbitraryClientId, 5, 0);
factory_->Create(id2);
- manager_.RegisterSurfaceClientId(0);
-
// Check that waiting before the sequence is satisfied works.
manager_.GetSurfaceForId(id2)
->AddDestructionDependency(SurfaceSequence(0, 4));
@@ -528,19 +526,22 @@ TEST_F(SurfaceFactoryTest, DestroySequence) {
// Tests that Surface ID namespace invalidation correctly allows
// Sequences to be ignored.
TEST_F(SurfaceFactoryTest, InvalidClientId) {
- uint32_t id_namespace = 9u;
- SurfaceId id(id_namespace, 5, 0);
- factory_->Create(id);
-
- manager_.RegisterSurfaceClientId(id_namespace);
- manager_.GetSurfaceForId(id)
- ->AddDestructionDependency(SurfaceSequence(id_namespace, 4));
- factory_->Destroy(id);
+ const uint32_t client_id = 9u;
+ TestSurfaceFactoryClient client2;
+ // Every client must get a new SurfaceFactory.
+ std::unique_ptr<SurfaceFactory> factory2(
+ new SurfaceFactory(client_id, &manager_, &client2));
+ SurfaceId id(client_id, 5, 0);
+ factory2->Create(id);
+
+ manager_.GetSurfaceForId(id)->AddDestructionDependency(
+ SurfaceSequence(client_id, 4));
+ factory2->Destroy(id);
// Verify the dependency has prevented the surface from getting destroyed.
EXPECT_TRUE(manager_.GetSurfaceForId(id));
- manager_.InvalidateSurfaceClientId(id_namespace);
+ factory2.reset();
// Verify that the invalidated namespace caused the unsatisfied sequence
// to be ignored.
@@ -551,8 +552,6 @@ TEST_F(SurfaceFactoryTest, DestroyCycle) {
SurfaceId id2(kArbitraryClientId, 5, 0);
factory_->Create(id2);
- manager_.RegisterSurfaceClientId(0);
-
manager_.GetSurfaceForId(id2)
->AddDestructionDependency(SurfaceSequence(0, 4));
« no previous file with comments | « cc/surfaces/surface_factory.cc ('k') | cc/surfaces/surface_hittest_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698