| 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_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 Loading... |
| 28 | 28 |
| 29 BeginFrameSource* begin_frame_source() { return begin_frame_source_; } | 29 BeginFrameSource* begin_frame_source() { return begin_frame_source_; } |
| 30 | 30 |
| 31 private: | 31 private: |
| 32 BeginFrameSource* begin_frame_source_; | 32 BeginFrameSource* begin_frame_source_; |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 TEST(SurfaceTest, SurfaceLifetime) { | 35 TEST(SurfaceTest, SurfaceLifetime) { |
| 36 SurfaceManager manager; | 36 SurfaceManager manager; |
| 37 FakeSurfaceFactoryClient surface_factory_client; | 37 FakeSurfaceFactoryClient surface_factory_client; |
| 38 SurfaceFactory factory(&manager, &surface_factory_client); | 38 SurfaceFactory factory(kArbitraryFrameSinkId, &manager, |
| 39 &surface_factory_client); |
| 39 | 40 |
| 40 SurfaceId surface_id(kArbitraryFrameSinkId, 6, 0); | 41 SurfaceId surface_id(kArbitraryFrameSinkId, 6, 0); |
| 41 { | 42 { |
| 42 factory.Create(surface_id); | 43 factory.Create(surface_id); |
| 43 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); | 44 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); |
| 44 factory.Destroy(surface_id); | 45 factory.Destroy(surface_id); |
| 45 } | 46 } |
| 46 | 47 |
| 47 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); | 48 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); |
| 48 } | 49 } |
| 49 | 50 |
| 50 TEST(SurfaceTest, SurfaceIds) { | 51 TEST(SurfaceTest, SurfaceIds) { |
| 51 FrameSinkId frame_sink_ids[] = {FrameSinkId(0, 0), FrameSinkId(37, 37), | 52 FrameSinkId frame_sink_ids[] = {FrameSinkId(0, 0), FrameSinkId(37, 37), |
| 52 FrameSinkId(1337, 1234)}; | 53 FrameSinkId(1337, 1234)}; |
| 53 for (size_t i = 0; i < 3; ++i) { | 54 for (size_t i = 0; i < 3; ++i) { |
| 54 const FrameSinkId& frame_sink_id = frame_sink_ids[i]; | 55 const FrameSinkId& frame_sink_id = frame_sink_ids[i]; |
| 55 SurfaceIdAllocator allocator(frame_sink_id); | 56 SurfaceIdAllocator allocator(frame_sink_id); |
| 56 SurfaceId id1 = allocator.GenerateId(); | 57 SurfaceId id1 = allocator.GenerateId(); |
| 57 EXPECT_EQ(id1.frame_sink_id(), frame_sink_id); | 58 EXPECT_EQ(id1.frame_sink_id(), frame_sink_id); |
| 58 SurfaceId id2 = allocator.GenerateId(); | 59 SurfaceId id2 = allocator.GenerateId(); |
| 59 EXPECT_EQ(id2.frame_sink_id(), frame_sink_id); | 60 EXPECT_EQ(id2.frame_sink_id(), frame_sink_id); |
| 60 EXPECT_NE(id1.local_id(), id2.local_id()); | 61 EXPECT_NE(id1.local_id(), id2.local_id()); |
| 61 EXPECT_NE(id1.nonce(), id2.nonce()); | 62 EXPECT_NE(id1.nonce(), id2.nonce()); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 } // namespace | 66 } // namespace |
| 66 } // namespace cc | 67 } // namespace cc |
| OLD | NEW |