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

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: Fixed 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 kArbitraryClientId = 0;
18
17 class FakeSurfaceFactoryClient : public SurfaceFactoryClient { 19 class FakeSurfaceFactoryClient : public SurfaceFactoryClient {
18 public: 20 public:
19 FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {} 21 FakeSurfaceFactoryClient() : begin_frame_source_(nullptr) {}
20 22
21 void ReturnResources(const ReturnedResourceArray& resources) override {} 23 void ReturnResources(const ReturnedResourceArray& resources) override {}
22 24
23 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override { 25 void SetBeginFrameSource(BeginFrameSource* begin_frame_source) override {
24 begin_frame_source_ = begin_frame_source; 26 begin_frame_source_ = begin_frame_source;
25 } 27 }
26 28
27 BeginFrameSource* begin_frame_source() { return begin_frame_source_; } 29 BeginFrameSource* begin_frame_source() { return begin_frame_source_; }
28 30
29 private: 31 private:
30 BeginFrameSource* begin_frame_source_; 32 BeginFrameSource* begin_frame_source_;
31 }; 33 };
32 34
33 TEST(SurfaceTest, SurfaceLifetime) { 35 TEST(SurfaceTest, SurfaceLifetime) {
34 SurfaceManager manager; 36 SurfaceManager manager;
35 FakeSurfaceFactoryClient surface_factory_client; 37 FakeSurfaceFactoryClient surface_factory_client;
36 SurfaceFactory factory(&manager, &surface_factory_client); 38 SurfaceFactory factory(&manager, &surface_factory_client);
37 39
38 SurfaceId surface_id(0, 6, 0); 40 SurfaceId surface_id(kArbitraryClientId, 6, 0);
39 { 41 {
40 factory.Create(surface_id); 42 factory.Create(surface_id);
41 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); 43 EXPECT_TRUE(manager.GetSurfaceForId(surface_id));
42 factory.Destroy(surface_id); 44 factory.Destroy(surface_id);
43 } 45 }
44 46
45 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); 47 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id));
46 } 48 }
47 49
48 TEST(SurfaceTest, SurfaceIds) { 50 TEST(SurfaceTest, SurfaceIds) {
49 uint32_t namespaces[] = {0u, 37u, ~0u}; 51 uint32_t client_ids[] = {0u, 37u, ~0u};
50 for (size_t i = 0; i < 3; ++i) { 52 for (size_t i = 0; i < 3; ++i) {
51 uint32_t id_namespace = namespaces[i]; 53 uint32_t client_id = client_ids[i];
52 SurfaceIdAllocator allocator(id_namespace); 54 SurfaceIdAllocator allocator(client_id);
53 SurfaceId id1 = allocator.GenerateId(); 55 SurfaceId id1 = allocator.GenerateId();
54 EXPECT_EQ(id1.id_namespace(), id_namespace); 56 EXPECT_EQ(id1.client_id(), client_id);
55 SurfaceId id2 = allocator.GenerateId(); 57 SurfaceId id2 = allocator.GenerateId();
56 EXPECT_EQ(id2.id_namespace(), id_namespace); 58 EXPECT_EQ(id2.client_id(), client_id);
57 EXPECT_NE(id1.local_id(), id2.local_id()); 59 EXPECT_NE(id1.local_id(), id2.local_id());
58 EXPECT_NE(id1.nonce(), id2.nonce()); 60 EXPECT_NE(id1.nonce(), id2.nonce());
59 } 61 }
60 } 62 }
61 63
62 } // namespace 64 } // namespace
63 } // namespace cc 65 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698