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 namespace display { |
| 8 |
| 9 namespace { |
| 10 |
| 11 const float kEpsilon = 0.0001f; |
| 12 |
| 13 // Matcher to check DisplayMode size and refresh rate. |
| 14 class DisplayModeMatcher |
| 15 : public testing::MatcherInterface<const ui::DisplayMode&> { |
| 16 public: |
| 17 DisplayModeMatcher(int width, int height, float refresh_rate) |
| 18 : size_(width, height), refresh_rate_(refresh_rate) {} |
| 19 |
| 20 bool MatchAndExplain(const ui::DisplayMode& mode, |
| 21 testing::MatchResultListener* listener) const override { |
| 22 return mode.size() == size_ && |
| 23 std::fabs(mode.refresh_rate() - refresh_rate_) < kEpsilon; |
| 24 } |
| 25 |
| 26 void DescribeTo(std::ostream* os) const override { |
| 27 *os << "[" << size_.ToString() << " rate=" << refresh_rate_ << "]"; |
| 28 } |
| 29 |
| 30 void DescribeNegationTo(std::ostream* os) const override { |
| 31 *os << "not [" << size_.ToString() << " rate=" << refresh_rate_ << "]"; |
| 32 } |
| 33 |
| 34 private: |
| 35 gfx::Size size_; |
| 36 float refresh_rate_; |
| 37 }; |
| 38 |
| 39 } // namespace |
| 40 |
| 41 testing::Matcher<const ui::DisplayMode&> IsDisplayMode(int width, |
| 42 int height, |
| 43 float refresh_rate) { |
| 44 return testing::MakeMatcher( |
| 45 new DisplayModeMatcher(width, height, refresh_rate)); |
| 46 } |
| 47 |
| 48 } // namespace display |
OLD | NEW |