Commit bd3ed862 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

cros: Add test for v2 app placement checking.

This will help prevent regressions like the one caused by
crrev.com/c/2189575. See [1] for more details on the regression.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1125403

Test: merged crrev.com/c/2189575 and test failed
Bug: 1129000
Change-Id: Ia2a79fda1553ad0298a064b957e122f2a0e2b962
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416734
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#808447}
parent cc750ee3
......@@ -22,6 +22,9 @@
#include "extensions/test/extension_test_message_listener.h"
#include "ui/aura/window.h"
#include "ui/base/ui_base_types.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/screen.h"
#include "ui/display/test/display_manager_test_api.h"
#include "ui/views/view_observer.h"
#include "ui/wm/core/window_util.h"
......@@ -346,3 +349,64 @@ IN_PROC_BROWSER_TEST_F(ChromeNativeAppWindowViewsAuraAshBrowserTest,
EXPECT_TRUE(window()->IsImmersiveModeEnabled());
EXPECT_TRUE(window()->exclusive_access_bubble_);
}
// Tests the auto positioning logic of created windows does not apply to apps
// which specify their own positions.
IN_PROC_BROWSER_TEST_F(ChromeNativeAppWindowViewsAuraAshBrowserTest,
UserGivenBoundsAreRespected) {
display::DisplayManager* display_manager =
ash::ShellTestApi().display_manager();
display::test::DisplayManagerTestApi(display_manager)
.UpdateDisplay("800x800");
const extensions::Extension* extension =
LoadAndLaunchPlatformApp("launch", "Launched");
// This is the default size apps are if no window or content specifications
// are given.
const gfx::Size default_size(512, 384);
// Create an app with no window or content specifications. Use no frame for
// simpler calculations.
extensions::AppWindow::CreateParams params;
params.frame = extensions::AppWindow::FRAME_NONE;
extensions::AppWindow* app_window =
CreateAppWindowFromParams(browser()->profile(), extension, params);
// Test that the window is centered within the work area.
gfx::Rect expected_bounds = display_manager->GetDisplayAt(0).work_area();
expected_bounds.ClampToCenteredSize(default_size);
EXPECT_EQ(expected_bounds,
app_window->GetNativeWindow()->GetBoundsInScreen());
CloseAppWindow(app_window);
// Create an app with content specifications. The window is placed where the
// user specified.
{
const gfx::Rect specified_bounds(10, 10, 600, 400);
extensions::AppWindow::BoundsSpecification content_spec;
content_spec.bounds = specified_bounds;
params.content_spec = content_spec;
app_window =
CreateAppWindowFromParams(browser()->profile(), extension, params);
EXPECT_EQ(specified_bounds,
app_window->GetNativeWindow()->GetBoundsInScreen());
}
CloseAppWindow(app_window);
// Create an app with content specifications on the secondary display. The
// window is placed where the user specified.
display::test::DisplayManagerTestApi(display_manager)
.UpdateDisplay("800x800,800+0-800x800");
{
const gfx::Rect specified_bounds(810, 10, 600, 400);
extensions::AppWindow::BoundsSpecification content_spec;
content_spec.bounds = specified_bounds;
params.content_spec = content_spec;
app_window =
CreateAppWindowFromParams(browser()->profile(), extension, params);
EXPECT_EQ(specified_bounds,
app_window->GetNativeWindow()->GetBoundsInScreen());
}
CloseAppWindow(app_window);
}
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