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

Unified Diff: ash/root_window_controller_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: for further feedback 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/root_window_controller_unittest.cc
diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc
index e3a1c2dc063b31ff59661887cb0b3943c150f748..8956f639051cf49a5a2435d358537087064d451f 100644
--- a/ash/root_window_controller_unittest.cc
+++ b/ash/root_window_controller_unittest.cc
@@ -6,6 +6,7 @@
#include <memory>
+#include "ash/common/material_design/material_design_controller.h"
#include "ash/common/session/session_state_delegate.h"
#include "ash/common/shell_window_ids.h"
#include "ash/common/system/tray/system_tray_delegate.h"
@@ -15,6 +16,7 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/display_manager_test_api.h"
+#include "ash/test/material_design_controller_test_api.h"
#include "ash/wm/system_modal_container_layout_manager.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_state_aura.h"
@@ -97,8 +99,25 @@ class DeleteOnBlurDelegate : public aura::test::TestWindowDelegate,
namespace test {
-class RootWindowControllerTest : public test::AshTestBase {
+class RootWindowControllerTest
+ : public test::AshTestBase,
+ public testing::WithParamInterface<ash::MaterialDesignController::Mode> {
public:
+ RootWindowControllerTest() : md_maximized_window_height_offset_(0) {}
+
+ void SetUp() override {
+ test::AshTestBase::SetUp();
+ material_design_state_.reset(
+ new test::MaterialDesignControllerTestAPI(GetParam()));
+ md_maximized_window_height_offset_ =
+ ash::MaterialDesignController::IsMaterial() ? -1 : 0;
+ }
+
+ void TearDown() override {
+ material_design_state_.reset();
+ test::AshTestBase::TearDown();
+ }
+
views::Widget* CreateTestWidget(const gfx::Rect& bounds) {
views::Widget* widget = views::Widget::CreateWindowWithContextAndBounds(
NULL, CurrentContext(), bounds);
@@ -127,11 +146,34 @@ class RootWindowControllerTest : public test::AshTestBase {
return Shell::GetContainer(root_window,
ash::kShellWindowId_SystemModalContainer);
}
+
+ int GetMdMaximizedWindowHeightOffset() {
+ return md_maximized_window_height_offset_;
+ }
+
+ private:
+ std::unique_ptr<test::MaterialDesignControllerTestAPI>
+ material_design_state_;
+
+ // The material design shelf is taller (by 1px) so use this offset to
+ // adjust the expected height of a maximized window.
+ int md_maximized_window_height_offset_;
};
-TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
+// Note: First argument is optional and intentionally left blank.
+// (it's a prefix for the generated test cases)
+INSTANTIATE_TEST_CASE_P(
+ ,
+ RootWindowControllerTest,
+ testing::Values(ash::MaterialDesignController::NON_MATERIAL,
+ ash::MaterialDesignController::MATERIAL_NORMAL,
+ ash::MaterialDesignController::MATERIAL_EXPERIMENTAL));
+
+TEST_P(RootWindowControllerTest, MoveWindows_Basic) {
if (!SupportsMultipleDisplays())
return;
+ const int height_offset = GetMdMaximizedWindowHeightOffset();
+
// Windows origin should be doubled when moved to the 1st display.
UpdateDisplay("600x600,300x300");
aura::Window::Windows root_windows = Shell::GetAllRootWindows();
@@ -145,8 +187,9 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
views::Widget* maximized = CreateTestWidget(gfx::Rect(700, 10, 100, 100));
maximized->Maximize();
EXPECT_EQ(root_windows[1], maximized->GetNativeView()->GetRootWindow());
- EXPECT_EQ("600,0 300x253", maximized->GetWindowBoundsInScreen().ToString());
- EXPECT_EQ("0,0 300x253",
+ EXPECT_EQ(gfx::Rect(600, 0, 300, 253 + height_offset).ToString(),
+ maximized->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 300, 253 + height_offset).ToString(),
maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
@@ -207,16 +250,18 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
// share the same desktop workspace, which cancels the shelf status.
fullscreen->SetFullscreen(false);
EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
- EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString());
- EXPECT_EQ("0,0 600x553",
+ EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
+ maximized->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
// Set fullscreen to true, but maximized window's size won't change because
// it's not visible. see crbug.com/504299.
fullscreen->SetFullscreen(true);
EXPECT_EQ(root_windows[0], maximized->GetNativeView()->GetRootWindow());
- EXPECT_EQ("0,0 600x553", maximized->GetWindowBoundsInScreen().ToString());
- EXPECT_EQ("0,0 600x553",
+ EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
+ maximized->GetWindowBoundsInScreen().ToString());
+ EXPECT_EQ(gfx::Rect(0, 0, 600, 553 + height_offset).ToString(),
maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
EXPECT_EQ(root_windows[0], minimized->GetNativeView()->GetRootWindow());
@@ -253,7 +298,7 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id());
}
-TEST_F(RootWindowControllerTest, MoveWindows_Modal) {
+TEST_P(RootWindowControllerTest, MoveWindows_Modal) {
if (!SupportsMultipleDisplays())
return;
@@ -286,7 +331,7 @@ TEST_F(RootWindowControllerTest, MoveWindows_Modal) {
}
// Make sure lock related windows moves.
-TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) {
+TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) {
if (!SupportsMultipleDisplays())
return;
Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true);
@@ -368,7 +413,7 @@ TEST_F(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) {
EXPECT_EQ("0,0 600x500", lock_screen->GetNativeWindow()->bounds().ToString());
}
-TEST_F(RootWindowControllerTest, ModalContainer) {
+TEST_P(RootWindowControllerTest, ModalContainer) {
UpdateDisplay("600x600");
Shell* shell = Shell::GetInstance();
WmShell* wm_shell = WmShell::Get();
@@ -409,7 +454,7 @@ TEST_F(RootWindowControllerTest, ModalContainer) {
shell->session_state_delegate()->UnlockScreen();
}
-TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
+TEST_P(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
UpdateDisplay("600x600");
Shell* shell = Shell::GetInstance();
WmShell* wm_shell = WmShell::Get();
@@ -455,7 +500,7 @@ TEST_F(RootWindowControllerTest, ModalContainerNotLoggedInLoggedIn) {
session_modal_widget->GetNativeView()));
}
-TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) {
+TEST_P(RootWindowControllerTest, ModalContainerBlockedSession) {
UpdateDisplay("600x600");
RootWindowController* controller = Shell::GetPrimaryRootWindowController();
aura::Window* lock_container =
@@ -501,7 +546,7 @@ TEST_F(RootWindowControllerTest, ModalContainerBlockedSession) {
}
}
-TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) {
+TEST_P(RootWindowControllerTest, GetWindowForFullscreenMode) {
UpdateDisplay("600x600");
RootWindowController* controller =
Shell::GetInstance()->GetPrimaryRootWindowController();
@@ -533,7 +578,7 @@ TEST_F(RootWindowControllerTest, GetWindowForFullscreenMode) {
EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode());
}
-TEST_F(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) {
+TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) {
if (!SupportsMultipleDisplays())
return;
@@ -573,7 +618,7 @@ TEST_F(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) {
// Test that GetRootWindowController() works with multiple displays and
// child widgets.
-TEST_F(RootWindowControllerTest, GetRootWindowController) {
+TEST_P(RootWindowControllerTest, GetRootWindowController) {
if (!SupportsMultipleDisplays())
return;
UpdateDisplay("600x600,600x600");
@@ -603,7 +648,7 @@ TEST_F(RootWindowControllerTest, GetRootWindowController) {
// Test that user session window can't be focused if user session blocked by
// some overlapping UI.
-TEST_F(RootWindowControllerTest, FocusBlockedWindow) {
+TEST_P(RootWindowControllerTest, FocusBlockedWindow) {
UpdateDisplay("600x600");
RootWindowController* controller =
Shell::GetInstance()->GetPrimaryRootWindowController();
@@ -662,7 +707,7 @@ class DestroyedWindowObserver : public aura::WindowObserver {
};
// Verifies shutdown doesn't delete windows that are not owned by the parent.
-TEST_F(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) {
+TEST_P(RootWindowControllerTest, DontDeleteWindowsNotOwnedByParent) {
DestroyedWindowObserver observer1;
aura::test::TestWindowDelegate delegate1;
aura::Window* window1 = new aura::Window(&delegate1);

Powered by Google App Engine
This is Rietveld 408576698