Commit b49c0117 authored by oshima@chromium.org's avatar oshima@chromium.org

Revert "Use WS_POPUP for ash_unittests"

Use WS_POPUP for ash_unittests
- Layout test windows starting from (1,1) and move
mouse to (0,0) so that they don't overlap unless
test moves the cursor.
- Enabled disabled tests.
- RootWindowHostWin::SetBounds should move the window
and call OnHostResized when the scale factor has changed.

This also seems to fix the desktop size limitation issue (148691)
probably because a popup window can be larger than the desktop size.

TBR=oshima@chromium.org
BUG=150986, 157817, 141577, 148691
TEST=none

Review URL: https://codereview.chromium.org/11419271

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@170632 0039d316-1c4b-4281-b951-d872f2087c98
parent 8e7bed1e
......@@ -27,8 +27,15 @@ namespace ash {
typedef ash::test::AshTestBase DIPTest;
#if defined(OS_WIN)
// Windows/Aura doesn't have DIP support in display yet.
#define MAYBE_WorkArea DISABLED_WorkArea
#else
#define MAYBE_WorkArea WorkArea
#endif
// Test if the WM sets correct work area under different density.
TEST_F(DIPTest, WorkArea) {
TEST_F(DIPTest, MAYBE_WorkArea) {
ChangeDisplayConfig(1.0f, gfx::Rect(0, 0, 1000, 900));
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
......
......@@ -98,11 +98,30 @@ class DisplayControllerShutdownTest : public test::AshTestBase {
typedef test::AshTestBase DisplayControllerTest;
TEST_F(DisplayControllerShutdownTest, Shutdown) {
#if defined(OS_WIN)
// TODO(oshima): Windows creates a window with smaller client area.
// Fix this and enable tests.
#define MAYBE_SecondaryDisplayLayout DISABLED_SecondaryDisplayLayout
#define MAYBE_BoundsUpdated DISABLED_BoundsUpdated
#define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin
#define MAYBE_CursorDeviceScaleFactorSwapPrimary \
DISABLED_CursorDeviceScaleFactorSwapPrimary
#define MAYBE_Shutdown DISABLED_Shutdown
#else
#define MAYBE_SecondaryDisplayLayout SecondaryDisplayLayout
#define MAYBE_BoundsUpdated BoundsUpdated
#define MAYBE_CursorDeviceScaleFactorSwapPrimary \
CursorDeviceScaleFactorSwapPrimary
#define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin
#define MAYBE_Shutdown Shutdown
#endif
TEST_F(DisplayControllerShutdownTest, MAYBE_Shutdown) {
UpdateDisplay("444x333, 200x200");
}
TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
// Flaky - crbug.com/161857
TEST_F(DisplayControllerTest, MAYBE_SecondaryDisplayLayout) {
TestObserver observer;
UpdateDisplay("500x500,400x400");
EXPECT_EQ(2, observer.CountAndReset())
......@@ -207,7 +226,7 @@ TEST_F(DisplayControllerTest, SecondaryDisplayLayout) {
}
TEST_F(DisplayControllerTest, BoundsUpdated) {
TEST_F(DisplayControllerTest, MAYBE_BoundsUpdated) {
TestObserver observer;
SetSecondaryDisplayLayout(DisplayLayout::BOTTOM);
UpdateDisplay("200x200,300x300"); // layout, resize and add.
......@@ -305,10 +324,12 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
EXPECT_EQ(primary_display.id(),
Shell::GetScreen()->GetDisplayNearestWindow(NULL).id());
#if !defined(OS_WIN)
EXPECT_EQ("0,0 200x200", primary_display.bounds().ToString());
EXPECT_EQ("0,0 200x152", primary_display.work_area().ToString());
EXPECT_EQ("200,0 300x300", secondary_display.bounds().ToString());
EXPECT_EQ("200,0 300x300", secondary_display.work_area().ToString());
#endif
// Switch primary and secondary
display_controller->SetPrimaryDisplay(secondary_display);
......@@ -330,6 +351,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
EXPECT_TRUE(primary_root->Contains(launcher_window));
EXPECT_FALSE(secondary_root->Contains(launcher_window));
#if !defined(OS_WIN)
// Test if the bounds are correctly swapped.
gfx::Display swapped_primary = Shell::GetScreen()->GetPrimaryDisplay();
gfx::Display swapped_secondary = ScreenAsh::GetSecondaryDisplay();
......@@ -337,6 +359,7 @@ TEST_F(DisplayControllerTest, SwapPrimary) {
EXPECT_EQ("0,0 300x252", swapped_primary.work_area().ToString());
EXPECT_EQ("-200,-50 200x200", swapped_secondary.bounds().ToString());
EXPECT_EQ("-200,-50 200x200", swapped_secondary.work_area().ToString());
#endif
const DisplayLayout& inverted_layout =
display_controller->GetLayoutForDisplay(primary_display);
......@@ -479,7 +502,7 @@ TEST_F(DisplayControllerTest, SwapPrimaryById) {
EXPECT_TRUE(primary_root->Contains(launcher_window));
}
TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {
TEST_F(DisplayControllerTest, MAYBE_CursorDeviceScaleFactorSwapPrimary) {
DisplayController* display_controller =
Shell::GetInstance()->display_controller();
......@@ -531,23 +554,16 @@ TEST_F(DisplayControllerTest, CursorDeviceScaleFactorSwapPrimary) {
EXPECT_EQ(1.0f, test_api.GetDeviceScaleFactor());
}
#if defined(OS_WIN)
// TODO(oshima): On Windows, we don't update the origin/size right away.
#define MAYBE_UpdateDisplayWithHostOrigin DISABLED_UpdateDisplayWithHostOrigin
#else
#define MAYBE_UpdateDisplayWithHostOrigin UpdateDisplayWithHostOrigin
#endif
TEST_F(DisplayControllerTest, MAYBE_UpdateDisplayWithHostOrigin) {
UpdateDisplay("100x200,300x400");
ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays());
Shell::RootWindowList root_windows =
Shell::GetInstance()->GetAllRootWindows();
ASSERT_EQ(2U, root_windows.size());
EXPECT_EQ("1,1", root_windows[0]->GetHostOrigin().ToString());
EXPECT_EQ("0,0", root_windows[0]->GetHostOrigin().ToString());
EXPECT_EQ("100x200", root_windows[0]->GetHostSize().ToString());
// UpdateDisplay set the origin if it's not set.
EXPECT_NE("1,1", root_windows[1]->GetHostOrigin().ToString());
EXPECT_NE("0,0", root_windows[1]->GetHostOrigin().ToString());
EXPECT_EQ("300x400", root_windows[1]->GetHostSize().ToString());
UpdateDisplay("100x200,200+300-300x400");
......
......@@ -95,7 +95,21 @@ class DisplayManagerTest : public test::AshTestBase,
DISALLOW_COPY_AND_ASSIGN(DisplayManagerTest);
};
TEST_F(DisplayManagerTest, NativeDisplayTest) {
#if defined(OS_CHROMEOS)
// TODO(oshima): This fails with non extended desktop on windows.
// Reenable when extended desktop is enabled by default.
#define MAYBE_NativeDisplayTest NativeDisplayTest
#define MAYBE_EmulatorTest EmulatorTest
#define MAYBE_OverscanInsetsTest OverscanInsetsTest
#define MAYBE_ZeroOverscanInsets ZeroOverscanInsets
#else
#define MAYBE_NativeDisplayTest DISABLED_NativeDisplayTest
#define MAYBE_EmulatorTest DISABLED_EmulatorTest
#define MAYBE_OverscanInsetsTest DISABLED_OverscanInsetsTest
#define MAYBE_ZeroOverscanInsets DISABLED_ZeroOverscanInsets
#endif
TEST_F(DisplayManagerTest, MAYBE_NativeDisplayTest) {
EXPECT_EQ(1U, display_manager()->GetNumDisplays());
// Update primary and add seconary.
......@@ -119,24 +133,24 @@ TEST_F(DisplayManagerTest, NativeDisplayTest) {
reset();
// Change primary.
UpdateDisplay("1+1-1000x600");
UpdateDisplay("0+0-1000x600");
EXPECT_EQ("1 0 0", GetCountSummary());
EXPECT_EQ(display_manager()->GetDisplayAt(0)->id(), changed()[0].id());
EXPECT_EQ("0,0 1000x600", changed()[0].bounds().ToString());
reset();
// Add secondary.
UpdateDisplay("1+1-1000x600,1002+0-600x400");
UpdateDisplay("0+0-1000x600,1001+0-600x400");
EXPECT_EQ(2U, display_manager()->GetNumDisplays());
EXPECT_EQ("0 1 0", GetCountSummary());
EXPECT_EQ(display_manager()->GetDisplayAt(1)->id(), added()[0].id());
// Secondary display is on right.
EXPECT_EQ("1000,0 600x400", added()[0].bounds().ToString());
EXPECT_EQ("1002,0 600x400", added()[0].bounds_in_pixel().ToString());
EXPECT_EQ("1001,0 600x400", added()[0].bounds_in_pixel().ToString());
reset();
// Secondary removed, primary changed.
UpdateDisplay("1+1-800x300");
UpdateDisplay("0+0-800x300");
EXPECT_EQ(1U, display_manager()->GetNumDisplays());
EXPECT_EQ("1 0 1", GetCountSummary());
EXPECT_EQ(display_manager()->GetDisplayAt(0)->id(), changed()[0].id());
......@@ -183,7 +197,7 @@ TEST_F(DisplayManagerTest, NativeDisplayTest) {
}
// Test in emulation mode (use_fullscreen_host_window=false)
TEST_F(DisplayManagerTest, EmulatorTest) {
TEST_F(DisplayManagerTest, MAYBE_EmulatorTest) {
EXPECT_EQ(1U, display_manager()->GetNumDisplays());
DisplayManager::CycleDisplay();
......@@ -203,7 +217,7 @@ TEST_F(DisplayManagerTest, EmulatorTest) {
reset();
}
TEST_F(DisplayManagerTest, OverscanInsetsTest) {
TEST_F(DisplayManagerTest, MAYBE_OverscanInsetsTest) {
UpdateDisplay("0+0-500x500,0+501-400x400");
reset();
ASSERT_EQ(2u, display_manager()->GetNumDisplays());
......@@ -277,7 +291,7 @@ TEST_F(DisplayManagerTest, OverscanInsetsTest) {
GetPrimaryDisplay().bounds_in_pixel().ToString());
}
TEST_F(DisplayManagerTest, ZeroOverscanInsets) {
TEST_F(DisplayManagerTest, MAYBE_ZeroOverscanInsets) {
// Make sure the display change events is emitted for overscan inset changes.
UpdateDisplay("0+0-500x500,0+501-400x400");
ASSERT_EQ(2u, display_manager()->GetNumDisplays());
......@@ -298,7 +312,20 @@ TEST_F(DisplayManagerTest, ZeroOverscanInsets) {
EXPECT_EQ(display2_id, changed()[0].id());
}
TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) {
// TODO(oshima): Device scale factor is supported on chromeos only for now.
#if defined(OS_CHROMEOS)
#define MAYBE_TestDeviceScaleOnlyChange TestDeviceScaleOnlyChange
#define MAYBE_TestNativeDisplaysChanged TestNativeDisplaysChanged
#define MAYBE_NativeDisplaysChangedAfterPrimaryChange \
NativeDisplaysChangedAfterPrimaryChange
#else
#define MAYBE_TestDeviceScaleOnlyChange DISABLED_TestDeviceScaleOnlyChange
#define MAYBE_TestNativeDisplaysChanged DISABLED_TestNativeDisplaysChanged
#define MAYBE_NativeDisplaysChangedAfterPrimaryChange \
DISABLED_NativeDisplaysChangedAfterPrimaryChange
#endif
TEST_F(DisplayManagerTest, MAYBE_TestDeviceScaleOnlyChange) {
UpdateDisplay("1000x600");
EXPECT_EQ(1,
Shell::GetPrimaryRootWindow()->compositor()->device_scale_factor());
......@@ -311,7 +338,7 @@ TEST_F(DisplayManagerTest, TestDeviceScaleOnlyChange) {
Shell::GetPrimaryRootWindow()->bounds().size().ToString());
}
TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) {
TEST_F(DisplayManagerTest, MAYBE_TestNativeDisplaysChanged) {
const int64 internal_display_id =
display_manager()->SetFirstDisplayAsInternalDisplayForTest();
const gfx::Display native_display(internal_display_id,
......@@ -375,7 +402,18 @@ TEST_F(DisplayManagerTest, TestNativeDisplaysChanged) {
FindDisplayForId(internal_display_id).bounds().ToString());
}
TEST_F(DisplayManagerTest, EnsurePointerInDisplays) {
#if defined(OS_CHROMEOS)
#define MAYBE_EnsurePointerInDisplays EnsurePointerInDisplays
#define MAYBE_EnsurePointerInDisplays_2ndOnLeft \
EnsurePointerInDisplays_2ndOnLeft
#else
// TODO(oshima): Re-enable these tests on WinAura (http://crbug.com/158163).
#define MAYBE_EnsurePointerInDisplays DISABLED_EnsurePointerInDisplays
#define MAYBE_EnsurePointerInDisplays_2ndOnLeft \
DISABLED_EnsurePointerInDisplays_2ndOnLeft
#endif
TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays) {
UpdateDisplay("200x200,300x300");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
......@@ -413,7 +451,7 @@ TEST_F(DisplayManagerTest, EnsurePointerInDisplays) {
EXPECT_EQ("150,140", env->last_mouse_location().ToString());
}
TEST_F(DisplayManagerTest, EnsurePointerInDisplays_2ndOnLeft) {
TEST_F(DisplayManagerTest, MAYBE_EnsurePointerInDisplays_2ndOnLeft) {
UpdateDisplay("200x200,300x300");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
......@@ -448,7 +486,7 @@ TEST_F(DisplayManagerTest, EnsurePointerInDisplays_2ndOnLeft) {
EXPECT_EQ("150,150", env->last_mouse_location().ToString());
}
TEST_F(DisplayManagerTest, NativeDisplaysChangedAfterPrimaryChange) {
TEST_F(DisplayManagerTest, MAYBE_NativeDisplaysChangedAfterPrimaryChange) {
const int64 internal_display_id =
display_manager()->SetFirstDisplayAsInternalDisplayForTest();
const gfx::Display native_display(internal_display_id,
......
......@@ -325,7 +325,14 @@ TEST_F(ExtendedDesktopTest, GetRootWindowMatching) {
wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)));
}
TEST_F(ExtendedDesktopTest, Capture) {
#if defined(OS_WIN)
// TODO(mazda): Re-enable this (http://crbug.com/150986).
#define MAYBE_Capture DISABLED_Capture
#else
#define MAYBE_Capture Capture
#endif
TEST_F(ExtendedDesktopTest, MAYBE_Capture) {
UpdateDisplay("1000x600,600x400");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
......@@ -352,7 +359,11 @@ TEST_F(ExtendedDesktopTest, Capture) {
// The mouse is outside. On chromeos, the mouse is warped to the
// dest root window, but it's not implemented on Win yet, so
// no mouse move event on Win.
#if defined(OS_WIN)
EXPECT_EQ("1 0 0", r1_d1.GetMouseMotionCountsAndReset());
#else
EXPECT_EQ("1 1 0", r1_d1.GetMouseMotionCountsAndReset());
#endif
EXPECT_EQ("1 1", r1_d1.GetMouseButtonCountsAndReset());
// (15,15) on 1st display is (-985,15) on 2nd display.
generator2.MoveMouseTo(-985, 15);
......@@ -431,7 +442,13 @@ TEST_F(ExtendedDesktopTest, MoveWindowByMouseClick) {
EXPECT_EQ(root_windows[1], window->GetRootWindow());
}
TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) {
// This test fails on the "Win Aura" bot: <http://crbug.com/157817>.
#if defined(OS_WIN)
#define MAYBE_MoveWindowToDisplay DISABLED_MoveWindowToDisplay
#else
#define MAYBE_MoveWindowToDisplay MoveWindowToDisplay
#endif
TEST_F(ExtendedDesktopTest, MAYBE_MoveWindowToDisplay) {
UpdateDisplay("1000x1000,1000x1000");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
......
......@@ -119,10 +119,12 @@ 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());
#if !defined(OS_WIN)
// TODO(oshima): Window reports smaller screen size. Investigate why.
EXPECT_EQ("600,0 500x500", maximized->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("0,0 500x500",
maximized->GetNativeView()->GetBoundsInRootWindow().ToString());
#endif
views::Widget* minimized = CreateTestWidget(gfx::Rect(800, 10, 100, 100));
minimized->Minimize();
......@@ -133,11 +135,13 @@ TEST_F(RootWindowControllerTest, MoveWindows_Basic) {
views::Widget* fullscreen = CreateTestWidget(gfx::Rect(900, 10, 100, 100));
fullscreen->SetFullscreen(true);
EXPECT_EQ(root_windows[1], fullscreen->GetNativeView()->GetRootWindow());
#if !defined(OS_WIN)
// TODO(oshima): Window reports smaller screen size. Investigate why.
EXPECT_EQ("600,0 500x500",
fullscreen->GetWindowBoundsInScreen().ToString());
EXPECT_EQ("0,0 500x500",
fullscreen->GetNativeView()->GetBoundsInRootWindow().ToString());
#endif
// Make sure a window that will delete itself when losing focus
// will not crash.
......
......@@ -20,6 +20,7 @@ namespace test {
typedef test::AshTestBase ScreenAshTest;
#if !defined(OS_WIN)
TEST_F(ScreenAshTest, Bounds) {
UpdateDisplay("600x600,500x500");
Shell::GetPrimaryRootWindowController()->SetShelfAutoHideBehavior(
......@@ -56,6 +57,7 @@ TEST_F(ScreenAshTest, Bounds) {
ScreenAsh::GetDisplayWorkAreaBoundsInParent(
secondary->GetNativeView()).ToString());
}
#endif
TEST_F(ScreenAshTest, ConvertRect) {
UpdateDisplay("600x600,500x500");
......
......@@ -26,10 +26,6 @@
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
#if defined(OS_WIN)
#include "ui/aura/root_window_host_win.h"
#endif
namespace ash {
namespace test {
......@@ -47,13 +43,8 @@ AshTestBase::~AshTestBase() {
}
void AshTestBase::SetUp() {
// Use the origin (1,1) so that it doesn't over
// lap with the native mouse cursor.
CommandLine::ForCurrentProcess()->AppendSwitchASCII(
switches::kAuraHostWindowSize, "1+1-800x600");
#if defined(OS_WIN)
aura::test::SetUsePopupAsRootWindowForTest(true);
#endif
switches::kAuraHostWindowSize, "0+0-800x600");
// Disable animations during tests.
ui::LayerAnimator::set_disable_animations_for_test(true);
ui::TextInputTestSupport::Initialize();
......@@ -62,9 +53,9 @@ void AshTestBase::SetUp() {
ash::Shell::CreateInstance(test_shell_delegate_);
Shell::GetPrimaryRootWindow()->Show();
Shell::GetPrimaryRootWindow()->ShowRootWindow();
// Move the mouse cursor to (0,0) so that native events doesn't
// Move the mouse cursor to far away so that native events doesn't
// interfere test expectations.
Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(0, 0));
Shell::GetPrimaryRootWindow()->MoveCursorTo(gfx::Point(-1000, -1000));
Shell::GetInstance()->cursor_manager()->ShowCursor(true);
}
......@@ -76,9 +67,6 @@ void AshTestBase::TearDown() {
Shell::DeleteInstance();
aura::Env::DeleteInstance();
ui::TextInputTestSupport::Shutdown();
#if defined(OS_WIN)
aura::test::SetUsePopupAsRootWindowForTest(false);
#endif
}
void AshTestBase::ChangeDisplayConfig(float scale,
......
......@@ -41,6 +41,9 @@ DisplayManagerTestApi::~DisplayManagerTestApi() {}
void DisplayManagerTestApi::UpdateDisplay(
const std::string& display_specs) {
std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs);
display_manager_->SetDisplayIdsForTest(&displays);
display_manager_->OnNativeDisplaysChanged(displays);
bool is_host_origin_set = false;
for (size_t i = 0; i < displays.size(); ++i) {
if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) {
......@@ -54,21 +57,14 @@ void DisplayManagerTestApi::UpdateDisplay(
// previous one for GPU performance reasons. Try to emulate the behavior
// unless host origins are explicitly set.
if (!is_host_origin_set) {
// Sart from (1,1) so that windows won't overlap with native mouse cursor.
// See |AshTestBase::SetUp()|.
int next_y = 1;
for (std::vector<gfx::Display>::iterator iter = displays.begin();
iter != displays.end(); ++iter) {
gfx::Rect bounds(iter->GetSizeInPixel());
bounds.set_x(1);
bounds.set_y(next_y);
next_y += bounds.height();
iter->SetScaleAndBounds(iter->device_scale_factor(), bounds);
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
int next_y = 0;
for (size_t i = 0; i < root_windows.size(); ++i) {
const gfx::Size size = root_windows[i]->GetHostSize();
root_windows[i]->SetHostBounds(gfx::Rect(gfx::Point(0, next_y), size));
next_y += size.height();
}
}
display_manager_->SetDisplayIdsForTest(&displays);
display_manager_->OnNativeDisplaysChanged(displays);
}
} // namespace test
......
......@@ -163,6 +163,25 @@ class WorkspaceWindowResizerTest : public test::AshTestBase {
} // namespace
// Fails on win_aura since ash::GetRootWindowRelativeToWindow is not implemented
// yet for the platform.
#if defined(OS_WIN)
#define MAYBE_WindowDragWithMultiDisplays \
DISABLED_WindowDragWithMultiDisplays
#define MAYBE_WindowDragWithMultiDisplaysRightToLeft \
DISABLED_WindowDragWithMultiDisplaysRightToLeft
#define MAYBE_PhantomStyle DISABLED_PhantomStyle
#define MAYBE_CancelSnapPhantom DISABLED_CancelSnapPhantom
#define MAYBE_CursorDeviceScaleFactor DISABLED_CursorDeviceScaleFactor
#else
#define MAYBE_WindowDragWithMultiDisplays WindowDragWithMultiDisplays
#define MAYBE_WindowDragWithMultiDisplaysRightToLeft \
WindowDragWithMultiDisplaysRightToLeft
#define MAYBE_PhantomStyle PhantomStyle
#define MAYBE_CancelSnapPhantom CancelSnapPhantom
#define MAYBE_CursorDeviceScaleFactor CursorDeviceScaleFactor
#endif
// Assertions around attached window resize dragging from the right with 2
// windows.
TEST_F(WorkspaceWindowResizerTest, AttachedResize_RIGHT_2) {
......@@ -371,7 +390,15 @@ TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_2) {
// Assertions around attached window resize dragging from the bottom with 3
// windows.
TEST_F(WorkspaceWindowResizerTest, AttachedResize_BOTTOM_3) {
// TODO(oshima): Host window doesn't get a resize event after
// SetHostSize on Windows trybot, which gives wrong work/display area.
// crbug.com/141577.
#if defined(OS_WIN)
#define MAYBE_AttachedResize_BOTTOM_3 DISABLED_AttachedResize_BOTTOM_3
#else
#define MAYBE_AttachedResize_BOTTOM_3 AttachedResize_BOTTOM_3
#endif
TEST_F(WorkspaceWindowResizerTest, MAYBE_AttachedResize_BOTTOM_3) {
aura::RootWindow* root = Shell::GetPrimaryRootWindow();
root->SetHostSize(gfx::Size(600, 800));
......@@ -479,6 +506,7 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
GetRestoreBoundsInScreen(window_.get())->ToString());
}
#if !defined(OS_WIN)
// Test if the restore bounds is correct in multiple displays.
ClearRestoreBounds(window_.get());
UpdateDisplay("800x600,200x600");
......@@ -505,6 +533,7 @@ TEST_F(WorkspaceWindowResizerTest, Edge) {
EXPECT_EQ("800,10 50x60",
GetRestoreBoundsInScreen(window_.get())->ToString());
}
#endif
}
// Check that non resizable windows will not get resized.
......@@ -521,7 +550,7 @@ TEST_F(WorkspaceWindowResizerTest, NonResizableWindows) {
}
// Verifies a window can be moved from the primary display to another.
TEST_F(WorkspaceWindowResizerTest, WindowDragWithMultiDisplays) {
TEST_F(WorkspaceWindowResizerTest, MAYBE_WindowDragWithMultiDisplays) {
// The secondary display is logically on the right, but on the system (e.g. X)
// layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
UpdateDisplay("800x600,800x600");
......@@ -584,7 +613,7 @@ TEST_F(WorkspaceWindowResizerTest, WindowDragWithMultiDisplays) {
// Verifies a window can be moved from the secondary display to primary.
TEST_F(WorkspaceWindowResizerTest,
WindowDragWithMultiDisplaysRightToLeft) {
MAYBE_WindowDragWithMultiDisplaysRightToLeft) {
UpdateDisplay("800x600,800x600");
shelf_layout_manager()->LayoutShelf();
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
......@@ -608,7 +637,7 @@ TEST_F(WorkspaceWindowResizerTest,
}
// Verifies the style of the drag phantom window is correct.
TEST_F(WorkspaceWindowResizerTest, PhantomStyle) {
TEST_F(WorkspaceWindowResizerTest, MAYBE_PhantomStyle) {
UpdateDisplay("800x600,800x600");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
ASSERT_EQ(2U, root_windows.size());
......@@ -683,7 +712,7 @@ TEST_F(WorkspaceWindowResizerTest, PhantomStyle) {
}
// Verifies the style of the drag phantom window is correct.
TEST_F(WorkspaceWindowResizerTest, CancelSnapPhantom) {
TEST_F(WorkspaceWindowResizerTest, MAYBE_CancelSnapPhantom) {
UpdateDisplay("800x600,800x600");
Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
ASSERT_EQ(2U, root_windows.size());
......@@ -1371,7 +1400,7 @@ TEST_F(WorkspaceWindowResizerTest, MagneticallyResize_LEFT) {
// Verifies cursor's device scale factor is updated whe a window is moved across
// root windows with different device scale factors (http://crbug.com/154183).
TEST_F(WorkspaceWindowResizerTest, CursorDeviceScaleFactor) {
TEST_F(WorkspaceWindowResizerTest, MAYBE_CursorDeviceScaleFactor) {
// The secondary display is logically on the right, but on the system (e.g. X)
// layer, it's below the primary one. See UpdateDisplay() in ash_test_base.cc.
UpdateDisplay("400x400,800x800*2");
......
......@@ -146,6 +146,11 @@ void RootWindow::Init() {
compositor()->SetScaleAndSize(GetDeviceScaleFactorFromDisplay(this),
host_->GetBounds().size());
Window::Init(ui::LAYER_NOT_DRAWN);
gfx::Point point;
if (host_->QueryMouseLocation(&point))
SetLastMouseLocation(this, ui::ConvertPointToDIP(layer(), point));
compositor()->SetRootLayer(layer());
SetBounds(
ui::ConvertRectToDIP(layer(), gfx::Rect(host_->GetBounds().size())));
......
......@@ -14,18 +14,11 @@
#include "ui/base/cursor/cursor_loader_win.h"
#include "ui/base/events/event.h"
#include "ui/base/view_prop.h"
#include "ui/gfx/display.h"
#include "ui/gfx/screen.h"
using std::max;
using std::min;
namespace aura {
namespace {
bool use_popup_as_root_window_for_test = false;
} // namespace
// static
RootWindowHost* RootWindowHost::Create(const gfx::Rect& bounds) {
......@@ -44,8 +37,6 @@ RootWindowHostWin::RootWindowHostWin(const gfx::Rect& bounds)
has_capture_(false),
saved_window_style_(0),
saved_window_ex_style_(0) {
if (use_popup_as_root_window_for_test)
set_window_style(WS_POPUP);
Init(NULL, bounds);
SetWindowText(hwnd(), L"aura::RootWindow!");
}
......@@ -130,19 +121,11 @@ void RootWindowHostWin::SetBounds(const gfx::Rect& bounds) {
SetWindowPos(
hwnd(),
NULL,
window_rect.left,
window_rect.top,
0,
0,
window_rect.right - window_rect.left,
window_rect.bottom - window_rect.top,
SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREDRAW | SWP_NOREPOSITION);
// Explicity call OnHostResized when the scale has changed because
// the window size may not have changed.
float current_scale = delegate_->GetDeviceScaleFactor();
float new_scale = gfx::Screen::GetScreenFor(delegate_->AsRootWindow())->
GetDisplayNearestWindow(delegate_->AsRootWindow()).device_scale_factor();
if (current_scale != new_scale)
delegate_->OnHostResized(bounds.size());
}
gfx::Point RootWindowHostWin::GetLocationOnNativeScreen() const {
......@@ -298,13 +281,4 @@ void RootWindowHostWin::OnSize(UINT param, const CSize& size) {
delegate_->OnHostResized(gfx::Size(size.cx, size.cy));
}
namespace test {
// static
void SetUsePopupAsRootWindowForTest(bool use) {
use_popup_as_root_window_for_test = use;
}
} // namespace test
} // namespace aura
......@@ -7,7 +7,6 @@
#include "base/compiler_specific.h"
#include "ui/aura/root_window_host.h"
#include "ui/base/ui_export.h"
#include "ui/base/win/window_impl.h"
namespace aura {
......@@ -89,15 +88,6 @@ class RootWindowHostWin : public RootWindowHost, public ui::WindowImpl {
DISALLOW_COPY_AND_ASSIGN(RootWindowHostWin);
};
namespace test {
// Set true to let RootWindowHostWin use a popup window
// with no frame/title so that the window size and test's
// expectations matches.
AURA_EXPORT void SetUsePopupAsRootWindowForTest(bool use);
} // namespace
} // namespace aura
#endif // UI_AURA_ROOT_WINDOW_HOST_WIN_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment