OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/output/copy_output_request.h" | 5 #include "cc/output/copy_output_request.h" |
6 #include "cc/output/copy_output_result.h" | 6 #include "cc/output/copy_output_result.h" |
7 #include "cc/test/fake_content_layer.h" | 7 #include "cc/test/fake_content_layer.h" |
8 #include "cc/test/fake_content_layer_client.h" | 8 #include "cc/test/fake_content_layer_client.h" |
9 #include "cc/test/fake_output_surface.h" | 9 #include "cc/test/fake_output_surface.h" |
10 #include "cc/test/layer_tree_test.h" | 10 #include "cc/test/layer_tree_test.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 &LayerTreeHostCopyRequestTestLayerDestroyed::CopyOutputCallback, | 176 &LayerTreeHostCopyRequestTestLayerDestroyed::CopyOutputCallback, |
177 base::Unretained(this)))); | 177 base::Unretained(this)))); |
178 impl_destroyed_->RequestCopyOfOutput( | 178 impl_destroyed_->RequestCopyOfOutput( |
179 CopyOutputRequest::CreateBitmapRequest(base::Bind( | 179 CopyOutputRequest::CreateBitmapRequest(base::Bind( |
180 &LayerTreeHostCopyRequestTestLayerDestroyed::CopyOutputCallback, | 180 &LayerTreeHostCopyRequestTestLayerDestroyed::CopyOutputCallback, |
181 base::Unretained(this)))); | 181 base::Unretained(this)))); |
182 EXPECT_EQ(0, callback_count_); | 182 EXPECT_EQ(0, callback_count_); |
183 | 183 |
184 // Destroy the main thread layer right away. | 184 // Destroy the main thread layer right away. |
185 main_destroyed_->RemoveFromParent(); | 185 main_destroyed_->RemoveFromParent(); |
186 main_destroyed_ = NULL; | 186 main_destroyed_ = nullptr; |
187 | 187 |
188 // Should callback with a NULL bitmap. | 188 // Should callback with a nullptr bitmap. |
189 EXPECT_EQ(1, callback_count_); | 189 EXPECT_EQ(1, callback_count_); |
190 | 190 |
191 // Prevent drawing so we can't make a copy of the impl_destroyed layer. | 191 // Prevent drawing so we can't make a copy of the impl_destroyed layer. |
192 layer_tree_host()->SetViewportSize(gfx::Size()); | 192 layer_tree_host()->SetViewportSize(gfx::Size()); |
193 break; | 193 break; |
194 case 2: | 194 case 2: |
195 // Flush the message loops and make sure the callbacks run. | 195 // Flush the message loops and make sure the callbacks run. |
196 layer_tree_host()->SetNeedsCommit(); | 196 layer_tree_host()->SetNeedsCommit(); |
197 break; | 197 break; |
198 case 3: | 198 case 3: |
199 // No drawing means no readback yet. | 199 // No drawing means no readback yet. |
200 EXPECT_EQ(1, callback_count_); | 200 EXPECT_EQ(1, callback_count_); |
201 | 201 |
202 // Destroy the impl thread layer. | 202 // Destroy the impl thread layer. |
203 impl_destroyed_->RemoveFromParent(); | 203 impl_destroyed_->RemoveFromParent(); |
204 impl_destroyed_ = NULL; | 204 impl_destroyed_ = nullptr; |
205 | 205 |
206 // No callback yet because it's on the impl side. | 206 // No callback yet because it's on the impl side. |
207 EXPECT_EQ(1, callback_count_); | 207 EXPECT_EQ(1, callback_count_); |
208 break; | 208 break; |
209 case 4: | 209 case 4: |
210 // Flush the message loops and make sure the callbacks run. | 210 // Flush the message loops and make sure the callbacks run. |
211 layer_tree_host()->SetNeedsCommit(); | 211 layer_tree_host()->SetNeedsCommit(); |
212 break; | 212 break; |
213 case 5: | 213 case 5: |
214 // We should get another callback with a NULL bitmap. | 214 // We should get another callback with a nullptr bitmap. |
215 EXPECT_EQ(2, callback_count_); | 215 EXPECT_EQ(2, callback_count_); |
216 EndTest(); | 216 EndTest(); |
217 break; | 217 break; |
218 } | 218 } |
219 } | 219 } |
220 | 220 |
221 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { | 221 void CopyOutputCallback(scoped_ptr<CopyOutputResult> result) { |
222 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); | 222 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
223 EXPECT_TRUE(result->IsEmpty()); | 223 EXPECT_TRUE(result->IsEmpty()); |
224 ++callback_count_; | 224 ++callback_count_; |
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 FakeContentLayerClient client_; | 965 FakeContentLayerClient client_; |
966 scoped_refptr<FakeContentLayer> root_; | 966 scoped_refptr<FakeContentLayer> root_; |
967 scoped_refptr<FakeContentLayer> copy_layer_; | 967 scoped_refptr<FakeContentLayer> copy_layer_; |
968 }; | 968 }; |
969 | 969 |
970 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( | 970 SINGLE_AND_MULTI_THREAD_DIRECT_RENDERER_TEST_F( |
971 LayerTreeHostCopyRequestTestShutdownBeforeCopy); | 971 LayerTreeHostCopyRequestTestShutdownBeforeCopy); |
972 | 972 |
973 } // namespace | 973 } // namespace |
974 } // namespace cc | 974 } // namespace cc |
OLD | NEW |