This source file includes following definitions.
- TEST_F
- TEST_F
#include <algorithm>
#include <vector>
#include "ash/ash_switches.h"
#include "ash/display/display_manager.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h"
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/compositor/layer.h"
#include "ui/gfx/display.h"
#include "ui/gfx/insets.h"
#include "ui/gfx/screen.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/shadow.h"
#include "ui/wm/core/shadow_controller.h"
#include "ui/wm/core/shadow_types.h"
#include "ui/wm/public/activation_client.h"
namespace ash {
typedef ash::test::AshTestBase DIPTest;
TEST_F(DIPTest, WorkArea) {
UpdateDisplay("1000x900*1.0f");
aura::Window* root = Shell::GetPrimaryRootWindow();
const gfx::Display display =
Shell::GetScreen()->GetDisplayNearestWindow(root);
EXPECT_EQ("0,0 1000x900", display.bounds().ToString());
gfx::Rect work_area = display.work_area();
EXPECT_EQ("0,0 1000x853", work_area.ToString());
EXPECT_EQ("0,0,47,0", display.bounds().InsetsFrom(work_area).ToString());
UpdateDisplay("2000x1800*2.0f");
gfx::Screen* screen = Shell::GetScreen();
const gfx::Display display_2x = screen->GetDisplayNearestWindow(root);
const DisplayInfo display_info_2x =
Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id());
EXPECT_EQ("1,1 2000x1800",
display_info_2x.bounds_in_native().ToString());
EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString());
work_area = display_2x.work_area();
EXPECT_EQ("0,0 1000x853", work_area.ToString());
EXPECT_EQ("0,0,47,0", display_2x.bounds().InsetsFrom(work_area).ToString());
Shelf* shelf = Shelf::ForPrimaryDisplay();
EXPECT_EQ(
display_2x.bounds().InsetsFrom(work_area).height(),
shelf->shelf_widget()->GetNativeView()->layer()->bounds().height());
}
TEST_F(DIPTest, WorkAreaForLegacyShelfLayout) {
CommandLine::ForCurrentProcess()->AppendSwitch(
ash::switches::kAshDisableAlternateShelfLayout);
UpdateDisplay("1000x900*1.0f");
aura::Window* root = Shell::GetPrimaryRootWindow();
const gfx::Display display =
Shell::GetScreen()->GetDisplayNearestWindow(root);
EXPECT_EQ("0,0 1000x900", display.bounds().ToString());
gfx::Rect work_area = display.work_area();
EXPECT_EQ("0,0 1000x852", work_area.ToString());
EXPECT_EQ("0,0,48,0", display.bounds().InsetsFrom(work_area).ToString());
UpdateDisplay("2000x1800*2.0f");
gfx::Screen* screen = Shell::GetScreen();
const gfx::Display display_2x = screen->GetDisplayNearestWindow(root);
const DisplayInfo display_info_2x =
Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id());
EXPECT_EQ("1,1 2000x1800",
display_info_2x.bounds_in_native().ToString());
EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString());
work_area = display_2x.work_area();
EXPECT_EQ("0,0 1000x852", work_area.ToString());
EXPECT_EQ("0,0,48,0", display_2x.bounds().InsetsFrom(work_area).ToString());
Shelf* shelf = Shelf::ForPrimaryDisplay();
EXPECT_EQ(
display_2x.bounds().InsetsFrom(work_area).height(),
shelf->shelf_widget()->GetNativeView()->layer()->bounds().height());
}
}