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

Unified Diff: ui/aura/test/test_screen.cc

Issue 2207043002: SetDeviceScaleFactorForTest Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: SetDeviceScaleFactorForTest Created 4 years, 4 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 | « ui/aura/test/test_screen.h ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/test/test_screen.cc
diff --git a/ui/aura/test/test_screen.cc b/ui/aura/test/test_screen.cc
index f19137c6dc5e3e675e1171ab4c42aa24dda6b905..349ca5eec19f56316e74cfe17a71426119c64f38 100644
--- a/ui/aura/test/test_screen.cc
+++ b/ui/aura/test/test_screen.cc
@@ -6,6 +6,8 @@
#include <stdint.h>
+#include <vector>
+
#include "base/logging.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
@@ -39,21 +41,14 @@ TestScreen* TestScreen::Create(const gfx::Size& size) {
TestScreen::~TestScreen() {
}
-WindowTreeHost* TestScreen::CreateHostForPrimaryDisplay() {
- DCHECK(!host_);
- host_ = WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel()));
+void TestScreen::CreateHostForPrimaryDisplay() {
+ DCHECK(!host_.get());
+ host_.reset(WindowTreeHost::Create(gfx::Rect(display_.GetSizeInPixel())));
// Some tests don't correctly manage window focus/activation states.
// Makes sure InputMethod is default focused so that IME basics can work.
host_->GetInputMethod()->OnFocus();
host_->window()->AddObserver(this);
host_->InitHost();
- return host_;
-}
-
-void TestScreen::SetDeviceScaleFactor(float device_scale_factor) {
- gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
- display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
- host_->OnHostResized(bounds_in_pixel.size());
}
void TestScreen::SetDisplayRotation(display::Display::Rotation rotation) {
@@ -121,11 +116,6 @@ void TestScreen::OnWindowBoundsChanged(
display_.device_scale_factor()));
}
-void TestScreen::OnWindowDestroying(Window* window) {
- if (host_->window() == window)
- host_ = NULL;
-}
-
gfx::Point TestScreen::GetCursorScreenPoint() {
return Env::GetInstance()->last_mouse_location();
}
@@ -163,13 +153,30 @@ display::Display TestScreen::GetDisplayMatching(
return display_;
}
-void TestScreen::AddObserver(display::DisplayObserver* observer) {}
+void TestScreen::AddObserver(display::DisplayObserver* observer) {
+ notifier_.AddObserver(observer);
+}
+
+void TestScreen::RemoveObserver(display::DisplayObserver* observer) {
+ notifier_.RemoveObserver(observer);
+}
+
+void TestScreen::SetDeviceScaleFactorForTest(float device_scale_factor) {
+ gfx::Rect bounds_in_pixel(display_.GetSizeInPixel());
-void TestScreen::RemoveObserver(display::DisplayObserver* observer) {}
+ std::vector<display::Display> old_displays;
+ old_displays.push_back(display_);
+ display_.SetScaleAndBounds(device_scale_factor, bounds_in_pixel);
+ std::vector<display::Display> new_displays;
+ new_displays.push_back(display_);
+ LOG(ERROR) << "Calling On Host Resized: display=" << display_.ToString();
+ host_->OnHostResized(bounds_in_pixel.size());
+ LOG(ERROR) << "Calling On Host Resized: Done";
+ notifier_.NotifyDisplaysChanged(old_displays, new_displays);
+}
TestScreen::TestScreen(const gfx::Rect& screen_bounds)
- : host_(NULL),
- ui_scale_(1.0f) {
+ : ui_scale_(1.0f) {
static int64_t synthesized_display_id = 2000;
display_.set_id(synthesized_display_id++);
display_.SetScaleAndBounds(1.0f, screen_bounds);
« no previous file with comments | « ui/aura/test/test_screen.h ('k') | ui/aura/window_event_dispatcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698