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

Unified Diff: cc/surfaces/surface_unittest.cc

Issue 1673783004: Hook up BeginFrameSource to SurfaceFactoryClient via SurfaceManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Register id namespace on Android Created 4 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 | « cc/surfaces/surface_manager_unittest.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/surface_unittest.cc
diff --git a/cc/surfaces/surface_unittest.cc b/cc/surfaces/surface_unittest.cc
index 5a9b744fd75dc320129d0be30ac106f4673fb65f..72070c6ddb9ad7bd75c557fd9c8cb208ffef9500 100644
--- a/cc/surfaces/surface_unittest.cc
+++ b/cc/surfaces/surface_unittest.cc
@@ -19,8 +19,7 @@ class FakeSurfaceFactoryClient : public SurfaceFactoryClient {
void ReturnResources(const ReturnedResourceArray& resources) override {}
- void SetBeginFrameSource(SurfaceId surface_id,
- BeginFrameSource* begin_frame_source) override {
+ void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {
begin_frame_source_ = begin_frame_source;
}
@@ -45,111 +44,5 @@ TEST(SurfaceTest, SurfaceLifetime) {
EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id));
}
-TEST(SurfaceTest, StableBeginFrameSourceIndependentOfOrderAdded) {
- SurfaceManager manager;
- FakeSurfaceFactoryClient surface_factory_client;
- SurfaceFactory factory(&manager, &surface_factory_client);
-
- SurfaceId surface_id(6);
- factory.Create(surface_id);
- Surface* surface = manager.GetSurfaceForId(surface_id);
-
- FakeBeginFrameSource bfs1;
- FakeBeginFrameSource bfs2;
- FakeBeginFrameSource bfs3;
-
- // Order 1.
- surface->AddBeginFrameSource(&bfs1);
- surface->AddBeginFrameSource(&bfs2);
- surface->AddBeginFrameSource(&bfs3);
- BeginFrameSource* bfs_order1 = surface_factory_client.begin_frame_source();
- // Make sure one of the provided sources was chosen.
- EXPECT_TRUE(&bfs1 == bfs_order1 || &bfs2 == bfs_order1 ||
- &bfs3 == bfs_order1);
- surface->RemoveBeginFrameSource(&bfs1);
- surface->RemoveBeginFrameSource(&bfs2);
- surface->RemoveBeginFrameSource(&bfs3);
- EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
-
- // Order 2.
- surface->AddBeginFrameSource(&bfs1);
- surface->AddBeginFrameSource(&bfs3);
- surface->AddBeginFrameSource(&bfs2);
- BeginFrameSource* bfs_order2 = surface_factory_client.begin_frame_source();
- // Verify choice is same as before.
- EXPECT_EQ(bfs_order1, bfs_order2);
- surface->RemoveBeginFrameSource(&bfs1);
- surface->RemoveBeginFrameSource(&bfs2);
- surface->RemoveBeginFrameSource(&bfs3);
- EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
-
- // Order 3.
- surface->AddBeginFrameSource(&bfs2);
- surface->AddBeginFrameSource(&bfs1);
- surface->AddBeginFrameSource(&bfs3);
- BeginFrameSource* bfs_order3 = surface_factory_client.begin_frame_source();
- // Verify choice is same as before.
- EXPECT_EQ(bfs_order2, bfs_order3);
- surface->RemoveBeginFrameSource(&bfs1);
- surface->RemoveBeginFrameSource(&bfs2);
- surface->RemoveBeginFrameSource(&bfs3);
- EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
-
- // Order 4.
- surface->AddBeginFrameSource(&bfs2);
- surface->AddBeginFrameSource(&bfs3);
- surface->AddBeginFrameSource(&bfs1);
- BeginFrameSource* bfs_order4 = surface_factory_client.begin_frame_source();
- // Verify choice is same as before.
- EXPECT_EQ(bfs_order3, bfs_order4);
- surface->RemoveBeginFrameSource(&bfs1);
- surface->RemoveBeginFrameSource(&bfs2);
- surface->RemoveBeginFrameSource(&bfs3);
- EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
-
- // Order 5.
- surface->AddBeginFrameSource(&bfs3);
- surface->AddBeginFrameSource(&bfs1);
- surface->AddBeginFrameSource(&bfs2);
- BeginFrameSource* bfs_order5 = surface_factory_client.begin_frame_source();
- // Verify choice is same as before.
- EXPECT_EQ(bfs_order4, bfs_order5);
- surface->RemoveBeginFrameSource(&bfs1);
- surface->RemoveBeginFrameSource(&bfs2);
- surface->RemoveBeginFrameSource(&bfs3);
- EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
-
- // Order 6.
- surface->AddBeginFrameSource(&bfs3);
- surface->AddBeginFrameSource(&bfs2);
- surface->AddBeginFrameSource(&bfs1);
- BeginFrameSource* bfs_order6 = surface_factory_client.begin_frame_source();
- // Verify choice is same as before.
- EXPECT_EQ(bfs_order5, bfs_order6);
- surface->RemoveBeginFrameSource(&bfs1);
- surface->RemoveBeginFrameSource(&bfs2);
- surface->RemoveBeginFrameSource(&bfs3);
- EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
-}
-
-TEST(SurfaceTest, BeginFrameSourceRemovedOnSurfaceDestruction) {
- SurfaceManager manager;
- FakeSurfaceFactoryClient surface_factory_client;
- SurfaceFactory factory(&manager, &surface_factory_client);
- FakeBeginFrameSource bfs;
-
- SurfaceId surface_id(6);
- factory.Create(surface_id);
- Surface* surface = manager.GetSurfaceForId(surface_id);
- surface->AddBeginFrameSource(&bfs);
-
- BeginFrameSource* bfs_before = surface_factory_client.begin_frame_source();
- factory.Destroy(surface_id);
- BeginFrameSource* bfs_after = surface_factory_client.begin_frame_source();
-
- EXPECT_EQ(&bfs, bfs_before);
- EXPECT_EQ(nullptr, bfs_after);
-}
-
} // namespace
} // namespace cc
« no previous file with comments | « cc/surfaces/surface_manager_unittest.cc ('k') | cc/surfaces/surfaces_pixeltest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698