OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ui/display/test/display_matchers.h" |
| 6 |
| 7 #include "ui/display/test/display_test_util.h" |
| 8 |
| 9 namespace display { |
| 10 |
| 11 namespace { |
| 12 |
| 13 const float kEpsilon = 0.0001f; |
| 14 |
| 15 // Matcher to check DisplayMode size and refresh rate. |
| 16 class DisplayModeMatcher |
| 17 : public testing::MatcherInterface<const ui::DisplayMode&> { |
| 18 public: |
| 19 DisplayModeMatcher(int width, int height, float refresh_rate) |
| 20 : size_(width, height), refresh_rate_(refresh_rate) {} |
| 21 |
| 22 bool MatchAndExplain(const ui::DisplayMode& mode, |
| 23 testing::MatchResultListener* listener) const override { |
| 24 return mode.size() == size_ && |
| 25 std::fabs(mode.refresh_rate() - refresh_rate_) < kEpsilon; |
| 26 } |
| 27 |
| 28 void DescribeTo(std::ostream* os) const override { |
| 29 *os << "[" << size_.ToString() << " rate=" << refresh_rate_ << "]"; |
| 30 } |
| 31 |
| 32 void DescribeNegationTo(std::ostream* os) const override { |
| 33 *os << "not [" << size_.ToString() << " rate=" << refresh_rate_ << "]"; |
| 34 } |
| 35 |
| 36 private: |
| 37 gfx::Size size_; |
| 38 float refresh_rate_; |
| 39 }; |
| 40 |
| 41 } // namespace |
| 42 |
| 43 testing::Matcher<const ui::DisplayMode&> IsDisplayMode(int width, |
| 44 int height, |
| 45 float refresh_rate) { |
| 46 return testing::MakeMatcher( |
| 47 new DisplayModeMatcher(width, height, refresh_rate)); |
| 48 } |
| 49 |
| 50 } // namespace display |
OLD | NEW |