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

Unified Diff: ash/wm/window_positioner_unittest.cc

Issue 2067223003: Parameterize Ash unittests to pass with material design enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SupportsHostWindowResize() Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
Index: ash/wm/window_positioner_unittest.cc
diff --git a/ash/wm/window_positioner_unittest.cc b/ash/wm/window_positioner_unittest.cc
index 12c7705d008ee80849d58fe982ee50f8eef2aca8..e4c7360f1aa3e631c5ffca0ffc581a79595c90b8 100644
--- a/ash/wm/window_positioner_unittest.cc
+++ b/ash/wm/window_positioner_unittest.cc
@@ -6,11 +6,12 @@
#include <string>
+#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/wm/window_positioner.h"
#include "ash/common/wm/window_state.h"
#include "ash/shell.h"
#include "ash/shell/toplevel_window.h"
-#include "ash/test/ash_test_base.h"
+#include "ash/test/ash_md_test_base.h"
#include "ash/test/test_shell_delegate.h"
#include "ash/wm/window_state_aura.h"
#include "base/strings/string_number_conversions.h"
@@ -21,11 +22,21 @@
namespace ash {
-typedef test::AshTestBase WindowPositionerTest;
+using WindowPositionerTest = test::AshMDTestBase;
-TEST_F(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) {
+// The prefix has intentionally been left blank since there is only one
+// parameterization of this test fixture.
+INSTANTIATE_TEST_CASE_P(
+ /* prefix intentionally left blank */,
+ WindowPositionerTest,
+ testing::Values(MaterialDesignController::NON_MATERIAL,
+ MaterialDesignController::MATERIAL_NORMAL,
+ MaterialDesignController::MATERIAL_EXPERIMENTAL));
+
+TEST_P(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) {
if (!SupportsMultipleDisplays())
return;
+ const int height_offset = GetMdMaximizedWindowHeightOffset();
// Tests that for a screen that is narrower than kForceMaximizeWidthLimit
// a new window gets maximized.
UpdateDisplay("400x400,500x500");
@@ -36,10 +47,11 @@ TEST_F(WindowPositionerTest, OpenMaximizedWindowOnSecondDisplay) {
params.can_maximize = true;
views::Widget* widget =
shell::ToplevelWindow::CreateToplevelWindow(params);
- EXPECT_EQ("400,0 500x453", widget->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ(gfx::Rect(400, 0, 500, 453 + height_offset).ToString(),
+ widget->GetWindowBoundsInScreen().ToString());
}
-TEST_F(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) {
+TEST_P(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) {
if (!SupportsMultipleDisplays())
return;
#if defined(OS_WIN)
@@ -69,18 +81,10 @@ TEST_F(WindowPositionerTest, OpenDefaultWindowOnSecondDisplay) {
// Tests that second window inherits first window's maximized state as well as
// its restore bounds.
-#if defined(OS_WIN) && !defined(USE_ASH)
// TODO(msw): Broken on Windows. http://crbug.com/584038
-#define MAYBE_SecondMaximizedWindowHasProperRestoreSize \
- DISABLED_SecondMaximizedWindowHasProperRestoreSize
-#else
-#define MAYBE_SecondMaximizedWindowHasProperRestoreSize \
- SecondMaximizedWindowHasProperRestoreSize
-#endif
-TEST_F(WindowPositionerTest, MAYBE_SecondMaximizedWindowHasProperRestoreSize) {
-#if defined(OS_WIN)
- ash::WindowPositioner::SetMaximizeFirstWindow(true);
-#endif
+#if defined(OS_CHROMEOS)
+TEST_P(WindowPositionerTest, SecondMaximizedWindowHasProperRestoreSize) {
+ const int height_offset = GetMdMaximizedWindowHeightOffset();
UpdateDisplay("1400x900");
shell::ToplevelWindow::CreateParams params;
params.can_resize = true;
@@ -89,16 +93,16 @@ TEST_F(WindowPositionerTest, MAYBE_SecondMaximizedWindowHasProperRestoreSize) {
shell::ToplevelWindow::CreateToplevelWindow(params);
gfx::Rect bounds = widget1->GetWindowBoundsInScreen();
-#if !defined(OS_WIN)
// The window should have default size.
EXPECT_FALSE(widget1->IsMaximized());
EXPECT_EQ("300x300", bounds.size().ToString());
widget1->Maximize();
-#endif
+
// The window should be maximized.
bounds = widget1->GetWindowBoundsInScreen();
EXPECT_TRUE(widget1->IsMaximized());
- EXPECT_EQ("0,0 1400x853", bounds.ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 1400, 853 + height_offset).ToString(),
+ bounds.ToString());
// Create another window
views::Widget* widget2 =
@@ -107,13 +111,15 @@ TEST_F(WindowPositionerTest, MAYBE_SecondMaximizedWindowHasProperRestoreSize) {
// The second window should be maximized.
bounds = widget2->GetWindowBoundsInScreen();
EXPECT_TRUE(widget2->IsMaximized());
- EXPECT_EQ("0,0 1400x853", bounds.ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 1400, 853 + height_offset).ToString(),
+ bounds.ToString());
widget2->Restore();
// Second window's restored size should be set to default size.
bounds = widget2->GetWindowBoundsInScreen();
EXPECT_EQ("300x300", bounds.size().ToString());
}
+#endif // defined(OS_CHROMEOS)
namespace {
@@ -143,7 +149,7 @@ class OutOfDisplayDelegate : public views::WidgetDelegate {
} // namespace
-TEST_F(WindowPositionerTest, EnsureMinimumVisibility) {
+TEST_P(WindowPositionerTest, EnsureMinimumVisibility) {
if (!SupportsHostWindowResize())
return;
@@ -167,7 +173,7 @@ TEST_F(WindowPositionerTest, EnsureMinimumVisibility) {
// resolutions, one can set "ForceMaximizeBrowserWindowOnFirstRun"
// policy. In the following tests we check if the window will be opened in
// maximized mode for low and high resolution when this policy is set.
-TEST_F(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) {
+TEST_P(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) {
const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() + 100;
// Set resolution to 1466x300.
const std::string resolution = base::IntToString(width) + "x300";
@@ -186,7 +192,7 @@ TEST_F(WindowPositionerTest, FirstRunMaximizeWindowHighResloution) {
}
// For detail see description of FirstRunMaximizeWindowHighResloution.
-TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) {
+TEST_P(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) {
const int width = ash::WindowPositioner::GetForceMaximizedWidthLimit() - 100;
// Set resolution to 1266x300.
const std::string resolution = base::IntToString(width) + "x300";
@@ -204,7 +210,7 @@ TEST_F(WindowPositionerTest, FirstRunMaximizeWindowLowResolution) {
EXPECT_EQ(show_state_out, ui::SHOW_STATE_MAXIMIZED);
}
-TEST_F(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) {
+TEST_P(WindowPositionerTest, IgnoreFullscreenInAutoRearrange) {
if (!SupportsHostWindowResize())
return;
// Set bigger than 1366 so that the new window is opened in normal state.

Powered by Google App Engine
This is Rietveld 408576698