Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: views/view_unittest.cc

Issue 8400059: Revert 107715 - Enable the new layer animation framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/view.cc ('k') | views/views.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "ui/base/clipboard/clipboard.h" 12 #include "ui/base/clipboard/clipboard.h"
13 #include "ui/base/keycodes/keyboard_codes.h" 13 #include "ui/base/keycodes/keyboard_codes.h"
14 #include "ui/base/models/simple_menu_model.h" 14 #include "ui/base/models/simple_menu_model.h"
15 #include "ui/gfx/canvas_skia.h" 15 #include "ui/gfx/canvas_skia.h"
16 #include "ui/gfx/compositor/compositor.h" 16 #include "ui/gfx/compositor/compositor.h"
17 #include "ui/gfx/compositor/layer.h" 17 #include "ui/gfx/compositor/layer.h"
18 #include "ui/gfx/compositor/layer_animator.h"
19 #include "ui/gfx/compositor/test_compositor.h" 18 #include "ui/gfx/compositor/test_compositor.h"
20 #include "ui/gfx/compositor/test_texture.h" 19 #include "ui/gfx/compositor/test_texture.h"
21 #include "ui/gfx/path.h" 20 #include "ui/gfx/path.h"
22 #include "ui/gfx/transform.h" 21 #include "ui/gfx/transform.h"
23 #include "views/background.h" 22 #include "views/background.h"
24 #include "views/controls/button/button_dropdown.h" 23 #include "views/controls/button/button_dropdown.h"
25 #include "views/controls/button/checkbox.h" 24 #include "views/controls/button/checkbox.h"
26 #include "views/controls/native/native_view_host.h" 25 #include "views/controls/native/native_view_host.h"
27 #include "views/controls/scroll_view.h" 26 #include "views/controls/scroll_view.h"
28 #include "views/controls/textfield/textfield.h" 27 #include "views/controls/textfield/textfield.h"
29 #include "views/events/event.h" 28 #include "views/events/event.h"
30 #include "views/focus/accelerator_handler.h" 29 #include "views/focus/accelerator_handler.h"
31 #include "views/focus/view_storage.h" 30 #include "views/focus/view_storage.h"
31 #include "views/layer_property_setter.h"
32 #include "views/test/views_test_base.h" 32 #include "views/test/views_test_base.h"
33 #include "views/touchui/gesture_manager.h" 33 #include "views/touchui/gesture_manager.h"
34 #include "views/view.h" 34 #include "views/view.h"
35 #include "views/views_delegate.h" 35 #include "views/views_delegate.h"
36 #include "views/widget/native_widget.h" 36 #include "views/widget/native_widget.h"
37 #include "views/widget/root_view.h" 37 #include "views/widget/root_view.h"
38 #include "views/window/dialog_delegate.h" 38 #include "views/window/dialog_delegate.h"
39 39
40 #if defined(OS_WIN) 40 #if defined(OS_WIN)
41 #include "views/test/test_views_delegate.h" 41 #include "views/test/test_views_delegate.h"
(...skipping 2395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2437 } 2437 }
2438 2438
2439 //////////////////////////////////////////////////////////////////////////////// 2439 ////////////////////////////////////////////////////////////////////////////////
2440 // Layers 2440 // Layers
2441 //////////////////////////////////////////////////////////////////////////////// 2441 ////////////////////////////////////////////////////////////////////////////////
2442 2442
2443 #if defined(VIEWS_COMPOSITOR) 2443 #if defined(VIEWS_COMPOSITOR)
2444 2444
2445 namespace { 2445 namespace {
2446 2446
2447 // Test implementation of LayerAnimator. 2447 // Test implementation of LayerPropertySetter;
2448 class TestLayerAnimator : public ui::LayerAnimator { 2448 class TestLayerPropertySetter : public LayerPropertySetter {
2449 public: 2449 public:
2450 TestLayerAnimator(); 2450 TestLayerPropertySetter();
2451 2451
2452 bool installed() const { return installed_; }
2452 const gfx::Rect& last_bounds() const { return last_bounds_; } 2453 const gfx::Rect& last_bounds() const { return last_bounds_; }
2453 2454
2454 // LayerAnimator. 2455 // LayerPropertySetter:
2455 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 2456 virtual void Installed(ui::Layer* layer) OVERRIDE;
2457 virtual void Uninstalled(ui::Layer* layer) OVERRIDE;
2458 virtual void SetTransform(ui::Layer* layer,
2459 const ui::Transform& transform) OVERRIDE;
2460 virtual void SetBounds(ui::Layer* layer, const gfx::Rect& bounds) OVERRIDE;
2456 2461
2457 private: 2462 private:
2463 bool installed_;
2458 gfx::Rect last_bounds_; 2464 gfx::Rect last_bounds_;
2459 2465
2460 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator); 2466 DISALLOW_COPY_AND_ASSIGN(TestLayerPropertySetter);
2461 }; 2467 };
2462 2468
2463 TestLayerAnimator::TestLayerAnimator() 2469 TestLayerPropertySetter::TestLayerPropertySetter() : installed_(false) {}
2464 : ui::LayerAnimator(base::TimeDelta::FromMilliseconds(0)) { 2470
2471 void TestLayerPropertySetter::Installed(ui::Layer* layer) {
2472 installed_ = true;
2465 } 2473 }
2466 2474
2467 void TestLayerAnimator::SetBounds(const gfx::Rect& bounds) { 2475 void TestLayerPropertySetter::Uninstalled(ui::Layer* layer) {
2476 installed_ = false;
2477 }
2478
2479 void TestLayerPropertySetter::SetTransform(ui::Layer* layer,
2480 const ui::Transform& transform) {
2481 }
2482
2483 void TestLayerPropertySetter::SetBounds(ui::Layer* layer,
2484 const gfx::Rect& bounds) {
2468 last_bounds_ = bounds; 2485 last_bounds_ = bounds;
2469 } 2486 }
2470 2487
2471 } // namespace 2488 } // namespace
2472 2489
2473 class ViewLayerTest : public ViewsTestBase { 2490 class ViewLayerTest : public ViewsTestBase {
2474 public: 2491 public:
2475 ViewLayerTest() : widget_(NULL), old_use_acceleration_(false) {} 2492 ViewLayerTest() : widget_(NULL), old_use_acceleration_(false) {}
2476 2493
2477 virtual ~ViewLayerTest() { 2494 virtual ~ViewLayerTest() {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
2652 v3->SetPaintToLayer(true); 2669 v3->SetPaintToLayer(true);
2653 v2->AddChildView(v3); 2670 v2->AddChildView(v3);
2654 ASSERT_TRUE(v3->layer() != NULL); 2671 ASSERT_TRUE(v3->layer() != NULL);
2655 2672
2656 // At this point we have v1-v2-v3. v3 has a layer, v1 and v2 don't. 2673 // At this point we have v1-v2-v3. v3 has a layer, v1 and v2 don't.
2657 2674
2658 v1->SetPaintToLayer(true); 2675 v1->SetPaintToLayer(true);
2659 EXPECT_EQ(v1->layer(), v3->layer()->parent()); 2676 EXPECT_EQ(v1->layer(), v3->layer()->parent());
2660 } 2677 }
2661 2678
2662 TEST_F(ViewLayerTest, LayerAnimator) { 2679 TEST_F(ViewLayerTest, LayerPropertySetter) {
2663 View* content_view = new View; 2680 View* content_view = new View;
2664 widget()->SetContentsView(content_view); 2681 widget()->SetContentsView(content_view);
2665 2682
2666 View* v1 = new View; 2683 View* v1 = new View;
2667 content_view->AddChildView(v1); 2684 content_view->AddChildView(v1);
2668 v1->SetPaintToLayer(true); 2685 v1->SetPaintToLayer(true);
2669 EXPECT_TRUE(v1->layer() != NULL); 2686 TestLayerPropertySetter* setter = new TestLayerPropertySetter;
2687 v1->SetLayerPropertySetter(setter);
2688 EXPECT_TRUE(setter->installed());
2670 2689
2671 TestLayerAnimator* animator = new TestLayerAnimator(); 2690 // Turn off the layer, which should trigger uninstall.
2672 v1->layer()->SetAnimator(animator); 2691 v1->SetPaintToLayer(false);
2692 EXPECT_FALSE(setter->installed());
2693
2694 v1->SetPaintToLayer(true);
2695 EXPECT_TRUE(setter->installed());
2673 2696
2674 gfx::Rect bounds(1, 2, 3, 4); 2697 gfx::Rect bounds(1, 2, 3, 4);
2675 v1->SetBoundsRect(bounds); 2698 v1->SetBoundsRect(bounds);
2676 EXPECT_EQ(bounds, animator->last_bounds()); 2699 EXPECT_EQ(bounds, setter->last_bounds());
2677 // TestLayerAnimator doesn't update the layer. 2700 // TestLayerPropertySetter doesn't update the layer.
2678 EXPECT_NE(bounds, v1->layer()->bounds()); 2701 EXPECT_NE(bounds, v1->layer()->bounds());
2679 } 2702 }
2680 2703
2681 // Verifies the bounds of a layer are updated if the bounds of ancestor that 2704 // Verifies the bounds of a layer are updated if the bounds of ancestor that
2682 // doesn't have a layer change. 2705 // doesn't have a layer change.
2683 TEST_F(ViewLayerTest, BoundsChangeWithLayer) { 2706 TEST_F(ViewLayerTest, BoundsChangeWithLayer) {
2684 View* content_view = new View; 2707 View* content_view = new View;
2685 widget()->SetContentsView(content_view); 2708 widget()->SetContentsView(content_view);
2686 2709
2687 View* v1 = new View; 2710 View* v1 = new View;
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3071 ScrambleTree(content); 3094 ScrambleTree(content);
3072 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); 3095 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer()));
3073 3096
3074 ScrambleTree(content); 3097 ScrambleTree(content);
3075 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); 3098 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer()));
3076 } 3099 }
3077 3100
3078 #endif // VIEWS_COMPOSITOR 3101 #endif // VIEWS_COMPOSITOR
3079 3102
3080 } // namespace views 3103 } // namespace views
OLDNEW
« no previous file with comments | « views/view.cc ('k') | views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698