X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fui%2Fviews%2Fview_unittest.cc;h=bb77ebfe2cf2250faa52cb350f041ec1cde6f442;hb=ff3e2503a20db9193d323c1d19c38c68004dec4a;hp=607438d4acdf4bbf8018e75dfb310ea9d3a8a0f0;hpb=7338fba38ba696536d1cc9d389afd716a6ab2fe6;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/ui/views/view_unittest.cc b/src/ui/views/view_unittest.cc index 607438d..bb77ebf 100644 --- a/src/ui/views/view_unittest.cc +++ b/src/ui/views/view_unittest.cc @@ -25,7 +25,6 @@ #include "ui/views/controls/native/native_view_host.h" #include "ui/views/controls/scroll_view.h" #include "ui/views/controls/textfield/textfield.h" -#include "ui/views/focus/accelerator_handler.h" #include "ui/views/focus/view_storage.h" #include "ui/views/test/views_test_base.h" #include "ui/views/view.h" @@ -2295,6 +2294,39 @@ TEST_F(ViewTest, SetBoundsSameBoundsDoesntSchedulePaint) { EXPECT_TRUE(view.scheduled_paint_rects_.empty()); } +// Verifies AddChildView() and RemoveChildView() schedule appropriate paints. +TEST_F(ViewTest, AddAndRemoveSchedulePaints) { + gfx::Rect viewport_bounds(0, 0, 100, 100); + + // We have to put the View hierarchy into a Widget or no paints will be + // scheduled. + scoped_ptr widget(new Widget); + Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); + params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; + params.bounds = viewport_bounds; + widget->Init(params); + widget->GetRootView()->SetBoundsRect(viewport_bounds); + + TestView* parent_view = new TestView; + widget->SetContentsView(parent_view); + parent_view->SetBoundsRect(viewport_bounds); + parent_view->scheduled_paint_rects_.clear(); + + View* child_view = new View; + child_view->SetBoundsRect(gfx::Rect(0, 0, 20, 20)); + parent_view->AddChildView(child_view); + ASSERT_EQ(1U, parent_view->scheduled_paint_rects_.size()); + EXPECT_EQ(child_view->bounds(), parent_view->scheduled_paint_rects_.front()); + + parent_view->scheduled_paint_rects_.clear(); + parent_view->RemoveChildView(child_view); + scoped_ptr child_deleter(child_view); + ASSERT_EQ(1U, parent_view->scheduled_paint_rects_.size()); + EXPECT_EQ(child_view->bounds(), parent_view->scheduled_paint_rects_.front()); + + widget->CloseNow(); +} + // Tests conversion methods with a transform. TEST_F(ViewTest, ConversionsWithTransform) { TestView top_view;