| 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 ~MockDisplayObserver() override {} |
| 23 | 23 |
| 24 virtual void OnDisplayAdded(const Display& display) override { | 24 void OnDisplayAdded(const Display& display) override { display_added_++; } |
| 25 display_added_++; | |
| 26 } | |
| 27 | 25 |
| 28 virtual void OnDisplayRemoved(const Display& display) override { | 26 void OnDisplayRemoved(const Display& display) override { display_removed_++; } |
| 29 display_removed_++; | |
| 30 } | |
| 31 | 27 |
| 32 virtual void OnDisplayMetricsChanged(const Display& display, | 28 void OnDisplayMetricsChanged(const Display& display, |
| 33 uint32_t metrics) override { | 29 uint32_t metrics) override { |
| 34 display_changed_++; | 30 display_changed_++; |
| 35 latest_metrics_change_ = metrics; | 31 latest_metrics_change_ = metrics; |
| 36 } | 32 } |
| 37 | 33 |
| 38 int display_added() const { | 34 int display_added() const { |
| 39 return display_added_; | 35 return display_added_; |
| 40 } | 36 } |
| 41 | 37 |
| 42 int display_removed() const { | 38 int display_removed() const { |
| 43 return display_removed_; | 39 return display_removed_; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 change_notifier.NotifyDisplaysChanged(old_displays, new_displays); | 485 change_notifier.NotifyDisplaysChanged(old_displays, new_displays); |
| 490 EXPECT_EQ(1, observer.display_changed()); | 486 EXPECT_EQ(1, observer.display_changed()); |
| 491 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_BOUNDS | | 487 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_BOUNDS | |
| 492 DisplayObserver::DISPLAY_METRIC_ROTATION | | 488 DisplayObserver::DISPLAY_METRIC_ROTATION | |
| 493 DisplayObserver::DISPLAY_METRIC_WORK_AREA | | 489 DisplayObserver::DISPLAY_METRIC_WORK_AREA | |
| 494 DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; | 490 DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; |
| 495 EXPECT_EQ(metrics, observer.latest_metrics_change()); | 491 EXPECT_EQ(metrics, observer.latest_metrics_change()); |
| 496 } | 492 } |
| 497 | 493 |
| 498 } // namespace gfx | 494 } // namespace gfx |
| OLD | NEW |