| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/gfx/display_change_notifier.h" | 5 #include "ui/gfx/display_change_notifier.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/gfx/display.h" | 8 #include "ui/gfx/display.h" |
| 9 #include "ui/gfx/display_observer.h" | 9 #include "ui/gfx/display_observer.h" |
| 10 | 10 |
| 11 namespace gfx { | 11 namespace gfx { |
| 12 | 12 |
| 13 class MockDisplayObserver : public DisplayObserver { | 13 class MockDisplayObserver : public DisplayObserver { |
| 14 public: | 14 public: |
| 15 MockDisplayObserver() | 15 MockDisplayObserver() |
| 16 : display_added_(0), | 16 : display_added_(0), |
| 17 display_removed_(0), | 17 display_removed_(0), |
| 18 display_changed_(0), | 18 display_changed_(0), |
| 19 latest_metrics_change_(DisplayObserver::DISPLAY_METRIC_NONE) | 19 latest_metrics_change_(DisplayObserver::DISPLAY_METRIC_NONE) |
| 20 {} | 20 {} |
| 21 | 21 |
| 22 virtual ~MockDisplayObserver() { } | 22 virtual ~MockDisplayObserver() { } |
| 23 | 23 |
| 24 virtual void OnDisplayAdded(const Display& display) OVERRIDE { | 24 virtual void OnDisplayAdded(const Display& display) override { |
| 25 display_added_++; | 25 display_added_++; |
| 26 } | 26 } |
| 27 | 27 |
| 28 virtual void OnDisplayRemoved(const Display& display) OVERRIDE { | 28 virtual void OnDisplayRemoved(const Display& display) override { |
| 29 display_removed_++; | 29 display_removed_++; |
| 30 } | 30 } |
| 31 | 31 |
| 32 virtual void OnDisplayMetricsChanged(const Display& display, | 32 virtual void OnDisplayMetricsChanged(const Display& display, |
| 33 uint32_t metrics) OVERRIDE { | 33 uint32_t metrics) override { |
| 34 display_changed_++; | 34 display_changed_++; |
| 35 latest_metrics_change_ = metrics; | 35 latest_metrics_change_ = metrics; |
| 36 } | 36 } |
| 37 | 37 |
| 38 int display_added() const { | 38 int display_added() const { |
| 39 return display_added_; | 39 return display_added_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 int display_removed() const { | 42 int display_removed() const { |
| 43 return display_removed_; | 43 return display_removed_; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 change_notifier.NotifyDisplaysChanged(old_displays, new_displays); | 489 change_notifier.NotifyDisplaysChanged(old_displays, new_displays); |
| 490 EXPECT_EQ(1, observer.display_changed()); | 490 EXPECT_EQ(1, observer.display_changed()); |
| 491 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_BOUNDS | | 491 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_BOUNDS | |
| 492 DisplayObserver::DISPLAY_METRIC_ROTATION | | 492 DisplayObserver::DISPLAY_METRIC_ROTATION | |
| 493 DisplayObserver::DISPLAY_METRIC_WORK_AREA | | 493 DisplayObserver::DISPLAY_METRIC_WORK_AREA | |
| 494 DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; | 494 DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; |
| 495 EXPECT_EQ(metrics, observer.latest_metrics_change()); | 495 EXPECT_EQ(metrics, observer.latest_metrics_change()); |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace gfx | 498 } // namespace gfx |
| OLD | NEW |