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