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

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

Issue 1996783002: Make cc::SurfaceId unguessable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Ben's comment Created 4 years, 6 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_id_allocator.cc ('k') | components/mus/public/interfaces/surface_id.mojom » ('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_id_allocator.h" 8 #include "cc/surfaces/surface_id_allocator.h"
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 #include "cc/test/scheduler_test_common.h" 10 #include "cc/test/scheduler_test_common.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(0, 6, 0);
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, SurfaceIds) { 48 TEST(SurfaceTest, SurfaceIds) {
49 uint32_t namespaces[] = {0u, 37u, ~0u}; 49 uint32_t namespaces[] = {0u, 37u, ~0u};
50 for (size_t i = 0; i < 3; ++i) { 50 for (size_t i = 0; i < 3; ++i) {
51 uint32_t id_namespace = namespaces[i]; 51 uint32_t id_namespace = namespaces[i];
52 SurfaceIdAllocator allocator(id_namespace); 52 SurfaceIdAllocator allocator(id_namespace);
53 SurfaceId id1 = allocator.GenerateId(); 53 SurfaceId id1 = allocator.GenerateId();
54 EXPECT_EQ(id1.id_namespace(), id_namespace); 54 EXPECT_EQ(id1.id_namespace(), id_namespace);
55 SurfaceId id2 = allocator.GenerateId(); 55 SurfaceId id2 = allocator.GenerateId();
56 EXPECT_EQ(id2.id_namespace(), id_namespace); 56 EXPECT_EQ(id2.id_namespace(), id_namespace);
57 EXPECT_NE(id1.id, id2.id); 57 EXPECT_NE(id1.local_id(), id2.local_id());
58 EXPECT_NE(id1.nonce(), id2.nonce());
58 } 59 }
59 } 60 }
60 61
61 } // namespace 62 } // namespace
62 } // namespace cc 63 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_id_allocator.cc ('k') | components/mus/public/interfaces/surface_id.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698