| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/widget/desktop_aura/desktop_screen_x11.h" | 5 #include "ui/views/widget/desktop_aura/desktop_screen_x11.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "ui/aura/client/aura_constants.h" | 12 #include "ui/aura/client/aura_constants.h" |
| 13 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
| 14 #include "ui/aura/window_event_dispatcher.h" | 14 #include "ui/aura/window_event_dispatcher.h" |
| 15 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
| 16 #include "ui/base/x/x11_util.h" | 16 #include "ui/base/x/x11_util.h" |
| 17 #include "ui/events/test/event_generator.h" | 17 #include "ui/events/test/event_generator.h" |
| 18 #include "ui/gfx/display_observer.h" | 18 #include "ui/gfx/display_observer.h" |
| 19 #include "ui/gfx/font_render_params.h" |
| 19 #include "ui/gfx/x/x11_types.h" | 20 #include "ui/gfx/x/x11_types.h" |
| 20 #include "ui/views/test/views_test_base.h" | 21 #include "ui/views/test/views_test_base.h" |
| 21 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 22 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 22 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" | 23 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h" |
| 23 | 24 |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| 26 // Class which allows for the designation of non-client component targets of | 27 // Class which allows for the designation of non-client component targets of |
| 27 // hit tests. | 28 // hit tests. |
| 28 class TestDesktopNativeWidgetAura : public views::DesktopNativeWidgetAura { | 29 class TestDesktopNativeWidgetAura : public views::DesktopNativeWidgetAura { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 } | 77 } |
| 77 | 78 |
| 78 protected: | 79 protected: |
| 79 std::vector<gfx::Display> changed_display_; | 80 std::vector<gfx::Display> changed_display_; |
| 80 std::vector<gfx::Display> added_display_; | 81 std::vector<gfx::Display> added_display_; |
| 81 std::vector<gfx::Display> removed_display_; | 82 std::vector<gfx::Display> removed_display_; |
| 82 | 83 |
| 83 DesktopScreenX11* screen() { return screen_.get(); } | 84 DesktopScreenX11* screen() { return screen_.get(); } |
| 84 | 85 |
| 85 void NotifyDisplaysChanged(const std::vector<gfx::Display>& displays) { | 86 void NotifyDisplaysChanged(const std::vector<gfx::Display>& displays) { |
| 86 DesktopScreenX11* screen = screen_.get(); | 87 std::vector<gfx::Display> old_displays = screen_->displays_; |
| 87 screen->change_notifier_.NotifyDisplaysChanged(screen->displays_, displays); | 88 screen_->SetDisplaysInternal(displays); |
| 88 screen->displays_ = displays; | 89 screen_->change_notifier_.NotifyDisplaysChanged(old_displays, |
| 90 screen_->displays_); |
| 89 } | 91 } |
| 90 | 92 |
| 91 void ResetDisplayChanges() { | 93 void ResetDisplayChanges() { |
| 92 changed_display_.clear(); | 94 changed_display_.clear(); |
| 93 added_display_.clear(); | 95 added_display_.clear(); |
| 94 removed_display_.clear(); | 96 removed_display_.clear(); |
| 95 } | 97 } |
| 96 | 98 |
| 97 Widget* BuildTopLevelDesktopWidget(const gfx::Rect& bounds, | 99 Widget* BuildTopLevelDesktopWidget(const gfx::Rect& bounds, |
| 98 bool use_test_native_widget) { | 100 bool use_test_native_widget) { |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 std::vector<gfx::Display> displays; | 434 std::vector<gfx::Display> displays; |
| 433 displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480))); | 435 displays.push_back(gfx::Display(kFirstDisplay, gfx::Rect(0, 0, 640, 480))); |
| 434 displays.push_back( | 436 displays.push_back( |
| 435 gfx::Display(kSecondDisplay, gfx::Rect(640, 0, 1024, 768))); | 437 gfx::Display(kSecondDisplay, gfx::Rect(640, 0, 1024, 768))); |
| 436 NotifyDisplaysChanged(displays); | 438 NotifyDisplaysChanged(displays); |
| 437 ResetDisplayChanges(); | 439 ResetDisplayChanges(); |
| 438 | 440 |
| 439 displays[0].set_device_scale_factor(2.5f); | 441 displays[0].set_device_scale_factor(2.5f); |
| 440 NotifyDisplaysChanged(displays); | 442 NotifyDisplaysChanged(displays); |
| 441 EXPECT_EQ(1u, changed_display_.size()); | 443 EXPECT_EQ(1u, changed_display_.size()); |
| 444 EXPECT_EQ(2.5f, gfx::GetFontRenderParamsDeviceScaleFactor()); |
| 442 | 445 |
| 443 displays[1].set_device_scale_factor(2.5f); | 446 displays[1].set_device_scale_factor(2.5f); |
| 444 NotifyDisplaysChanged(displays); | 447 NotifyDisplaysChanged(displays); |
| 445 EXPECT_EQ(2u, changed_display_.size()); | 448 EXPECT_EQ(2u, changed_display_.size()); |
| 446 | 449 |
| 447 displays[0].set_device_scale_factor(2.5f); | 450 displays[0].set_device_scale_factor(2.5f); |
| 448 NotifyDisplaysChanged(displays); | 451 NotifyDisplaysChanged(displays); |
| 449 EXPECT_EQ(2u, changed_display_.size()); | 452 EXPECT_EQ(2u, changed_display_.size()); |
| 450 | 453 |
| 451 displays[1].set_device_scale_factor(2.5f); | 454 displays[1].set_device_scale_factor(2.5f); |
| 452 NotifyDisplaysChanged(displays); | 455 NotifyDisplaysChanged(displays); |
| 453 EXPECT_EQ(2u, changed_display_.size()); | 456 EXPECT_EQ(2u, changed_display_.size()); |
| 454 | 457 |
| 455 displays[0].set_device_scale_factor(1.f); | 458 displays[0].set_device_scale_factor(1.f); |
| 456 displays[1].set_device_scale_factor(1.f); | 459 displays[1].set_device_scale_factor(1.f); |
| 457 NotifyDisplaysChanged(displays); | 460 NotifyDisplaysChanged(displays); |
| 458 EXPECT_EQ(4u, changed_display_.size()); | 461 EXPECT_EQ(4u, changed_display_.size()); |
| 462 EXPECT_EQ(1.f, gfx::GetFontRenderParamsDeviceScaleFactor()); |
| 459 } | 463 } |
| 460 | 464 |
| 461 } // namespace views | 465 } // namespace views |
| OLD | NEW |