| OLD | NEW |
| 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" |
| (...skipping 2931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2942 EXPECT_FALSE(LayerIsAncestor(widget()->GetCompositor()->root_layer(), | 2942 EXPECT_FALSE(LayerIsAncestor(widget()->GetCompositor()->root_layer(), |
| 2943 v2->layer())); | 2943 v2->layer())); |
| 2944 | 2944 |
| 2945 // Reparent |v2|. | 2945 // Reparent |v2|. |
| 2946 content_view->AddChildView(v2); | 2946 content_view->AddChildView(v2); |
| 2947 EXPECT_TRUE(LayerIsAncestor(widget()->GetCompositor()->root_layer(), | 2947 EXPECT_TRUE(LayerIsAncestor(widget()->GetCompositor()->root_layer(), |
| 2948 v2->layer())); | 2948 v2->layer())); |
| 2949 EXPECT_TRUE(v2->layer()->IsDrawn()); | 2949 EXPECT_TRUE(v2->layer()->IsDrawn()); |
| 2950 } | 2950 } |
| 2951 | 2951 |
| 2952 // TODO(sky): reenable once focus issues are straightened out so that this | |
| 2953 // doesn't crash. | |
| 2954 TEST_F(ViewLayerTest, DISABLED_NativeWidgetView) { | |
| 2955 View* content_view = new View; | |
| 2956 widget()->SetContentsView(content_view); | |
| 2957 View* view = new View; | |
| 2958 content_view->AddChildView(view); | |
| 2959 view->SetBounds(10, 20, 300, 400); | |
| 2960 | |
| 2961 views_delegate().set_default_parent_view(view); | |
| 2962 Widget::SetPureViews(true); | |
| 2963 scoped_ptr<Widget> child_widget(new Widget); | |
| 2964 Widget::InitParams params(Widget::InitParams::TYPE_WINDOW); | |
| 2965 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 2966 params.bounds = gfx::Rect(1, 2, 100, 200); | |
| 2967 child_widget->Init(params); | |
| 2968 | |
| 2969 // NativeWidgetView should have been added to view. | |
| 2970 ASSERT_EQ(1, view->child_count()); | |
| 2971 View* widget_view_host = view->child_at(0); | |
| 2972 ASSERT_TRUE(widget_view_host->layer() != NULL); | |
| 2973 EXPECT_EQ(gfx::Rect(11, 22, 100, 200), widget_view_host->layer()->bounds()); | |
| 2974 | |
| 2975 View* widget_content_view = new View; | |
| 2976 child_widget->SetContentsView(widget_content_view); | |
| 2977 View* child_view = new View; | |
| 2978 child_view->SetPaintToLayer(true); | |
| 2979 child_view->SetBounds(5, 6, 10, 11); | |
| 2980 widget_content_view->AddChildView(child_view); | |
| 2981 | |
| 2982 ASSERT_TRUE(child_view->layer() != NULL); | |
| 2983 EXPECT_EQ(gfx::Rect(5, 6, 10, 11), child_view->layer()->bounds()); | |
| 2984 | |
| 2985 widget_view_host->SetPaintToLayer(false); | |
| 2986 EXPECT_TRUE(widget_view_host->layer() == NULL); | |
| 2987 | |
| 2988 ASSERT_TRUE(child_view->layer() != NULL); | |
| 2989 EXPECT_EQ(gfx::Rect(16, 28, 10, 11), child_view->layer()->bounds()); | |
| 2990 | |
| 2991 widget_view_host->SetPaintToLayer(true); | |
| 2992 ASSERT_TRUE(widget_view_host->layer() != NULL); | |
| 2993 EXPECT_EQ(gfx::Rect(11, 22, 100, 200), widget_view_host->layer()->bounds()); | |
| 2994 ASSERT_TRUE(child_view->layer() != NULL); | |
| 2995 EXPECT_EQ(gfx::Rect(5, 6, 10, 11), child_view->layer()->bounds()); | |
| 2996 | |
| 2997 child_widget->CloseNow(); | |
| 2998 } | |
| 2999 | |
| 3000 class PaintTrackingView : public View { | 2952 class PaintTrackingView : public View { |
| 3001 public: | 2953 public: |
| 3002 PaintTrackingView() : painted_(false) { | 2954 PaintTrackingView() : painted_(false) { |
| 3003 } | 2955 } |
| 3004 | 2956 |
| 3005 bool painted() const { return painted_; } | 2957 bool painted() const { return painted_; } |
| 3006 void set_painted(bool value) { painted_ = value; } | 2958 void set_painted(bool value) { painted_ = value; } |
| 3007 | 2959 |
| 3008 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { | 2960 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { |
| 3009 painted_ = true; | 2961 painted_ = true; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3107 ScrambleTree(content); | 3059 ScrambleTree(content); |
| 3108 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); | 3060 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); |
| 3109 | 3061 |
| 3110 ScrambleTree(content); | 3062 ScrambleTree(content); |
| 3111 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); | 3063 EXPECT_TRUE(ViewAndLayerTreeAreConsistent(content, content->layer())); |
| 3112 } | 3064 } |
| 3113 | 3065 |
| 3114 #endif // VIEWS_COMPOSITOR | 3066 #endif // VIEWS_COMPOSITOR |
| 3115 | 3067 |
| 3116 } // namespace views | 3068 } // namespace views |
| OLD | NEW |