OLD | NEW |
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_manager.h" | 9 #include "cc/surfaces/surface_manager.h" |
9 #include "cc/test/scheduler_test_common.h" | 10 #include "cc/test/scheduler_test_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
12 | 13 |
13 namespace cc { | 14 namespace cc { |
14 namespace { | 15 namespace { |
15 | 16 |
16 class FakeSurfaceFactoryClient : public SurfaceFactoryClient { | 17 class FakeSurfaceFactoryClient : public SurfaceFactoryClient { |
17 public: | 18 public: |
(...skipping 19 matching lines...) Expand all Loading... |
37 SurfaceId surface_id(6); | 38 SurfaceId surface_id(6); |
38 { | 39 { |
39 factory.Create(surface_id); | 40 factory.Create(surface_id); |
40 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); | 41 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); |
41 factory.Destroy(surface_id); | 42 factory.Destroy(surface_id); |
42 } | 43 } |
43 | 44 |
44 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); | 45 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); |
45 } | 46 } |
46 | 47 |
| 48 TEST(SurfaceTest, SurfaceIds) { |
| 49 uint32_t namespaces[] = {0, 37, ~0}; |
| 50 for (size_t i = 0; i < 3; ++i) { |
| 51 uint32_t id_namespace = namespaces[i]; |
| 52 SurfaceIdAllocator allocator(id_namespace); |
| 53 SurfaceId id1 = allocator.GenerateId(); |
| 54 EXPECT_EQ(id1.id_namespace(), id_namespace); |
| 55 SurfaceId id2 = allocator.GenerateId(); |
| 56 EXPECT_EQ(id2.id_namespace(), id_namespace); |
| 57 EXPECT_NE(id1.id, id2.id); |
| 58 } |
| 59 } |
| 60 |
47 } // namespace | 61 } // namespace |
48 } // namespace cc | 62 } // namespace cc |
OLD | NEW |