#include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
#include "base/compiler_specific.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
const int kWindowTilePixels = …;
}
TEST(WindowSizerTest, DefaultSizeCase) { … }
TEST(WindowSizerTest, LastWindowBoundsCase) { … }
TEST(WindowSizerTest, PersistedBoundsCase) { … }
#if !BUILDFLAG(IS_MAC)
TEST(WindowSizerTest, TinyWorkAreaAndBounds) { … }
#endif
#if BUILDFLAG(IS_MAC)
TEST(WindowSizerTest, LastWindowOffscreenWithAggressiveRepositioning) {
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithMonitorWorkArea(taskbar_left_work_area)
.WithLastActiveBounds(
gfx::Rect(kWindowTilePixels, kWindowTilePixels, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(taskbar_left_work_area.x(),
kWindowTilePixels * 2, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithLastActiveBounds(gfx::Rect(10, 729, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(10 + kWindowTilePixels,
0 ,
500, 400),
window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithLastActiveBounds(gfx::Rect(985, 10, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 ,
10 + kWindowTilePixels,
500, 400),
window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithLastActiveBounds(gfx::Rect(985, 729, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 ,
0 ,
500, 400),
window_bounds);
}
}
TEST(WindowSizerTest, PersistedWindowOffscreenWithAggressiveRepositioning) {
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(-471, 50, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 50, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(50, -370, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(995, 50, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 50, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(50, 739, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(50, 0 , 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(-471, -371, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 0 , 500, 400),
window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(995, -371, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 0 , 500, 400),
window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(-471, 739, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 0 , 500, 400),
window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(995, 739, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 0 , 500, 400),
window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(-700, 50, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 50, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(-700, 50, 500, 400))
.WithPersistedWorkArea(left_s1024x768)
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0, 50, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(50, -500, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(50, -500, 500, 400))
.WithPersistedWorkArea(top_s1024x768)
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(50, 0, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(1200, 50, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 50, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(1200, 50, 500, 400))
.WithPersistedWorkArea(right_s1024x768)
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(524 , 50, 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(50, 800, 500, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(50, 0 , 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(50, 800, 500, 400))
.WithPersistedWorkArea(bottom_s1024x768)
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(50, 368 , 500, 400), window_bounds);
}
{
gfx::Rect window_bounds =
WindowSizerTestUtil()
.WithMonitorBounds(p1024x768)
.WithPersistedBounds(gfx::Rect(-100, 50, 2000, 400))
.GetWindowBounds();
EXPECT_EQ(gfx::Rect(0 , 50, 2000, 400), window_bounds);
}
}
#else
TEST(WindowSizerTest, LastWindowOffscreenWithNonAggressiveRepositioning) { … }
#endif