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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer_common_unittest.cc

Issue 1920263003: Rename gfx::Display/Screen to display::Display/Screen in chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
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 "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h" 5 #include "chrome/browser/ui/window_sizer/window_sizer_common_unittest.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/wm/common/window_resizer.h" 10 #include "ash/wm/common/window_resizer.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_switches.h" 15 #include "chrome/common/chrome_switches.h"
16 #include "chrome/test/base/testing_profile.h" 16 #include "chrome/test/base/testing_profile.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 #include "ui/gfx/display.h" 18 #include "ui/display/display.h"
19 #include "ui/gfx/screen.h" 19 #include "ui/display/screen.h"
20 20
21 #if defined(USE_AURA) 21 #if defined(USE_AURA)
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #endif 23 #endif
24 24
25 namespace { 25 namespace {
26 26
27 class TestScreen : public gfx::Screen { 27 class TestScreen : public display::Screen {
28 public: 28 public:
29 TestScreen() : previous_screen_(gfx::Screen::GetScreen()) { 29 TestScreen() : previous_screen_(display::Screen::GetScreen()) {
30 gfx::Screen::SetScreenInstance(this); 30 display::Screen::SetScreenInstance(this);
31 } 31 }
32 ~TestScreen() override { gfx::Screen::SetScreenInstance(previous_screen_); } 32 ~TestScreen() override {
33 display::Screen::SetScreenInstance(previous_screen_);
34 }
33 35
34 // Sets the index of the display returned from GetDisplayNearestWindow(). 36 // Sets the index of the display returned from GetDisplayNearestWindow().
35 // Only used on aura. 37 // Only used on aura.
36 void set_index_of_display_nearest_window(int index) { 38 void set_index_of_display_nearest_window(int index) {
37 index_of_display_nearest_window_ = index; 39 index_of_display_nearest_window_ = index;
38 } 40 }
39 41
40 // Overridden from gfx::Screen: 42 // Overridden from display::Screen:
41 gfx::Point GetCursorScreenPoint() override { 43 gfx::Point GetCursorScreenPoint() override {
42 NOTREACHED(); 44 NOTREACHED();
43 return gfx::Point(); 45 return gfx::Point();
44 } 46 }
45 47
46 gfx::NativeWindow GetWindowUnderCursor() override { 48 gfx::NativeWindow GetWindowUnderCursor() override {
47 NOTREACHED(); 49 NOTREACHED();
48 return NULL; 50 return NULL;
49 } 51 }
50 52
51 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override { 53 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override {
52 NOTREACHED(); 54 NOTREACHED();
53 return NULL; 55 return NULL;
54 } 56 }
55 57
56 int GetNumDisplays() const override { return displays_.size(); } 58 int GetNumDisplays() const override { return displays_.size(); }
57 59
58 std::vector<gfx::Display> GetAllDisplays() const override { 60 std::vector<display::Display> GetAllDisplays() const override {
59 return displays_; 61 return displays_;
60 } 62 }
61 63
62 gfx::Display GetDisplayNearestWindow(gfx::NativeView view) const override { 64 display::Display GetDisplayNearestWindow(
65 gfx::NativeView view) const override {
63 #if defined(USE_AURA) 66 #if defined(USE_AURA)
64 return displays_[index_of_display_nearest_window_]; 67 return displays_[index_of_display_nearest_window_];
65 #else 68 #else
66 NOTREACHED(); 69 NOTREACHED();
67 return gfx::Display(); 70 return display::Display();
68 #endif 71 #endif
69 } 72 }
70 73
71 gfx::Display GetDisplayNearestPoint(const gfx::Point& point) const override { 74 display::Display GetDisplayNearestPoint(
75 const gfx::Point& point) const override {
72 NOTREACHED(); 76 NOTREACHED();
73 return gfx::Display(); 77 return display::Display();
74 } 78 }
75 79
76 gfx::Display GetDisplayMatching(const gfx::Rect& match_rect) const override { 80 display::Display GetDisplayMatching(
81 const gfx::Rect& match_rect) const override {
77 int max_area = 0; 82 int max_area = 0;
78 size_t max_area_index = 0; 83 size_t max_area_index = 0;
79 84
80 for (size_t i = 0; i < displays_.size(); ++i) { 85 for (size_t i = 0; i < displays_.size(); ++i) {
81 gfx::Rect overlap = displays_[i].bounds(); 86 gfx::Rect overlap = displays_[i].bounds();
82 overlap.Intersect(match_rect); 87 overlap.Intersect(match_rect);
83 int area = overlap.width() * overlap.height(); 88 int area = overlap.width() * overlap.height();
84 if (area > max_area) { 89 if (area > max_area) {
85 max_area = area; 90 max_area = area;
86 max_area_index = i; 91 max_area_index = i;
87 } 92 }
88 } 93 }
89 return displays_[max_area_index]; 94 return displays_[max_area_index];
90 } 95 }
91 96
92 gfx::Display GetPrimaryDisplay() const override { return displays_[0]; } 97 display::Display GetPrimaryDisplay() const override { return displays_[0]; }
93 98
94 void AddObserver(gfx::DisplayObserver* observer) override { NOTREACHED(); } 99 void AddObserver(display::DisplayObserver* observer) override {
100 NOTREACHED();
101 }
95 102
96 void RemoveObserver(gfx::DisplayObserver* observer) override { NOTREACHED(); } 103 void RemoveObserver(display::DisplayObserver* observer) override {
104 NOTREACHED();
105 }
97 106
98 void AddDisplay(const gfx::Rect& bounds, 107 void AddDisplay(const gfx::Rect& bounds,
99 const gfx::Rect& work_area) { 108 const gfx::Rect& work_area) {
100 gfx::Display display(displays_.size(), bounds); 109 display::Display display(displays_.size(), bounds);
101 display.set_work_area(work_area); 110 display.set_work_area(work_area);
102 displays_.push_back(display); 111 displays_.push_back(display);
103 } 112 }
104 113
105 private: 114 private:
106 gfx::Screen* previous_screen_; 115 display::Screen* previous_screen_;
107 size_t index_of_display_nearest_window_ = 0u; 116 size_t index_of_display_nearest_window_ = 0u;
108 std::vector<gfx::Display> displays_; 117 std::vector<display::Display> displays_;
109 118
110 DISALLOW_COPY_AND_ASSIGN(TestScreen); 119 DISALLOW_COPY_AND_ASSIGN(TestScreen);
111 }; 120 };
112 121
113 class TestTargetDisplayProvider : public WindowSizer::TargetDisplayProvider { 122 class TestTargetDisplayProvider : public WindowSizer::TargetDisplayProvider {
114 public: 123 public:
115 TestTargetDisplayProvider() {} 124 TestTargetDisplayProvider() {}
116 ~TestTargetDisplayProvider() override {} 125 ~TestTargetDisplayProvider() override {}
117 126
118 gfx::Display GetTargetDisplay(const gfx::Screen* screen, 127 display::Display GetTargetDisplay(const display::Screen* screen,
119 const gfx::Rect& bounds) const override { 128 const gfx::Rect& bounds) const override {
120 // On ash, the bounds is used as a indicator to specify 129 // On ash, the bounds is used as a indicator to specify
121 // the target display. 130 // the target display.
122 return screen->GetDisplayMatching(bounds); 131 return screen->GetDisplayMatching(bounds);
123 } 132 }
124 133
125 private: 134 private:
126 DISALLOW_COPY_AND_ASSIGN(TestTargetDisplayProvider); 135 DISALLOW_COPY_AND_ASSIGN(TestTargetDisplayProvider);
127 }; 136 };
128 137
129 } // namespace 138 } // namespace
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 { // Check that a window which hangs out of the screen get moved back in. 465 { // Check that a window which hangs out of the screen get moved back in.
457 gfx::Rect window_bounds; 466 gfx::Rect window_bounds;
458 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(), 467 GetWindowBounds(p1024x768, p1024x768, gfx::Rect(), gfx::Rect(),
459 gfx::Rect(), DEFAULT, NULL, 468 gfx::Rect(), DEFAULT, NULL,
460 gfx::Rect(1020, 700, 100, 100), &window_bounds); 469 gfx::Rect(1020, 700, 100, 100), &window_bounds);
461 EXPECT_EQ("924,668 100x100", window_bounds.ToString()); 470 EXPECT_EQ("924,668 100x100", window_bounds.ToString());
462 } 471 }
463 } 472 }
464 473
465 #endif // defined(OS_MACOSX) 474 #endif // defined(OS_MACOSX)
OLDNEW
« no previous file with comments | « chrome/browser/ui/window_sizer/window_sizer_ash_unittest.cc ('k') | chrome/test/base/view_event_test_platform_part_default.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698