Index: ash/shelf/shelf_widget_unittest.cc |
diff --git a/ash/shelf/shelf_widget_unittest.cc b/ash/shelf/shelf_widget_unittest.cc |
index 354cb262aa0986c139044cdd703b4c1cbaa630d8..7a8d7fb3caa25e6b9fac6c1f5bcfad1657a5350d 100644 |
--- a/ash/shelf/shelf_widget_unittest.cc |
+++ b/ash/shelf/shelf_widget_unittest.cc |
@@ -4,13 +4,14 @@ |
#include "ash/shelf/shelf_widget.h" |
+#include "ash/common/material_design/material_design_controller.h" |
#include "ash/root_window_controller.h" |
#include "ash/shelf/shelf.h" |
#include "ash/shelf/shelf_delegate.h" |
#include "ash/shelf/shelf_layout_manager.h" |
#include "ash/shelf/shelf_view.h" |
#include "ash/shell.h" |
-#include "ash/test/ash_test_base.h" |
+#include "ash/test/ash_md_test_base.h" |
#include "ash/test/ash_test_helper.h" |
#include "ash/test/shelf_test_api.h" |
#include "ash/test/shelf_view_test_api.h" |
@@ -37,7 +38,16 @@ ShelfLayoutManager* GetShelfLayoutManager() { |
} // namespace |
-typedef test::AshTestBase ShelfWidgetTest; |
+using ShelfWidgetTest = test::AshMDTestBase; |
+ |
+// Note: First argument is optional and intentionally left blank. |
+// (it's a prefix for the generated test cases) |
+INSTANTIATE_TEST_CASE_P( |
+ , |
+ ShelfWidgetTest, |
+ testing::Values(MaterialDesignController::NON_MATERIAL, |
+ MaterialDesignController::MATERIAL_NORMAL, |
+ MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
void TestLauncherAlignment(aura::Window* root, |
ShelfAlignment alignment, |
@@ -48,33 +58,35 @@ void TestLauncherAlignment(aura::Window* root, |
screen->GetDisplayNearestWindow(root).work_area().ToString()); |
} |
-#if defined(OS_WIN) && !defined(USE_ASH) |
// TODO(msw): Broken on Windows. http://crbug.com/584038 |
-#define MAYBE_TestAlignment DISABLED_TestAlignment |
-#else |
-#define MAYBE_TestAlignment TestAlignment |
-#endif |
-TEST_F(ShelfWidgetTest, MAYBE_TestAlignment) { |
+#if defined(OS_CHROMEOS) |
+TEST_P(ShelfWidgetTest, TestAlignment) { |
+ // Note that for a left- and right-aligned shelf, this offset must be |
+ // applied to a maximized window's width rather than its height. |
+ const int offset = GetMdMaximizedWindowHeightOffset(); |
+ const int kShelfSize = GetShelfConstant(SHELF_SIZE); |
UpdateDisplay("400x400"); |
{ |
SCOPED_TRACE("Single Bottom"); |
TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_BOTTOM, |
- "0,0 400x353"); |
+ gfx::Rect(0, 0, 400, 353 + offset).ToString()); |
} |
{ |
SCOPED_TRACE("Single Locked"); |
TestLauncherAlignment(Shell::GetPrimaryRootWindow(), |
- SHELF_ALIGNMENT_BOTTOM_LOCKED, "0,0 400x353"); |
+ SHELF_ALIGNMENT_BOTTOM_LOCKED, |
+ gfx::Rect(0, 0, 400, 353 + offset).ToString()); |
} |
{ |
SCOPED_TRACE("Single Right"); |
TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_RIGHT, |
- "0,0 353x400"); |
+ gfx::Rect(0, 0, 353 + offset, 400).ToString()); |
} |
{ |
SCOPED_TRACE("Single Left"); |
- TestLauncherAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT, |
- "47,0 353x400"); |
+ TestLauncherAlignment( |
+ Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_LEFT, |
+ gfx::Rect(kShelfSize, 0, 353 + offset, 400).ToString()); |
} |
if (!SupportsMultipleDisplays()) |
return; |
@@ -84,47 +96,50 @@ TEST_F(ShelfWidgetTest, MAYBE_TestAlignment) { |
{ |
SCOPED_TRACE("Primary Bottom"); |
TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM, |
- "0,0 300x253"); |
+ gfx::Rect(0, 0, 300, 253 + offset).ToString()); |
} |
{ |
SCOPED_TRACE("Primary Locked"); |
TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_BOTTOM_LOCKED, |
- "0,0 300x253"); |
+ gfx::Rect(0, 0, 300, 253 + offset).ToString()); |
} |
{ |
SCOPED_TRACE("Primary Right"); |
TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_RIGHT, |
- "0,0 253x300"); |
+ gfx::Rect(0, 0, 253 + offset, 300).ToString()); |
} |
{ |
SCOPED_TRACE("Primary Left"); |
- TestLauncherAlignment(root_windows[0], SHELF_ALIGNMENT_LEFT, |
- "47,0 253x300"); |
+ TestLauncherAlignment( |
+ root_windows[0], SHELF_ALIGNMENT_LEFT, |
+ gfx::Rect(kShelfSize, 0, 253 + offset, 300).ToString()); |
} |
{ |
SCOPED_TRACE("Secondary Bottom"); |
TestLauncherAlignment(root_windows[1], SHELF_ALIGNMENT_BOTTOM, |
- "300,0 500x453"); |
+ gfx::Rect(300, 0, 500, 453 + offset).ToString()); |
} |
{ |
SCOPED_TRACE("Secondary Locked"); |
TestLauncherAlignment(root_windows[1], SHELF_ALIGNMENT_BOTTOM_LOCKED, |
- "300,0 500x453"); |
+ gfx::Rect(300, 0, 500, 453 + offset).ToString()); |
} |
{ |
SCOPED_TRACE("Secondary Right"); |
TestLauncherAlignment(root_windows[1], SHELF_ALIGNMENT_RIGHT, |
- "300,0 453x500"); |
+ gfx::Rect(300, 0, 453 + offset, 500).ToString()); |
} |
{ |
SCOPED_TRACE("Secondary Left"); |
- TestLauncherAlignment(root_windows[1], SHELF_ALIGNMENT_LEFT, |
- "347,0 453x500"); |
+ TestLauncherAlignment( |
+ root_windows[1], SHELF_ALIGNMENT_LEFT, |
+ gfx::Rect(300 + kShelfSize, 0, 453 + offset, 500).ToString()); |
} |
} |
+#endif // defined(OS_CHROMEOS) |
// Makes sure the shelf is initially sized correctly. |
-TEST_F(ShelfWidgetTest, LauncherInitiallySized) { |
+TEST_P(ShelfWidgetTest, LauncherInitiallySized) { |
ShelfWidget* shelf_widget = GetShelfWidget(); |
Shelf* shelf = shelf_widget->shelf(); |
ASSERT_TRUE(shelf); |
@@ -140,7 +155,7 @@ TEST_F(ShelfWidgetTest, LauncherInitiallySized) { |
} |
// Verifies when the shell is deleted with a full screen window we don't crash. |
-TEST_F(ShelfWidgetTest, DontReferenceShelfAfterDeletion) { |
+TEST_P(ShelfWidgetTest, DontReferenceShelfAfterDeletion) { |
views::Widget* widget = new views::Widget; |
views::Widget::InitParams params(views::Widget::InitParams::TYPE_WINDOW); |
params.bounds = gfx::Rect(0, 0, 200, 200); |
@@ -154,7 +169,7 @@ TEST_F(ShelfWidgetTest, DontReferenceShelfAfterDeletion) { |
// Verifies shelf is created with correct size after user login and when its |
// container and status widget has finished sizing. |
// See http://crbug.com/252533 |
-TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
+TEST_P(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
SetUserLoggedIn(false); |
UpdateDisplay("300x200,400x300"); |
@@ -188,9 +203,10 @@ TEST_F(ShelfWidgetTest, ShelfInitiallySizedAfterLogin) { |
// Tests that the shelf lets mouse-events close to the edge fall through to the |
// window underneath. |
-TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { |
+TEST_P(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { |
tdanderson
2016/06/21 19:52:21
ditto to the comments I made in WindowStateTest.Re
|
ShelfWidget* shelf_widget = GetShelfWidget(); |
gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); |
+ |
EXPECT_TRUE(!shelf_bounds.IsEmpty()); |
ShelfLayoutManager* shelf_layout_manager = |
shelf_widget->shelf_layout_manager(); |
@@ -271,7 +287,7 @@ TEST_F(ShelfWidgetTest, ShelfEdgeOverlappingWindowHitTestMouse) { |
// Tests that the shelf has a slightly larger hit-region for touch-events when |
// it's in the auto-hidden state. |
-TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) { |
+TEST_P(ShelfWidgetTest, HiddenShelfHitTestTouch) { |
Shelf* shelf = Shelf::ForPrimaryDisplay(); |
ShelfWidget* shelf_widget = GetShelfWidget(); |
gfx::Rect shelf_bounds = shelf_widget->GetWindowBoundsInScreen(); |
@@ -433,28 +449,37 @@ class ShelfWidgetTestWithDelegate : public ShelfWidgetTest { |
} // namespace |
-TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysShelf) { |
+// Note: First argument is optional and intentionally left blank. |
+// (it's a prefix for the generated test cases) |
+INSTANTIATE_TEST_CASE_P( |
+ , |
+ ShelfWidgetTestWithDelegate, |
+ testing::Values(MaterialDesignController::NON_MATERIAL, |
+ MaterialDesignController::MATERIAL_NORMAL, |
+ MaterialDesignController::MATERIAL_EXPERIMENTAL)); |
+ |
+TEST_P(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysShelf) { |
// The actual auto hide state is shown because there are no open windows. |
TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM, |
SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, |
SHELF_AUTO_HIDE, SHELF_AUTO_HIDE_SHOWN); |
} |
-TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideNeverShelf) { |
+TEST_P(ShelfWidgetTestWithDelegate, CreateAutoHideNeverShelf) { |
// The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_LEFT, |
SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |
SHELF_VISIBLE, SHELF_AUTO_HIDE_HIDDEN); |
} |
-TEST_F(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysHideShelf) { |
+TEST_P(ShelfWidgetTestWithDelegate, CreateAutoHideAlwaysHideShelf) { |
// The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_RIGHT, |
SHELF_AUTO_HIDE_ALWAYS_HIDDEN, SHELF_HIDDEN, |
SHELF_AUTO_HIDE_HIDDEN); |
} |
-TEST_F(ShelfWidgetTestWithDelegate, CreateLockedShelf) { |
+TEST_P(ShelfWidgetTestWithDelegate, CreateLockedShelf) { |
// The auto hide state 'HIDDEN' is returned for any non-auto-hide behavior. |
TestCreateShelfWithInitialValues(SHELF_ALIGNMENT_BOTTOM_LOCKED, |
SHELF_AUTO_HIDE_BEHAVIOR_NEVER, |