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

Unified Diff: ui/display/test/display_matchers.cc

Issue 2395873002: Add more options to --screen-config flag. (Closed)
Patch Set: Fix windows compile 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/display/test/display_matchers.h ('k') | ui/display/types/display_mode.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/display/test/display_matchers.cc
diff --git a/ui/display/test/display_matchers.cc b/ui/display/test/display_matchers.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9668986491481050a49f0c22567f2095840998c1
--- /dev/null
+++ b/ui/display/test/display_matchers.cc
@@ -0,0 +1,48 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/display/test/display_matchers.h"
+
+namespace display {
+
+namespace {
+
+const float kEpsilon = 0.0001f;
+
+// Matcher to check DisplayMode size and refresh rate.
+class DisplayModeMatcher
+ : public testing::MatcherInterface<const ui::DisplayMode&> {
+ public:
+ DisplayModeMatcher(int width, int height, float refresh_rate)
+ : size_(width, height), refresh_rate_(refresh_rate) {}
+
+ bool MatchAndExplain(const ui::DisplayMode& mode,
+ testing::MatchResultListener* listener) const override {
+ return mode.size() == size_ &&
+ std::fabs(mode.refresh_rate() - refresh_rate_) < kEpsilon;
+ }
+
+ void DescribeTo(std::ostream* os) const override {
+ *os << "[" << size_.ToString() << " rate=" << refresh_rate_ << "]";
+ }
+
+ void DescribeNegationTo(std::ostream* os) const override {
+ *os << "not [" << size_.ToString() << " rate=" << refresh_rate_ << "]";
+ }
+
+ private:
+ gfx::Size size_;
+ float refresh_rate_;
+};
+
+} // namespace
+
+testing::Matcher<const ui::DisplayMode&> IsDisplayMode(int width,
+ int height,
+ float refresh_rate) {
+ return testing::MakeMatcher(
+ new DisplayModeMatcher(width, height, refresh_rate));
+}
+
+} // namespace display
« no previous file with comments | « ui/display/test/display_matchers.h ('k') | ui/display/types/display_mode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698