Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(468)

Side by Side Diff: ui/display/test/display_matchers.cc

Issue 2395873002: Add more options to --screen-config flag. (Closed)
Patch Set: Move matcher + add epsilon. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698