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

Unified Diff: remoting/host/resizing_host_observer_unittest.cc

Issue 15927033: Add host-side rate-limiting to desktop resize events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed ResizingHostObserver unit-tests. Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/resizing_host_observer.cc ('k') | remoting/webapp/client_plugin_async.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « remoting/host/resizing_host_observer.cc ('k') | remoting/webapp/client_plugin_async.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698