| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ash/system/date/system_info_default_view.h" | |
| 6 #include "ash/system/tray/tray_constants.h" | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 #include "ui/views/view.h" | |
| 9 | |
| 10 namespace ash { | |
| 11 | |
| 12 class SystemInfoDefaultViewTest : public testing::Test { | |
| 13 public: | |
| 14 SystemInfoDefaultViewTest() {} | |
| 15 | |
| 16 protected: | |
| 17 // Wrapper calls for SystemInfoDefaultView internals. | |
| 18 int CalculateDateViewWidth(int preferred_width) { | |
| 19 return SystemInfoDefaultView::CalculateDateViewWidth(preferred_width); | |
| 20 } | |
| 21 | |
| 22 private: | |
| 23 DISALLOW_COPY_AND_ASSIGN(SystemInfoDefaultViewTest); | |
| 24 }; | |
| 25 | |
| 26 TEST_F(SystemInfoDefaultViewTest, PreferredWidthSmallerThanButtonWidth) { | |
| 27 const int kPreferredWidth = 10; | |
| 28 EXPECT_LT(kPreferredWidth, kMenuButtonSize); | |
| 29 const int effective_width = CalculateDateViewWidth(kPreferredWidth); | |
| 30 | |
| 31 EXPECT_EQ(effective_width, | |
| 32 kMenuButtonSize + kSeparatorWidth + kMenuButtonSize); | |
| 33 } | |
| 34 | |
| 35 TEST_F(SystemInfoDefaultViewTest, PreferredWidthGreaterThanOneButtonWidth) { | |
| 36 const int kPreferredWidth = kMenuButtonSize + 1; | |
| 37 const int effective_width = CalculateDateViewWidth(kPreferredWidth); | |
| 38 | |
| 39 EXPECT_EQ(effective_width, | |
| 40 kMenuButtonSize + kSeparatorWidth + kMenuButtonSize); | |
| 41 } | |
| 42 | |
| 43 TEST_F(SystemInfoDefaultViewTest, PreferredWidthEqualToTwoButtonWidths) { | |
| 44 const int kPreferredWidth = | |
| 45 kMenuButtonSize + kSeparatorWidth + kMenuButtonSize; | |
| 46 const int effective_width = CalculateDateViewWidth(kPreferredWidth); | |
| 47 | |
| 48 EXPECT_EQ(effective_width, kPreferredWidth); | |
| 49 } | |
| 50 | |
| 51 TEST_F(SystemInfoDefaultViewTest, PreferredWidthGreaterThanTwoButtonWidths) { | |
| 52 const int kPreferredWidth = | |
| 53 kMenuButtonSize + (kSeparatorWidth + kMenuButtonSize) + 1; | |
| 54 const int effective_width = CalculateDateViewWidth(kPreferredWidth); | |
| 55 | |
| 56 EXPECT_EQ(effective_width, | |
| 57 kMenuButtonSize + (kSeparatorWidth + kMenuButtonSize) * 2); | |
| 58 } | |
| 59 | |
| 60 TEST_F(SystemInfoDefaultViewTest, PreferredWidthEqualToThreeButtonWidths) { | |
| 61 const int kPreferredWidth = | |
| 62 kMenuButtonSize + (kSeparatorWidth + kMenuButtonSize) * 2; | |
| 63 const int effective_width = CalculateDateViewWidth(kPreferredWidth); | |
| 64 | |
| 65 EXPECT_EQ(effective_width, kPreferredWidth); | |
| 66 } | |
| 67 | |
| 68 TEST_F(SystemInfoDefaultViewTest, PreferredWidthGreaterThanThreeButtonWidths) { | |
| 69 const int kPreferredWidth = | |
| 70 kMenuButtonSize + (kSeparatorWidth + kMenuButtonSize) * 2 + 1; | |
| 71 const int effective_width = CalculateDateViewWidth(kPreferredWidth); | |
| 72 | |
| 73 EXPECT_EQ(effective_width, | |
| 74 kMenuButtonSize + (kSeparatorWidth + kMenuButtonSize) * 2); | |
| 75 } | |
| 76 | |
| 77 } // namespace ash | |
| OLD | NEW |