Commit 578483a2 authored by James Cook's avatar James Cook Committed by Commit Bot

lacros: Rename window_sizer_ash.cc to window_sizer_chromeos.cc

Naming conventions for lacros are:
* foo_ash runs in ash-chrome
* foo_lacros runs in lacros-chrome
* foo_chromeos runs in both

We're going to use this positioning code in both, so rename to use
_chromeos.

WindowSizer itself has methods with Ash in their names, for historical
reasons. Rename those as well. Fixing those methods is out of scope for
this CL -- crbug.com/846736 tracks the cleanup work.

Bug: 1109050
Change-Id: I263df5f0f2740b4560a78c08b2bcc56e1abefcf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2321242
Commit-Queue: James Cook <jamescook@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Auto-Submit: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#792397}
parent 75a59538
...@@ -2418,7 +2418,7 @@ static_library("ui") { ...@@ -2418,7 +2418,7 @@ static_library("ui") {
"webui/signin/inline_login_handler_modal_delegate.h", "webui/signin/inline_login_handler_modal_delegate.h",
"webui/version_handler_chromeos.cc", "webui/version_handler_chromeos.cc",
"webui/version_handler_chromeos.h", "webui/version_handler_chromeos.h",
"window_sizer/window_sizer_ash.cc", "window_sizer/window_sizer_chromeos.cc",
] ]
deps += [ deps += [
......
...@@ -243,7 +243,7 @@ class Browser : public TabStripModelObserver, ...@@ -243,7 +243,7 @@ class Browser : public TabStripModelObserver,
private: private:
friend class Browser; friend class Browser;
friend class WindowSizerAshTest; friend class WindowSizerChromeOSTest;
static CreateParams CreateForAppBase(bool is_popup, static CreateParams CreateForAppBase(bool is_popup,
const std::string& app_name, const std::string& app_name,
......
per-file *ash*=estade@chromium.org per-file *chromeos*=estade@chromium.org
per-file *ash*=jamescook@chromium.org per-file *chromeos*=jamescook@chromium.org
# COMPONENT: UI>Browser
...@@ -169,8 +169,8 @@ void WindowSizer::DetermineWindowBoundsAndShowState( ...@@ -169,8 +169,8 @@ void WindowSizer::DetermineWindowBoundsAndShowState(
*bounds = specified_bounds; *bounds = specified_bounds;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// See if ash should decide the window placement. // Check for custom window placement for Chrome OS.
if (GetBrowserBoundsAsh(bounds, show_state)) if (GetBrowserBoundsChromeOS(bounds, show_state))
return; return;
#endif #endif
...@@ -234,7 +234,7 @@ void WindowSizer::GetDefaultWindowBounds(const display::Display& display, ...@@ -234,7 +234,7 @@ void WindowSizer::GetDefaultWindowBounds(const display::Display& display,
gfx::Rect* default_bounds) const { gfx::Rect* default_bounds) const {
DCHECK(default_bounds); DCHECK(default_bounds);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
*default_bounds = GetDefaultWindowBoundsAsh(browser_, display); *default_bounds = GetDefaultWindowBoundsChromeOS(browser_, display);
#else #else
gfx::Rect work_area = display.work_area(); gfx::Rect work_area = display.work_area();
......
...@@ -103,7 +103,7 @@ class WindowSizer { ...@@ -103,7 +103,7 @@ class WindowSizer {
const StateProvider* state_provider() const { return state_provider_.get(); } const StateProvider* state_provider() const { return state_provider_.get(); }
private: private:
friend class WindowSizerAshTest; friend class WindowSizerChromeOSTest;
friend class WindowSizerTestUtil; friend class WindowSizerTestUtil;
// WindowSizer will use the platforms's display::Screen. // WindowSizer will use the platforms's display::Screen.
...@@ -147,24 +147,25 @@ class WindowSizer { ...@@ -147,24 +147,25 @@ class WindowSizer {
gfx::Rect* bounds) const; gfx::Rect* bounds) const;
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
// Ash specific logic for window placement. Returns true if |bounds| and // Chrome OS specific logic for window placement. Returns true if |bounds| and
// |show_state| have been fully determined, otherwise returns false (but // |show_state| have been fully determined, otherwise returns false (but
// may still affect |show_state|). // may still affect |show_state|).
// If the window is too big to fit in the display work area then the |bounds| // If the window is too big to fit in the display work area then the |bounds|
// are adjusted to default bounds and the |show_state| is adjusted to // are adjusted to default bounds and the |show_state| is adjusted to
// SHOW_STATE_MAXIMIZED. // SHOW_STATE_MAXIMIZED.
bool GetBrowserBoundsAsh(gfx::Rect* bounds, bool GetBrowserBoundsChromeOS(gfx::Rect* bounds,
ui::WindowShowState* show_state) const; ui::WindowShowState* show_state) const;
// Determines the position and size for a tabbed browser window in // Determines the position and size for a tabbed browser window in
// ash as it gets created. This will be called before other standard // ash as it gets created. This will be called before other standard
// placement logic. |show_state| will only be changed // placement logic. |show_state| will only be changed
// if it was set to SHOW_STATE_DEFAULT. // if it was set to SHOW_STATE_DEFAULT.
void GetTabbedBrowserBoundsAsh(gfx::Rect* bounds, void GetTabbedBrowserBoundsChromeOS(gfx::Rect* bounds,
ui::WindowShowState* show_state) const; ui::WindowShowState* show_state) const;
// Returns the default bounds for a |browser| window on |display|. // Returns the default bounds for a |browser| window on |display|.
static gfx::Rect GetDefaultWindowBoundsAsh(const Browser* browser, static gfx::Rect GetDefaultWindowBoundsChromeOS(
const Browser* browser,
const display::Display& display); const display::Display& display);
#endif #endif
......
...@@ -37,7 +37,8 @@ bool ShouldForceMaximizeOnFirstRun() { ...@@ -37,7 +37,8 @@ bool ShouldForceMaximizeOnFirstRun() {
} // namespace } // namespace
bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, bool WindowSizer::GetBrowserBoundsChromeOS(
gfx::Rect* bounds,
ui::WindowShowState* show_state) const { ui::WindowShowState* show_state) const {
if (!browser_) if (!browser_)
return false; return false;
...@@ -48,16 +49,18 @@ bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, ...@@ -48,16 +49,18 @@ bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds,
bool determined = false; bool determined = false;
if (bounds->IsEmpty()) { if (bounds->IsEmpty()) {
if (browser_->is_type_normal()) { if (browser_->is_type_normal()) {
GetTabbedBrowserBoundsAsh(bounds, show_state); GetTabbedBrowserBoundsChromeOS(bounds, show_state);
determined = true; determined = true;
} else if (browser_->is_trusted_source()) { } else if (browser_->is_trusted_source()) {
// For trusted popups (v1 apps and system windows), do not use the last // For trusted popups (v1 apps and system windows), do not use the last
// active window bounds, only use saved or default bounds. // active window bounds, only use saved or default bounds.
if (!GetSavedWindowBounds(bounds, show_state)) if (!GetSavedWindowBounds(bounds, show_state)) {
*bounds = GetDefaultWindowBoundsAsh(browser_, GetDisplayForNewWindow()); *bounds =
GetDefaultWindowBoundsChromeOS(browser_, GetDisplayForNewWindow());
}
determined = true; determined = true;
} else if (state_provider_) { } else if (state_provider_) {
// In Ash, prioritize the last saved |show_state|. If you have questions // Finally, prioritize the last saved |show_state|. If you have questions
// or comments about this behavior please contact oshima@chromium.org. // or comments about this behavior please contact oshima@chromium.org.
gfx::Rect ignored_bounds, ignored_work_area; gfx::Rect ignored_bounds, ignored_work_area;
state_provider_->GetPersistentState(&ignored_bounds, &ignored_work_area, state_provider_->GetPersistentState(&ignored_bounds, &ignored_work_area,
...@@ -76,14 +79,14 @@ bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds, ...@@ -76,14 +79,14 @@ bool WindowSizer::GetBrowserBoundsAsh(gfx::Rect* bounds,
// gets maximized after this method returns. Return a sensible default // gets maximized after this method returns. Return a sensible default
// in order to make restored state visibly different from maximized. // in order to make restored state visibly different from maximized.
*show_state = ui::SHOW_STATE_MAXIMIZED; *show_state = ui::SHOW_STATE_MAXIMIZED;
*bounds = GetDefaultWindowBoundsAsh(browser_, display); *bounds = GetDefaultWindowBoundsChromeOS(browser_, display);
determined = true; determined = true;
} }
} }
return determined; return determined;
} }
void WindowSizer::GetTabbedBrowserBoundsAsh( void WindowSizer::GetTabbedBrowserBoundsChromeOS(
gfx::Rect* bounds_in_screen, gfx::Rect* bounds_in_screen,
ui::WindowShowState* show_state) const { ui::WindowShowState* show_state) const {
DCHECK(show_state); DCHECK(show_state);
...@@ -96,7 +99,7 @@ void WindowSizer::GetTabbedBrowserBoundsAsh( ...@@ -96,7 +99,7 @@ void WindowSizer::GetTabbedBrowserBoundsAsh(
bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state); bool is_saved_bounds = GetSavedWindowBounds(bounds_in_screen, show_state);
display::Display display = GetDisplayForNewWindow(*bounds_in_screen); display::Display display = GetDisplayForNewWindow(*bounds_in_screen);
if (!is_saved_bounds) if (!is_saved_bounds)
*bounds_in_screen = GetDefaultWindowBoundsAsh(browser_, display); *bounds_in_screen = GetDefaultWindowBoundsChromeOS(browser_, display);
if (browser_->is_session_restore()) { if (browser_->is_session_restore()) {
// Respect display for saved bounds during session restore. // Respect display for saved bounds during session restore.
...@@ -126,7 +129,8 @@ void WindowSizer::GetTabbedBrowserBoundsAsh( ...@@ -126,7 +129,8 @@ void WindowSizer::GetTabbedBrowserBoundsAsh(
bounds_in_screen->AdjustToFit(display.work_area()); bounds_in_screen->AdjustToFit(display.work_area());
} }
gfx::Rect WindowSizer::GetDefaultWindowBoundsAsh( // static
gfx::Rect WindowSizer::GetDefaultWindowBoundsChromeOS(
const Browser* browser, const Browser* browser,
const display::Display& display) { const display::Display& display) {
// Let apps set their own default. // Let apps set their own default.
......
...@@ -23,10 +23,12 @@ ...@@ -23,10 +23,12 @@
#include "ui/display/test/display_manager_test_api.h" #include "ui/display/test/display_manager_test_api.h"
#include "ui/wm/public/activation_client.h" #include "ui/wm/public/activation_client.h"
class WindowSizerAshTest : public ChromeAshTestBase { class WindowSizerChromeOSTest : public ChromeAshTestBase {
public: public:
WindowSizerAshTest() = default; WindowSizerChromeOSTest() = default;
~WindowSizerAshTest() override = default; WindowSizerChromeOSTest(const WindowSizerChromeOSTest&) = delete;
WindowSizerChromeOSTest& operator=(const WindowSizerChromeOSTest&) = delete;
~WindowSizerChromeOSTest() override = default;
// The window sizing code only works when the window hasn't yet been created. // The window sizing code only works when the window hasn't yet been created.
std::unique_ptr<Browser> CreateWindowlessBrowser( std::unique_ptr<Browser> CreateWindowlessBrowser(
...@@ -94,9 +96,6 @@ class WindowSizerAshTest : public ChromeAshTestBase { ...@@ -94,9 +96,6 @@ class WindowSizerAshTest : public ChromeAshTestBase {
protected: protected:
TestingProfile profile_; TestingProfile profile_;
private:
DISALLOW_COPY_AND_ASSIGN(WindowSizerAshTest);
}; };
namespace { namespace {
...@@ -125,8 +124,9 @@ std::unique_ptr<Browser> CreateTestBrowser(aura::Window* window, ...@@ -125,8 +124,9 @@ std::unique_ptr<Browser> CreateTestBrowser(aura::Window* window,
// Test that the window is sized appropriately for the first run experience // Test that the window is sized appropriately for the first run experience
// where the default window bounds calculation is invoked. // where the default window bounds calculation is invoked.
TEST_F(WindowSizerAshTest, DefaultSizeCase) { TEST_F(WindowSizerChromeOSTest, DefaultSizeCase) {
{ // 4:3 monitor case, 1024x768, no taskbar {
// 4:3 monitor case, 1024x768, no taskbar.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), WindowSizerTestUtil::GetWindowBounds(p1024x768, p1024x768, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, gfx::Rect(), gfx::Rect(), DEFAULT,
...@@ -137,7 +137,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -137,7 +137,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 4:3 monitor case, 1024x768, taskbar on bottom {
// 4:3 monitor case, 1024x768, taskbar on bottom.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, taskbar_bottom_work_area, gfx::Rect(), gfx::Rect(), p1024x768, taskbar_bottom_work_area, gfx::Rect(), gfx::Rect(),
...@@ -148,7 +149,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -148,7 +149,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 4:3 monitor case, 1024x768, taskbar on right {
// 4:3 monitor case, 1024x768, taskbar on right.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, taskbar_right_work_area, gfx::Rect(), gfx::Rect(), p1024x768, taskbar_right_work_area, gfx::Rect(), gfx::Rect(),
...@@ -160,7 +162,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -160,7 +162,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 4:3 monitor case, 1024x768, taskbar on left {
// 4:3 monitor case, 1024x768, taskbar on left.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, taskbar_left_work_area, gfx::Rect(), gfx::Rect(), p1024x768, taskbar_left_work_area, gfx::Rect(), gfx::Rect(),
...@@ -172,7 +175,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -172,7 +175,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 4:3 monitor case, 1024x768, taskbar on top {
// 4:3 monitor case, 1024x768, taskbar on top.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, taskbar_top_work_area, gfx::Rect(), gfx::Rect(), gfx::Rect(), p1024x768, taskbar_top_work_area, gfx::Rect(), gfx::Rect(), gfx::Rect(),
...@@ -184,7 +188,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -184,7 +188,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 4:3 monitor case, 1280x1024 {
// 4:3 monitor case, 1280x1024.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds(p1280x1024, p1280x1024, gfx::Rect(), WindowSizerTestUtil::GetWindowBounds(p1280x1024, p1280x1024, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, gfx::Rect(), gfx::Rect(), DEFAULT,
...@@ -194,7 +199,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -194,7 +199,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 4:3 monitor case, 1600x1200 {
// 4:3 monitor case, 1600x1200.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(), WindowSizerTestUtil::GetWindowBounds(p1600x1200, p1600x1200, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, gfx::Rect(), gfx::Rect(), DEFAULT,
...@@ -204,7 +210,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -204,7 +210,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 16:10 monitor case, 1680x1050 {
// 16:10 monitor case, 1680x1050.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds(p1680x1050, p1680x1050, gfx::Rect(), WindowSizerTestUtil::GetWindowBounds(p1680x1050, p1680x1050, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, gfx::Rect(), gfx::Rect(), DEFAULT,
...@@ -214,7 +221,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -214,7 +221,8 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
window_bounds); window_bounds);
} }
{ // 16:10 monitor case, 1920x1200 {
// 16:10 monitor case, 1920x1200.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds(p1920x1200, p1920x1200, gfx::Rect(), WindowSizerTestUtil::GetWindowBounds(p1920x1200, p1920x1200, gfx::Rect(),
gfx::Rect(), gfx::Rect(), DEFAULT, gfx::Rect(), gfx::Rect(), DEFAULT,
...@@ -227,8 +235,9 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) { ...@@ -227,8 +235,9 @@ TEST_F(WindowSizerAshTest, DefaultSizeCase) {
// Test that the next opened window is positioned appropriately given the // Test that the next opened window is positioned appropriately given the
// bounds of an existing window of the same type. // bounds of an existing window of the same type.
TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { TEST_F(WindowSizerChromeOSTest, LastWindowBoundsCase) {
{ // normal, in the middle of the screen somewhere. {
// Normal, in the middle of the screen somewhere.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, p1024x768, gfx::Rect(), p1024x768, p1024x768, gfx::Rect(),
...@@ -240,7 +249,8 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { ...@@ -240,7 +249,8 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) {
window_bounds.ToString()); window_bounds.ToString());
} }
{ // taskbar on top. {
// Taskbar on top.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, taskbar_top_work_area, gfx::Rect(), p1024x768, taskbar_top_work_area, gfx::Rect(),
...@@ -254,7 +264,8 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { ...@@ -254,7 +264,8 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) {
window_bounds.ToString()); window_bounds.ToString());
} }
{ // Too small to satisify the minimum visibility condition. {
// Too small to satisify the minimum visibility condition.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, p1024x768, gfx::Rect(), p1024x768, p1024x768, gfx::Rect(),
...@@ -267,8 +278,8 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { ...@@ -267,8 +278,8 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) {
window_bounds.ToString()); window_bounds.ToString());
} }
{
{ // Normal. // Normal.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, p1024x768, gfx::Rect(), p1024x768, p1024x768, gfx::Rect(),
...@@ -281,8 +292,10 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) { ...@@ -281,8 +292,10 @@ TEST_F(WindowSizerAshTest, LastWindowBoundsCase) {
} }
} }
TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) { TEST_F(WindowSizerChromeOSTest,
{ // taskbar on left. LastWindowOffscreenWithNonAggressiveRepositioning) {
{
// Taskbar on left.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, taskbar_left_work_area, gfx::Rect(), p1024x768, taskbar_left_work_area, gfx::Rect(),
...@@ -294,7 +307,8 @@ TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) { ...@@ -294,7 +307,8 @@ TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
window_bounds.ToString()); window_bounds.ToString());
} }
{ // offset would put the new window offscreen at the bottom but the minimum {
// Offset would put the new window offscreen at the bottom but the minimum
// visibility condition is barely satisfied without relocation. // visibility condition is barely satisfied without relocation.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
...@@ -304,20 +318,20 @@ TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) { ...@@ -304,20 +318,20 @@ TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
window_bounds.ToString()); window_bounds.ToString());
} }
{ // offset would put the new window offscreen at the bottom and the minimum {
// Offset would put the new window offscreen at the bottom and the minimum
// visibility condition is satisified by relocation. // visibility condition is satisified by relocation.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, p1024x768, gfx::Rect(), gfx::Rect(10, 729, 500, 400), p1024x768, p1024x768, gfx::Rect(), gfx::Rect(10, 729, 500, 400),
gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), &window_bounds); gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), &window_bounds);
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels, 738 /* not 739 */, 500, 400)
738 /* not 739 */, .ToString(),
500,
400).ToString(),
window_bounds.ToString()); window_bounds.ToString());
} }
{ // offset would put the new window offscreen at the right but the minimum {
// Offset would put the new window offscreen at the right but the minimum
// visibility condition is barely satisfied without relocation. // visibility condition is barely satisfied without relocation.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
...@@ -327,35 +341,33 @@ TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) { ...@@ -327,35 +341,33 @@ TEST_F(WindowSizerAshTest, LastWindowOffscreenWithNonAggressiveRepositioning) {
window_bounds.ToString()); window_bounds.ToString());
} }
{ // offset would put the new window offscreen at the right and the minimum {
// Offset would put the new window offscreen at the right and the minimum
// visibility condition is satisified by relocation. // visibility condition is satisified by relocation.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, p1024x768, gfx::Rect(), gfx::Rect(985, 10, 500, 400), p1024x768, p1024x768, gfx::Rect(), gfx::Rect(985, 10, 500, 400),
gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), &window_bounds); gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), &window_bounds);
EXPECT_EQ(gfx::Rect(994 /* not 995 */, EXPECT_EQ(gfx::Rect(994 /* not 995 */, 10 + kWindowTilePixels, 500, 400)
10 + kWindowTilePixels, .ToString(),
500,
400).ToString(),
window_bounds.ToString()); window_bounds.ToString());
} }
{ // offset would put the new window offscreen at the bottom right and the {
// Offset would put the new window offscreen at the bottom right and the
// minimum visibility condition is satisified by relocation. // minimum visibility condition is satisified by relocation.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1024x768, p1024x768, gfx::Rect(), gfx::Rect(985, 729, 500, 400), p1024x768, p1024x768, gfx::Rect(), gfx::Rect(985, 729, 500, 400),
gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), &window_bounds); gfx::Rect(), LAST_ACTIVE, NULL, gfx::Rect(), &window_bounds);
EXPECT_EQ(gfx::Rect(994 /* not 995 */, EXPECT_EQ(
738 /* not 739 */, gfx::Rect(994 /* not 995 */, 738 /* not 739 */, 500, 400).ToString(),
500,
400).ToString(),
window_bounds.ToString()); window_bounds.ToString());
} }
} }
// Test the placement of newly created windows. // Test the placement of newly created windows.
TEST_F(WindowSizerAshTest, PlaceNewWindows) { TEST_F(WindowSizerChromeOSTest, PlaceNewWindows) {
// Create a browser to pass into the WindowSizerTestUtil::GetWindowBounds // Create a browser to pass into the WindowSizerTestUtil::GetWindowBounds
// function. // function.
Browser::CreateParams native_params(&profile_, true); Browser::CreateParams native_params(&profile_, true);
...@@ -389,7 +401,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindows) { ...@@ -389,7 +401,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindows) {
} }
browser_window->Hide(); browser_window->Hide();
{ // If a window is there but not shown the persisted default should be used. {
// If a window is there but not shown the persisted default should be used.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1600x1200, p1600x1200, gfx::Rect(), gfx::Rect(50, 100, 300, 150), p1600x1200, p1600x1200, gfx::Rect(), gfx::Rect(50, 100, 300, 150),
...@@ -398,7 +411,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindows) { ...@@ -398,7 +411,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindows) {
EXPECT_EQ("50,100 300x150", window_bounds.ToString()); EXPECT_EQ("50,100 300x150", window_bounds.ToString());
} }
{ // If a window is there but not shown the default should be returned. {
// If a window is there but not shown the default should be returned.
gfx::Rect window_bounds; gfx::Rect window_bounds;
WindowSizerTestUtil::GetWindowBounds( WindowSizerTestUtil::GetWindowBounds(
p1600x1200, p1600x1200, gfx::Rect(), gfx::Rect(), bottom_s1600x1200, p1600x1200, p1600x1200, gfx::Rect(), gfx::Rect(), bottom_s1600x1200,
...@@ -419,7 +433,7 @@ TEST_F(WindowSizerAshTest, PlaceNewWindows) { ...@@ -419,7 +433,7 @@ TEST_F(WindowSizerAshTest, PlaceNewWindows) {
// Test the placement of newly created windows on an empty desktop. // Test the placement of newly created windows on an empty desktop.
// This test supplements "PlaceNewWindows" by testing the creation of a newly // This test supplements "PlaceNewWindows" by testing the creation of a newly
// created browser window on an empty desktop. // created browser window on an empty desktop.
TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnEmptyDesktop) { TEST_F(WindowSizerChromeOSTest, PlaceNewBrowserWindowOnEmptyDesktop) {
Browser::CreateParams native_params(&profile_, true); Browser::CreateParams native_params(&profile_, true);
auto browser = CreateWindowlessBrowser(native_params); auto browser = CreateWindowlessBrowser(native_params);
...@@ -458,7 +472,7 @@ TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnEmptyDesktop) { ...@@ -458,7 +472,7 @@ TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnEmptyDesktop) {
EXPECT_EQ("50,100 300x150", window_bounds.ToString()); EXPECT_EQ("50,100 300x150", window_bounds.ToString());
} }
TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnLargeDesktop) { TEST_F(WindowSizerChromeOSTest, PlaceNewBrowserWindowOnLargeDesktop) {
Browser::CreateParams native_params(&profile_, true); Browser::CreateParams native_params(&profile_, true);
auto browser = CreateWindowlessBrowser(native_params); auto browser = CreateWindowlessBrowser(native_params);
...@@ -479,7 +493,7 @@ TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnLargeDesktop) { ...@@ -479,7 +493,7 @@ TEST_F(WindowSizerAshTest, PlaceNewBrowserWindowOnLargeDesktop) {
} }
// Test the placement of newly created windows on multiple dislays. // Test the placement of newly created windows on multiple dislays.
TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) { TEST_F(WindowSizerChromeOSTest, PlaceNewWindowsOnMultipleDisplays) {
UpdateDisplay("1600x1200,1600x1200"); UpdateDisplay("1600x1200,1600x1200");
display::Display primary_display = display::Display primary_display =
display::Screen::GetScreen()->GetPrimaryDisplay(); display::Screen::GetScreen()->GetPrimaryDisplay();
...@@ -521,9 +535,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) { ...@@ -521,9 +535,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) {
gfx::Rect window_bounds; gfx::Rect window_bounds;
GetWindowBounds(new_browser.get(), gfx::Rect(), primary_display.id(), GetWindowBounds(new_browser.get(), gfx::Rect(), primary_display.id(),
&window_bounds); &window_bounds);
// TODO(oshima): Use exact bounds when the window_sizer_ash is // TODO(oshima): Use exact bounds when the window sizer includes the result
// moved to ash and changed to include the result from // from RearrangeVisibleWindowOnShow.
// RearrangeVisibleWindowOnShow.
EXPECT_TRUE(primary_bounds.Contains(window_bounds)); EXPECT_TRUE(primary_bounds.Contains(window_bounds));
} }
...@@ -540,9 +553,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) { ...@@ -540,9 +553,8 @@ TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) {
gfx::Rect window_bounds; gfx::Rect window_bounds;
GetWindowBounds(new_browser.get(), gfx::Rect(), second_display.id(), GetWindowBounds(new_browser.get(), gfx::Rect(), second_display.id(),
&window_bounds); &window_bounds);
// TODO(oshima): Use exact bounds when the window_sizer_ash is // TODO(oshima): Use exact bounds when the window sizer includes the result
// moved to ash and changed to include the result from // from RearrangeVisibleWindowOnShow.
// RearrangeVisibleWindowOnShow.
EXPECT_TRUE(secondary_bounds.Contains(window_bounds)); EXPECT_TRUE(secondary_bounds.Contains(window_bounds));
} }
...@@ -557,15 +569,14 @@ TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) { ...@@ -557,15 +569,14 @@ TEST_F(WindowSizerAshTest, PlaceNewWindowsOnMultipleDisplays) {
gfx::Rect window_bounds; gfx::Rect window_bounds;
GetWindowBounds(new_browser.get(), gfx::Rect(), primary_display.id(), GetWindowBounds(new_browser.get(), gfx::Rect(), primary_display.id(),
&window_bounds); &window_bounds);
// TODO(oshima): Use exact bounds when the window_sizer_ash is // TODO(oshima): Use exact bounds when the window sizer includes the result
// moved to ash and changed to include the result from // from RearrangeVisibleWindowOnShow.
// RearrangeVisibleWindowOnShow.
EXPECT_TRUE(primary_bounds.Contains(window_bounds)); EXPECT_TRUE(primary_bounds.Contains(window_bounds));
} }
} }
// Test that the show state is properly returned for non default cases. // Test that the show state is properly returned for non default cases.
TEST_F(WindowSizerAshTest, TestShowState) { TEST_F(WindowSizerChromeOSTest, TestShowState) {
UpdateDisplay("1600x1200"); UpdateDisplay("1600x1200");
// Creating a browser & window to play with. // Creating a browser & window to play with.
...@@ -615,7 +626,7 @@ TEST_F(WindowSizerAshTest, TestShowState) { ...@@ -615,7 +626,7 @@ TEST_F(WindowSizerAshTest, TestShowState) {
browser_popup.get(), p1600x1200, p1600x1200)); browser_popup.get(), p1600x1200, p1600x1200));
} }
TEST_F(WindowSizerAshTest, TestShowStateOnTinyScreen) { TEST_F(WindowSizerChromeOSTest, TestShowStateOnTinyScreen) {
Browser::CreateParams params(Browser::TYPE_NORMAL, &profile_, true); Browser::CreateParams params(Browser::TYPE_NORMAL, &profile_, true);
auto browser = CreateWindowlessBrowser(params); auto browser = CreateWindowlessBrowser(params);
...@@ -630,7 +641,7 @@ TEST_F(WindowSizerAshTest, TestShowStateOnTinyScreen) { ...@@ -630,7 +641,7 @@ TEST_F(WindowSizerAshTest, TestShowStateOnTinyScreen) {
} }
// Test that the default show state override behavior is properly handled. // Test that the default show state override behavior is properly handled.
TEST_F(WindowSizerAshTest, TestShowStateDefaults) { TEST_F(WindowSizerChromeOSTest, TestShowStateDefaults) {
UpdateDisplay("1600x1200"); UpdateDisplay("1600x1200");
// Creating a browser & window to play with. // Creating a browser & window to play with.
...@@ -683,7 +694,7 @@ TEST_F(WindowSizerAshTest, TestShowStateDefaults) { ...@@ -683,7 +694,7 @@ TEST_F(WindowSizerAshTest, TestShowStateDefaults) {
ui::SHOW_STATE_NORMAL); ui::SHOW_STATE_NORMAL);
} }
TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { TEST_F(WindowSizerChromeOSTest, DefaultStateBecomesMaximized) {
// Create a browser to pass into the WindowSizerTestUtil::GetWindowBounds // Create a browser to pass into the WindowSizerTestUtil::GetWindowBounds
// function. // function.
Browser::CreateParams native_params(&profile_, true); Browser::CreateParams native_params(&profile_, true);
...@@ -718,7 +729,7 @@ TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) { ...@@ -718,7 +729,7 @@ TEST_F(WindowSizerAshTest, DefaultStateBecomesMaximized) {
// the non browser window. This differ from PersistedBoundsCase // the non browser window. This differ from PersistedBoundsCase
// in that this uses real ash shell implementations + StateProvider // in that this uses real ash shell implementations + StateProvider
// rather than mocks. // rather than mocks.
TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) { TEST_F(WindowSizerChromeOSTest, DefaultBoundsInTargetDisplay) {
UpdateDisplay("500x500,600x600"); UpdateDisplay("500x500,600x600");
// By default windows are placed on the primary display. // By default windows are placed on the primary display.
...@@ -740,16 +751,13 @@ TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) { ...@@ -740,16 +751,13 @@ TEST_F(WindowSizerAshTest, DefaultBoundsInTargetDisplay) {
display::Screen::GetScreen()->SetDisplayForNewWindows(second_display_id); display::Screen::GetScreen()->SetDisplayForNewWindows(second_display_id);
gfx::Rect bounds; gfx::Rect bounds;
ui::WindowShowState show_state; ui::WindowShowState show_state;
WindowSizer::GetBrowserWindowBoundsAndShowState( WindowSizer::GetBrowserWindowBoundsAndShowState(gfx::Rect(), nullptr,
gfx::Rect(), &bounds, &show_state);
NULL,
&bounds,
&show_state);
EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds)); EXPECT_TRUE(second_root->GetBoundsInScreen().Contains(bounds));
} }
} }
TEST_F(WindowSizerAshTest, TrustedPopupBehavior) { TEST_F(WindowSizerChromeOSTest, TrustedPopupBehavior) {
Browser::CreateParams trusted_popup_create_params(Browser::TYPE_POPUP, Browser::CreateParams trusted_popup_create_params(Browser::TYPE_POPUP,
&profile_, true); &profile_, true);
trusted_popup_create_params.trusted_source = true; trusted_popup_create_params.trusted_source = true;
......
...@@ -2554,7 +2554,7 @@ if (!is_android) { ...@@ -2554,7 +2554,7 @@ if (!is_android) {
"../browser/ui/webui/chromeos/system_web_dialog_browsertest.cc", "../browser/ui/webui/chromeos/system_web_dialog_browsertest.cc",
"../browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc", "../browser/ui/webui/settings/chromeos/account_manager_handler_browsertest.cc",
"../browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc", "../browser/ui/webui/settings/chromeos/device_power_handler_browsertest.cc",
"../browser/ui/window_sizer/window_sizer_ash_uitest.cc", "../browser/ui/window_sizer/window_sizer_chromeos_uitest.cc",
"base/interactive_test_utils.cc", "base/interactive_test_utils.cc",
"base/interactive_test_utils.h", "base/interactive_test_utils.h",
"base/interactive_test_utils_aura.cc", "base/interactive_test_utils_aura.cc",
...@@ -4537,7 +4537,7 @@ test("unit_tests") { ...@@ -4537,7 +4537,7 @@ test("unit_tests") {
"../browser/ui/passwords/account_storage_auth_helper_unittest.cc", "../browser/ui/passwords/account_storage_auth_helper_unittest.cc",
"../browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc", "../browser/ui/webui/settings/settings_manage_profile_handler_unittest.cc",
# Chrome OS uses window_sizer_ash_unittest.cc # Chrome OS uses window_sizer_chromeos_unittest.cc
"../browser/ui/window_sizer/window_sizer_unittest.cc", "../browser/ui/window_sizer/window_sizer_unittest.cc",
] ]
sources += [ sources += [
...@@ -4637,7 +4637,7 @@ test("unit_tests") { ...@@ -4637,7 +4637,7 @@ test("unit_tests") {
"../browser/ui/webui/chromeos/login/fake_update_required_screen_handler.cc", "../browser/ui/webui/chromeos/login/fake_update_required_screen_handler.cc",
"../browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h", "../browser/ui/webui/chromeos/login/fake_update_required_screen_handler.h",
"../browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc", "../browser/ui/webui/chromeos/sync/os_sync_handler_unittest.cc",
"../browser/ui/window_sizer/window_sizer_ash_unittest.cc", "../browser/ui/window_sizer/window_sizer_chromeos_unittest.cc",
] ]
deps += [ deps += [
"//ash:test_support", "//ash:test_support",
......
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