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

Side by Side Diff: views/view_unittest.cc

Issue 7845033: Rework View Layer Draw() to use the Layer::DrawTree() method and the LayerDelegate. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « views/view.cc ('k') | views/widget/native_widget_aura.h » ('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/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "testing/gmock/include/gmock/gmock.h" 10 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 last_clip_.setEmpty(); 60 last_clip_.setEmpty();
61 accelerator_count_map_.clear(); 61 accelerator_count_map_.clear();
62 } 62 }
63 63
64 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE; 64 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
65 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE; 65 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE;
66 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE; 66 virtual bool OnMouseDragged(const MouseEvent& event) OVERRIDE;
67 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE; 67 virtual void OnMouseReleased(const MouseEvent& event) OVERRIDE;
68 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE; 68 virtual ui::TouchStatus OnTouchEvent(const TouchEvent& event) OVERRIDE;
69 virtual void Paint(gfx::Canvas* canvas) OVERRIDE; 69 virtual void Paint(gfx::Canvas* canvas) OVERRIDE;
70 virtual void SchedulePaintInternal(const gfx::Rect& rect) OVERRIDE; 70 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
71 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE; 71 virtual bool AcceleratorPressed(const Accelerator& accelerator) OVERRIDE;
72 72
73 // OnBoundsChanged. 73 // OnBoundsChanged.
74 bool did_change_bounds_; 74 bool did_change_bounds_;
75 gfx::Rect new_bounds_; 75 gfx::Rect new_bounds_;
76 76
77 // MouseEvent. 77 // MouseEvent.
78 int last_mouse_event_type_; 78 int last_mouse_event_type_;
79 gfx::Point location_; 79 gfx::Point location_;
80 80
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 391 }
392 392
393 //////////////////////////////////////////////////////////////////////////////// 393 ////////////////////////////////////////////////////////////////////////////////
394 // Painting 394 // Painting
395 //////////////////////////////////////////////////////////////////////////////// 395 ////////////////////////////////////////////////////////////////////////////////
396 396
397 void TestView::Paint(gfx::Canvas* canvas) { 397 void TestView::Paint(gfx::Canvas* canvas) {
398 canvas->AsCanvasSkia()->getClipBounds(&last_clip_); 398 canvas->AsCanvasSkia()->getClipBounds(&last_clip_);
399 } 399 }
400 400
401 void TestView::SchedulePaintInternal(const gfx::Rect& rect) { 401 void TestView::SchedulePaintInRect(const gfx::Rect& rect) {
402 scheduled_paint_rects_.push_back(rect); 402 scheduled_paint_rects_.push_back(rect);
403 View::SchedulePaintInternal(rect); 403 View::SchedulePaintInRect(rect);
404 } 404 }
405 405
406 void CheckRect(const SkRect& check_rect, const SkRect& target_rect) { 406 void CheckRect(const SkRect& check_rect, const SkRect& target_rect) {
407 EXPECT_EQ(target_rect.fLeft, check_rect.fLeft); 407 EXPECT_EQ(target_rect.fLeft, check_rect.fLeft);
408 EXPECT_EQ(target_rect.fRight, check_rect.fRight); 408 EXPECT_EQ(target_rect.fRight, check_rect.fRight);
409 EXPECT_EQ(target_rect.fTop, check_rect.fTop); 409 EXPECT_EQ(target_rect.fTop, check_rect.fTop);
410 EXPECT_EQ(target_rect.fBottom, check_rect.fBottom); 410 EXPECT_EQ(target_rect.fBottom, check_rect.fBottom);
411 } 411 }
412 412
413 /* This test is disabled because it is flakey on some systems. 413 /* This test is disabled because it is flakey on some systems.
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 TransformPaintView() {} 1473 TransformPaintView() {}
1474 virtual ~TransformPaintView() {} 1474 virtual ~TransformPaintView() {}
1475 1475
1476 void ClearScheduledPaintRect() { 1476 void ClearScheduledPaintRect() {
1477 scheduled_paint_rect_ = gfx::Rect(); 1477 scheduled_paint_rect_ = gfx::Rect();
1478 } 1478 }
1479 1479
1480 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; } 1480 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; }
1481 1481
1482 // Overridden from View: 1482 // Overridden from View:
1483 virtual void SchedulePaintInternal(const gfx::Rect& rect) { 1483 virtual void SchedulePaintInRect(const gfx::Rect& rect) {
1484 gfx::Rect xrect = ConvertRectToParent(rect); 1484 gfx::Rect xrect = ConvertRectToParent(rect);
1485 scheduled_paint_rect_ = scheduled_paint_rect_.Union(xrect); 1485 scheduled_paint_rect_ = scheduled_paint_rect_.Union(xrect);
1486 } 1486 }
1487 1487
1488 private: 1488 private:
1489 gfx::Rect scheduled_paint_rect_; 1489 gfx::Rect scheduled_paint_rect_;
1490 1490
1491 DISALLOW_COPY_AND_ASSIGN(TransformPaintView); 1491 DISALLOW_COPY_AND_ASSIGN(TransformPaintView);
1492 }; 1492 };
1493 1493
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2338 void TestTexture::SetCanvas(const SkCanvas& canvas, 2338 void TestTexture::SetCanvas(const SkCanvas& canvas,
2339 const gfx::Point& origin, 2339 const gfx::Point& origin,
2340 const gfx::Size& overall_size) { 2340 const gfx::Size& overall_size) {
2341 const SkBitmap& bitmap = canvas.getDevice()->accessBitmap(false); 2341 const SkBitmap& bitmap = canvas.getDevice()->accessBitmap(false);
2342 bounds_of_last_paint_.SetRect( 2342 bounds_of_last_paint_.SetRect(
2343 origin.x(), origin.y(), bitmap.width(), bitmap.height()); 2343 origin.x(), origin.y(), bitmap.width(), bitmap.height());
2344 } 2344 }
2345 2345
2346 class TestCompositor : public ui::Compositor { 2346 class TestCompositor : public ui::Compositor {
2347 public: 2347 public:
2348 TestCompositor() : Compositor(gfx::Size(100, 100)) {} 2348 TestCompositor() : Compositor(NULL, gfx::Size(100, 100)) {}
2349 2349
2350 // ui::Compositor: 2350 // ui::Compositor:
2351 virtual ui::Texture* CreateTexture() OVERRIDE { 2351 virtual ui::Texture* CreateTexture() OVERRIDE {
2352 return new TestTexture(); 2352 return new TestTexture();
2353 } 2353 }
2354 virtual void NotifyStart() OVERRIDE {} 2354 virtual void OnNotifyStart() OVERRIDE {}
2355 virtual void NotifyEnd() OVERRIDE {} 2355 virtual void OnNotifyEnd() OVERRIDE {}
2356 virtual void Blur(const gfx::Rect& bounds) OVERRIDE {} 2356 virtual void Blur(const gfx::Rect& bounds) OVERRIDE {}
2357 virtual void SchedulePaint() OVERRIDE {}
2358 2357
2359 protected: 2358 protected:
2360 virtual void OnWidgetSizeChanged() OVERRIDE {} 2359 virtual void OnWidgetSizeChanged() OVERRIDE {}
2361 2360
2362 private: 2361 private:
2363 DISALLOW_COPY_AND_ASSIGN(TestCompositor); 2362 DISALLOW_COPY_AND_ASSIGN(TestCompositor);
2364 }; 2363 };
2365 2364
2366 static ui::Compositor* TestCreateCompositor() { 2365 static ui::Compositor* TestCreateCompositor() {
2367 return new TestCompositor(); 2366 return new TestCompositor();
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2799 EXPECT_EQ(gfx::Rect(11, 22, 100, 200), widget_view_host->layer()->bounds()); 2798 EXPECT_EQ(gfx::Rect(11, 22, 100, 200), widget_view_host->layer()->bounds());
2800 ASSERT_TRUE(child_view->layer() != NULL); 2799 ASSERT_TRUE(child_view->layer() != NULL);
2801 EXPECT_EQ(gfx::Rect(5, 6, 10, 11), child_view->layer()->bounds()); 2800 EXPECT_EQ(gfx::Rect(5, 6, 10, 11), child_view->layer()->bounds());
2802 2801
2803 child_widget->CloseNow(); 2802 child_widget->CloseNow();
2804 } 2803 }
2805 2804
2806 #endif // VIEWS_COMPOSITOR 2805 #endif // VIEWS_COMPOSITOR
2807 2806
2808 } // namespace views 2807 } // namespace views
OLDNEW
« no previous file with comments | « views/view.cc ('k') | views/widget/native_widget_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698