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

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

Issue 12386035: Moving host status events monitoring to a separate interface (HostStatusMonitor). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased 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
« no previous file with comments | « remoting/host/resizing_host_observer.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "remoting/host/resizing_host_observer.h"
6 #include "remoting/host/desktop_resizer.h"
7
8 #include <list> 5 #include <list>
9 6
10 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
11 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "remoting/host/desktop_resizer.h"
10 #include "remoting/host/host_status_monitor_fake.h"
11 #include "remoting/host/resizing_host_observer.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/skia/include/core/SkSize.h" 13 #include "third_party/skia/include/core/SkSize.h"
14 14
15 std::ostream& operator<<(std::ostream& os, const SkISize& size) { 15 std::ostream& operator<<(std::ostream& os, const SkISize& size) {
16 return os << size.width() << "x" << size.height(); 16 return os << size.width() << "x" << size.height();
17 } 17 }
18 18
19 namespace remoting { 19 namespace remoting {
20 20
21 class FakeDesktopResizer : public DesktopResizer { 21 class FakeDesktopResizer : public DesktopResizer {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 bool exact_size_supported_; 60 bool exact_size_supported_;
61 std::list<SkISize> supported_sizes_; 61 std::list<SkISize> supported_sizes_;
62 62
63 int set_size_call_count_; 63 int set_size_call_count_;
64 }; 64 };
65 65
66 class ResizingHostObserverTest : public testing::Test { 66 class ResizingHostObserverTest : public testing::Test {
67 public: 67 public:
68 void SetDesktopResizer(FakeDesktopResizer* desktop_resizer) { 68 void SetDesktopResizer(FakeDesktopResizer* desktop_resizer) {
69 CHECK(!desktop_resizer_.get()) << "Call SetDeskopResizer once per test"; 69 CHECK(!desktop_resizer_.get()) << "Call SetDeskopResizer once per test";
70 resizing_host_observer_.reset(new ResizingHostObserver(desktop_resizer, 70 resizing_host_observer_.reset(
71 NULL)); 71 new ResizingHostObserver(desktop_resizer,
72 host_status_monitor_.AsWeakPtr()));
72 desktop_resizer_.reset(desktop_resizer); 73 desktop_resizer_.reset(desktop_resizer);
73 resizing_host_observer_->OnClientAuthenticated(""); 74 resizing_host_observer_->OnClientAuthenticated("");
74 } 75 }
75 76
76 SkISize GetBestSize(const SkISize& client_size) { 77 SkISize GetBestSize(const SkISize& client_size) {
77 resizing_host_observer_->OnClientResolutionChanged( 78 resizing_host_observer_->OnClientResolutionChanged(
78 "", client_size, SkIPoint()); 79 "", client_size, SkIPoint());
79 return desktop_resizer_->GetCurrentSize(); 80 return desktop_resizer_->GetCurrentSize();
80 } 81 }
81 82
(...skipping 14 matching lines...) Expand all
96 // testing::Test interface 97 // testing::Test interface
97 virtual void TearDown() OVERRIDE { 98 virtual void TearDown() OVERRIDE {
98 resizing_host_observer_->OnClientDisconnected(""); 99 resizing_host_observer_->OnClientDisconnected("");
99 EXPECT_EQ(desktop_resizer_->initial_size(), 100 EXPECT_EQ(desktop_resizer_->initial_size(),
100 desktop_resizer_->GetCurrentSize()); 101 desktop_resizer_->GetCurrentSize());
101 } 102 }
102 103
103 private: 104 private:
104 scoped_ptr<ResizingHostObserver> resizing_host_observer_; 105 scoped_ptr<ResizingHostObserver> resizing_host_observer_;
105 scoped_ptr<FakeDesktopResizer> desktop_resizer_; 106 scoped_ptr<FakeDesktopResizer> desktop_resizer_;
107 HostStatusMonitorFake host_status_monitor_;
106 }; 108 };
107 109
108 // Check that the host is not resized if GetSupportedSizes returns an empty 110 // Check that the host is not resized if GetSupportedSizes returns an empty
109 // list (even if GetCurrentSize is supported). 111 // list (even if GetCurrentSize is supported).
110 TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) { 112 TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) {
111 SkISize initial = { 640, 480 }; 113 SkISize initial = { 640, 480 };
112 SetDesktopResizer( 114 SetDesktopResizer(
113 new FakeDesktopResizer(initial, false, NULL, 0)); 115 new FakeDesktopResizer(initial, false, NULL, 0));
114 SkISize client_sizes[] = { { 200, 100 }, { 100, 200 } }; 116 SkISize client_sizes[] = { { 200, 100 }, { 100, 200 } };
115 SkISize expected_sizes[] = { initial, initial }; 117 SkISize expected_sizes[] = { initial, initial };
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 new FakeDesktopResizer(SkISize::Make(640, 480), false, 178 new FakeDesktopResizer(SkISize::Make(640, 480), false,
177 supported_sizes, arraysize(supported_sizes)); 179 supported_sizes, arraysize(supported_sizes));
178 SetDesktopResizer(desktop_resizer); 180 SetDesktopResizer(desktop_resizer);
179 SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } }; 181 SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } };
180 SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } }; 182 SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } };
181 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); 183 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes));
182 EXPECT_EQ(desktop_resizer->set_size_call_count(), 0); 184 EXPECT_EQ(desktop_resizer->set_size_call_count(), 0);
183 } 185 }
184 186
185 } // namespace remoting 187 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/resizing_host_observer.cc ('k') | remoting/remoting.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698