OLD | NEW |
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 virtual ~SquareView() {} |
20 | 20 |
21 private: | 21 private: |
22 virtual gfx::Size GetPreferredSize() const OVERRIDE { | 22 virtual gfx::Size GetPreferredSize() const override { |
23 return gfx::Size(1, 1); | 23 return gfx::Size(1, 1); |
24 } | 24 } |
25 virtual int GetHeightForWidth(int width) const OVERRIDE { | 25 virtual int GetHeightForWidth(int width) const override { |
26 return width; | 26 return width; |
27 } | 27 } |
28 }; | 28 }; |
29 | 29 |
30 // A MenuItemView implementation with a public destructor (so we can clean up | 30 // A MenuItemView implementation with a public destructor (so we can clean up |
31 // in tests). | 31 // in tests). |
32 class TestMenuItemView : public views::MenuItemView { | 32 class TestMenuItemView : public views::MenuItemView { |
33 public: | 33 public: |
34 TestMenuItemView() : views::MenuItemView(NULL) {} | 34 TestMenuItemView() : views::MenuItemView(NULL) {} |
35 virtual ~TestMenuItemView() {} | 35 virtual ~TestMenuItemView() {} |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 // ...but it should use whatever space is available to make a square. | 68 // ...but it should use whatever space is available to make a square. |
69 int flex_height = flexible_view->GetHeightForWidth(label_size.width()); | 69 int flex_height = flexible_view->GetHeightForWidth(label_size.width()); |
70 EXPECT_EQ(label_size.width(), flex_height); | 70 EXPECT_EQ(label_size.width(), flex_height); |
71 | 71 |
72 // The submenu should be tall enough to allow for both menu items at the given | 72 // The submenu should be tall enough to allow for both menu items at the given |
73 // width. | 73 // width. |
74 EXPECT_EQ(label_size.height() + flex_height, | 74 EXPECT_EQ(label_size.height() + flex_height, |
75 submenu->GetPreferredSize().height()); | 75 submenu->GetPreferredSize().height()); |
76 } | 76 } |
OLD | NEW |