Index: services/ui/ws/test_utils.cc |
diff --git a/services/ui/ws/test_utils.cc b/services/ui/ws/test_utils.cc |
index d444e0c6798c9025c0376e3fa2b4abf6e2404e56..94e8dbcdf008a2b6bed62508a7663499a84088c7 100644 |
--- a/services/ui/ws/test_utils.cc |
+++ b/services/ui/ws/test_utils.cc |
@@ -13,7 +13,6 @@ |
#include "services/ui/public/interfaces/cursor.mojom.h" |
#include "services/ui/ws/display_binding.h" |
#include "services/ui/ws/display_manager.h" |
-#include "services/ui/ws/platform_display_init_params.h" |
#include "services/ui/ws/window_manager_access_policy.h" |
#include "services/ui/ws/window_manager_window_tree_factory.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -28,21 +27,15 @@ namespace { |
// Empty implementation of PlatformDisplay. |
class TestPlatformDisplay : public PlatformDisplay { |
public: |
- explicit TestPlatformDisplay(const PlatformDisplayInitParams& params, |
+ explicit TestPlatformDisplay(const display::ViewportMetrics& metrics, |
mojom::Cursor* cursor_storage) |
- : id_(params.display_id), |
- display_metrics_(params.metrics), |
- cursor_storage_(cursor_storage) { |
- display_metrics_.bounds = gfx::Rect(0, 0, 400, 300); |
- display_metrics_.device_scale_factor = 1.f; |
- } |
+ : metrics_(metrics), cursor_storage_(cursor_storage) {} |
~TestPlatformDisplay() override {} |
// PlatformDisplay: |
void Init(PlatformDisplayDelegate* delegate) override { |
delegate->OnAcceleratedWidgetAvailable(); |
} |
- int64_t GetId() const override { return id_; } |
void SetViewportSize(const gfx::Size& size) override {} |
void SetTitle(const base::string16& title) override {} |
void SetCapture() override {} |
@@ -52,24 +45,19 @@ class TestPlatformDisplay : public PlatformDisplay { |
} |
void UpdateTextInputState(const ui::TextInputState& state) override {} |
void SetImeVisibility(bool visible) override {} |
- gfx::Rect GetBounds() const override { return display_metrics_.bounds; } |
bool UpdateViewportMetrics(const display::ViewportMetrics& metrics) override { |
- if (display_metrics_ == metrics) |
+ if (metrics_ == metrics) |
return false; |
- display_metrics_ = metrics; |
+ metrics_ = metrics; |
return true; |
} |
- const display::ViewportMetrics& GetViewportMetrics() const override { |
- return display_metrics_; |
- } |
gfx::AcceleratedWidget GetAcceleratedWidget() const override { |
return gfx::kNullAcceleratedWidget; |
} |
FrameGenerator* GetFrameGenerator() override { return nullptr; } |
private: |
- const int64_t id_; |
- display::ViewportMetrics display_metrics_; |
+ display::ViewportMetrics metrics_; |
mojom::Cursor* cursor_storage_; |
DISALLOW_COPY_AND_ASSIGN(TestPlatformDisplay); |
@@ -86,16 +74,14 @@ ClientWindowId NextUnusedClientWindowId(WindowTree* tree) { |
} |
} |
-// Creates a Display with |id| and same attributes as |metrics|. |
-display::Display CreateDisplay(int64_t id, |
- const display::ViewportMetrics& metrics) { |
- display::Display display(id); |
- display.set_bounds(metrics.bounds); |
- display.set_work_area(metrics.work_area); |
- display.set_device_scale_factor(metrics.device_scale_factor); |
- display.set_rotation(metrics.rotation); |
- display.set_touch_support(metrics.touch_support); |
- return display; |
+display::ViewportMetrics MakeViewportMetrics(const display::Display& display) { |
+ gfx::Size pixel_size = gfx::ConvertSizeToPixel(display.device_scale_factor(), |
+ display.bounds().size()); |
+ |
+ display::ViewportMetrics metrics; |
+ metrics.bounds_in_pixels.set_size(pixel_size); |
+ metrics.device_scale_factor = display.device_scale_factor(); |
+ return metrics; |
} |
} // namespace |
@@ -109,21 +95,25 @@ TestScreenManager::~TestScreenManager() { |
} |
int64_t TestScreenManager::AddDisplay() { |
- return AddDisplay(MakeViewportMetrics(0, 0, 100, 100, 1.0f)); |
+ return AddDisplay( |
+ display::Display(display::kInvalidDisplayId, gfx::Rect(100, 100))); |
} |
-int64_t TestScreenManager::AddDisplay(const display::ViewportMetrics& metrics) { |
+int64_t TestScreenManager::AddDisplay(const display::Display& input_display) { |
// Generate a unique display id. |
int64_t display_id = display_ids_.empty() ? 1 : *display_ids_.rbegin() + 1; |
display_ids_.insert(display_id); |
+ display::Display display = input_display; |
+ display.set_id(display_id); |
+ |
// First display added will be the primary display. |
display::DisplayList::Type type = display::DisplayList::Type::NOT_PRIMARY; |
if (display_ids_.size() == 1) |
type = display::DisplayList::Type::PRIMARY; |
- screen_->display_list().AddDisplay(CreateDisplay(display_id, metrics), type); |
- delegate_->OnDisplayAdded(display_id, metrics); |
+ screen_->display_list().AddDisplay(display, type); |
+ delegate_->OnDisplayAdded(display, MakeViewportMetrics(display)); |
if (type == display::DisplayList::Type::PRIMARY) |
delegate_->OnPrimaryDisplayChanged(display_id); |
@@ -131,11 +121,10 @@ int64_t TestScreenManager::AddDisplay(const display::ViewportMetrics& metrics) { |
return display_id; |
} |
-void TestScreenManager::ModifyDisplay(int64_t display_id, |
- const display::ViewportMetrics& metrics) { |
- DCHECK(display_ids_.count(display_id) == 1); |
- screen_->display_list().UpdateDisplay(CreateDisplay(display_id, metrics)); |
- delegate_->OnDisplayModified(display_id, metrics); |
+void TestScreenManager::ModifyDisplay(const display::Display& display) { |
+ DCHECK(display_ids_.count(display.id()) == 1); |
+ screen_->display_list().UpdateDisplay(display); |
+ delegate_->OnDisplayModified(display, MakeViewportMetrics(display)); |
} |
void TestScreenManager::RemoveDisplay(int64_t display_id) { |
@@ -165,8 +154,9 @@ TestPlatformDisplayFactory::~TestPlatformDisplayFactory() {} |
std::unique_ptr<PlatformDisplay> |
TestPlatformDisplayFactory::CreatePlatformDisplay( |
- const PlatformDisplayInitParams& init_params) { |
- return base::MakeUnique<TestPlatformDisplay>(init_params, cursor_storage_); |
+ ServerWindow* root_window, |
+ const display::ViewportMetrics& metrics) { |
+ return base::MakeUnique<TestPlatformDisplay>(metrics, cursor_storage_); |
} |
// TestFrameGeneratorDelegate ------------------------------------------------- |
@@ -522,7 +512,7 @@ WindowServerTestHelper::~WindowServerTestHelper() { |
WindowEventTargetingHelper::WindowEventTargetingHelper() { |
display_ = new Display(window_server()); |
display_binding_ = new TestDisplayBinding(window_server()); |
- display_->Init(PlatformDisplayInitParams(), |
+ display_->Init(display::ViewportMetrics(), |
base::WrapUnique(display_binding_)); |
wm_client_ = ws_test_helper_.window_server_delegate()->last_client(); |
wm_client_->tracker()->changes()->clear(); |
@@ -602,19 +592,20 @@ void AddWindowManager(WindowServer* window_server, const UserId& user_id) { |
->CreateWindowTree(nullptr, nullptr); |
} |
-display::ViewportMetrics MakeViewportMetrics(int origin_x, |
- int origin_y, |
- int width_pixels, |
- int height_pixels, |
- float scale_factor) { |
- display::ViewportMetrics metrics; |
+display::Display MakeDisplay(int origin_x, |
+ int origin_y, |
+ int width_pixels, |
+ int height_pixels, |
+ float scale_factor) { |
gfx::Size scaled_size = gfx::ConvertSizeToDIP( |
scale_factor, gfx::Size(width_pixels, height_pixels)); |
- metrics.bounds = gfx::Rect(gfx::Point(origin_x, origin_y), scaled_size); |
- metrics.work_area = metrics.bounds; |
- metrics.pixel_size = gfx::Size(width_pixels, height_pixels); |
- metrics.device_scale_factor = scale_factor; |
- return metrics; |
+ gfx::Rect bounds(gfx::Point(origin_x, origin_y), scaled_size); |
+ |
+ display::Display display; |
+ display.set_bounds(bounds); |
+ display.set_work_area(bounds); |
+ display.set_device_scale_factor(scale_factor); |
+ return display; |
} |
ServerWindow* FirstRoot(WindowTree* tree) { |