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

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

Issue 2685393003: Surfaces: Allow parent to refer to child surfaces that don't exist yet. (Closed)
Patch Set: Rebased Created 3 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.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <unordered_map> 7 #include <unordered_map>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 259
260 RemoveSurfaceReference(manager().GetRootSurfaceId(), id1); 260 RemoveSurfaceReference(manager().GetRootSurfaceId(), id1);
261 261
262 // Removing the reference from the root to id1 should allow all three surfaces 262 // Removing the reference from the root to id1 should allow all three surfaces
263 // to be deleted during GC. 263 // to be deleted during GC.
264 EXPECT_EQ(nullptr, manager().GetSurfaceForId(id1)); 264 EXPECT_EQ(nullptr, manager().GetSurfaceForId(id1));
265 EXPECT_EQ(nullptr, manager().GetSurfaceForId(id2)); 265 EXPECT_EQ(nullptr, manager().GetSurfaceForId(id2));
266 EXPECT_EQ(nullptr, manager().GetSurfaceForId(id3)); 266 EXPECT_EQ(nullptr, manager().GetSurfaceForId(id3));
267 } 267 }
268 268
269 TEST_F(SurfaceManagerRefTest, TryAddReferenceToBadSurface) {
270 // Not creating an accompanying Surface and SurfaceFactory.
271 SurfaceId id(FrameSinkId(100u, 200u),
272 LocalSurfaceId(1u, base::UnguessableToken::Create()));
273
274 // Adding reference from root to the Surface should do nothing because
275 // SurfaceManager doesn't know Surface for |id| exists.
276 manager().AddSurfaceReference(manager().GetRootSurfaceId(), id);
277 EXPECT_THAT(GetReferencesFor(id), IsEmpty());
278 }
279
280 TEST_F(SurfaceManagerRefTest, TryDoubleAddReference) { 269 TEST_F(SurfaceManagerRefTest, TryDoubleAddReference) {
281 SurfaceId id1 = CreateSurface(kFrameSink1, 1); 270 SurfaceId id1 = CreateSurface(kFrameSink1, 1);
282 SurfaceId id2 = CreateSurface(kFrameSink2, 1); 271 SurfaceId id2 = CreateSurface(kFrameSink2, 1);
283 272
284 manager().AddSurfaceReference(manager().GetRootSurfaceId(), id1); 273 manager().AddSurfaceReference(manager().GetRootSurfaceId(), id1);
285 manager().AddSurfaceReference(id1, id2); 274 manager().AddSurfaceReference(id1, id2);
286 EXPECT_THAT(GetReferencesFor(id2), SizeIs(1)); 275 EXPECT_THAT(GetReferencesFor(id2), SizeIs(1));
287 EXPECT_THAT(GetReferencesFrom(id1), SizeIs(1)); 276 EXPECT_THAT(GetReferencesFrom(id1), SizeIs(1));
288 277
289 // The second request should be ignored without crashing. 278 // The second request should be ignored without crashing.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 // reference should be removed. The temporary reference for |surface_id2| 422 // reference should be removed. The temporary reference for |surface_id2|
434 // should remain. A temporary reference must be added for |parent_id|. 423 // should remain. A temporary reference must be added for |parent_id|.
435 EXPECT_THAT(GetAllTempReferences(), 424 EXPECT_THAT(GetAllTempReferences(),
436 UnorderedElementsAre(parent_id, surface_id2)); 425 UnorderedElementsAre(parent_id, surface_id2));
437 EXPECT_THAT(GetReferencesFromRoot(), 426 EXPECT_THAT(GetReferencesFromRoot(),
438 UnorderedElementsAre(parent_id, surface_id2)); 427 UnorderedElementsAre(parent_id, surface_id2));
439 EXPECT_THAT(GetReferencesFrom(parent_id), ElementsAre(surface_id1)); 428 EXPECT_THAT(GetReferencesFrom(parent_id), ElementsAre(surface_id1));
440 } 429 }
441 430
442 } // namespace cc 431 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698