Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(876)

Side by Side Diff: remoting/host/resizing_host_observer_unittest.cc

Issue 12678008: Reworked the plumbing required to pass the client resolution to the desktop resizer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
18 namespace remoting { 19 namespace remoting {
19 20
20 class FakeDesktopResizer : public DesktopResizer { 21 class FakeDesktopResizer : public DesktopResizer {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 73
73 void SetDesktopResizer(scoped_ptr<FakeDesktopResizer> desktop_resizer) { 74 void SetDesktopResizer(scoped_ptr<FakeDesktopResizer> desktop_resizer) {
74 CHECK(!desktop_resizer_) << "Call SetDeskopResizer once per test"; 75 CHECK(!desktop_resizer_) << "Call SetDeskopResizer once per test";
75 desktop_resizer_ = desktop_resizer.get(); 76 desktop_resizer_ = desktop_resizer.get();
76 77
77 resizing_host_observer_.reset( 78 resizing_host_observer_.reset(
78 new ResizingHostObserver(desktop_resizer.PassAs<DesktopResizer>())); 79 new ResizingHostObserver(desktop_resizer.PassAs<DesktopResizer>()));
79 } 80 }
80 81
81 SkISize GetBestSize(const SkISize& client_size) { 82 SkISize GetBestSize(const SkISize& client_size) {
82 resizing_host_observer_->OnClientResolutionChanged(SkIPoint(), client_size); 83 resizing_host_observer_->SetScreenResolution(ScreenResolution(client_size));
83 return desktop_resizer_->GetCurrentSize(); 84 return desktop_resizer_->GetCurrentSize();
84 } 85 }
85 86
86 void VerifySizes(const SkISize* client_sizes, const SkISize* expected_sizes, 87 void VerifySizes(const SkISize* client_sizes, const SkISize* expected_sizes,
87 int number_of_sizes) { 88 int number_of_sizes) {
88 for (int i = 0; i < number_of_sizes; ++i) { 89 for (int i = 0; i < number_of_sizes; ++i) {
89 SkISize best_size = GetBestSize(client_sizes[i]); 90 SkISize best_size = GetBestSize(client_sizes[i]);
90 EXPECT_EQ(expected_sizes[i], best_size) 91 EXPECT_EQ(expected_sizes[i], best_size)
91 << "Input size = " << client_sizes[i]; 92 << "Input size = " << client_sizes[i];
92 } 93 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 supported_sizes, arraysize(supported_sizes)); 180 supported_sizes, arraysize(supported_sizes));
180 SetDesktopResizer(scoped_ptr<FakeDesktopResizer>(desktop_resizer)); 181 SetDesktopResizer(scoped_ptr<FakeDesktopResizer>(desktop_resizer));
181 182
182 SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } }; 183 SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } };
183 SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } }; 184 SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } };
184 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); 185 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes));
185 EXPECT_EQ(desktop_resizer->set_size_call_count(), 0); 186 EXPECT_EQ(desktop_resizer->set_size_call_count(), 0);
186 } 187 }
187 188
188 } // namespace remoting 189 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698