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

Side by Side Diff: ui/views/controls/menu/menu_item_view_unittest.cc

Issue 683563002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/views/controls/menu/menu_item_view.h" 5 #include "ui/views/controls/menu/menu_item_view.h"
6 6
7 #include "base/strings/string16.h" 7 #include "base/strings/string16.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/views/controls/menu/submenu_view.h" 10 #include "ui/views/controls/menu/submenu_view.h"
11 #include "ui/views/view.h" 11 #include "ui/views/view.h"
12 12
13 namespace { 13 namespace {
14 14
15 // A simple View class that will match its height to the available width. 15 // A simple View class that will match its height to the available width.
16 class SquareView : public views::View { 16 class SquareView : public views::View {
17 public: 17 public:
18 SquareView() {} 18 SquareView() {}
19 virtual ~SquareView() {} 19 ~SquareView() override {}
20 20
21 private: 21 private:
22 virtual gfx::Size GetPreferredSize() const override { 22 gfx::Size GetPreferredSize() const override { return gfx::Size(1, 1); }
23 return gfx::Size(1, 1); 23 int GetHeightForWidth(int width) const override { return width; }
24 }
25 virtual int GetHeightForWidth(int width) const override {
26 return width;
27 }
28 }; 24 };
29 25
30 // A MenuItemView implementation with a public destructor (so we can clean up 26 // A MenuItemView implementation with a public destructor (so we can clean up
31 // in tests). 27 // in tests).
32 class TestMenuItemView : public views::MenuItemView { 28 class TestMenuItemView : public views::MenuItemView {
33 public: 29 public:
34 TestMenuItemView() : views::MenuItemView(NULL) {} 30 TestMenuItemView() : views::MenuItemView(NULL) {}
35 virtual ~TestMenuItemView() {} 31 ~TestMenuItemView() override {}
36 }; 32 };
37 33
38 } // namespace 34 } // namespace
39 35
40 TEST(MenuItemViewUnitTest, TestMenuItemViewWithFlexibleWidthChild) { 36 TEST(MenuItemViewUnitTest, TestMenuItemViewWithFlexibleWidthChild) {
41 TestMenuItemView root_menu; 37 TestMenuItemView root_menu;
42 root_menu.set_owned_by_client(); 38 root_menu.set_owned_by_client();
43 39
44 // Append a normal MenuItemView. 40 // Append a normal MenuItemView.
45 views::MenuItemView* label_view = 41 views::MenuItemView* label_view =
(...skipping 21 matching lines...) Expand all
67 63
68 // ...but it should use whatever space is available to make a square. 64 // ...but it should use whatever space is available to make a square.
69 int flex_height = flexible_view->GetHeightForWidth(label_size.width()); 65 int flex_height = flexible_view->GetHeightForWidth(label_size.width());
70 EXPECT_EQ(label_size.width(), flex_height); 66 EXPECT_EQ(label_size.width(), flex_height);
71 67
72 // The submenu should be tall enough to allow for both menu items at the given 68 // The submenu should be tall enough to allow for both menu items at the given
73 // width. 69 // width.
74 EXPECT_EQ(label_size.height() + flex_height, 70 EXPECT_EQ(label_size.height() + flex_height,
75 submenu->GetPreferredSize().height()); 71 submenu->GetPreferredSize().height());
76 } 72 }
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_item_view.cc ('k') | ui/views/controls/menu/menu_message_loop_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698