| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 typedef ViewsTestBase ViewTest; | 183 typedef ViewsTestBase ViewTest; |
| 184 | 184 |
| 185 // A derived class for testing purpose. | 185 // A derived class for testing purpose. |
| 186 class TestView : public View { | 186 class TestView : public View { |
| 187 public: | 187 public: |
| 188 TestView() | 188 TestView() |
| 189 : View(), | 189 : View(), |
| 190 delete_on_pressed_(false), | 190 delete_on_pressed_(false), |
| 191 native_theme_(NULL), | 191 native_theme_(NULL), |
| 192 can_process_events_within_subtree_(true) {} | 192 can_process_events_within_subtree_(true) {} |
| 193 virtual ~TestView() {} | 193 ~TestView() override {} |
| 194 | 194 |
| 195 // Reset all test state | 195 // Reset all test state |
| 196 void Reset() { | 196 void Reset() { |
| 197 did_change_bounds_ = false; | 197 did_change_bounds_ = false; |
| 198 last_mouse_event_type_ = 0; | 198 last_mouse_event_type_ = 0; |
| 199 location_.SetPoint(0, 0); | 199 location_.SetPoint(0, 0); |
| 200 received_mouse_enter_ = false; | 200 received_mouse_enter_ = false; |
| 201 received_mouse_exit_ = false; | 201 received_mouse_exit_ = false; |
| 202 last_clip_.setEmpty(); | 202 last_clip_.setEmpty(); |
| 203 accelerator_count_map_.clear(); | 203 accelerator_count_map_.clear(); |
| 204 can_process_events_within_subtree_ = true; | 204 can_process_events_within_subtree_ = true; |
| 205 } | 205 } |
| 206 | 206 |
| 207 // Exposed as public for testing. | 207 // Exposed as public for testing. |
| 208 void DoFocus() { | 208 void DoFocus() { |
| 209 views::View::Focus(); | 209 views::View::Focus(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void DoBlur() { | 212 void DoBlur() { |
| 213 views::View::Blur(); | 213 views::View::Blur(); |
| 214 } | 214 } |
| 215 | 215 |
| 216 bool focusable() const { return View::focusable(); } | 216 bool focusable() const { return View::focusable(); } |
| 217 | 217 |
| 218 void set_can_process_events_within_subtree(bool can_process) { | 218 void set_can_process_events_within_subtree(bool can_process) { |
| 219 can_process_events_within_subtree_ = can_process; | 219 can_process_events_within_subtree_ = can_process; |
| 220 } | 220 } |
| 221 | 221 |
| 222 virtual bool CanProcessEventsWithinSubtree() const override { | 222 bool CanProcessEventsWithinSubtree() const override { |
| 223 return can_process_events_within_subtree_; | 223 return can_process_events_within_subtree_; |
| 224 } | 224 } |
| 225 | 225 |
| 226 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override; | 226 void OnBoundsChanged(const gfx::Rect& previous_bounds) override; |
| 227 virtual bool OnMousePressed(const ui::MouseEvent& event) override; | 227 bool OnMousePressed(const ui::MouseEvent& event) override; |
| 228 virtual bool OnMouseDragged(const ui::MouseEvent& event) override; | 228 bool OnMouseDragged(const ui::MouseEvent& event) override; |
| 229 virtual void OnMouseReleased(const ui::MouseEvent& event) override; | 229 void OnMouseReleased(const ui::MouseEvent& event) override; |
| 230 virtual void OnMouseEntered(const ui::MouseEvent& event) override; | 230 void OnMouseEntered(const ui::MouseEvent& event) override; |
| 231 virtual void OnMouseExited(const ui::MouseEvent& event) override; | 231 void OnMouseExited(const ui::MouseEvent& event) override; |
| 232 | 232 |
| 233 virtual void Paint(gfx::Canvas* canvas, const CullSet& cull_set) override; | 233 void Paint(gfx::Canvas* canvas, const CullSet& cull_set) override; |
| 234 virtual void SchedulePaintInRect(const gfx::Rect& rect) override; | 234 void SchedulePaintInRect(const gfx::Rect& rect) override; |
| 235 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 235 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 236 | 236 |
| 237 virtual void OnNativeThemeChanged(const ui::NativeTheme* native_theme) | 237 void OnNativeThemeChanged(const ui::NativeTheme* native_theme) override; |
| 238 override; | |
| 239 | 238 |
| 240 // OnBoundsChanged. | 239 // OnBoundsChanged. |
| 241 bool did_change_bounds_; | 240 bool did_change_bounds_; |
| 242 gfx::Rect new_bounds_; | 241 gfx::Rect new_bounds_; |
| 243 | 242 |
| 244 // MouseEvent. | 243 // MouseEvent. |
| 245 int last_mouse_event_type_; | 244 int last_mouse_event_type_; |
| 246 gfx::Point location_; | 245 gfx::Point location_; |
| 247 bool received_mouse_enter_; | 246 bool received_mouse_enter_; |
| 248 bool received_mouse_exit_; | 247 bool received_mouse_exit_; |
| (...skipping 1234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 } | 1482 } |
| 1484 #endif // 0 | 1483 #endif // 0 |
| 1485 | 1484 |
| 1486 //////////////////////////////////////////////////////////////////////////////// | 1485 //////////////////////////////////////////////////////////////////////////////// |
| 1487 // Native view hierachy | 1486 // Native view hierachy |
| 1488 //////////////////////////////////////////////////////////////////////////////// | 1487 //////////////////////////////////////////////////////////////////////////////// |
| 1489 class ToplevelWidgetObserverView : public View { | 1488 class ToplevelWidgetObserverView : public View { |
| 1490 public: | 1489 public: |
| 1491 ToplevelWidgetObserverView() : toplevel_(NULL) { | 1490 ToplevelWidgetObserverView() : toplevel_(NULL) { |
| 1492 } | 1491 } |
| 1493 virtual ~ToplevelWidgetObserverView() { | 1492 ~ToplevelWidgetObserverView() override {} |
| 1494 } | |
| 1495 | 1493 |
| 1496 // View overrides: | 1494 // View overrides: |
| 1497 virtual void ViewHierarchyChanged( | 1495 void ViewHierarchyChanged( |
| 1498 const ViewHierarchyChangedDetails& details) override { | 1496 const ViewHierarchyChangedDetails& details) override { |
| 1499 if (details.is_add) { | 1497 if (details.is_add) { |
| 1500 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; | 1498 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; |
| 1501 } else { | 1499 } else { |
| 1502 toplevel_ = NULL; | 1500 toplevel_ = NULL; |
| 1503 } | 1501 } |
| 1504 } | 1502 } |
| 1505 virtual void NativeViewHierarchyChanged() override { | 1503 void NativeViewHierarchyChanged() override { |
| 1506 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; | 1504 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; |
| 1507 } | 1505 } |
| 1508 | 1506 |
| 1509 Widget* toplevel() { return toplevel_; } | 1507 Widget* toplevel() { return toplevel_; } |
| 1510 | 1508 |
| 1511 private: | 1509 private: |
| 1512 Widget* toplevel_; | 1510 Widget* toplevel_; |
| 1513 | 1511 |
| 1514 DISALLOW_COPY_AND_ASSIGN(ToplevelWidgetObserverView); | 1512 DISALLOW_COPY_AND_ASSIGN(ToplevelWidgetObserverView); |
| 1515 }; | 1513 }; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 child->SetContentsView(observer_view); | 1551 child->SetContentsView(observer_view); |
| 1554 } | 1552 } |
| 1555 | 1553 |
| 1556 //////////////////////////////////////////////////////////////////////////////// | 1554 //////////////////////////////////////////////////////////////////////////////// |
| 1557 // Transformations | 1555 // Transformations |
| 1558 //////////////////////////////////////////////////////////////////////////////// | 1556 //////////////////////////////////////////////////////////////////////////////// |
| 1559 | 1557 |
| 1560 class TransformPaintView : public TestView { | 1558 class TransformPaintView : public TestView { |
| 1561 public: | 1559 public: |
| 1562 TransformPaintView() {} | 1560 TransformPaintView() {} |
| 1563 virtual ~TransformPaintView() {} | 1561 ~TransformPaintView() override {} |
| 1564 | 1562 |
| 1565 void ClearScheduledPaintRect() { | 1563 void ClearScheduledPaintRect() { |
| 1566 scheduled_paint_rect_ = gfx::Rect(); | 1564 scheduled_paint_rect_ = gfx::Rect(); |
| 1567 } | 1565 } |
| 1568 | 1566 |
| 1569 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; } | 1567 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; } |
| 1570 | 1568 |
| 1571 // Overridden from View: | 1569 // Overridden from View: |
| 1572 virtual void SchedulePaintInRect(const gfx::Rect& rect) override { | 1570 void SchedulePaintInRect(const gfx::Rect& rect) override { |
| 1573 gfx::Rect xrect = ConvertRectToParent(rect); | 1571 gfx::Rect xrect = ConvertRectToParent(rect); |
| 1574 scheduled_paint_rect_.Union(xrect); | 1572 scheduled_paint_rect_.Union(xrect); |
| 1575 } | 1573 } |
| 1576 | 1574 |
| 1577 private: | 1575 private: |
| 1578 gfx::Rect scheduled_paint_rect_; | 1576 gfx::Rect scheduled_paint_rect_; |
| 1579 | 1577 |
| 1580 DISALLOW_COPY_AND_ASSIGN(TransformPaintView); | 1578 DISALLOW_COPY_AND_ASSIGN(TransformPaintView); |
| 1581 }; | 1579 }; |
| 1582 | 1580 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1792 | 1790 |
| 1793 widget->CloseNow(); | 1791 widget->CloseNow(); |
| 1794 } | 1792 } |
| 1795 | 1793 |
| 1796 //////////////////////////////////////////////////////////////////////////////// | 1794 //////////////////////////////////////////////////////////////////////////////// |
| 1797 // OnVisibleBoundsChanged() | 1795 // OnVisibleBoundsChanged() |
| 1798 | 1796 |
| 1799 class VisibleBoundsView : public View { | 1797 class VisibleBoundsView : public View { |
| 1800 public: | 1798 public: |
| 1801 VisibleBoundsView() : received_notification_(false) {} | 1799 VisibleBoundsView() : received_notification_(false) {} |
| 1802 virtual ~VisibleBoundsView() {} | 1800 ~VisibleBoundsView() override {} |
| 1803 | 1801 |
| 1804 bool received_notification() const { return received_notification_; } | 1802 bool received_notification() const { return received_notification_; } |
| 1805 void set_received_notification(bool received) { | 1803 void set_received_notification(bool received) { |
| 1806 received_notification_ = received; | 1804 received_notification_ = received; |
| 1807 } | 1805 } |
| 1808 | 1806 |
| 1809 private: | 1807 private: |
| 1810 // Overridden from View: | 1808 // Overridden from View: |
| 1811 virtual bool GetNeedsNotificationWhenVisibleBoundsChange() const override { | 1809 bool GetNeedsNotificationWhenVisibleBoundsChange() const override { |
| 1812 return true; | 1810 return true; |
| 1813 } | 1811 } |
| 1814 virtual void OnVisibleBoundsChanged() override { | 1812 void OnVisibleBoundsChanged() override { received_notification_ = true; } |
| 1815 received_notification_ = true; | |
| 1816 } | |
| 1817 | 1813 |
| 1818 bool received_notification_; | 1814 bool received_notification_; |
| 1819 | 1815 |
| 1820 DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView); | 1816 DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView); |
| 1821 }; | 1817 }; |
| 1822 | 1818 |
| 1823 TEST_F(ViewTest, OnVisibleBoundsChanged) { | 1819 TEST_F(ViewTest, OnVisibleBoundsChanged) { |
| 1824 gfx::Rect viewport_bounds(0, 0, 100, 100); | 1820 gfx::Rect viewport_bounds(0, 0, 100, 100); |
| 1825 | 1821 |
| 1826 scoped_ptr<Widget> widget(new Widget); | 1822 scoped_ptr<Widget> widget(new Widget); |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 // |v2| now occupies (20, 20) to (120, 70) in |widget| | 2204 // |v2| now occupies (20, 20) to (120, 70) in |widget| |
| 2209 EXPECT_EQ(gfx::Rect(22, 60, 21, 8).ToString(), | 2205 EXPECT_EQ(gfx::Rect(22, 60, 21, 8).ToString(), |
| 2210 v2->ConvertRectToWidget(rect).ToString()); | 2206 v2->ConvertRectToWidget(rect).ToString()); |
| 2211 | 2207 |
| 2212 widget->CloseNow(); | 2208 widget->CloseNow(); |
| 2213 } | 2209 } |
| 2214 | 2210 |
| 2215 class ObserverView : public View { | 2211 class ObserverView : public View { |
| 2216 public: | 2212 public: |
| 2217 ObserverView(); | 2213 ObserverView(); |
| 2218 virtual ~ObserverView(); | 2214 ~ObserverView() override; |
| 2219 | 2215 |
| 2220 void ResetTestState(); | 2216 void ResetTestState(); |
| 2221 | 2217 |
| 2222 bool has_add_details() const { return has_add_details_; } | 2218 bool has_add_details() const { return has_add_details_; } |
| 2223 bool has_remove_details() const { return has_remove_details_; } | 2219 bool has_remove_details() const { return has_remove_details_; } |
| 2224 | 2220 |
| 2225 const ViewHierarchyChangedDetails& add_details() const { | 2221 const ViewHierarchyChangedDetails& add_details() const { |
| 2226 return add_details_; | 2222 return add_details_; |
| 2227 } | 2223 } |
| 2228 | 2224 |
| 2229 const ViewHierarchyChangedDetails& remove_details() const { | 2225 const ViewHierarchyChangedDetails& remove_details() const { |
| 2230 return remove_details_; | 2226 return remove_details_; |
| 2231 } | 2227 } |
| 2232 | 2228 |
| 2233 private: | 2229 private: |
| 2234 // View: | 2230 // View: |
| 2235 virtual void ViewHierarchyChanged( | 2231 void ViewHierarchyChanged( |
| 2236 const ViewHierarchyChangedDetails& details) override; | 2232 const ViewHierarchyChangedDetails& details) override; |
| 2237 | 2233 |
| 2238 bool has_add_details_; | 2234 bool has_add_details_; |
| 2239 bool has_remove_details_; | 2235 bool has_remove_details_; |
| 2240 ViewHierarchyChangedDetails add_details_; | 2236 ViewHierarchyChangedDetails add_details_; |
| 2241 ViewHierarchyChangedDetails remove_details_; | 2237 ViewHierarchyChangedDetails remove_details_; |
| 2242 | 2238 |
| 2243 DISALLOW_COPY_AND_ASSIGN(ObserverView); | 2239 DISALLOW_COPY_AND_ASSIGN(ObserverView); |
| 2244 }; | 2240 }; |
| 2245 | 2241 |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2643 | 2639 |
| 2644 //////////////////////////////////////////////////////////////////////////////// | 2640 //////////////////////////////////////////////////////////////////////////////// |
| 2645 // FocusManager | 2641 // FocusManager |
| 2646 //////////////////////////////////////////////////////////////////////////////// | 2642 //////////////////////////////////////////////////////////////////////////////// |
| 2647 | 2643 |
| 2648 // A widget that always claims to be active, regardless of its real activation | 2644 // A widget that always claims to be active, regardless of its real activation |
| 2649 // status. | 2645 // status. |
| 2650 class ActiveWidget : public Widget { | 2646 class ActiveWidget : public Widget { |
| 2651 public: | 2647 public: |
| 2652 ActiveWidget() {} | 2648 ActiveWidget() {} |
| 2653 virtual ~ActiveWidget() {} | 2649 ~ActiveWidget() override {} |
| 2654 | 2650 |
| 2655 virtual bool IsActive() const override { | 2651 bool IsActive() const override { return true; } |
| 2656 return true; | |
| 2657 } | |
| 2658 | 2652 |
| 2659 private: | 2653 private: |
| 2660 DISALLOW_COPY_AND_ASSIGN(ActiveWidget); | 2654 DISALLOW_COPY_AND_ASSIGN(ActiveWidget); |
| 2661 }; | 2655 }; |
| 2662 | 2656 |
| 2663 TEST_F(ViewTest, AdvanceFocusIfNecessaryForUnfocusableView) { | 2657 TEST_F(ViewTest, AdvanceFocusIfNecessaryForUnfocusableView) { |
| 2664 // Create a widget with two views and give the first one focus. | 2658 // Create a widget with two views and give the first one focus. |
| 2665 ActiveWidget widget; | 2659 ActiveWidget widget; |
| 2666 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 2660 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 2667 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 2661 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2711 namespace { | 2705 namespace { |
| 2712 | 2706 |
| 2713 // Test implementation of LayerAnimator. | 2707 // Test implementation of LayerAnimator. |
| 2714 class TestLayerAnimator : public ui::LayerAnimator { | 2708 class TestLayerAnimator : public ui::LayerAnimator { |
| 2715 public: | 2709 public: |
| 2716 TestLayerAnimator(); | 2710 TestLayerAnimator(); |
| 2717 | 2711 |
| 2718 const gfx::Rect& last_bounds() const { return last_bounds_; } | 2712 const gfx::Rect& last_bounds() const { return last_bounds_; } |
| 2719 | 2713 |
| 2720 // LayerAnimator. | 2714 // LayerAnimator. |
| 2721 virtual void SetBounds(const gfx::Rect& bounds) override; | 2715 void SetBounds(const gfx::Rect& bounds) override; |
| 2722 | 2716 |
| 2723 protected: | 2717 protected: |
| 2724 virtual ~TestLayerAnimator() { } | 2718 ~TestLayerAnimator() override {} |
| 2725 | 2719 |
| 2726 private: | 2720 private: |
| 2727 gfx::Rect last_bounds_; | 2721 gfx::Rect last_bounds_; |
| 2728 | 2722 |
| 2729 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator); | 2723 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator); |
| 2730 }; | 2724 }; |
| 2731 | 2725 |
| 2732 TestLayerAnimator::TestLayerAnimator() | 2726 TestLayerAnimator::TestLayerAnimator() |
| 2733 : ui::LayerAnimator(base::TimeDelta::FromMilliseconds(0)) { | 2727 : ui::LayerAnimator(base::TimeDelta::FromMilliseconds(0)) { |
| 2734 } | 2728 } |
| 2735 | 2729 |
| 2736 void TestLayerAnimator::SetBounds(const gfx::Rect& bounds) { | 2730 void TestLayerAnimator::SetBounds(const gfx::Rect& bounds) { |
| 2737 last_bounds_ = bounds; | 2731 last_bounds_ = bounds; |
| 2738 } | 2732 } |
| 2739 | 2733 |
| 2740 } // namespace | 2734 } // namespace |
| 2741 | 2735 |
| 2742 class ViewLayerTest : public ViewsTestBase { | 2736 class ViewLayerTest : public ViewsTestBase { |
| 2743 public: | 2737 public: |
| 2744 ViewLayerTest() : widget_(NULL) {} | 2738 ViewLayerTest() : widget_(NULL) {} |
| 2745 | 2739 |
| 2746 virtual ~ViewLayerTest() { | 2740 ~ViewLayerTest() override {} |
| 2747 } | |
| 2748 | 2741 |
| 2749 // Returns the Layer used by the RootView. | 2742 // Returns the Layer used by the RootView. |
| 2750 ui::Layer* GetRootLayer() { | 2743 ui::Layer* GetRootLayer() { |
| 2751 return widget()->GetLayer(); | 2744 return widget()->GetLayer(); |
| 2752 } | 2745 } |
| 2753 | 2746 |
| 2754 virtual void SetUp() override { | 2747 void SetUp() override { |
| 2755 ViewTest::SetUp(); | 2748 ViewTest::SetUp(); |
| 2756 widget_ = new Widget; | 2749 widget_ = new Widget; |
| 2757 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); | 2750 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 2758 params.bounds = gfx::Rect(50, 50, 200, 200); | 2751 params.bounds = gfx::Rect(50, 50, 200, 200); |
| 2759 widget_->Init(params); | 2752 widget_->Init(params); |
| 2760 widget_->Show(); | 2753 widget_->Show(); |
| 2761 widget_->GetRootView()->SetBounds(0, 0, 200, 200); | 2754 widget_->GetRootView()->SetBounds(0, 0, 200, 200); |
| 2762 } | 2755 } |
| 2763 | 2756 |
| 2764 virtual void TearDown() override { | 2757 void TearDown() override { |
| 2765 widget_->CloseNow(); | 2758 widget_->CloseNow(); |
| 2766 ViewsTestBase::TearDown(); | 2759 ViewsTestBase::TearDown(); |
| 2767 } | 2760 } |
| 2768 | 2761 |
| 2769 Widget* widget() { return widget_; } | 2762 Widget* widget() { return widget_; } |
| 2770 | 2763 |
| 2771 private: | 2764 private: |
| 2772 Widget* widget_; | 2765 Widget* widget_; |
| 2773 }; | 2766 }; |
| 2774 | 2767 |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3063 } | 3056 } |
| 3064 | 3057 |
| 3065 class PaintTrackingView : public View { | 3058 class PaintTrackingView : public View { |
| 3066 public: | 3059 public: |
| 3067 PaintTrackingView() : painted_(false) { | 3060 PaintTrackingView() : painted_(false) { |
| 3068 } | 3061 } |
| 3069 | 3062 |
| 3070 bool painted() const { return painted_; } | 3063 bool painted() const { return painted_; } |
| 3071 void set_painted(bool value) { painted_ = value; } | 3064 void set_painted(bool value) { painted_ = value; } |
| 3072 | 3065 |
| 3073 virtual void OnPaint(gfx::Canvas* canvas) override { | 3066 void OnPaint(gfx::Canvas* canvas) override { painted_ = true; } |
| 3074 painted_ = true; | |
| 3075 } | |
| 3076 | 3067 |
| 3077 private: | 3068 private: |
| 3078 bool painted_; | 3069 bool painted_; |
| 3079 | 3070 |
| 3080 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); | 3071 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); |
| 3081 }; | 3072 }; |
| 3082 | 3073 |
| 3083 // Makes sure child views with layers aren't painted when paint starts at an | 3074 // Makes sure child views with layers aren't painted when paint starts at an |
| 3084 // ancestor. | 3075 // ancestor. |
| 3085 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { | 3076 TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) { |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3301 ASSERT_TRUE(v.layer() != NULL); | 3292 ASSERT_TRUE(v.layer() != NULL); |
| 3302 ASSERT_EQ(2u, v.layer()->children().size()); | 3293 ASSERT_EQ(2u, v.layer()->children().size()); |
| 3303 EXPECT_EQ(v.layer()->children()[0], &layer); | 3294 EXPECT_EQ(v.layer()->children()[0], &layer); |
| 3304 EXPECT_EQ(v.layer()->children()[1], child.layer()); | 3295 EXPECT_EQ(v.layer()->children()[1], child.layer()); |
| 3305 } | 3296 } |
| 3306 | 3297 |
| 3307 class BoundsTreeTestView : public View { | 3298 class BoundsTreeTestView : public View { |
| 3308 public: | 3299 public: |
| 3309 BoundsTreeTestView() {} | 3300 BoundsTreeTestView() {} |
| 3310 | 3301 |
| 3311 virtual void PaintChildren(gfx::Canvas* canvas, | 3302 void PaintChildren(gfx::Canvas* canvas, const CullSet& cull_set) override { |
| 3312 const CullSet& cull_set) override { | |
| 3313 // Save out a copy of the cull_set before calling the base implementation. | 3303 // Save out a copy of the cull_set before calling the base implementation. |
| 3314 last_cull_set_.clear(); | 3304 last_cull_set_.clear(); |
| 3315 if (cull_set.cull_set_) { | 3305 if (cull_set.cull_set_) { |
| 3316 for (base::hash_set<intptr_t>::iterator it = cull_set.cull_set_->begin(); | 3306 for (base::hash_set<intptr_t>::iterator it = cull_set.cull_set_->begin(); |
| 3317 it != cull_set.cull_set_->end(); | 3307 it != cull_set.cull_set_->end(); |
| 3318 ++it) { | 3308 ++it) { |
| 3319 last_cull_set_.insert(reinterpret_cast<View*>(*it)); | 3309 last_cull_set_.insert(reinterpret_cast<View*>(*it)); |
| 3320 } | 3310 } |
| 3321 } | 3311 } |
| 3322 View::PaintChildren(canvas, cull_set); | 3312 View::PaintChildren(canvas, cull_set); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3698 // notification. | 3688 // notification. |
| 3699 TestView* test_view_child_2 = new TestView(); | 3689 TestView* test_view_child_2 = new TestView(); |
| 3700 test_view->AddChildView(test_view_child_2); | 3690 test_view->AddChildView(test_view_child_2); |
| 3701 EXPECT_TRUE(test_view_child_2->native_theme_); | 3691 EXPECT_TRUE(test_view_child_2->native_theme_); |
| 3702 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); | 3692 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); |
| 3703 | 3693 |
| 3704 widget->CloseNow(); | 3694 widget->CloseNow(); |
| 3705 } | 3695 } |
| 3706 | 3696 |
| 3707 } // namespace views | 3697 } // namespace views |
| OLD | NEW |