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

Unified Diff: services/ui/ws/test_utils.cc

Issue 2692863009: Remove usage of ws::Display in ws::UserDisplayManager. (Closed)
Patch Set: Fix mash_browser_tests. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/user_display_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/test_utils.cc
diff --git a/services/ui/ws/test_utils.cc b/services/ui/ws/test_utils.cc
index 914a72fc6bfef0aae509b7196b19740b15b095f4..d29df44fe9c5cc9a0d5a2893fdb4970ae142e3eb 100644
--- a/services/ui/ws/test_utils.cc
+++ b/services/ui/ws/test_utils.cc
@@ -87,13 +87,27 @@ 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;
+}
+
} // namespace
// TestScreenManager -------------------------------------------------
TestScreenManager::TestScreenManager() {}
-TestScreenManager::~TestScreenManager() {}
+TestScreenManager::~TestScreenManager() {
+ display::Screen::SetScreenInstance(nullptr);
+}
int64_t TestScreenManager::AddDisplay() {
return AddDisplay(MakeViewportMetrics(0, 0, 100, 100, 1.0f));
@@ -104,38 +118,42 @@ int64_t TestScreenManager::AddDisplay(const display::ViewportMetrics& metrics) {
int64_t display_id = display_ids_.empty() ? 1 : *display_ids_.rbegin() + 1;
display_ids_.insert(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);
- // First display added will be the primary display.
- if (primary_display_id_ == display::kInvalidDisplayId) {
- primary_display_id_ = display_id;
+ if (type == display::DisplayList::Type::PRIMARY)
delegate_->OnPrimaryDisplayChanged(display_id);
- }
return display_id;
}
-void TestScreenManager::ModifyDisplay(int64_t id,
+void TestScreenManager::ModifyDisplay(int64_t display_id,
const display::ViewportMetrics& metrics) {
- DCHECK(display_ids_.count(id) == 1);
- delegate_->OnDisplayModified(id, metrics);
+ DCHECK(display_ids_.count(display_id) == 1);
+ screen_->display_list().UpdateDisplay(CreateDisplay(display_id, metrics));
+ delegate_->OnDisplayModified(display_id, metrics);
}
-void TestScreenManager::RemoveDisplay(int64_t id) {
- DCHECK(display_ids_.count(id) == 1);
- delegate_->OnDisplayRemoved(id);
- display_ids_.erase(id);
+void TestScreenManager::RemoveDisplay(int64_t display_id) {
+ DCHECK(display_ids_.count(display_id) == 1);
+ screen_->display_list().RemoveDisplay(display_id);
+ delegate_->OnDisplayRemoved(display_id);
+ display_ids_.erase(display_id);
}
void TestScreenManager::Init(display::ScreenManagerDelegate* delegate) {
- // Reset
delegate_ = delegate;
- display_ids_.clear();
- primary_display_id_ = display::kInvalidDisplayId;
-}
-int64_t TestScreenManager::GetPrimaryDisplayId() const {
- return primary_display_id_;
+ // Reset everything.
+ display_ids_.clear();
+ display::Screen::SetScreenInstance(nullptr);
+ screen_ = base::MakeUnique<display::ScreenBase>();
+ display::Screen::SetScreenInstance(screen_.get());
}
// TestPlatformDisplayFactory -------------------------------------------------
« no previous file with comments | « services/ui/ws/test_utils.h ('k') | services/ui/ws/user_display_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698