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

Side by Side Diff: cc/surfaces/surface_unittest.cc

Issue 1496103002: Reusing base::IdType<...> to implement SurfaceId. Base URL: https://chromium.googlesource.com/chromium/src.git@type-safe-id-base
Patch Set: Rebasing + dusting off... Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/test/surface_aggregator_test_helpers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/surface.h" 5 #include "cc/surfaces/surface.h"
6 #include "cc/surfaces/surface_factory.h" 6 #include "cc/surfaces/surface_factory.h"
7 #include "cc/surfaces/surface_factory_client.h" 7 #include "cc/surfaces/surface_factory_client.h"
8 #include "cc/surfaces/surface_manager.h" 8 #include "cc/surfaces/surface_manager.h"
9 #include "cc/test/scheduler_test_common.h" 9 #include "cc/test/scheduler_test_common.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 17 matching lines...) Expand all
28 28
29 private: 29 private:
30 BeginFrameSource* begin_frame_source_; 30 BeginFrameSource* begin_frame_source_;
31 }; 31 };
32 32
33 TEST(SurfaceTest, SurfaceLifetime) { 33 TEST(SurfaceTest, SurfaceLifetime) {
34 SurfaceManager manager; 34 SurfaceManager manager;
35 FakeSurfaceFactoryClient surface_factory_client; 35 FakeSurfaceFactoryClient surface_factory_client;
36 SurfaceFactory factory(&manager, &surface_factory_client); 36 SurfaceFactory factory(&manager, &surface_factory_client);
37 37
38 SurfaceId surface_id(6); 38 SurfaceId surface_id = SurfaceId::FromUnsafeValue(6);
39 { 39 {
40 factory.Create(surface_id); 40 factory.Create(surface_id);
41 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); 41 EXPECT_TRUE(manager.GetSurfaceForId(surface_id));
42 factory.Destroy(surface_id); 42 factory.Destroy(surface_id);
43 } 43 }
44 44
45 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); 45 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id));
46 } 46 }
47 47
48 TEST(SurfaceTest, StableBeginFrameSourceIndependentOfOrderAdded) { 48 TEST(SurfaceTest, StableBeginFrameSourceIndependentOfOrderAdded) {
49 SurfaceManager manager; 49 SurfaceManager manager;
50 FakeSurfaceFactoryClient surface_factory_client; 50 FakeSurfaceFactoryClient surface_factory_client;
51 SurfaceFactory factory(&manager, &surface_factory_client); 51 SurfaceFactory factory(&manager, &surface_factory_client);
52 52
53 SurfaceId surface_id(6); 53 SurfaceId surface_id = SurfaceId::FromUnsafeValue(6);
54 factory.Create(surface_id); 54 factory.Create(surface_id);
55 Surface* surface = manager.GetSurfaceForId(surface_id); 55 Surface* surface = manager.GetSurfaceForId(surface_id);
56 56
57 FakeBeginFrameSource bfs1; 57 FakeBeginFrameSource bfs1;
58 FakeBeginFrameSource bfs2; 58 FakeBeginFrameSource bfs2;
59 FakeBeginFrameSource bfs3; 59 FakeBeginFrameSource bfs3;
60 60
61 // Order 1. 61 // Order 1.
62 surface->AddBeginFrameSource(&bfs1); 62 surface->AddBeginFrameSource(&bfs1);
63 surface->AddBeginFrameSource(&bfs2); 63 surface->AddBeginFrameSource(&bfs2);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 surface->RemoveBeginFrameSource(&bfs3); 131 surface->RemoveBeginFrameSource(&bfs3);
132 EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source()); 132 EXPECT_EQ(nullptr, surface_factory_client.begin_frame_source());
133 } 133 }
134 134
135 TEST(SurfaceTest, BeginFrameSourceRemovedOnSurfaceDestruction) { 135 TEST(SurfaceTest, BeginFrameSourceRemovedOnSurfaceDestruction) {
136 SurfaceManager manager; 136 SurfaceManager manager;
137 FakeSurfaceFactoryClient surface_factory_client; 137 FakeSurfaceFactoryClient surface_factory_client;
138 SurfaceFactory factory(&manager, &surface_factory_client); 138 SurfaceFactory factory(&manager, &surface_factory_client);
139 FakeBeginFrameSource bfs; 139 FakeBeginFrameSource bfs;
140 140
141 SurfaceId surface_id(6); 141 SurfaceId surface_id = SurfaceId::FromUnsafeValue(6);
142 factory.Create(surface_id); 142 factory.Create(surface_id);
143 Surface* surface = manager.GetSurfaceForId(surface_id); 143 Surface* surface = manager.GetSurfaceForId(surface_id);
144 surface->AddBeginFrameSource(&bfs); 144 surface->AddBeginFrameSource(&bfs);
145 145
146 BeginFrameSource* bfs_before = surface_factory_client.begin_frame_source(); 146 BeginFrameSource* bfs_before = surface_factory_client.begin_frame_source();
147 factory.Destroy(surface_id); 147 factory.Destroy(surface_id);
148 BeginFrameSource* bfs_after = surface_factory_client.begin_frame_source(); 148 BeginFrameSource* bfs_after = surface_factory_client.begin_frame_source();
149 149
150 EXPECT_EQ(&bfs, bfs_before); 150 EXPECT_EQ(&bfs, bfs_before);
151 EXPECT_EQ(nullptr, bfs_after); 151 EXPECT_EQ(nullptr, bfs_after);
152 } 152 }
153 153
154 } // namespace 154 } // namespace
155 } // namespace cc 155 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.h ('k') | cc/test/surface_aggregator_test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698