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 "remoting/host/resizing_host_observer.h" | 5 #include "remoting/host/resizing_host_observer.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 | 33 |
34 const int kDefaultDPI = 96; | 34 const int kDefaultDPI = 96; |
35 | 35 |
36 ScreenResolution MakeResolution(int width, int height) { | 36 ScreenResolution MakeResolution(int width, int height) { |
37 return ScreenResolution(webrtc::DesktopSize(width, height), | 37 return ScreenResolution(webrtc::DesktopSize(width, height), |
38 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); | 38 webrtc::DesktopVector(kDefaultDPI, kDefaultDPI)); |
39 } | 39 } |
40 | 40 |
41 class FakeDesktopResizer : public DesktopResizer { | 41 class FakeDesktopResizer : public DesktopResizer { |
42 public: | 42 public: |
43 FakeDesktopResizer(const ScreenResolution& initial_resolution, | 43 struct CallCounts { |
44 bool exact_size_supported, | 44 int set_resolution = 0; |
45 const ScreenResolution* supported_resolutions, | 45 int restore_resolution = 0; |
46 int num_supported_resolutions, | 46 }; |
47 int* restore_resolution_call_count) | 47 |
48 : initial_resolution_(initial_resolution), | 48 FakeDesktopResizer(bool exact_size_supported, |
49 current_resolution_(initial_resolution), | 49 std::vector<ScreenResolution> supported_resolutions, |
50 exact_size_supported_(exact_size_supported), | 50 ScreenResolution* current_resolution, |
51 set_resolution_call_count_(0), | 51 CallCounts* call_counts) |
52 restore_resolution_call_count_(restore_resolution_call_count) { | 52 : exact_size_supported_(exact_size_supported), |
53 for (int i = 0; i < num_supported_resolutions; ++i) { | 53 initial_resolution_(*current_resolution), |
54 supported_resolutions_.push_back(supported_resolutions[i]); | 54 current_resolution_(current_resolution), |
55 } | 55 supported_resolutions_(std::move(supported_resolutions)), |
56 call_counts_(call_counts) { | |
56 } | 57 } |
57 | 58 |
58 ~FakeDesktopResizer() override { | 59 ~FakeDesktopResizer() override { |
59 EXPECT_EQ(initial_resolution_, GetCurrentResolution()); | 60 EXPECT_EQ(initial_resolution_, GetCurrentResolution()); |
60 } | 61 } |
61 | 62 |
62 int set_resolution_call_count() { return set_resolution_call_count_; } | |
63 | |
64 // remoting::DesktopResizer interface | 63 // remoting::DesktopResizer interface |
65 ScreenResolution GetCurrentResolution() override { | 64 ScreenResolution GetCurrentResolution() override { |
66 return current_resolution_; | 65 return *current_resolution_; |
67 } | 66 } |
68 std::list<ScreenResolution> GetSupportedResolutions( | 67 std::list<ScreenResolution> GetSupportedResolutions( |
69 const ScreenResolution& preferred) override { | 68 const ScreenResolution& preferred) override { |
70 std::list<ScreenResolution> result = supported_resolutions_; | 69 std::list<ScreenResolution> result(supported_resolutions_.begin(), |
70 supported_resolutions_.end()); | |
71 if (exact_size_supported_) { | 71 if (exact_size_supported_) { |
72 result.push_back(preferred); | 72 result.push_back(preferred); |
73 } | 73 } |
74 return result; | 74 return result; |
75 } | 75 } |
76 void SetResolution(const ScreenResolution& resolution) override { | 76 void SetResolution(const ScreenResolution& resolution) override { |
77 current_resolution_ = resolution; | 77 *current_resolution_ = resolution; |
78 ++set_resolution_call_count_; | 78 ++call_counts_->set_resolution; |
79 } | 79 } |
80 void RestoreResolution(const ScreenResolution& resolution) override { | 80 void RestoreResolution(const ScreenResolution& resolution) override { |
81 current_resolution_ = resolution; | 81 *current_resolution_ = resolution; |
82 if (restore_resolution_call_count_) | 82 ++call_counts_->restore_resolution; |
83 ++(*restore_resolution_call_count_); | |
84 } | 83 } |
85 | 84 |
86 private: | 85 private: |
86 bool exact_size_supported_; | |
87 ScreenResolution initial_resolution_; | 87 ScreenResolution initial_resolution_; |
88 ScreenResolution current_resolution_; | 88 ScreenResolution *current_resolution_; |
89 bool exact_size_supported_; | 89 std::vector<ScreenResolution> supported_resolutions_; |
90 std::list<ScreenResolution> supported_resolutions_; | 90 CallCounts* call_counts_; |
91 | |
92 int set_resolution_call_count_; | |
93 int* restore_resolution_call_count_; | |
94 }; | 91 }; |
95 | 92 |
96 class ResizingHostObserverTest : public testing::Test { | 93 class ResizingHostObserverTest : public testing::Test { |
97 public: | 94 public: |
98 ResizingHostObserverTest() | 95 ResizingHostObserverTest() |
99 : desktop_resizer_(nullptr), | 96 : now_(base::Time::Now()) { |
100 now_(base::Time::Now()) { | |
101 } | 97 } |
102 | 98 |
103 // This needs to be public because the derived test-case class needs to | 99 // This needs to be public because the derived test-case class needs to |
104 // pass it to Bind, which fails if it's protected. | 100 // pass it to Bind, which fails if it's protected. |
105 base::Time GetTime() { | 101 base::Time GetTime() { |
106 return now_; | 102 return now_; |
107 } | 103 } |
108 | 104 |
109 protected: | 105 protected: |
110 void SetDesktopResizer(std::unique_ptr<FakeDesktopResizer> desktop_resizer) { | 106 void SetDesktopResizer(const ScreenResolution& initial_resolution, |
Jamie
2016/06/03 23:47:20
Maybe rename this InitDesktopResizer, since it's n
rkjnsn
2016/06/04 00:08:21
Acknowledged.
| |
111 CHECK(!desktop_resizer_) << "Call SetDeskopResizer once per test"; | 107 bool exact_size_supported, |
112 desktop_resizer_ = desktop_resizer.get(); | 108 std::vector<ScreenResolution> supported_resolutions) { |
113 | 109 current_resolution_ = initial_resolution; |
114 resizing_host_observer_.reset( | 110 call_counts_ = FakeDesktopResizer::CallCounts(); |
115 new ResizingHostObserver(std::move(desktop_resizer))); | 111 resizing_host_observer_ = base::MakeUnique<ResizingHostObserver>( |
112 base::MakeUnique<FakeDesktopResizer>(exact_size_supported, | |
113 std::move(supported_resolutions), | |
114 ¤t_resolution_, | |
115 &call_counts_)); | |
116 resizing_host_observer_->SetNowFunctionForTesting( | 116 resizing_host_observer_->SetNowFunctionForTesting( |
117 base::Bind(&ResizingHostObserverTest::GetTimeAndIncrement, | 117 base::Bind(&ResizingHostObserverTest::GetTimeAndIncrement, |
118 base::Unretained(this))); | 118 base::Unretained(this))); |
119 } | 119 } |
120 | 120 |
121 ScreenResolution GetBestResolution(const ScreenResolution& client_size) { | 121 ScreenResolution GetBestResolution(const ScreenResolution& client_size) { |
122 resizing_host_observer_->SetScreenResolution(client_size); | 122 resizing_host_observer_->SetScreenResolution(client_size); |
123 return desktop_resizer_->GetCurrentResolution(); | 123 return current_resolution_; |
124 } | 124 } |
125 | 125 |
126 void VerifySizes(const ScreenResolution* client_sizes, | 126 void VerifySizes(const std::vector<ScreenResolution>& client_sizes, |
127 const ScreenResolution* expected_sizes, | 127 const std::vector<ScreenResolution>& expected_sizes) { |
128 int number_of_sizes) { | 128 for (auto client = client_sizes.begin(), expected = expected_sizes.begin(); |
Jamie
2016/06/03 23:47:20
Since we can validate that they are the same size
rkjnsn
2016/06/04 00:08:21
Would CHECK_EQ be the preferred way of doing so? W
Jamie
2016/06/04 00:29:48
I don't think it matters tbh. The extra check is j
Jamie
2016/06/04 00:32:05
Sorry, I missed the first half of your question. I
rkjnsn
2016/06/04 00:43:53
Honestly, I have no idea how the various macros di
Jamie
2016/06/06 19:12:42
Basically, CHECK does the same thing it does in pr
| |
129 for (int i = 0; i < number_of_sizes; ++i) { | 129 client != client_sizes.end() && expected != expected_sizes.end(); |
130 ScreenResolution best_size = GetBestResolution(client_sizes[i]); | 130 ++client, ++expected) { |
131 EXPECT_EQ(expected_sizes[i], best_size) | 131 ScreenResolution best_size = GetBestResolution(*client); |
132 << "Input resolution = " << client_sizes[i]; | 132 EXPECT_EQ(*expected, best_size) << "Input resolution = " << *client; |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 base::Time GetTimeAndIncrement() { | 136 base::Time GetTimeAndIncrement() { |
137 base::Time result = now_; | 137 base::Time result = now_; |
138 now_ += base::TimeDelta::FromSeconds(1); | 138 now_ += base::TimeDelta::FromSeconds(1); |
139 return result; | 139 return result; |
140 } | 140 } |
141 | 141 |
142 std::unique_ptr<ResizingHostObserver> resizing_host_observer_; | 142 ScreenResolution current_resolution_; |
143 FakeDesktopResizer* desktop_resizer_; | 143 FakeDesktopResizer::CallCounts call_counts_; |
144 std::unique_ptr<ResizingHostObserver> resizing_host_observer_ = nullptr; | |
rkjnsn
2016/06/03 21:33:37
` = nullptr` isn't actually necessary, because tha
Jamie
2016/06/03 23:47:20
I think it's fine to remove this. The original cod
rkjnsn
2016/06/04 00:08:21
Acknowledged.
| |
144 base::Time now_; | 145 base::Time now_; |
145 }; | 146 }; |
146 | 147 |
147 // Check that the resolution isn't restored if it wasn't changed by this class. | 148 // Check that the resolution isn't restored if it wasn't changed by this class. |
148 TEST_F(ResizingHostObserverTest, NoRestoreResolution) { | 149 TEST_F(ResizingHostObserverTest, NoRestoreResolution) { |
149 int restore_resolution_call_count = 0; | 150 SetDesktopResizer(MakeResolution(640, 480), false, {}); |
150 ScreenResolution initial = MakeResolution(640, 480); | 151 VerifySizes({}, {}); |
Jamie
2016/06/03 23:47:20
I don't think this is needed (and wasn't needed be
rkjnsn
2016/06/04 00:08:21
Acknowledged.
| |
151 std::unique_ptr<FakeDesktopResizer> desktop_resizer(new FakeDesktopResizer( | |
152 initial, false, nullptr, 0, &restore_resolution_call_count)); | |
153 SetDesktopResizer(std::move(desktop_resizer)); | |
154 VerifySizes(nullptr, nullptr, 0); | |
155 resizing_host_observer_.reset(); | 152 resizing_host_observer_.reset(); |
156 EXPECT_EQ(0, restore_resolution_call_count); | 153 EXPECT_EQ(0, call_counts_.restore_resolution); |
157 } | 154 } |
158 | 155 |
159 // Check that the host is not resized if GetSupportedSizes returns an empty | 156 // Check that the host is not resized if GetSupportedSizes returns an empty |
160 // list (even if GetCurrentSize is supported). | 157 // list (even if GetCurrentSize is supported). |
161 TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) { | 158 TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) { |
162 int restore_resolution_call_count = 0; | |
163 ScreenResolution initial = MakeResolution(640, 480); | 159 ScreenResolution initial = MakeResolution(640, 480); |
164 std::unique_ptr<FakeDesktopResizer> desktop_resizer(new FakeDesktopResizer( | 160 SetDesktopResizer(initial, false, {}); |
165 initial, false, nullptr, 0, &restore_resolution_call_count)); | 161 VerifySizes({ MakeResolution(200, 100), MakeResolution(100, 200) }, |
166 SetDesktopResizer(std::move(desktop_resizer)); | 162 { initial, initial }); |
167 | |
168 ScreenResolution client_sizes[] = { MakeResolution(200, 100), | |
169 MakeResolution(100, 200) }; | |
170 ScreenResolution expected_sizes[] = { initial, initial }; | |
171 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); | |
172 | |
173 resizing_host_observer_.reset(); | 163 resizing_host_observer_.reset(); |
174 EXPECT_EQ(0, restore_resolution_call_count); | 164 EXPECT_EQ(0, call_counts_.set_resolution); |
165 EXPECT_EQ(0, call_counts_.restore_resolution); | |
175 } | 166 } |
176 | 167 |
177 // Check that if the implementation supports exact size matching, it is used. | 168 // Check that if the implementation supports exact size matching, it is used. |
178 TEST_F(ResizingHostObserverTest, SelectExactSize) { | 169 TEST_F(ResizingHostObserverTest, SelectExactSize) { |
179 int restore_resolution_call_count = 0; | 170 SetDesktopResizer(MakeResolution(640, 480), true, {}); |
180 std::unique_ptr<FakeDesktopResizer> desktop_resizer( | 171 std::vector<ScreenResolution> client_sizes { MakeResolution(200, 100), |
181 new FakeDesktopResizer(MakeResolution(640, 480), true, nullptr, 0, | 172 MakeResolution(100, 200), |
182 &restore_resolution_call_count)); | 173 MakeResolution(640, 480), |
183 SetDesktopResizer(std::move(desktop_resizer)); | 174 MakeResolution(480, 640), |
184 | 175 MakeResolution(1280, 1024) }; |
185 ScreenResolution client_sizes[] = { MakeResolution(200, 100), | 176 VerifySizes(client_sizes, client_sizes); |
186 MakeResolution(100, 200), | |
187 MakeResolution(640, 480), | |
188 MakeResolution(480, 640), | |
189 MakeResolution(1280, 1024) }; | |
190 VerifySizes(client_sizes, client_sizes, arraysize(client_sizes)); | |
191 resizing_host_observer_.reset(); | 177 resizing_host_observer_.reset(); |
192 EXPECT_EQ(1, restore_resolution_call_count); | 178 EXPECT_EQ(1, call_counts_.restore_resolution); |
193 } | 179 } |
194 | 180 |
195 // Check that if the implementation supports a size that is no larger than | 181 // Check that if the implementation supports a size that is no larger than |
196 // the requested size, then the largest such size is used. | 182 // the requested size, then the largest such size is used. |
197 TEST_F(ResizingHostObserverTest, SelectBestSmallerSize) { | 183 TEST_F(ResizingHostObserverTest, SelectBestSmallerSize) { |
198 ScreenResolution supported_sizes[] = { MakeResolution(639, 479), | 184 std::vector<ScreenResolution> supported_sizes { MakeResolution(639, 479), |
199 MakeResolution(640, 480) }; | 185 MakeResolution(640, 480) }; |
200 std::unique_ptr<FakeDesktopResizer> desktop_resizer( | 186 SetDesktopResizer(MakeResolution(640, 480), false, supported_sizes); |
201 new FakeDesktopResizer(MakeResolution(640, 480), false, supported_sizes, | 187 VerifySizes({ MakeResolution(639, 479), |
202 arraysize(supported_sizes), nullptr)); | 188 MakeResolution(640, 480), |
203 SetDesktopResizer(std::move(desktop_resizer)); | 189 MakeResolution(641, 481), |
204 | 190 MakeResolution(999, 999) }, |
205 ScreenResolution client_sizes[] = { MakeResolution(639, 479), | 191 { supported_sizes[0], |
206 MakeResolution(640, 480), | 192 supported_sizes[1], |
207 MakeResolution(641, 481), | 193 supported_sizes[1], |
208 MakeResolution(999, 999) }; | 194 supported_sizes[1] }); |
209 ScreenResolution expected_sizes[] = { supported_sizes[0], supported_sizes[1], | |
210 supported_sizes[1], supported_sizes[1] }; | |
211 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); | |
212 } | 195 } |
213 | 196 |
214 // Check that if the implementation supports only sizes that are larger than | 197 // Check that if the implementation supports only sizes that are larger than |
215 // the requested size, then the one that requires the least down-scaling. | 198 // the requested size, then the one that requires the least down-scaling. |
216 TEST_F(ResizingHostObserverTest, SelectBestScaleFactor) { | 199 TEST_F(ResizingHostObserverTest, SelectBestScaleFactor) { |
217 ScreenResolution supported_sizes[] = { MakeResolution(100, 100), | 200 std::vector<ScreenResolution> supported_sizes { MakeResolution(100, 100), |
218 MakeResolution(200, 100) }; | 201 MakeResolution(200, 100) }; |
219 std::unique_ptr<FakeDesktopResizer> desktop_resizer( | 202 SetDesktopResizer(MakeResolution(200, 100), false, supported_sizes); |
220 new FakeDesktopResizer(MakeResolution(200, 100), false, supported_sizes, | 203 VerifySizes({ MakeResolution(1, 1), |
221 arraysize(supported_sizes), nullptr)); | 204 MakeResolution(99, 99), |
222 SetDesktopResizer(std::move(desktop_resizer)); | 205 MakeResolution(199, 99) }, |
223 | 206 { supported_sizes[0], |
224 ScreenResolution client_sizes[] = { MakeResolution(1, 1), | 207 supported_sizes[0], |
225 MakeResolution(99, 99), | 208 supported_sizes[1] }); |
226 MakeResolution(199, 99) }; | |
227 ScreenResolution expected_sizes[] = { supported_sizes[0], supported_sizes[0], | |
228 supported_sizes[1] }; | |
229 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); | |
230 } | 209 } |
231 | 210 |
232 // Check that if the implementation supports two sizes that have the same | 211 // Check that if the implementation supports two sizes that have the same |
233 // resultant scale factor, then the widest one is selected. | 212 // resultant scale factor, then the widest one is selected. |
234 TEST_F(ResizingHostObserverTest, SelectWidest) { | 213 TEST_F(ResizingHostObserverTest, SelectWidest) { |
235 ScreenResolution supported_sizes[] = { MakeResolution(640, 480), | 214 std::vector<ScreenResolution> supported_sizes { MakeResolution(640, 480), |
236 MakeResolution(480, 640) }; | 215 MakeResolution(480, 640) }; |
237 std::unique_ptr<FakeDesktopResizer> desktop_resizer( | 216 SetDesktopResizer(MakeResolution(480, 640), false, supported_sizes); |
238 new FakeDesktopResizer(MakeResolution(480, 640), false, supported_sizes, | 217 VerifySizes({ MakeResolution(100, 100), |
239 arraysize(supported_sizes), nullptr)); | 218 MakeResolution(480, 480), |
240 SetDesktopResizer(std::move(desktop_resizer)); | 219 MakeResolution(500, 500), |
241 | 220 MakeResolution(640, 640), |
242 ScreenResolution client_sizes[] = { MakeResolution(100, 100), | 221 MakeResolution(1000, 1000) }, |
243 MakeResolution(480, 480), | 222 { supported_sizes[0], |
244 MakeResolution(500, 500), | 223 supported_sizes[0], |
245 MakeResolution(640, 640), | 224 supported_sizes[0], |
246 MakeResolution(1000, 1000) }; | 225 supported_sizes[0], |
247 ScreenResolution expected_sizes[] = { supported_sizes[0], supported_sizes[0], | 226 supported_sizes[0] }); |
248 supported_sizes[0], supported_sizes[0], | |
249 supported_sizes[0] }; | |
250 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); | |
251 } | 227 } |
252 | 228 |
253 // Check that if the best match for the client size doesn't change, then we | 229 // Check that if the best match for the client size doesn't change, then we |
254 // don't call SetSize. | 230 // don't call SetSize. |
255 TEST_F(ResizingHostObserverTest, NoSetSizeForSameSize) { | 231 TEST_F(ResizingHostObserverTest, NoSetSizeForSameSize) { |
256 ScreenResolution supported_sizes[] = { MakeResolution(640, 480), | 232 std::vector<ScreenResolution> supported_sizes { MakeResolution(640, 480), |
257 MakeResolution(480, 640) }; | 233 MakeResolution(480, 640) }; |
258 SetDesktopResizer(base::WrapUnique( | 234 SetDesktopResizer(MakeResolution(480, 640), false, supported_sizes); |
259 new FakeDesktopResizer(MakeResolution(480, 640), false, supported_sizes, | 235 VerifySizes({ MakeResolution(640, 640), |
260 arraysize(supported_sizes), nullptr))); | 236 MakeResolution(1024, 768), |
261 | 237 MakeResolution(640, 480) }, |
262 ScreenResolution client_sizes[] = { MakeResolution(640, 640), | 238 { supported_sizes[0], |
263 MakeResolution(1024, 768), | 239 supported_sizes[0], |
264 MakeResolution(640, 480) }; | 240 supported_sizes[0] }); |
265 ScreenResolution expected_sizes[] = { MakeResolution(640, 480), | 241 EXPECT_EQ(1, call_counts_.set_resolution); |
266 MakeResolution(640, 480), | |
267 MakeResolution(640, 480) }; | |
268 VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes)); | |
269 EXPECT_EQ(desktop_resizer_->set_resolution_call_count(), 1); | |
270 } | 242 } |
271 | 243 |
272 // Check that desktop resizes are rate-limited, and that if multiple resize | 244 // Check that desktop resizes are rate-limited, and that if multiple resize |
273 // requests are received in the time-out period, the most recent is respected. | 245 // requests are received in the time-out period, the most recent is respected. |
274 TEST_F(ResizingHostObserverTest, RateLimited) { | 246 TEST_F(ResizingHostObserverTest, RateLimited) { |
275 SetDesktopResizer(base::WrapUnique(new FakeDesktopResizer( | 247 SetDesktopResizer(MakeResolution(640, 480), true, {}); |
276 MakeResolution(640, 480), true, nullptr, 0, nullptr))); | |
277 resizing_host_observer_->SetNowFunctionForTesting( | 248 resizing_host_observer_->SetNowFunctionForTesting( |
278 base::Bind(&ResizingHostObserverTest::GetTime, base::Unretained(this))); | 249 base::Bind(&ResizingHostObserverTest::GetTime, base::Unretained(this))); |
279 | 250 |
280 base::MessageLoop message_loop; | 251 base::MessageLoop message_loop; |
281 base::RunLoop run_loop; | 252 base::RunLoop run_loop; |
282 | 253 |
283 EXPECT_EQ(GetBestResolution(MakeResolution(100, 100)), | 254 EXPECT_EQ(GetBestResolution(MakeResolution(100, 100)), |
284 MakeResolution(100, 100)); | 255 MakeResolution(100, 100)); |
285 now_ += base::TimeDelta::FromMilliseconds(900); | 256 now_ += base::TimeDelta::FromMilliseconds(900); |
286 EXPECT_EQ(GetBestResolution(MakeResolution(200, 200)), | 257 EXPECT_EQ(GetBestResolution(MakeResolution(200, 200)), |
287 MakeResolution(100, 100)); | 258 MakeResolution(100, 100)); |
288 now_ += base::TimeDelta::FromMilliseconds(99); | 259 now_ += base::TimeDelta::FromMilliseconds(99); |
289 EXPECT_EQ(GetBestResolution(MakeResolution(300, 300)), | 260 EXPECT_EQ(GetBestResolution(MakeResolution(300, 300)), |
290 MakeResolution(100, 100)); | 261 MakeResolution(100, 100)); |
291 now_ += base::TimeDelta::FromMilliseconds(1); | 262 now_ += base::TimeDelta::FromMilliseconds(1); |
292 | 263 |
293 // Due to the kMinimumResizeIntervalMs constant in resizing_host_observer.cc, | 264 // Due to the kMinimumResizeIntervalMs constant in resizing_host_observer.cc, |
294 // We need to wait a total of 1000ms for the final resize to be processed. | 265 // We need to wait a total of 1000ms for the final resize to be processed. |
295 // Since it was queued 900 + 99 ms after the first, we need to wait an | 266 // Since it was queued 900 + 99 ms after the first, we need to wait an |
296 // additional 1ms. However, since RunLoop is not guaranteed to process tasks | 267 // additional 1ms. However, since RunLoop is not guaranteed to process tasks |
297 // with the same due time in FIFO order, wait an additional 1ms for safety. | 268 // with the same due time in FIFO order, wait an additional 1ms for safety. |
298 message_loop.PostDelayedTask( | 269 message_loop.PostDelayedTask( |
299 FROM_HERE, | 270 FROM_HERE, |
300 run_loop.QuitClosure(), | 271 run_loop.QuitClosure(), |
301 base::TimeDelta::FromMilliseconds(2)); | 272 base::TimeDelta::FromMilliseconds(2)); |
302 run_loop.Run(); | 273 run_loop.Run(); |
303 | 274 |
304 // If the QuitClosure fired before the final resize, it's a test failure. | 275 // If the QuitClosure fired before the final resize, it's a test failure. |
305 EXPECT_EQ(desktop_resizer_->GetCurrentResolution(), MakeResolution(300, 300)); | 276 EXPECT_EQ(current_resolution_, MakeResolution(300, 300)); |
306 } | 277 } |
307 | 278 |
308 } // namespace remoting | 279 } // namespace remoting |
OLD | NEW |