OLD | NEW |
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 "ui/aura/test/test_screen.h" | 5 #include "ui/aura/test/test_screen.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
| 11 #include "ui/aura/mus/window_tree_client.h" |
| 12 #include "ui/aura/test/mus/window_tree_client_private.h" |
11 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
12 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
13 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
14 #include "ui/base/ime/input_method.h" | 16 #include "ui/base/ime/input_method.h" |
15 #include "ui/display/screen.h" | 17 #include "ui/display/screen.h" |
16 #include "ui/gfx/geometry/rect_conversions.h" | 18 #include "ui/gfx/geometry/rect_conversions.h" |
17 #include "ui/gfx/geometry/size_conversions.h" | 19 #include "ui/gfx/geometry/size_conversions.h" |
18 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
19 | 21 |
20 namespace aura { | 22 namespace aura { |
21 | 23 |
22 namespace { | 24 namespace { |
23 | 25 |
24 bool IsRotationPortrait(display::Display::Rotation rotation) { | 26 bool IsRotationPortrait(display::Display::Rotation rotation) { |
25 return rotation == display::Display::ROTATE_90 || | 27 return rotation == display::Display::ROTATE_90 || |
26 rotation == display::Display::ROTATE_270; | 28 rotation == display::Display::ROTATE_270; |
27 } | 29 } |
28 | 30 |
29 } // namespace | 31 } // namespace |
30 | 32 |
31 // static | 33 // static |
32 TestScreen* TestScreen::Create(const gfx::Size& size) { | 34 TestScreen* TestScreen::Create(const gfx::Size& size, |
| 35 WindowTreeClient* window_tree_client) { |
33 const gfx::Size kDefaultSize(800, 600); | 36 const gfx::Size kDefaultSize(800, 600); |
34 // Use (0,0) because the desktop aura tests are executed in | 37 // Use (0,0) because the desktop aura tests are executed in |
35 // native environment where the display's origin is (0,0). | 38 // native environment where the display's origin is (0,0). |
36 return new TestScreen(gfx::Rect(size.IsEmpty() ? kDefaultSize : size)); | 39 return new TestScreen(gfx::Rect(size.IsEmpty() ? kDefaultSize : size), |
| 40 window_tree_client); |
37 } | 41 } |
38 | 42 |
39 TestScreen::~TestScreen() { | 43 TestScreen::~TestScreen() { |
40 } | 44 } |
41 | 45 |
42 WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() { | 46 WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() { |
43 DCHECK(!host_); | 47 DCHECK(!host_); |
44 host_ = WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel())); | 48 if (window_tree_client_) { |
| 49 host_ = WindowTreeClientPrivate(window_tree_client_) |
| 50 .CallWmNewDisplayAdded(display_); |
| 51 } else { |
| 52 host_ = WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel())); |
| 53 } |
45 // Some tests don't correctly manage window focus/activation states. | 54 // Some tests don't correctly manage window focus/activation states. |
46 // Makes sure InputMethod is default focused so that IME basics can work. | 55 // Makes sure InputMethod is default focused so that IME basics can work. |
47 host_->GetInputMethod()->OnFocus(); | 56 host_->GetInputMethod()->OnFocus(); |
48 host_->window()->AddObserver(this); | 57 host_->window()->AddObserver(this); |
49 host_->InitHost(); | 58 host_->InitHost(); |
50 return host_; | 59 return host_; |
51 } | 60 } |
52 | 61 |
53 void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { | 62 void TestScreen::SetDeviceScaleFactor(float device_scale_factor) { |
54 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); | 63 gfx::Rect bounds_in_pixel(display_.GetSizeInPixel()); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 169 |
161 display::Display TestScreen::GetDisplayMatching( | 170 display::Display TestScreen::GetDisplayMatching( |
162 const gfx::Rect& match_rect) const { | 171 const gfx::Rect& match_rect) const { |
163 return display_; | 172 return display_; |
164 } | 173 } |
165 | 174 |
166 void TestScreen::AddObserver(display::DisplayObserver* observer) {} | 175 void TestScreen::AddObserver(display::DisplayObserver* observer) {} |
167 | 176 |
168 void TestScreen::RemoveObserver(display::DisplayObserver* observer) {} | 177 void TestScreen::RemoveObserver(display::DisplayObserver* observer) {} |
169 | 178 |
170 TestScreen::TestScreen(const gfx::Rect& screen_bounds) | 179 TestScreen::TestScreen(const gfx::Rect& screen_bounds, |
171 : host_(NULL), | 180 WindowTreeClient* window_tree_client) |
172 ui_scale_(1.0f) { | 181 : host_(nullptr), ui_scale_(1.0f), window_tree_client_(window_tree_client) { |
173 static int64_t synthesized_display_id = 2000; | 182 static int64_t synthesized_display_id = 2000; |
174 display_.set_id(synthesized_display_id++); | 183 display_.set_id(synthesized_display_id++); |
175 display_.SetScaleAndBounds(1.0f, screen_bounds); | 184 display_.SetScaleAndBounds(1.0f, screen_bounds); |
176 } | 185 } |
177 | 186 |
178 } // namespace aura | 187 } // namespace aura |
OLD | NEW |