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

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

Issue 11110004: Make gfx::Rect class operations consistently mutate the class they are called on. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: cc/ fixes Created 8 years, 2 months 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/view.cc ('k') | ui/views/widget/desktop_root_window_host_linux.cc » ('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) 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 2001 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 2012
2013 void ClearScheduledPaintRect() { 2013 void ClearScheduledPaintRect() {
2014 scheduled_paint_rect_ = gfx::Rect(); 2014 scheduled_paint_rect_ = gfx::Rect();
2015 } 2015 }
2016 2016
2017 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; } 2017 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; }
2018 2018
2019 // Overridden from View: 2019 // Overridden from View:
2020 virtual void SchedulePaintInRect(const gfx::Rect& rect) { 2020 virtual void SchedulePaintInRect(const gfx::Rect& rect) {
2021 gfx::Rect xrect = ConvertRectToParent(rect); 2021 gfx::Rect xrect = ConvertRectToParent(rect);
2022 scheduled_paint_rect_ = scheduled_paint_rect_.Union(xrect); 2022 scheduled_paint_rect_.Union(xrect);
2023 } 2023 }
2024 2024
2025 private: 2025 private:
2026 gfx::Rect scheduled_paint_rect_; 2026 gfx::Rect scheduled_paint_rect_;
2027 2027
2028 DISALLOW_COPY_AND_ASSIGN(TransformPaintView); 2028 DISALLOW_COPY_AND_ASSIGN(TransformPaintView);
2029 }; 2029 };
2030 2030
2031 TEST_F(ViewTest, TransformPaint) { 2031 TEST_F(ViewTest, TransformPaint) {
2032 TransformPaintView* v1 = new TransformPaintView(); 2032 TransformPaintView* v1 = new TransformPaintView();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2318 top_view.SetBoundsRect(gfx::Rect(0, 0, 100, 100)); 2318 top_view.SetBoundsRect(gfx::Rect(0, 0, 100, 100));
2319 top_view.scheduled_paint_rects_.clear(); 2319 top_view.scheduled_paint_rects_.clear();
2320 child_view->SetBoundsRect(gfx::Rect(10, 10, 20, 20)); 2320 child_view->SetBoundsRect(gfx::Rect(10, 10, 20, 20));
2321 top_view.AddChildView(child_view); 2321 top_view.AddChildView(child_view);
2322 2322
2323 top_view.scheduled_paint_rects_.clear(); 2323 top_view.scheduled_paint_rects_.clear();
2324 child_view->SetBoundsRect(gfx::Rect(30, 30, 20, 20)); 2324 child_view->SetBoundsRect(gfx::Rect(30, 30, 20, 20));
2325 EXPECT_EQ(2U, top_view.scheduled_paint_rects_.size()); 2325 EXPECT_EQ(2U, top_view.scheduled_paint_rects_.size());
2326 2326
2327 // There should be 2 rects, spanning from (10, 10) to (50, 50). 2327 // There should be 2 rects, spanning from (10, 10) to (50, 50).
2328 gfx::Rect paint_rect = 2328 gfx::Rect paint_rect = top_view.scheduled_paint_rects_[0];
2329 top_view.scheduled_paint_rects_[0].Union( 2329 paint_rect.Union(top_view.scheduled_paint_rects_[1]);
2330 top_view.scheduled_paint_rects_[1]);
2331 EXPECT_EQ(gfx::Rect(10, 10, 40, 40), paint_rect); 2330 EXPECT_EQ(gfx::Rect(10, 10, 40, 40), paint_rect);
2332 } 2331 }
2333 2332
2334 // Tests conversion methods with a transform. 2333 // Tests conversion methods with a transform.
2335 TEST_F(ViewTest, ConvertPointToViewWithTransform) { 2334 TEST_F(ViewTest, ConvertPointToViewWithTransform) {
2336 TestView top_view; 2335 TestView top_view;
2337 TestView* child = new TestView; 2336 TestView* child = new TestView;
2338 TestView* child_child = new TestView; 2337 TestView* child_child = new TestView;
2339 2338
2340 top_view.AddChildView(child); 2339 top_view.AddChildView(child);
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
3387 // Set to non default value. 3386 // Set to non default value.
3388 v->layer()->set_scale_content(false); 3387 v->layer()->set_scale_content(false);
3389 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer()); 3388 scoped_ptr<ui::Layer> old_layer(v->RecreateLayer());
3390 ui::Layer* new_layer = v->layer(); 3389 ui::Layer* new_layer = v->layer();
3391 EXPECT_FALSE(new_layer->scale_content()); 3390 EXPECT_FALSE(new_layer->scale_content());
3392 } 3391 }
3393 3392
3394 #endif // USE_AURA 3393 #endif // USE_AURA
3395 3394
3396 } // namespace views 3395 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.cc ('k') | ui/views/widget/desktop_root_window_host_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698