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" |
11 #include "grit/ui_strings.h" | 11 #include "grit/ui_strings.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "ui/base/accelerators/accelerator.h" | 13 #include "ui/base/accelerators/accelerator.h" |
14 #include "ui/base/clipboard/clipboard.h" | 14 #include "ui/base/clipboard/clipboard.h" |
15 #include "ui/base/events/event.h" | 15 #include "ui/base/events/event.h" |
16 #include "ui/base/keycodes/keyboard_codes.h" | 16 #include "ui/base/keycodes/keyboard_codes.h" |
17 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/models/simple_menu_model.h" | 18 #include "ui/base/models/simple_menu_model.h" |
19 #include "ui/compositor/compositor.h" | 19 #include "ui/compositor/compositor.h" |
20 #include "ui/compositor/layer.h" | 20 #include "ui/compositor/layer.h" |
21 #include "ui/compositor/layer_animator.h" | 21 #include "ui/compositor/layer_animator.h" |
| 22 #include "ui/compositor/test/test_utils.h" |
22 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/path.h" | 24 #include "ui/gfx/path.h" |
24 #include "ui/gfx/transform.h" | 25 #include "ui/gfx/transform.h" |
25 #include "ui/views/background.h" | 26 #include "ui/views/background.h" |
26 #include "ui/views/controls/button/button_dropdown.h" | 27 #include "ui/views/controls/button/button_dropdown.h" |
27 #include "ui/views/controls/button/checkbox.h" | 28 #include "ui/views/controls/button/checkbox.h" |
28 #include "ui/views/controls/button/label_button.h" | 29 #include "ui/views/controls/button/label_button.h" |
29 #include "ui/views/controls/native/native_view_host.h" | 30 #include "ui/views/controls/native/native_view_host.h" |
30 #include "ui/views/controls/scroll_view.h" | 31 #include "ui/views/controls/scroll_view.h" |
31 #include "ui/views/controls/textfield/textfield.h" | 32 #include "ui/views/controls/textfield/textfield.h" |
(...skipping 3217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3249 | 3250 |
3250 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); | 3251 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); |
3251 }; | 3252 }; |
3252 | 3253 |
3253 // Makes sure child views with layers aren't painted when paint starts at an | 3254 // Makes sure child views with layers aren't painted when paint starts at an |
3254 // ancestor. | 3255 // ancestor. |
3255 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { | 3256 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { |
3256 PaintTrackingView* content_view = new PaintTrackingView; | 3257 PaintTrackingView* content_view = new PaintTrackingView; |
3257 widget()->SetContentsView(content_view); | 3258 widget()->SetContentsView(content_view); |
3258 content_view->SetPaintToLayer(true); | 3259 content_view->SetPaintToLayer(true); |
3259 // TODO(piman): Compositor::Draw() won't work for the threaded compositor. | 3260 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
3260 GetRootLayer()->GetCompositor()->Draw(false); | 3261 EXPECT_TRUE(GetRootLayer()->GetCompositor()->WaitForDraw()); |
3261 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 3262 GetRootLayer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
3262 content_view->set_painted(false); | 3263 content_view->set_painted(false); |
3263 // content_view no longer has a dirty rect. Paint from the root and make sure | 3264 // content_view no longer has a dirty rect. Paint from the root and make sure |
3264 // PaintTrackingView isn't painted. | 3265 // PaintTrackingView isn't painted. |
3265 GetRootLayer()->GetCompositor()->Draw(false); | 3266 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
| 3267 EXPECT_TRUE(GetRootLayer()->GetCompositor()->WaitForDraw()); |
3266 EXPECT_FALSE(content_view->painted()); | 3268 EXPECT_FALSE(content_view->painted()); |
3267 | 3269 |
3268 // Make content_view have a dirty rect, paint the layers and make sure | 3270 // Make content_view have a dirty rect, paint the layers and make sure |
3269 // PaintTrackingView is painted. | 3271 // PaintTrackingView is painted. |
3270 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); | 3272 content_view->layer()->SchedulePaint(gfx::Rect(0, 0, 10, 10)); |
3271 GetRootLayer()->GetCompositor()->Draw(false); | 3273 GetRootLayer()->GetCompositor()->ScheduleDraw(); |
| 3274 EXPECT_TRUE(GetRootLayer()->GetCompositor()->WaitForDraw()); |
3272 EXPECT_TRUE(content_view->painted()); | 3275 EXPECT_TRUE(content_view->painted()); |
3273 } | 3276 } |
3274 | 3277 |
3275 // Tests that the visibility of child layers are updated correctly when a View's | 3278 // Tests that the visibility of child layers are updated correctly when a View's |
3276 // visibility changes. | 3279 // visibility changes. |
3277 TEST_F(ViewLayerTest, VisibilityChildLayers) { | 3280 TEST_F(ViewLayerTest, VisibilityChildLayers) { |
3278 View* v1 = new View; | 3281 View* v1 = new View; |
3279 v1->SetPaintToLayer(true); | 3282 v1->SetPaintToLayer(true); |
3280 widget()->SetContentsView(v1); | 3283 widget()->SetContentsView(v1); |
3281 | 3284 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3390 // Set to non default value. | 3393 // Set to non default value. |
3391 v->layer()->set_scale_content(false); | 3394 v->layer()->set_scale_content(false); |
3392 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); | 3395 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); |
3393 ui::Layer* new_layer = v->layer(); | 3396 ui::Layer* new_layer = v->layer(); |
3394 EXPECT_FALSE(new_layer->scale_content()); | 3397 EXPECT_FALSE(new_layer->scale_content()); |
3395 } | 3398 } |
3396 | 3399 |
3397 #endif // USE_AURA | 3400 #endif // USE_AURA |
3398 | 3401 |
3399 } // namespace views | 3402 } // namespace views |
OLD | NEW |