Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <list> | 5 #include <list> |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "remoting/host/desktop_resizer.h" | 9 #include "remoting/host/desktop_resizer.h" |
| 10 #include "remoting/host/resizing_host_observer.h" | 10 #include "remoting/host/resizing_host_observer.h" |
| 11 #include "remoting/host/screen_resolution.h" | |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "third_party/skia/include/core/SkSize.h" | 13 #include "third_party/skia/include/core/SkSize.h" |
| 13 | 14 |
| 14 std::ostream& operator<<(std::ostream& os, const SkISize& size) { | 15 std::ostream& operator<<(std::ostream& os, const SkISize& size) { |
| 15 return os << size.width() << "x" << size.height(); | 16 return os << size.width() << "x" << size.height(); |
| 16 } | 17 } |
| 17 | 18 |
| 19 const int kDefaultDPI = 96; | |
|
Jamie
2013/03/15 22:06:27
Anonymous namespace?
alexeypa (please no reviews)
2013/03/15 22:32:12
Not needed. See my previous comment.
| |
| 20 | |
| 18 namespace remoting { | 21 namespace remoting { |
| 19 | 22 |
| 20 class FakeDesktopResizer : public DesktopResizer { | 23 class FakeDesktopResizer : public DesktopResizer { |
| 21 public: | 24 public: |
| 22 FakeDesktopResizer(const SkISize& initial_size, bool exact_size_supported, | 25 FakeDesktopResizer(const SkISize& initial_size, bool exact_size_supported, |
| 23 const SkISize* supported_sizes, int num_supported_sizes) | 26 const SkISize* supported_sizes, int num_supported_sizes) |
| 24 : initial_size_(initial_size), | 27 : initial_size_(initial_size), |
| 25 current_size_(initial_size), | 28 current_size_(initial_size), |
| 26 exact_size_supported_(exact_size_supported), | 29 exact_size_supported_(exact_size_supported), |
| 27 set_size_call_count_(0) { | 30 set_size_call_count_(0) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 75 |
| 73 void SetDesktopResizer(scoped_ptr<FakeDesktopResizer> desktop_resizer) { | 76 void SetDesktopResizer(scoped_ptr<FakeDesktopResizer> desktop_resizer) { |
| 74 CHECK(!desktop_resizer_) << "Call SetDeskopResizer once per test"; | 77 CHECK(!desktop_resizer_) << "Call SetDeskopResizer once per test"; |
| 75 desktop_resizer_ = desktop_resizer.get(); | 78 desktop_resizer_ = desktop_resizer.get(); |
| 76 | 79 |
| 77 resizing_host_observer_.reset( | 80 resizing_host_observer_.reset( |
| 78 new ResizingHostObserver(desktop_resizer.PassAs<DesktopResizer>())); | 81 new ResizingHostObserver(desktop_resizer.PassAs<DesktopResizer>())); |
| 79 } | 82 } |
| 80 | 83 |
| 81 SkISize GetBestSize(const SkISize& client_size) { | 84 SkISize GetBestSize(const SkISize& client_size) { |
| 82 resizing_host_observer_->OnClientResolutionChanged(SkIPoint(), client_size); | 85 resizing_host_observer_->SetScreenResolution(ScreenResolution( |
| 86 client_size, SkIPoint::Make(kDefaultDPI, kDefaultDPI))); | |
| 83 return desktop_resizer_->GetCurrentSize(); | 87 return desktop_resizer_->GetCurrentSize(); |
| 84 } | 88 } |
| 85 | 89 |
| 86 void VerifySizes(const SkISize* client_sizes, const SkISize* expected_sizes, | 90 void VerifySizes(const SkISize* client_sizes, const SkISize* expected_sizes, |
| 87 int number_of_sizes) { | 91 int number_of_sizes) { |
| 88 for (int i = 0; i < number_of_sizes; ++i) { | 92 for (int i = 0; i < number_of_sizes; ++i) { |
| 89 SkISize best_size = GetBestSize(client_sizes[i]); | 93 SkISize best_size = GetBestSize(client_sizes[i]); |
| 90 EXPECT_EQ(expected_sizes[i], best_size) | 94 EXPECT_EQ(expected_sizes[i], best_size) |
| 91 << "Input size = " << client_sizes[i]; | 95 << "Input size = " << client_sizes[i]; |
| 92 } | 96 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 supported_sizes, arraysize(supported_sizes)); | 183 supported_sizes, arraysize(supported_sizes)); |
| 180 SetDesktopResizer(scoped_ptr<FakeDesktopResizer>(desktop_resizer)); | 184 SetDesktopResizer(scoped_ptr<FakeDesktopResizer>(desktop_resizer)); |
| 181 | 185 |
| 182 SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } }; | 186 SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } }; |
| 183 SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } }; | 187 SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } }; |
| 184 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); | 188 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); |
| 185 EXPECT_EQ(desktop_resizer->set_size_call_count(), 0); | 189 EXPECT_EQ(desktop_resizer->set_size_call_count(), 0); |
| 186 } | 190 } |
| 187 | 191 |
| 188 } // namespace remoting | 192 } // namespace remoting |
| OLD | NEW |