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

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

Issue 623293004: replace OVERRIDE and FINAL with override and final in ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 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_targeter_unittest.cc ('k') | ui/views/views_touch_selection_controller_factory.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) 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual 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 virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) override;
227 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 227 virtual bool OnMousePressed(const ui::MouseEvent& event) override;
228 virtual bool OnMouseDragged(const ui::MouseEvent& event) OVERRIDE; 228 virtual bool OnMouseDragged(const ui::MouseEvent& event) override;
229 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; 229 virtual void OnMouseReleased(const ui::MouseEvent& event) override;
230 virtual void OnMouseEntered(const ui::MouseEvent& event) OVERRIDE; 230 virtual void OnMouseEntered(const ui::MouseEvent& event) override;
231 virtual void OnMouseExited(const ui::MouseEvent& event) OVERRIDE; 231 virtual void OnMouseExited(const ui::MouseEvent& event) override;
232 232
233 virtual void Paint(gfx::Canvas* canvas, const CullSet& cull_set) OVERRIDE; 233 virtual void Paint(gfx::Canvas* canvas, const CullSet& cull_set) override;
234 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE; 234 virtual void SchedulePaintInRect(const gfx::Rect& rect) override;
235 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; 235 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
236 236
237 virtual void OnNativeThemeChanged(const ui::NativeTheme* native_theme) 237 virtual void OnNativeThemeChanged(const ui::NativeTheme* native_theme)
238 OVERRIDE; 238 override;
239 239
240 // OnBoundsChanged. 240 // OnBoundsChanged.
241 bool did_change_bounds_; 241 bool did_change_bounds_;
242 gfx::Rect new_bounds_; 242 gfx::Rect new_bounds_;
243 243
244 // MouseEvent. 244 // MouseEvent.
245 int last_mouse_event_type_; 245 int last_mouse_event_type_;
246 gfx::Point location_; 246 gfx::Point location_;
247 bool received_mouse_enter_; 247 bool received_mouse_enter_;
248 bool received_mouse_exit_; 248 bool received_mouse_exit_;
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 //////////////////////////////////////////////////////////////////////////////// 1488 ////////////////////////////////////////////////////////////////////////////////
1489 class ToplevelWidgetObserverView : public View { 1489 class ToplevelWidgetObserverView : public View {
1490 public: 1490 public:
1491 ToplevelWidgetObserverView() : toplevel_(NULL) { 1491 ToplevelWidgetObserverView() : toplevel_(NULL) {
1492 } 1492 }
1493 virtual ~ToplevelWidgetObserverView() { 1493 virtual ~ToplevelWidgetObserverView() {
1494 } 1494 }
1495 1495
1496 // View overrides: 1496 // View overrides:
1497 virtual void ViewHierarchyChanged( 1497 virtual void ViewHierarchyChanged(
1498 const ViewHierarchyChangedDetails& details) OVERRIDE { 1498 const ViewHierarchyChangedDetails& details) override {
1499 if (details.is_add) { 1499 if (details.is_add) {
1500 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; 1500 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
1501 } else { 1501 } else {
1502 toplevel_ = NULL; 1502 toplevel_ = NULL;
1503 } 1503 }
1504 } 1504 }
1505 virtual void NativeViewHierarchyChanged() OVERRIDE { 1505 virtual void NativeViewHierarchyChanged() override {
1506 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL; 1506 toplevel_ = GetWidget() ? GetWidget()->GetTopLevelWidget() : NULL;
1507 } 1507 }
1508 1508
1509 Widget* toplevel() { return toplevel_; } 1509 Widget* toplevel() { return toplevel_; }
1510 1510
1511 private: 1511 private:
1512 Widget* toplevel_; 1512 Widget* toplevel_;
1513 1513
1514 DISALLOW_COPY_AND_ASSIGN(ToplevelWidgetObserverView); 1514 DISALLOW_COPY_AND_ASSIGN(ToplevelWidgetObserverView);
1515 }; 1515 };
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1562 TransformPaintView() {} 1562 TransformPaintView() {}
1563 virtual ~TransformPaintView() {} 1563 virtual ~TransformPaintView() {}
1564 1564
1565 void ClearScheduledPaintRect() { 1565 void ClearScheduledPaintRect() {
1566 scheduled_paint_rect_ = gfx::Rect(); 1566 scheduled_paint_rect_ = gfx::Rect();
1567 } 1567 }
1568 1568
1569 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; } 1569 gfx::Rect scheduled_paint_rect() const { return scheduled_paint_rect_; }
1570 1570
1571 // Overridden from View: 1571 // Overridden from View:
1572 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE { 1572 virtual void SchedulePaintInRect(const gfx::Rect& rect) override {
1573 gfx::Rect xrect = ConvertRectToParent(rect); 1573 gfx::Rect xrect = ConvertRectToParent(rect);
1574 scheduled_paint_rect_.Union(xrect); 1574 scheduled_paint_rect_.Union(xrect);
1575 } 1575 }
1576 1576
1577 private: 1577 private:
1578 gfx::Rect scheduled_paint_rect_; 1578 gfx::Rect scheduled_paint_rect_;
1579 1579
1580 DISALLOW_COPY_AND_ASSIGN(TransformPaintView); 1580 DISALLOW_COPY_AND_ASSIGN(TransformPaintView);
1581 }; 1581 };
1582 1582
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 VisibleBoundsView() : received_notification_(false) {} 1801 VisibleBoundsView() : received_notification_(false) {}
1802 virtual ~VisibleBoundsView() {} 1802 virtual ~VisibleBoundsView() {}
1803 1803
1804 bool received_notification() const { return received_notification_; } 1804 bool received_notification() const { return received_notification_; }
1805 void set_received_notification(bool received) { 1805 void set_received_notification(bool received) {
1806 received_notification_ = received; 1806 received_notification_ = received;
1807 } 1807 }
1808 1808
1809 private: 1809 private:
1810 // Overridden from View: 1810 // Overridden from View:
1811 virtual bool GetNeedsNotificationWhenVisibleBoundsChange() const OVERRIDE { 1811 virtual bool GetNeedsNotificationWhenVisibleBoundsChange() const override {
1812 return true; 1812 return true;
1813 } 1813 }
1814 virtual void OnVisibleBoundsChanged() OVERRIDE { 1814 virtual void OnVisibleBoundsChanged() override {
1815 received_notification_ = true; 1815 received_notification_ = true;
1816 } 1816 }
1817 1817
1818 bool received_notification_; 1818 bool received_notification_;
1819 1819
1820 DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView); 1820 DISALLOW_COPY_AND_ASSIGN(VisibleBoundsView);
1821 }; 1821 };
1822 1822
1823 TEST_F(ViewTest, OnVisibleBoundsChanged) { 1823 TEST_F(ViewTest, OnVisibleBoundsChanged) {
1824 gfx::Rect viewport_bounds(0, 0, 100, 100); 1824 gfx::Rect viewport_bounds(0, 0, 100, 100);
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
2226 return add_details_; 2226 return add_details_;
2227 } 2227 }
2228 2228
2229 const ViewHierarchyChangedDetails& remove_details() const { 2229 const ViewHierarchyChangedDetails& remove_details() const {
2230 return remove_details_; 2230 return remove_details_;
2231 } 2231 }
2232 2232
2233 private: 2233 private:
2234 // View: 2234 // View:
2235 virtual void ViewHierarchyChanged( 2235 virtual void ViewHierarchyChanged(
2236 const ViewHierarchyChangedDetails& details) OVERRIDE; 2236 const ViewHierarchyChangedDetails& details) override;
2237 2237
2238 bool has_add_details_; 2238 bool has_add_details_;
2239 bool has_remove_details_; 2239 bool has_remove_details_;
2240 ViewHierarchyChangedDetails add_details_; 2240 ViewHierarchyChangedDetails add_details_;
2241 ViewHierarchyChangedDetails remove_details_; 2241 ViewHierarchyChangedDetails remove_details_;
2242 2242
2243 DISALLOW_COPY_AND_ASSIGN(ObserverView); 2243 DISALLOW_COPY_AND_ASSIGN(ObserverView);
2244 }; 2244 };
2245 2245
2246 ObserverView::ObserverView() 2246 ObserverView::ObserverView()
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
2645 // FocusManager 2645 // FocusManager
2646 //////////////////////////////////////////////////////////////////////////////// 2646 ////////////////////////////////////////////////////////////////////////////////
2647 2647
2648 // A widget that always claims to be active, regardless of its real activation 2648 // A widget that always claims to be active, regardless of its real activation
2649 // status. 2649 // status.
2650 class ActiveWidget : public Widget { 2650 class ActiveWidget : public Widget {
2651 public: 2651 public:
2652 ActiveWidget() {} 2652 ActiveWidget() {}
2653 virtual ~ActiveWidget() {} 2653 virtual ~ActiveWidget() {}
2654 2654
2655 virtual bool IsActive() const OVERRIDE { 2655 virtual bool IsActive() const override {
2656 return true; 2656 return true;
2657 } 2657 }
2658 2658
2659 private: 2659 private:
2660 DISALLOW_COPY_AND_ASSIGN(ActiveWidget); 2660 DISALLOW_COPY_AND_ASSIGN(ActiveWidget);
2661 }; 2661 };
2662 2662
2663 TEST_F(ViewTest, AdvanceFocusIfNecessaryForUnfocusableView) { 2663 TEST_F(ViewTest, AdvanceFocusIfNecessaryForUnfocusableView) {
2664 // Create a widget with two views and give the first one focus. 2664 // Create a widget with two views and give the first one focus.
2665 ActiveWidget widget; 2665 ActiveWidget widget;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2711 namespace { 2711 namespace {
2712 2712
2713 // Test implementation of LayerAnimator. 2713 // Test implementation of LayerAnimator.
2714 class TestLayerAnimator : public ui::LayerAnimator { 2714 class TestLayerAnimator : public ui::LayerAnimator {
2715 public: 2715 public:
2716 TestLayerAnimator(); 2716 TestLayerAnimator();
2717 2717
2718 const gfx::Rect& last_bounds() const { return last_bounds_; } 2718 const gfx::Rect& last_bounds() const { return last_bounds_; }
2719 2719
2720 // LayerAnimator. 2720 // LayerAnimator.
2721 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 2721 virtual void SetBounds(const gfx::Rect& bounds) override;
2722 2722
2723 protected: 2723 protected:
2724 virtual ~TestLayerAnimator() { } 2724 virtual ~TestLayerAnimator() { }
2725 2725
2726 private: 2726 private:
2727 gfx::Rect last_bounds_; 2727 gfx::Rect last_bounds_;
2728 2728
2729 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator); 2729 DISALLOW_COPY_AND_ASSIGN(TestLayerAnimator);
2730 }; 2730 };
2731 2731
(...skipping 12 matching lines...) Expand all
2744 ViewLayerTest() : widget_(NULL) {} 2744 ViewLayerTest() : widget_(NULL) {}
2745 2745
2746 virtual ~ViewLayerTest() { 2746 virtual ~ViewLayerTest() {
2747 } 2747 }
2748 2748
2749 // Returns the Layer used by the RootView. 2749 // Returns the Layer used by the RootView.
2750 ui::Layer* GetRootLayer() { 2750 ui::Layer* GetRootLayer() {
2751 return widget()->GetLayer(); 2751 return widget()->GetLayer();
2752 } 2752 }
2753 2753
2754 virtual void SetUp() OVERRIDE { 2754 virtual void SetUp() override {
2755 ViewTest::SetUp(); 2755 ViewTest::SetUp();
2756 widget_ = new Widget; 2756 widget_ = new Widget;
2757 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 2757 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
2758 params.bounds = gfx::Rect(50, 50, 200, 200); 2758 params.bounds = gfx::Rect(50, 50, 200, 200);
2759 widget_->Init(params); 2759 widget_->Init(params);
2760 widget_->Show(); 2760 widget_->Show();
2761 widget_->GetRootView()->SetBounds(0, 0, 200, 200); 2761 widget_->GetRootView()->SetBounds(0, 0, 200, 200);
2762 } 2762 }
2763 2763
2764 virtual void TearDown() OVERRIDE { 2764 virtual void TearDown() override {
2765 widget_->CloseNow(); 2765 widget_->CloseNow();
2766 ViewsTestBase::TearDown(); 2766 ViewsTestBase::TearDown();
2767 } 2767 }
2768 2768
2769 Widget* widget() { return widget_; } 2769 Widget* widget() { return widget_; }
2770 2770
2771 private: 2771 private:
2772 Widget* widget_; 2772 Widget* widget_;
2773 }; 2773 };
2774 2774
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
3063 } 3063 }
3064 3064
3065 class PaintTrackingView : public View { 3065 class PaintTrackingView : public View {
3066 public: 3066 public:
3067 PaintTrackingView() : painted_(false) { 3067 PaintTrackingView() : painted_(false) {
3068 } 3068 }
3069 3069
3070 bool painted() const { return painted_; } 3070 bool painted() const { return painted_; }
3071 void set_painted(bool value) { painted_ = value; } 3071 void set_painted(bool value) { painted_ = value; }
3072 3072
3073 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 3073 virtual void OnPaint(gfx::Canvas* canvas) override {
3074 painted_ = true; 3074 painted_ = true;
3075 } 3075 }
3076 3076
3077 private: 3077 private:
3078 bool painted_; 3078 bool painted_;
3079 3079
3080 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView); 3080 DISALLOW_COPY_AND_ASSIGN(PaintTrackingView);
3081 }; 3081 };
3082 3082
3083 // Makes sure child views with layers aren't painted when paint starts at an 3083 // Makes sure child views with layers aren't painted when paint starts at an
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
3305 ASSERT_EQ(2u, v.layer()->children().size()); 3305 ASSERT_EQ(2u, v.layer()->children().size());
3306 EXPECT_EQ(v.layer()->children()[0], &layer); 3306 EXPECT_EQ(v.layer()->children()[0], &layer);
3307 EXPECT_EQ(v.layer()->children()[1], child.layer()); 3307 EXPECT_EQ(v.layer()->children()[1], child.layer());
3308 } 3308 }
3309 3309
3310 class BoundsTreeTestView : public View { 3310 class BoundsTreeTestView : public View {
3311 public: 3311 public:
3312 BoundsTreeTestView() {} 3312 BoundsTreeTestView() {}
3313 3313
3314 virtual void PaintChildren(gfx::Canvas* canvas, 3314 virtual void PaintChildren(gfx::Canvas* canvas,
3315 const CullSet& cull_set) OVERRIDE { 3315 const CullSet& cull_set) override {
3316 // Save out a copy of the cull_set before calling the base implementation. 3316 // Save out a copy of the cull_set before calling the base implementation.
3317 last_cull_set_.clear(); 3317 last_cull_set_.clear();
3318 if (cull_set.cull_set_) { 3318 if (cull_set.cull_set_) {
3319 for (base::hash_set<intptr_t>::iterator it = cull_set.cull_set_->begin(); 3319 for (base::hash_set<intptr_t>::iterator it = cull_set.cull_set_->begin();
3320 it != cull_set.cull_set_->end(); 3320 it != cull_set.cull_set_->end();
3321 ++it) { 3321 ++it) {
3322 last_cull_set_.insert(reinterpret_cast<View*>(*it)); 3322 last_cull_set_.insert(reinterpret_cast<View*>(*it));
3323 } 3323 }
3324 } 3324 }
3325 View::PaintChildren(canvas, cull_set); 3325 View::PaintChildren(canvas, cull_set);
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 // notification. 3718 // notification.
3719 TestView* test_view_child_2 = new TestView(); 3719 TestView* test_view_child_2 = new TestView();
3720 test_view->AddChildView(test_view_child_2); 3720 test_view->AddChildView(test_view_child_2);
3721 EXPECT_TRUE(test_view_child_2->native_theme_); 3721 EXPECT_TRUE(test_view_child_2->native_theme_);
3722 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_); 3722 EXPECT_EQ(widget->GetNativeTheme(), test_view_child_2->native_theme_);
3723 3723
3724 widget->CloseNow(); 3724 widget->CloseNow();
3725 } 3725 }
3726 3726
3727 } // namespace views 3727 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view_targeter_unittest.cc ('k') | ui/views/views_touch_selection_controller_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698