Skip to content

Commit

Permalink
Parameterize Ash unittests to pass with material design enabled
Browse files Browse the repository at this point in the history
Parameterize test fixtures in ash_unittests
to run with the three modes used in Ash
material design (non-material, material stable,
and material experimental); see the runtime flag
--ash-md.

Also introduce the AshMdTestBase class to aid
in modifying test expectations across the
parameterized test runs.

BUG=617296
TEST=ash_unittests

Review-Url: https://codereview.chromium.org/2067223003
Cr-Commit-Position: refs/heads/master@{#401420}
  • Loading branch information
tdanderson authored and Commit bot committed Jun 22, 2016
1 parent c319999 commit 0b7905b
Show file tree
Hide file tree
Showing 12 changed files with 426 additions and 260 deletions.
2 changes: 2 additions & 0 deletions ash/ash.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,8 @@
'desktop_background/desktop_background_controller_test_api.h',
'shell/toplevel_window.cc',
'shell/toplevel_window.h',
'test/ash_md_test_base.cc',
'test/ash_md_test_base.h',
'test/ash_test_base.cc',
'test/ash_test_base.h',
'test/ash_test_helper.cc',
Expand Down
34 changes: 22 additions & 12 deletions ash/dip_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
#include <vector>

#include "ash/common/ash_switches.h"
#include "ash/common/material_design/material_design_controller.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/test/ash_md_test_base.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
Expand All @@ -28,16 +29,20 @@

namespace ash {

typedef ash::test::AshTestBase DIPTest;
using DIPTest = test::AshMDTestBase;

INSTANTIATE_TEST_CASE_P(
/* prefix intentionally left blank due to only one parameterization */,
DIPTest,
testing::Values(MaterialDesignController::NON_MATERIAL,
MaterialDesignController::MATERIAL_NORMAL,
MaterialDesignController::MATERIAL_EXPERIMENTAL));

// Test if the WM sets correct work area under different density.
#if defined(OS_WIN) && !defined(USE_ASH)
// TODO(msw): Broken on Windows. http://crbug.com/584038
#define MAYBE_WorkArea DISABLED_WorkArea
#else
#define MAYBE_WorkArea WorkArea
#endif
TEST_F(DIPTest, MAYBE_WorkArea) {
#if defined(OS_CHROMEOS)
TEST_P(DIPTest, WorkArea) {
const int height_offset = GetMdMaximizedWindowHeightOffset();
UpdateDisplay("1000x900*1.0f");

aura::Window* root = Shell::GetPrimaryRootWindow();
Expand All @@ -46,8 +51,10 @@ TEST_F(DIPTest, MAYBE_WorkArea) {

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());
EXPECT_EQ(gfx::Rect(0, 0, 1000, 853 + height_offset).ToString(),
work_area.ToString());
EXPECT_EQ(gfx::Insets(0, 0, 47 - height_offset, 0).ToString(),
display.bounds().InsetsFrom(work_area).ToString());

UpdateDisplay("2000x1800*2.0f");
display::Screen* screen = display::Screen::GetScreen();
Expand All @@ -63,8 +70,10 @@ TEST_F(DIPTest, MAYBE_WorkArea) {
// Aura and views coordinates are in DIP, so they their bounds do not change.
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());
EXPECT_EQ(gfx::Rect(0, 0, 1000, 853 + height_offset).ToString(),
work_area.ToString());
EXPECT_EQ(gfx::Insets(0, 0, 47 - height_offset, 0).ToString(),
display_2x.bounds().InsetsFrom(work_area).ToString());

// Sanity check if the workarea's inset hight is same as
// the shelf's height.
Expand All @@ -73,5 +82,6 @@ TEST_F(DIPTest, MAYBE_WorkArea) {
display_2x.bounds().InsetsFrom(work_area).height(),
shelf->shelf_widget()->GetNativeView()->layer()->bounds().height());
}
#endif // defined(OS_CHROMEOS)

} // namespace ash
Loading

0 comments on commit 0b7905b

Please sign in to comment.