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

Side by Side Diff: ui/views/view_unittest.cc

Issue 1440593004: Make operators on scoped_ptr match the ones defined for std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrequals: followupfix-after-rebase Created 5 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
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | no next file » | 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) 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/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 2151 matching lines...) Expand 10 before | Expand all | Expand 10 after
2162 Widget* child = new Widget; 2162 Widget* child = new Widget;
2163 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL); 2163 Widget::InitParams child_params(Widget::InitParams::TYPE_CONTROL);
2164 child_params.parent = toplevel1->GetNativeView(); 2164 child_params.parent = toplevel1->GetNativeView();
2165 child->Init(child_params); 2165 child->Init(child_params);
2166 2166
2167 ToplevelWidgetObserverView* observer_view = 2167 ToplevelWidgetObserverView* observer_view =
2168 new ToplevelWidgetObserverView(); 2168 new ToplevelWidgetObserverView();
2169 EXPECT_EQ(NULL, observer_view->toplevel()); 2169 EXPECT_EQ(NULL, observer_view->toplevel());
2170 2170
2171 child->SetContentsView(observer_view); 2171 child->SetContentsView(observer_view);
2172 EXPECT_EQ(toplevel1, observer_view->toplevel()); 2172 EXPECT_EQ(toplevel1.get(), observer_view->toplevel());
2173 2173
2174 Widget::ReparentNativeView(child->GetNativeView(), 2174 Widget::ReparentNativeView(child->GetNativeView(),
2175 toplevel2->GetNativeView()); 2175 toplevel2->GetNativeView());
2176 EXPECT_EQ(toplevel2, observer_view->toplevel()); 2176 EXPECT_EQ(toplevel2.get(), observer_view->toplevel());
2177 2177
2178 observer_view->parent()->RemoveChildView(observer_view); 2178 observer_view->parent()->RemoveChildView(observer_view);
2179 EXPECT_EQ(NULL, observer_view->toplevel()); 2179 EXPECT_EQ(NULL, observer_view->toplevel());
2180 2180
2181 // Make |observer_view| |child|'s contents view again so that it gets deleted 2181 // Make |observer_view| |child|'s contents view again so that it gets deleted
2182 // with the widget. 2182 // with the widget.
2183 child->SetContentsView(observer_view); 2183 child->SetContentsView(observer_view);
2184 } 2184 }
2185 2185
2186 //////////////////////////////////////////////////////////////////////////////// 2186 ////////////////////////////////////////////////////////////////////////////////
(...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after
3914 EXPECT_EQ(v1->layer(), child_layers_pre[0]); 3914 EXPECT_EQ(v1->layer(), child_layers_pre[0]);
3915 EXPECT_EQ(v2->layer(), child_layers_pre[1]); 3915 EXPECT_EQ(v2->layer(), child_layers_pre[1]);
3916 3916
3917 scoped_ptr<ui::Layer> v1_old_layer(v1->RecreateLayer()); 3917 scoped_ptr<ui::Layer> v1_old_layer(v1->RecreateLayer());
3918 3918
3919 // Test the new layer order. We expect: |v1| |v1_old_layer| |v2|. 3919 // Test the new layer order. We expect: |v1| |v1_old_layer| |v2|.
3920 // for |v1| and |v2|. 3920 // for |v1| and |v2|.
3921 const std::vector<ui::Layer*>& child_layers_post = v->layer()->children(); 3921 const std::vector<ui::Layer*>& child_layers_post = v->layer()->children();
3922 ASSERT_EQ(3u, child_layers_post.size()); 3922 ASSERT_EQ(3u, child_layers_post.size());
3923 EXPECT_EQ(v1->layer(), child_layers_post[0]); 3923 EXPECT_EQ(v1->layer(), child_layers_post[0]);
3924 EXPECT_EQ(v1_old_layer, child_layers_post[1]); 3924 EXPECT_EQ(v1_old_layer.get(), child_layers_post[1]);
3925 EXPECT_EQ(v2->layer(), child_layers_post[2]); 3925 EXPECT_EQ(v2->layer(), child_layers_post[2]);
3926 } 3926 }
3927 3927
3928 // Verify the z-order of the layers as a result of calling RecreateLayer when 3928 // Verify the z-order of the layers as a result of calling RecreateLayer when
3929 // the widget is the parent with the layer. 3929 // the widget is the parent with the layer.
3930 TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) { 3930 TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) {
3931 View* v = new View(); 3931 View* v = new View();
3932 widget()->SetContentsView(v); 3932 widget()->SetContentsView(v);
3933 3933
3934 View* v1 = new View(); 3934 View* v1 = new View();
(...skipping 10 matching lines...) Expand all
3945 ASSERT_EQ(2u, child_layers_pre.size()); 3945 ASSERT_EQ(2u, child_layers_pre.size());
3946 EXPECT_EQ(v1->layer(), child_layers_pre[0]); 3946 EXPECT_EQ(v1->layer(), child_layers_pre[0]);
3947 EXPECT_EQ(v2->layer(), child_layers_pre[1]); 3947 EXPECT_EQ(v2->layer(), child_layers_pre[1]);
3948 3948
3949 scoped_ptr<ui::Layer> v1_old_layer(v1->RecreateLayer()); 3949 scoped_ptr<ui::Layer> v1_old_layer(v1->RecreateLayer());
3950 3950
3951 // Test the new layer order. We expect: |v1| |v1_old_layer| |v2|. 3951 // Test the new layer order. We expect: |v1| |v1_old_layer| |v2|.
3952 const std::vector<ui::Layer*>& child_layers_post = root_layer->children(); 3952 const std::vector<ui::Layer*>& child_layers_post = root_layer->children();
3953 ASSERT_EQ(3u, child_layers_post.size()); 3953 ASSERT_EQ(3u, child_layers_post.size());
3954 EXPECT_EQ(v1->layer(), child_layers_post[0]); 3954 EXPECT_EQ(v1->layer(), child_layers_post[0]);
3955 EXPECT_EQ(v1_old_layer, child_layers_post[1]); 3955 EXPECT_EQ(v1_old_layer.get(), child_layers_post[1]);
3956 EXPECT_EQ(v2->layer(), child_layers_post[2]); 3956 EXPECT_EQ(v2->layer(), child_layers_post[2]);
3957 } 3957 }
3958 3958
3959 // Verifies RecreateLayer() moves all Layers over, even those that don't have 3959 // Verifies RecreateLayer() moves all Layers over, even those that don't have
3960 // a View. 3960 // a View.
3961 TEST_F(ViewLayerTest, RecreateLayerMovesNonViewChildren) { 3961 TEST_F(ViewLayerTest, RecreateLayerMovesNonViewChildren) {
3962 View v; 3962 View v;
3963 v.SetPaintToLayer(true); 3963 v.SetPaintToLayer(true);
3964 View child; 3964 View child;
3965 child.SetPaintToLayer(true); 3965 child.SetPaintToLayer(true);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
4093 // notification. 4093 // notification.
4094 TestView* test_view_child_2 = new TestView(); 4094 TestView* test_view_child_2 = new TestView();
4095 test_view->AddChildView(test_view_child_2); 4095 test_view->AddChildView(test_view_child_2);
4096 EXPECT_TRUE(test_view_child_2->native_theme_); 4096 EXPECT_TRUE(test_view_child_2->native_theme_);
4097 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); 4097 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_);
4098 4098
4099 widget->CloseNow(); 4099 widget->CloseNow();
4100 } 4100 }
4101 4101
4102 } // namespace views 4102 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698