Chromium Code Reviews| Index: remoting/host/resizing_host_observer_unittest.cc |
| diff --git a/remoting/host/resizing_host_observer_unittest.cc b/remoting/host/resizing_host_observer_unittest.cc |
| index 2d61e5e4e8dd312d0f1508e028d303c2bf2cc31e..4b665cbe83c519a26abc7aeb39c8656b292eafe9 100644 |
| --- a/remoting/host/resizing_host_observer_unittest.cc |
| +++ b/remoting/host/resizing_host_observer_unittest.cc |
| @@ -6,6 +6,8 @@ |
| #include "base/compiler_specific.h" |
| #include "base/logging.h" |
| +#include "base/message_loop.h" |
| +#include "base/run_loop.h" |
| #include "remoting/host/desktop_resizer.h" |
| #include "remoting/host/resizing_host_observer.h" |
| #include "remoting/host/screen_resolution.h" |
| @@ -80,6 +82,8 @@ class ResizingHostObserverTest : public testing::Test { |
| resizing_host_observer_.reset( |
| new ResizingHostObserver(desktop_resizer.PassAs<DesktopResizer>())); |
| + resizing_host_observer_->SetMinimumResizeIntervalForTesting( |
| + base::TimeDelta::FromMilliseconds(0)); |
| } |
| SkISize GetBestSize(const SkISize& client_size) { |
| @@ -98,7 +102,7 @@ class ResizingHostObserverTest : public testing::Test { |
| } |
| } |
| - private: |
| + protected: |
| scoped_ptr<ResizingHostObserver> resizing_host_observer_; |
| FakeDesktopResizer* desktop_resizer_; |
| }; |
| @@ -191,4 +195,30 @@ TEST_F(ResizingHostObserverTest, NoSetSizeForSameSize) { |
| EXPECT_EQ(desktop_resizer->set_size_call_count(), 0); |
| } |
| +// Check that desktop resizes are rate-limited, and that if multiple resize |
| +// requests are received in the time-out period, the most recent is respected. |
| +TEST_F(ResizingHostObserverTest, RateLimited) { |
| + int interval_ms = 10; |
|
alexeypa (please no reviews)
2013/06/06 21:45:11
1ms should be good enough. All we need is to cause
Jamie
2013/06/06 22:08:04
There is a small chance that it might take > 1ms b
alexeypa (please no reviews)
2013/06/07 16:23:10
Oh, I see. So the first SetScreenResoultion() reco
|
| + FakeDesktopResizer* desktop_resizer = |
| + new FakeDesktopResizer(SkISize::Make(640, 480), true, NULL, 0); |
| + SetDesktopResizer(scoped_ptr<FakeDesktopResizer>(desktop_resizer)); |
| + resizing_host_observer_->SetMinimumResizeIntervalForTesting( |
| + base::TimeDelta::FromMilliseconds(interval_ms)); |
| + |
| + base::MessageLoop message_loop; |
| + base::RunLoop run_loop; |
| + |
| + EXPECT_EQ(GetBestSize(SkISize::Make(100, 100)), SkISize::Make(100, 100)); |
|
alexeypa (please no reviews)
2013/06/06 21:45:11
If I read this correctly, it does not check whethe
Jamie
2013/06/06 22:08:04
That expectation is at the end of the test, after
|
| + EXPECT_EQ(GetBestSize(SkISize::Make(200, 200)), SkISize::Make(100, 100)); |
| + EXPECT_EQ(GetBestSize(SkISize::Make(300, 300)), SkISize::Make(100, 100)); |
| + |
| + message_loop.PostDelayedTask( |
| + FROM_HERE, |
| + base::Bind(&base::RunLoop::Quit, base::Unretained(&run_loop)), |
|
alexeypa (please no reviews)
2013/06/06 21:45:11
Use |run_loop.QuitClosure()| instead of base::Bind
Jamie
2013/06/06 22:08:04
Done.
|
| + base::TimeDelta::FromMilliseconds(interval_ms + 1)); |
| + run_loop.Run(); |
| + |
| + EXPECT_EQ(desktop_resizer_->GetCurrentSize(), SkISize::Make(300, 300)); |
|
alexeypa (please no reviews)
2013/06/07 16:23:10
This expectation is flaky. Posting QuitClosure() b
|
| +} |
| + |
| } // namespace remoting |