12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "remoting/host/screen_resolution.h"
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <limits>
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "testing/gmock/include/gmock/gmock.h"
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace remoting {
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST(ScreenResolutionTest, Empty) {
1590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  ScreenResolution resolution1(
1690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      webrtc::DesktopSize(100, 100), webrtc::DesktopVector(10, 10));
1790dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  EXPECT_FALSE(resolution1.IsEmpty());
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
1990dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  ScreenResolution resolution2(
2090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      webrtc::DesktopSize(), webrtc::DesktopVector(10, 10));
2190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  EXPECT_TRUE(resolution2.IsEmpty());
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
2390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  ScreenResolution resolution3(
2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      webrtc::DesktopSize(1, 1), webrtc::DesktopVector(0, 0));
2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  EXPECT_TRUE(resolution3.IsEmpty());
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST(ScreenResolutionTest, Scaling) {
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ScreenResolution resolution(
3090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      webrtc::DesktopSize(100, 100), webrtc::DesktopVector(10, 10));
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3290dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  EXPECT_TRUE(webrtc::DesktopSize(50, 50).equals(
3390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      resolution.ScaleDimensionsToDpi(webrtc::DesktopVector(5, 5))));
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
3590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  EXPECT_TRUE(webrtc::DesktopSize(200, 200).equals(
3690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      resolution.ScaleDimensionsToDpi(webrtc::DesktopVector(20, 20))));
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)TEST(ScreenResolutionTest, ScalingSaturation) {
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ScreenResolution resolution(
4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      webrtc::DesktopSize(10000000, 1000000), webrtc::DesktopVector(1, 1));
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
4390dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  int32 max_int = std::numeric_limits<int32>::max();
4490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)  EXPECT_TRUE(webrtc::DesktopSize(max_int, max_int).equals(
4590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)      resolution.ScaleDimensionsToDpi(
4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)          webrtc::DesktopVector(1000000, 1000000))));
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace remoting
50