[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 1 | // Copyright (c) 2013 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 "remoting/host/screen_resolution.h" |
| 6 | |
avi | c5960f3 | 2015-12-22 22:49:48 | [diff] [blame] | 7 | #include <stdint.h> |
| 8 | |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 9 | #include <limits> |
| 10 | |
| 11 | #include "testing/gmock/include/gmock/gmock.h" |
| 12 | #include "testing/gtest/include/gtest/gtest.h" |
| 13 | |
| 14 | namespace remoting { |
| 15 | |
| 16 | TEST(ScreenResolutionTest, Empty) { |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 17 | ScreenResolution resolution1( |
| 18 | webrtc::DesktopSize(100, 100), webrtc::DesktopVector(10, 10)); |
| 19 | EXPECT_FALSE(resolution1.IsEmpty()); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 20 | |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 21 | ScreenResolution resolution2( |
| 22 | webrtc::DesktopSize(), webrtc::DesktopVector(10, 10)); |
| 23 | EXPECT_TRUE(resolution2.IsEmpty()); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 24 | |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 25 | ScreenResolution resolution3( |
| 26 | webrtc::DesktopSize(1, 1), webrtc::DesktopVector(0, 0)); |
| 27 | EXPECT_TRUE(resolution3.IsEmpty()); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | TEST(ScreenResolutionTest, Scaling) { |
| 31 | ScreenResolution resolution( |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 32 | webrtc::DesktopSize(100, 100), webrtc::DesktopVector(10, 10)); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 33 | |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 34 | EXPECT_TRUE(webrtc::DesktopSize(50, 50).equals( |
| 35 | resolution.ScaleDimensionsToDpi(webrtc::DesktopVector(5, 5)))); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 36 | |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 37 | EXPECT_TRUE(webrtc::DesktopSize(200, 200).equals( |
| 38 | resolution.ScaleDimensionsToDpi(webrtc::DesktopVector(20, 20)))); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | TEST(ScreenResolutionTest, ScalingSaturation) { |
| 42 | ScreenResolution resolution( |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 43 | webrtc::DesktopSize(10000000, 1000000), webrtc::DesktopVector(1, 1)); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 44 | |
avi | c5960f3 | 2015-12-22 22:49:48 | [diff] [blame] | 45 | int32_t max_int = std::numeric_limits<int32_t>::max(); |
[email protected] | b9ed58f | 2013-05-16 10:45:24 | [diff] [blame] | 46 | EXPECT_TRUE(webrtc::DesktopSize(max_int, max_int).equals( |
| 47 | resolution.ScaleDimensionsToDpi( |
| 48 | webrtc::DesktopVector(1000000, 1000000)))); |
[email protected] | 739e280 | 2013-03-18 01:03:48 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | } // namespace remoting |