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

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

Issue 2136413002: Update Surface ID Terminology (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix webkit_unit_tests 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 unified diff | Download patch
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"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
13 13
14 namespace cc { 14 namespace cc {
15 namespace { 15 namespace {
16 16
17 static constexpr uint32_t kArbitraryGpuId = 0;
18 static constexpr uint32_t kArbitraryClientId = 0;
19
17 class FakeSurfaceFactoryClient : public SurfaceFactoryClient { 20 class FakeSurfaceFactoryClient : public SurfaceFactoryClient {
18 public: 21 public:
19 FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {} 22 FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {}
20 23
21 void ReturnResources(const ReturnedResourceArray& resources) override {} 24 void ReturnResources(const ReturnedResourceArray& resources) override {}
22 25
23 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override { 26 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {
24 begin_frame_source_ = begin_frame_source; 27 begin_frame_source_ = begin_frame_source;
25 } 28 }
26 29
27 BeginFrameSource* begin_frame_source() { return begin_frame_source_; } 30 BeginFrameSource* begin_frame_source() { return begin_frame_source_; }
28 31
29 private: 32 private:
30 BeginFrameSource* begin_frame_source_; 33 BeginFrameSource* begin_frame_source_;
31 }; 34 };
32 35
33 TEST(SurfaceTest, SurfaceLifetime) { 36 TEST(SurfaceTest, SurfaceLifetime) {
34 SurfaceManager manager; 37 SurfaceManager manager;
35 FakeSurfaceFactoryClient surface_factory_client; 38 FakeSurfaceFactoryClient surface_factory_client;
36 SurfaceFactory factory(&manager, &surface_factory_client); 39 SurfaceFactory factory(&manager, &surface_factory_client);
37 40
38 SurfaceId surface_id(0, 6, 0); 41 SurfaceId surface_id(kArbitraryGpuId, kArbitraryClientId, 6, 0);
39 { 42 {
40 factory.Create(surface_id); 43 factory.Create(surface_id);
41 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); 44 EXPECT_TRUE(manager.GetSurfaceForId(surface_id));
42 factory.Destroy(surface_id); 45 factory.Destroy(surface_id);
43 } 46 }
44 47
45 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); 48 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id));
46 } 49 }
47 50
48 TEST(SurfaceTest, SurfaceIds) { 51 TEST(SurfaceTest, SurfaceIds) {
49 uint32_t namespaces[] = {0u, 37u, ~0u}; 52 uint32_t client_ids[] = {0u, 37u, ~0u};
50 for (size_t i = 0; i < 3; ++i) { 53 for (size_t i = 0; i < 3; ++i) {
51 uint32_t id_namespace = namespaces[i]; 54 uint32_t client_id = client_ids[i];
52 SurfaceIdAllocator allocator(id_namespace); 55 SurfaceIdAllocator allocator(kArbitraryGpuId, client_id);
53 SurfaceId id1 = allocator.GenerateId(); 56 SurfaceId id1 = allocator.GenerateId();
54 EXPECT_EQ(id1.id_namespace(), id_namespace); 57 EXPECT_EQ(id1.client_id(), client_id);
55 SurfaceId id2 = allocator.GenerateId(); 58 SurfaceId id2 = allocator.GenerateId();
56 EXPECT_EQ(id2.id_namespace(), id_namespace); 59 EXPECT_EQ(id2.client_id(), client_id);
57 EXPECT_NE(id1.local_id(), id2.local_id()); 60 EXPECT_NE(id1.local_id(), id2.local_id());
58 EXPECT_NE(id1.nonce(), id2.nonce()); 61 EXPECT_NE(id1.nonce(), id2.nonce());
59 } 62 }
60 } 63 }
61 64
62 } // namespace 65 } // namespace
63 } // namespace cc 66 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698