Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Side by Side Diff: ash/dip_unittest.cc

Issue 2067223003: Parameterize Ash unittests to pass with material design enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/ash.gyp ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "ash/common/ash_switches.h" 8 #include "ash/common/ash_switches.h"
9 #include "ash/common/material_design/material_design_controller.h"
9 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
10 #include "ash/shelf/shelf.h" 11 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_widget.h" 12 #include "ash/shelf/shelf_widget.h"
12 #include "ash/shell.h" 13 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_md_test_base.h"
14 #include "ash/wm/window_properties.h" 15 #include "ash/wm/window_properties.h"
15 #include "ash/wm/window_util.h" 16 #include "ash/wm/window_util.h"
16 #include "base/command_line.h" 17 #include "base/command_line.h"
17 #include "ui/aura/window.h" 18 #include "ui/aura/window.h"
18 #include "ui/aura/window_event_dispatcher.h" 19 #include "ui/aura/window_event_dispatcher.h"
19 #include "ui/compositor/layer.h" 20 #include "ui/compositor/layer.h"
20 #include "ui/display/display.h" 21 #include "ui/display/display.h"
21 #include "ui/display/screen.h" 22 #include "ui/display/screen.h"
22 #include "ui/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
23 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
24 #include "ui/wm/core/shadow.h" 25 #include "ui/wm/core/shadow.h"
25 #include "ui/wm/core/shadow_controller.h" 26 #include "ui/wm/core/shadow_controller.h"
26 #include "ui/wm/core/shadow_types.h" 27 #include "ui/wm/core/shadow_types.h"
27 #include "ui/wm/public/activation_client.h" 28 #include "ui/wm/public/activation_client.h"
28 29
29 namespace ash { 30 namespace ash {
30 31
31 typedef ash::test::AshTestBase DIPTest; 32 using DIPTest = test::AshMDTestBase;
33
34 INSTANTIATE_TEST_CASE_P(
35 /* prefix intentionally left blank due to only one parameterization */,
36 DIPTest,
37 testing::Values(MaterialDesignController::NON_MATERIAL,
38 MaterialDesignController::MATERIAL_NORMAL,
39 MaterialDesignController::MATERIAL_EXPERIMENTAL));
32 40
33 // Test if the WM sets correct work area under different density. 41 // Test if the WM sets correct work area under different density.
34 #if defined(OS_WIN) && !defined(USE_ASH)
35 // TODO(msw): Broken on Windows. http://crbug.com/584038 42 // TODO(msw): Broken on Windows. http://crbug.com/584038
36 #define MAYBE_WorkArea DISABLED_WorkArea 43 #if defined(OS_CHROMEOS)
37 #else 44 TEST_P(DIPTest, WorkArea) {
38 #define MAYBE_WorkArea WorkArea 45 const int height_offset = GetMdMaximizedWindowHeightOffset();
39 #endif
40 TEST_F(DIPTest, MAYBE_WorkArea) {
41 UpdateDisplay("1000x900*1.0f"); 46 UpdateDisplay("1000x900*1.0f");
42 47
43 aura::Window* root = Shell::GetPrimaryRootWindow(); 48 aura::Window* root = Shell::GetPrimaryRootWindow();
44 const display::Display display = 49 const display::Display display =
45 display::Screen::GetScreen()->GetDisplayNearestWindow(root); 50 display::Screen::GetScreen()->GetDisplayNearestWindow(root);
46 51
47 EXPECT_EQ("0,0 1000x900", display.bounds().ToString()); 52 EXPECT_EQ("0,0 1000x900", display.bounds().ToString());
48 gfx::Rect work_area = display.work_area(); 53 gfx::Rect work_area = display.work_area();
49 EXPECT_EQ("0,0 1000x853", work_area.ToString()); 54 EXPECT_EQ(gfx::Rect(0, 0, 1000, 853 + height_offset).ToString(),
50 EXPECT_EQ("0,0,47,0", display.bounds().InsetsFrom(work_area).ToString()); 55 work_area.ToString());
56 EXPECT_EQ(gfx::Insets(0, 0, 47 - height_offset, 0).ToString(),
57 display.bounds().InsetsFrom(work_area).ToString());
51 58
52 UpdateDisplay("2000x1800*2.0f"); 59 UpdateDisplay("2000x1800*2.0f");
53 display::Screen* screen = display::Screen::GetScreen(); 60 display::Screen* screen = display::Screen::GetScreen();
54 61
55 const display::Display display_2x = screen->GetDisplayNearestWindow(root); 62 const display::Display display_2x = screen->GetDisplayNearestWindow(root);
56 const DisplayInfo display_info_2x = 63 const DisplayInfo display_info_2x =
57 Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id()); 64 Shell::GetInstance()->display_manager()->GetDisplayInfo(display_2x.id());
58 65
59 // The |bounds_in_pixel()| should report bounds in pixel coordinate. 66 // The |bounds_in_pixel()| should report bounds in pixel coordinate.
60 EXPECT_EQ("1,1 2000x1800", 67 EXPECT_EQ("1,1 2000x1800",
61 display_info_2x.bounds_in_native().ToString()); 68 display_info_2x.bounds_in_native().ToString());
62 69
63 // Aura and views coordinates are in DIP, so they their bounds do not change. 70 // Aura and views coordinates are in DIP, so they their bounds do not change.
64 EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString()); 71 EXPECT_EQ("0,0 1000x900", display_2x.bounds().ToString());
65 work_area = display_2x.work_area(); 72 work_area = display_2x.work_area();
66 EXPECT_EQ("0,0 1000x853", work_area.ToString()); 73 EXPECT_EQ(gfx::Rect(0, 0, 1000, 853 + height_offset).ToString(),
67 EXPECT_EQ("0,0,47,0", display_2x.bounds().InsetsFrom(work_area).ToString()); 74 work_area.ToString());
75 EXPECT_EQ(gfx::Insets(0, 0, 47 - height_offset, 0).ToString(),
76 display_2x.bounds().InsetsFrom(work_area).ToString());
68 77
69 // Sanity check if the workarea's inset hight is same as 78 // Sanity check if the workarea's inset hight is same as
70 // the shelf's height. 79 // the shelf's height.
71 Shelf* shelf = Shelf::ForPrimaryDisplay(); 80 Shelf* shelf = Shelf::ForPrimaryDisplay();
72 EXPECT_EQ( 81 EXPECT_EQ(
73 display_2x.bounds().InsetsFrom(work_area).height(), 82 display_2x.bounds().InsetsFrom(work_area).height(),
74 shelf->shelf_widget()->GetNativeView()->layer()->bounds().height()); 83 shelf->shelf_widget()->GetNativeView()->layer()->bounds().height());
75 } 84 }
85 #endif // defined(OS_CHROMEOS)
76 86
77 } // namespace ash 87 } // namespace ash
OLDNEW
« no previous file with comments | « ash/ash.gyp ('k') | ash/display/display_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698