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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/single_thread_task_runner.h" |
17 #include "remoting/host/desktop_resizer.h" | 18 #include "remoting/host/desktop_resizer.h" |
18 #include "remoting/host/screen_resolution.h" | 19 #include "remoting/host/screen_resolution.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 21 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
21 | 22 |
22 namespace remoting { | 23 namespace remoting { |
23 | 24 |
24 std::ostream& operator<<(std::ostream& os, const ScreenResolution& resolution) { | 25 std::ostream& operator<<(std::ostream& os, const ScreenResolution& resolution) { |
25 return os << resolution.dimensions().width() << "x" | 26 return os << resolution.dimensions().width() << "x" |
26 << resolution.dimensions().height() << " @ " | 27 << resolution.dimensions().height() << " @ " |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 now_ += base::TimeDelta::FromMilliseconds(99); | 296 now_ += base::TimeDelta::FromMilliseconds(99); |
296 EXPECT_EQ(MakeResolution(100, 100), | 297 EXPECT_EQ(MakeResolution(100, 100), |
297 GetBestResolution(MakeResolution(300, 300))); | 298 GetBestResolution(MakeResolution(300, 300))); |
298 now_ += base::TimeDelta::FromMilliseconds(1); | 299 now_ += base::TimeDelta::FromMilliseconds(1); |
299 | 300 |
300 // Due to the kMinimumResizeIntervalMs constant in resizing_host_observer.cc, | 301 // Due to the kMinimumResizeIntervalMs constant in resizing_host_observer.cc, |
301 // We need to wait a total of 1000ms for the final resize to be processed. | 302 // We need to wait a total of 1000ms for the final resize to be processed. |
302 // Since it was queued 900 + 99 ms after the first, we need to wait an | 303 // Since it was queued 900 + 99 ms after the first, we need to wait an |
303 // additional 1ms. However, since RunLoop is not guaranteed to process tasks | 304 // additional 1ms. However, since RunLoop is not guaranteed to process tasks |
304 // with the same due time in FIFO order, wait an additional 1ms for safety. | 305 // with the same due time in FIFO order, wait an additional 1ms for safety. |
305 message_loop.PostDelayedTask( | 306 message_loop.task_runner()->PostDelayedTask( |
306 FROM_HERE, | 307 FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(2)); |
307 run_loop.QuitClosure(), | |
308 base::TimeDelta::FromMilliseconds(2)); | |
309 run_loop.Run(); | 308 run_loop.Run(); |
310 | 309 |
311 // If the QuitClosure fired before the final resize, it's a test failure. | 310 // If the QuitClosure fired before the final resize, it's a test failure. |
312 EXPECT_EQ(MakeResolution(300, 300), current_resolution_); | 311 EXPECT_EQ(MakeResolution(300, 300), current_resolution_); |
313 } | 312 } |
314 | 313 |
315 } // namespace remoting | 314 } // namespace remoting |
OLD | NEW |