| OLD | NEW |
| 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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 } | 425 } |
| 426 | 426 |
| 427 //////////////////////////////////////////////////////////////////////////////// | 427 //////////////////////////////////////////////////////////////////////////////// |
| 428 // Painting | 428 // Painting |
| 429 //////////////////////////////////////////////////////////////////////////////// | 429 //////////////////////////////////////////////////////////////////////////////// |
| 430 | 430 |
| 431 void TestView::OnPaint(gfx::Canvas* canvas) { | 431 void TestView::OnPaint(gfx::Canvas* canvas) { |
| 432 did_paint_ = true; | 432 did_paint_ = true; |
| 433 } | 433 } |
| 434 | 434 |
| 435 TEST_F(ViewTest, PaintEmptyView) { |
| 436 Widget* widget = new Widget; |
| 437 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 438 widget->Init(params); |
| 439 View* root_view = widget->GetRootView(); |
| 440 root_view->SetBounds(0, 0, 25, 26); |
| 441 |
| 442 // |v1| is empty. |
| 443 TestView* v1 = new TestView; |
| 444 v1->SetBounds(10, 11, 0, 1); |
| 445 root_view->AddChildView(v1); |
| 446 |
| 447 // |v11| is a child of an empty |v1|. |
| 448 TestView* v11 = new TestView; |
| 449 v11->SetBounds(3, 4, 6, 5); |
| 450 v1->AddChildView(v11); |
| 451 |
| 452 // |v2| is not. |
| 453 TestView* v2 = new TestView; |
| 454 v2->SetBounds(3, 4, 6, 5); |
| 455 root_view->AddChildView(v2); |
| 456 |
| 457 // Paint "everything". |
| 458 gfx::Rect first_paint(1, 1); |
| 459 scoped_refptr<cc::DisplayItemList> list = |
| 460 cc::DisplayItemList::Create(first_paint, cc::DisplayItemListSettings()); |
| 461 root_view->Paint(ui::PaintContext(list.get(), 1.f, first_paint, first_paint)); |
| 462 |
| 463 // The empty view has nothing to paint so it doesn't try build a cache, nor do |
| 464 // its children which would be clipped by its (empty) self. |
| 465 EXPECT_FALSE(v1->did_paint_); |
| 466 EXPECT_FALSE(v11->did_paint_); |
| 467 EXPECT_TRUE(v2->did_paint_); |
| 468 } |
| 469 |
| 435 TEST_F(ViewTest, PaintWithUnknownInvalidation) { | 470 TEST_F(ViewTest, PaintWithUnknownInvalidation) { |
| 436 Widget* widget = new Widget; | 471 Widget* widget = new Widget; |
| 437 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 472 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 438 widget->Init(params); | 473 widget->Init(params); |
| 439 View* root_view = widget->GetRootView(); | 474 View* root_view = widget->GetRootView(); |
| 440 root_view->SetBounds(0, 0, 25, 26); | 475 root_view->SetBounds(0, 0, 25, 26); |
| 441 | 476 |
| 442 TestView* v1 = new TestView; | 477 TestView* v1 = new TestView; |
| 443 v1->SetBounds(10, 11, 12, 13); | 478 v1->SetBounds(10, 11, 12, 13); |
| 444 root_view->AddChildView(v1); | 479 root_view->AddChildView(v1); |
| (...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4020 // notification. | 4055 // notification. |
| 4021 TestView* test_view_child_2 = new TestView(); | 4056 TestView* test_view_child_2 = new TestView(); |
| 4022 test_view->AddChildView(test_view_child_2); | 4057 test_view->AddChildView(test_view_child_2); |
| 4023 EXPECT_TRUE(test_view_child_2->native_theme_); | 4058 EXPECT_TRUE(test_view_child_2->native_theme_); |
| 4024 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); | 4059 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); |
| 4025 | 4060 |
| 4026 widget->CloseNow(); | 4061 widget->CloseNow(); |
| 4027 } | 4062 } |
| 4028 | 4063 |
| 4029 } // namespace views | 4064 } // namespace views |
| OLD | NEW |