Chromium Code Reviews| 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 "chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.h" | 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 EXPECT_EQ(3u, toolbar_actions_bar()->GetIconCount()); | 217 EXPECT_EQ(3u, toolbar_actions_bar()->GetIconCount()); |
| 218 // Check the widths. IconWidth(true) includes the spacing to the left of | 218 // Check the widths. IconWidth(true) includes the spacing to the left of |
| 219 // each icon and |item_spacing| accounts for the spacing to the right | 219 // each icon and |item_spacing| accounts for the spacing to the right |
| 220 // of the rightmost icon. | 220 // of the rightmost icon. |
| 221 int expected_width = | 221 int expected_width = |
| 222 3 * ToolbarActionsBar::IconWidth(true) + platform_settings.item_spacing; | 222 3 * ToolbarActionsBar::IconWidth(true) + platform_settings.item_spacing; |
| 223 EXPECT_EQ(expected_width, toolbar_actions_bar()->GetPreferredSize().width()); | 223 EXPECT_EQ(expected_width, toolbar_actions_bar()->GetPreferredSize().width()); |
| 224 // Since all icons are showing, the current width should be the max width. | 224 // Since all icons are showing, the current width should be the max width. |
| 225 int maximum_width = expected_width; | 225 int maximum_width = expected_width; |
| 226 EXPECT_EQ(maximum_width, toolbar_actions_bar()->GetMaximumWidth()); | 226 EXPECT_EQ(maximum_width, toolbar_actions_bar()->GetMaximumWidth()); |
| 227 // The minimum width should be just enough for the chevron to be displayed | 227 // The minimum width should be just enough some padding. |
|
Evan Stade
2016/05/24 17:58:55
I'm stymied by this sentence
Devlin
2016/05/24 21:59:00
Rephrased to be more clear.
| |
| 228 // along with left and right padding. | 228 int minimum_width = platform_settings.item_spacing; |
| 229 int minimum_width = 2 * platform_settings.item_spacing + | |
| 230 toolbar_actions_bar()->delegate_for_test()-> | |
| 231 GetChevronWidth(); | |
| 232 EXPECT_EQ(minimum_width, toolbar_actions_bar()->GetMinimumWidth()); | 229 EXPECT_EQ(minimum_width, toolbar_actions_bar()->GetMinimumWidth()); |
| 233 | 230 |
| 234 // Test the connection between the ToolbarActionsBar and the model by | 231 // Test the connection between the ToolbarActionsBar and the model by |
| 235 // adjusting the visible count. | 232 // adjusting the visible count. |
| 236 toolbar_model()->SetVisibleIconCount(2u); | 233 toolbar_model()->SetVisibleIconCount(2u); |
| 237 EXPECT_EQ(2u, toolbar_actions_bar()->GetIconCount()); | 234 EXPECT_EQ(2u, toolbar_actions_bar()->GetIconCount()); |
| 238 | 235 |
| 239 // The current width should now be enough for two icons, and the chevron. | 236 // The current width should now be enough for two icons. |
| 240 // IconWidth(true) includes the spacing to the left of each icon and | 237 // IconWidth(true) includes the spacing to the left of each icon and |
| 241 // |item_spacing| accounts for the spacing to the right of the rightmost | 238 // |item_spacing| accounts for the spacing to the right of the rightmost |
| 242 // icon. | 239 // icon. |
| 243 expected_width = 2 * ToolbarActionsBar::IconWidth(true) + | 240 expected_width = 2 * ToolbarActionsBar::IconWidth(true) + |
| 244 platform_settings.item_spacing + | 241 platform_settings.item_spacing; |
| 245 toolbar_actions_bar()->delegate_for_test()-> | |
| 246 GetChevronWidth(); | |
| 247 EXPECT_EQ(expected_width, toolbar_actions_bar()->GetPreferredSize().width()); | 242 EXPECT_EQ(expected_width, toolbar_actions_bar()->GetPreferredSize().width()); |
| 248 // The maximum and minimum widths should have remained constant (since we have | 243 // The maximum and minimum widths should have remained constant (since we have |
| 249 // the same number of actions). | 244 // the same number of actions). |
| 250 EXPECT_EQ(maximum_width, toolbar_actions_bar()->GetMaximumWidth()); | 245 EXPECT_EQ(maximum_width, toolbar_actions_bar()->GetMaximumWidth()); |
| 251 EXPECT_EQ(minimum_width, toolbar_actions_bar()->GetMinimumWidth()); | 246 EXPECT_EQ(minimum_width, toolbar_actions_bar()->GetMinimumWidth()); |
| 252 | 247 |
| 253 // Test drag-and-drop logic. | 248 // Test drag-and-drop logic. |
| 254 const char kExtension0[] = "extension 0"; | 249 const char kExtension0[] = "extension 0"; |
| 255 const char kExtension1[] = "extension 1"; | 250 const char kExtension1[] = "extension 1"; |
| 256 const char kExtension2[] = "extension 2"; | 251 const char kExtension2[] = "extension 2"; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 extensions::extension_action_test_util::BROWSER_ACTION); | 590 extensions::extension_action_test_util::BROWSER_ACTION); |
| 596 toolbar_model()->SetVisibleIconCount(0u); | 591 toolbar_model()->SetVisibleIconCount(0u); |
| 597 { | 592 { |
| 598 base::RunLoop run_loop; | 593 base::RunLoop run_loop; |
| 599 toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure()); | 594 toolbar_actions_bar()->PopOutAction(action, true, run_loop.QuitClosure()); |
| 600 run_loop.Run(); | 595 run_loop.Run(); |
| 601 } | 596 } |
| 602 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount()); | 597 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount()); |
| 603 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow()); | 598 EXPECT_TRUE(toolbar_actions_bar()->NeedsOverflow()); |
| 604 } | 599 } |
| OLD | NEW |