OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "components/exo/buffer.h" | 6 #include "components/exo/buffer.h" |
7 #include "components/exo/surface.h" | 7 #include "components/exo/surface.h" |
8 #include "components/exo/test/exo_test_base.h" | 8 #include "components/exo/test/exo_test_base.h" |
9 #include "components/exo/test/exo_test_helper.h" | 9 #include "components/exo/test/exo_test_helper.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 gfx::Size buffer_size(256, 256); | 25 gfx::Size buffer_size(256, 256); |
26 scoped_ptr<Buffer> buffer( | 26 scoped_ptr<Buffer> buffer( |
27 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(), | 27 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(), |
28 GL_TEXTURE_2D)); | 28 GL_TEXTURE_2D)); |
29 | 29 |
30 // Set the release callback that will be run when buffer is no longer in use. | 30 // Set the release callback that will be run when buffer is no longer in use. |
31 int release_buffer_call_count = 0; | 31 int release_buffer_call_count = 0; |
32 buffer->set_release_callback( | 32 buffer->set_release_callback( |
33 base::Bind(&ReleaseBuffer, base::Unretained(&release_buffer_call_count))); | 33 base::Bind(&ReleaseBuffer, base::Unretained(&release_buffer_call_count))); |
34 | 34 |
35 scoped_ptr<Surface> surface1(new Surface); | 35 scoped_ptr<Surface> surface(new Surface); |
36 scoped_ptr<Surface> surface2(new Surface); | |
37 | 36 |
38 // Attach the buffer to surface1. | 37 // Attach the buffer to surface1. |
39 surface1->Attach(buffer.get()); | 38 surface->Attach(buffer.get()); |
40 surface1->Commit(); | 39 surface->Commit(); |
41 | 40 |
42 // Attaching buffer to surface2 when it is already attached to surface1 | 41 // Commit without calling Attach() should have no effect. |
43 // should fail and buffer should remain attached to surface1. | 42 surface->Commit(); |
44 surface2->Attach(buffer.get()); | 43 EXPECT_EQ(0, release_buffer_call_count); |
45 surface2->Commit(); | |
46 | 44 |
47 // Attach a null buffer to surface1, this should release the previously | 45 // Attach a null buffer to surface, this should release the previously |
48 // attached buffer. | 46 // attached buffer. |
49 surface1->Attach(nullptr); | 47 surface->Attach(nullptr); |
50 surface1->Commit(); | 48 surface->Commit(); |
51 ASSERT_EQ(release_buffer_call_count, 1); | 49 ASSERT_EQ(1, release_buffer_call_count); |
52 } | 50 } |
53 | 51 |
54 TEST_F(SurfaceTest, Damage) { | 52 TEST_F(SurfaceTest, Damage) { |
55 gfx::Size buffer_size(256, 256); | 53 gfx::Size buffer_size(256, 256); |
56 scoped_ptr<Buffer> buffer( | 54 scoped_ptr<Buffer> buffer( |
57 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(), | 55 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(), |
58 GL_TEXTURE_2D)); | 56 GL_TEXTURE_2D)); |
59 scoped_ptr<Surface> surface(new Surface); | 57 scoped_ptr<Surface> surface(new Surface); |
60 | 58 |
61 // Attach the buffer to the surface. This will update the pending bounds of | 59 // Attach the buffer to the surface. This will update the pending bounds of |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 94 |
97 TEST_F(SurfaceTest, Commit) { | 95 TEST_F(SurfaceTest, Commit) { |
98 scoped_ptr<Surface> surface(new Surface); | 96 scoped_ptr<Surface> surface(new Surface); |
99 | 97 |
100 // Calling commit without a buffer should succeed. | 98 // Calling commit without a buffer should succeed. |
101 surface->Commit(); | 99 surface->Commit(); |
102 } | 100 } |
103 | 101 |
104 } // namespace | 102 } // namespace |
105 } // namespace exo | 103 } // namespace exo |
OLD | NEW |