OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <map> | 5 #include <map> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 3210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3221 | 3221 |
3222 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); | 3222 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); |
3223 }; | 3223 }; |
3224 | 3224 |
3225 // Makes sure child views with layers aren't painted when paint starts at an | 3225 // Makes sure child views with layers aren't painted when paint starts at an |
3226 // ancestor. | 3226 // ancestor. |
3227 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { | 3227 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { |
3228 PaintTrackingView* content_view = new PaintTrackingView; | 3228 PaintTrackingView* content_view = new PaintTrackingView; |
3229 widget()->SetContentsView(content_view); | 3229 widget()->SetContentsView(content_view); |
3230 content_view->SetPaintToLayer(true); | 3230 content_view->SetPaintToLayer(true); |
3231 // TODO(piman): Compositor::Draw() won't work for the threaded compositor. | 3231 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3232 GetRootLayer()->GetCompositor()->Draw(false); | 3232 EXPECT_TRUE(ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor())); |
3233 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 3233 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
3234 content_view->set_painted(false); | 3234 content_view->set_painted(false); |
3235 // content_view no longer has a dirty rect. Paint from the root and make sure | 3235 // content_view no longer has a dirty rect. Paint from the root and make sure |
3236 // PaintTrackingView isn't painted. | 3236 // PaintTrackingView isn't painted. |
3237 GetRootLayer()->GetCompositor()->Draw(false); | 3237 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
| 3238 EXPECT_TRUE(ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor())); |
3238 EXPECT_FALSE(content_view->painted()); | 3239 EXPECT_FALSE(content_view->painted()); |
3239 | 3240 |
3240 // Make content_view have a dirty rect, paint the layers and make sure | 3241 // Make content_view have a dirty rect, paint the layers and make sure |
3241 // PaintTrackingView is painted. | 3242 // PaintTrackingView is painted. |
3242 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 3243 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
3243 GetRootLayer()->GetCompositor()->Draw(false); | 3244 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
| 3245 EXPECT_TRUE(ui::DrawWaiterForTest::Wait(GetRootLayer()->GetCompositor())); |
3244 EXPECT_TRUE(content_view->painted()); | 3246 EXPECT_TRUE(content_view->painted()); |
3245 } | 3247 } |
3246 | 3248 |
3247 // Tests that the visibility of child layers are updated correctly when a View's | 3249 // Tests that the visibility of child layers are updated correctly when a View's |
3248 // visibility changes. | 3250 // visibility changes. |
3249 TEST_F(ViewLayerTest, VisibilityChildLayers) { | 3251 TEST_F(ViewLayerTest, VisibilityChildLayers) { |
3250 View* v1 = new View; | 3252 View* v1 = new View; |
3251 v1->SetPaintToLayer(true); | 3253 v1->SetPaintToLayer(true); |
3252 widget()->SetContentsView(v1); | 3254 widget()->SetContentsView(v1); |
3253 | 3255 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3362 // Set to non default value. | 3364 // Set to non default value. |
3363 v->layer()->set_scale_content(false); | 3365 v->layer()->set_scale_content(false); |
3364 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); | 3366 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); |
3365 ui::Layer* new_layer = v->layer(); | 3367 ui::Layer* new_layer = v->layer(); |
3366 EXPECT_FALSE(new_layer->scale_content()); | 3368 EXPECT_FALSE(new_layer->scale_content()); |
3367 } | 3369 } |
3368 | 3370 |
3369 #endif // USE_AURA | 3371 #endif // USE_AURA |
3370 | 3372 |
3371 } // namespace views | 3373 } // namespace views |
OLD | NEW |