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

Unified Diff: remoting/host/screen_resolution_unittest.cc

Issue 12678008: Reworked the plumbing required to pass the client resolution to the desktop resizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback Created 7 years, 9 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 | « remoting/host/screen_resolution.cc ('k') | remoting/host/session_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/screen_resolution_unittest.cc
diff --git a/remoting/host/screen_resolution_unittest.cc b/remoting/host/screen_resolution_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dce7bc0cd2c7defa0c032a2f8ec3efdfb7e7dfc0
--- /dev/null
+++ b/remoting/host/screen_resolution_unittest.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2013 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 "remoting/host/screen_resolution.h"
+
+#include <limits>
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace remoting {
+
+TEST(ScreenResolutionTest, Empty) {
+ ScreenResolution resolution;
+ EXPECT_TRUE(resolution.IsEmpty());
+
+ resolution.dimensions_.set(-1, 0);
+ EXPECT_TRUE(resolution.IsEmpty());
+
+ resolution.dimensions_.set(0, -1);
+ EXPECT_TRUE(resolution.IsEmpty());
+
+ resolution.dimensions_.set(-1, -1);
+ EXPECT_TRUE(resolution.IsEmpty());
+
+ resolution.dpi_.set(-1, 0);
+ EXPECT_TRUE(resolution.IsEmpty());
+
+ resolution.dpi_.set(0, -1);
+ EXPECT_TRUE(resolution.IsEmpty());
+
+ resolution.dpi_.set(-1, -1);
+ EXPECT_TRUE(resolution.IsEmpty());
+}
+
+TEST(ScreenResolutionTest, Invalid) {
+ ScreenResolution resolution;
+ EXPECT_TRUE(resolution.IsValid());
+
+ resolution.dimensions_.set(-1, 0);
+ EXPECT_FALSE(resolution.IsValid());
+
+ resolution.dimensions_.set(0, -1);
+ EXPECT_FALSE(resolution.IsValid());
+
+ resolution.dimensions_.set(-1, -1);
+ EXPECT_FALSE(resolution.IsValid());
+
+ resolution.dpi_.set(-1, 0);
+ EXPECT_FALSE(resolution.IsValid());
+
+ resolution.dpi_.set(0, -1);
+ EXPECT_FALSE(resolution.IsValid());
+
+ resolution.dpi_.set(-1, -1);
+ EXPECT_FALSE(resolution.IsValid());
+}
+
+TEST(ScreenResolutionTest, Scaling) {
+ ScreenResolution resolution(
+ SkISize::Make(100, 100), SkIPoint::Make(10, 10));
+
+ EXPECT_EQ(resolution.ScaleDimensionsToDpi(SkIPoint::Make(5, 5)),
+ SkISize::Make(50, 50));
+
+ EXPECT_EQ(resolution.ScaleDimensionsToDpi(SkIPoint::Make(20, 20)),
+ SkISize::Make(200, 200));
+}
+
+TEST(ScreenResolutionTest, ScalingSaturation) {
+ ScreenResolution resolution(
+ SkISize::Make(10000000, 1000000), SkIPoint::Make(1, 1));
+
+ EXPECT_EQ(resolution.ScaleDimensionsToDpi(SkIPoint::Make(1000000, 1000000)),
+ SkISize::Make(std::numeric_limits<int32>::max(),
+ std::numeric_limits<int32>::max()));
+}
+
+} // namespace remoting
« no previous file with comments | « remoting/host/screen_resolution.cc ('k') | remoting/host/session_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698