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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 TEST_F(SurfaceTest, SetOpaqueRegion) { | 84 TEST_F(SurfaceTest, SetOpaqueRegion) { |
85 scoped_ptr<Surface> surface(new Surface); | 85 scoped_ptr<Surface> surface(new Surface); |
86 | 86 |
87 // Setting a non-empty opaque region should succeed. | 87 // Setting a non-empty opaque region should succeed. |
88 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeWH(256, 256))); | 88 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeWH(256, 256))); |
89 | 89 |
90 // Setting an empty opaque region should succeed. | 90 // Setting an empty opaque region should succeed. |
91 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeEmpty())); | 91 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeEmpty())); |
92 } | 92 } |
93 | 93 |
| 94 TEST_F(SurfaceTest, SetBufferScale) { |
| 95 gfx::Size buffer_size(512, 512); |
| 96 scoped_ptr<Buffer> buffer( |
| 97 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(), |
| 98 GL_TEXTURE_2D)); |
| 99 scoped_ptr<Surface> surface(new Surface); |
| 100 |
| 101 // Attach the buffer to the surface. This will update the pending bounds of |
| 102 // the surface to the buffer size. |
| 103 surface->Attach(buffer.get()); |
| 104 EXPECT_EQ(buffer_size.ToString(), surface->GetPreferredSize().ToString()); |
| 105 |
| 106 // This will update the pending bounds of the surface and take the buffer |
| 107 // scale into account. |
| 108 const float kBufferScale = 2.0f; |
| 109 surface->SetBufferScale(kBufferScale); |
| 110 EXPECT_EQ( |
| 111 gfx::ScaleToFlooredSize(buffer_size, 1.0f / kBufferScale).ToString(), |
| 112 surface->GetPreferredSize().ToString()); |
| 113 } |
| 114 |
94 TEST_F(SurfaceTest, Commit) { | 115 TEST_F(SurfaceTest, Commit) { |
95 scoped_ptr<Surface> surface(new Surface); | 116 scoped_ptr<Surface> surface(new Surface); |
96 | 117 |
97 // Calling commit without a buffer should succeed. | 118 // Calling commit without a buffer should succeed. |
98 surface->Commit(); | 119 surface->Commit(); |
99 } | 120 } |
100 | 121 |
101 } // namespace | 122 } // namespace |
102 } // namespace exo | 123 } // namespace exo |
OLD | NEW |