blob: 0b6686564cdd6e109b8dca04cf6eba7ff33c5ef5 [file] [log] [blame]
[email protected]739e2802013-03-18 01:03:481// 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
avic5960f32015-12-22 22:49:487#include <stdint.h>
8
[email protected]739e2802013-03-18 01:03:489#include <limits>
10
11#include "testing/gmock/include/gmock/gmock.h"
12#include "testing/gtest/include/gtest/gtest.h"
13
14namespace remoting {
15
16TEST(ScreenResolutionTest, Empty) {
[email protected]b9ed58f2013-05-16 10:45:2417 ScreenResolution resolution1(
18 webrtc::DesktopSize(100, 100), webrtc::DesktopVector(10, 10));
19 EXPECT_FALSE(resolution1.IsEmpty());
[email protected]739e2802013-03-18 01:03:4820
[email protected]b9ed58f2013-05-16 10:45:2421 ScreenResolution resolution2(
22 webrtc::DesktopSize(), webrtc::DesktopVector(10, 10));
23 EXPECT_TRUE(resolution2.IsEmpty());
[email protected]739e2802013-03-18 01:03:4824
[email protected]b9ed58f2013-05-16 10:45:2425 ScreenResolution resolution3(
26 webrtc::DesktopSize(1, 1), webrtc::DesktopVector(0, 0));
27 EXPECT_TRUE(resolution3.IsEmpty());
[email protected]739e2802013-03-18 01:03:4828}
29
30TEST(ScreenResolutionTest, Scaling) {
31 ScreenResolution resolution(
[email protected]b9ed58f2013-05-16 10:45:2432 webrtc::DesktopSize(100, 100), webrtc::DesktopVector(10, 10));
[email protected]739e2802013-03-18 01:03:4833
[email protected]b9ed58f2013-05-16 10:45:2434 EXPECT_TRUE(webrtc::DesktopSize(50, 50).equals(
35 resolution.ScaleDimensionsToDpi(webrtc::DesktopVector(5, 5))));
[email protected]739e2802013-03-18 01:03:4836
[email protected]b9ed58f2013-05-16 10:45:2437 EXPECT_TRUE(webrtc::DesktopSize(200, 200).equals(
38 resolution.ScaleDimensionsToDpi(webrtc::DesktopVector(20, 20))));
[email protected]739e2802013-03-18 01:03:4839}
40
41TEST(ScreenResolutionTest, ScalingSaturation) {
42 ScreenResolution resolution(
[email protected]b9ed58f2013-05-16 10:45:2443 webrtc::DesktopSize(10000000, 1000000), webrtc::DesktopVector(1, 1));
[email protected]739e2802013-03-18 01:03:4844
avic5960f32015-12-22 22:49:4845 int32_t max_int = std::numeric_limits<int32_t>::max();
[email protected]b9ed58f2013-05-16 10:45:2446 EXPECT_TRUE(webrtc::DesktopSize(max_int, max_int).equals(
47 resolution.ScaleDimensionsToDpi(
48 webrtc::DesktopVector(1000000, 1000000))));
[email protected]739e2802013-03-18 01:03:4849}
50
51} // namespace remoting