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

Unified Diff: remoting/host/resizing_host_observer_unittest.cc

Issue 12545026: ResizingHostObserver is created by the desktop environment together with other stubs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CR feedback & 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/host/resizing_host_observer.cc ('k') | remoting/host/session_controller.h » ('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 ec0ae10bb021244af5f7af0a47acffc72c2f73a2..d54b5423386f9c276f7c3fbb00921f661079211b 100644
--- a/remoting/host/resizing_host_observer_unittest.cc
+++ b/remoting/host/resizing_host_observer_unittest.cc
@@ -7,7 +7,6 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
#include "remoting/host/desktop_resizer.h"
-#include "remoting/host/host_status_monitor_fake.h"
#include "remoting/host/resizing_host_observer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkSize.h"
@@ -31,7 +30,10 @@ class FakeDesktopResizer : public DesktopResizer {
}
}
- const SkISize& initial_size() { return initial_size_; }
+ ~FakeDesktopResizer() {
+ EXPECT_EQ(initial_size_, GetCurrentSize());
+ }
+
int set_size_call_count() { return set_size_call_count_; }
// remoting::DesktopResizer interface
@@ -65,18 +67,19 @@ class FakeDesktopResizer : public DesktopResizer {
class ResizingHostObserverTest : public testing::Test {
public:
- void SetDesktopResizer(FakeDesktopResizer* desktop_resizer) {
- CHECK(!desktop_resizer_.get()) << "Call SetDeskopResizer once per test";
+ ResizingHostObserverTest() : desktop_resizer_(NULL) {
+ }
+
+ void SetDesktopResizer(scoped_ptr<FakeDesktopResizer> desktop_resizer) {
+ CHECK(!desktop_resizer_) << "Call SetDeskopResizer once per test";
+ desktop_resizer_ = desktop_resizer.get();
+
resizing_host_observer_.reset(
- new ResizingHostObserver(desktop_resizer,
- host_status_monitor_.AsWeakPtr()));
- desktop_resizer_.reset(desktop_resizer);
- resizing_host_observer_->OnClientAuthenticated("");
+ new ResizingHostObserver(desktop_resizer.PassAs<DesktopResizer>()));
}
SkISize GetBestSize(const SkISize& client_size) {
- resizing_host_observer_->OnClientResolutionChanged(
- "", client_size, SkIPoint());
+ resizing_host_observer_->OnClientResolutionChanged(SkIPoint(), client_size);
return desktop_resizer_->GetCurrentSize();
}
@@ -89,30 +92,19 @@ class ResizingHostObserverTest : public testing::Test {
}
}
- void Reconnect() {
- resizing_host_observer_->OnClientDisconnected("");
- resizing_host_observer_->OnClientAuthenticated("");
- }
-
- // testing::Test interface
- virtual void TearDown() OVERRIDE {
- resizing_host_observer_->OnClientDisconnected("");
- EXPECT_EQ(desktop_resizer_->initial_size(),
- desktop_resizer_->GetCurrentSize());
- }
-
private:
scoped_ptr<ResizingHostObserver> resizing_host_observer_;
- scoped_ptr<FakeDesktopResizer> desktop_resizer_;
- HostStatusMonitorFake host_status_monitor_;
+ FakeDesktopResizer* desktop_resizer_;
};
// Check that the host is not resized if GetSupportedSizes returns an empty
// list (even if GetCurrentSize is supported).
TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) {
SkISize initial = { 640, 480 };
- SetDesktopResizer(
+ scoped_ptr<FakeDesktopResizer> desktop_resizer(
new FakeDesktopResizer(initial, false, NULL, 0));
+ SetDesktopResizer(desktop_resizer.Pass());
+
SkISize client_sizes[] = { { 200, 100 }, { 100, 200 } };
SkISize expected_sizes[] = { initial, initial };
VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes));
@@ -120,8 +112,10 @@ TEST_F(ResizingHostObserverTest, EmptyGetSupportedSizes) {
// Check that if the implementation supports exact size matching, it is used.
TEST_F(ResizingHostObserverTest, SelectExactSize) {
- SetDesktopResizer(
+ scoped_ptr<FakeDesktopResizer> desktop_resizer(
new FakeDesktopResizer(SkISize::Make(640, 480), true, NULL, 0));
+ SetDesktopResizer(desktop_resizer.Pass());
+
SkISize client_sizes[] = { { 200, 100 }, { 100, 200 } , { 640, 480 },
{ 480, 640 }, { 1280, 1024 } };
VerifySizes(client_sizes, client_sizes, arraysize(client_sizes));
@@ -132,9 +126,11 @@ TEST_F(ResizingHostObserverTest, SelectExactSize) {
TEST_F(ResizingHostObserverTest, SelectBestSmallerSize) {
SkISize supported_sizes[] = {
SkISize::Make(639, 479), SkISize::Make(640, 480) };
- SetDesktopResizer(
+ scoped_ptr<FakeDesktopResizer> desktop_resizer(
new FakeDesktopResizer(SkISize::Make(640, 480), false,
supported_sizes, arraysize(supported_sizes)));
+ SetDesktopResizer(desktop_resizer.Pass());
+
SkISize client_sizes[] = { { 639, 479 }, { 640, 480 }, { 641, 481 },
{ 999, 999 } };
SkISize expected_sizes[] = { supported_sizes[0], supported_sizes[1],
@@ -146,9 +142,11 @@ TEST_F(ResizingHostObserverTest, SelectBestSmallerSize) {
// the requested size, then the one that requires the least down-scaling.
TEST_F(ResizingHostObserverTest, SelectBestScaleFactor) {
SkISize supported_sizes[] = { { 100, 100 }, { 200, 100 } };
- SetDesktopResizer(
+ scoped_ptr<FakeDesktopResizer> desktop_resizer(
new FakeDesktopResizer(SkISize::Make(200, 100), false,
supported_sizes, arraysize(supported_sizes)));
+ SetDesktopResizer(desktop_resizer.Pass());
+
SkISize client_sizes[] = { { 1, 1 }, { 99, 99 }, { 199, 99 } };
SkISize expected_sizes[] = { supported_sizes[0], supported_sizes[0],
supported_sizes[1] };
@@ -159,9 +157,11 @@ TEST_F(ResizingHostObserverTest, SelectBestScaleFactor) {
// resultant scale factor, then the widest one is selected.
TEST_F(ResizingHostObserverTest, SelectWidest) {
SkISize supported_sizes[] = { { 640, 480 }, { 480, 640 } };
- SetDesktopResizer(
+ scoped_ptr<FakeDesktopResizer> desktop_resizer(
new FakeDesktopResizer(SkISize::Make(480, 640), false,
supported_sizes, arraysize(supported_sizes)));
+ SetDesktopResizer(desktop_resizer.Pass());
+
SkISize client_sizes[] = { { 100, 100 }, { 480, 480 }, { 500, 500 },
{ 640, 640 }, { 1000, 1000 } };
SkISize expected_sizes[] = { supported_sizes[0], supported_sizes[0],
@@ -177,7 +177,8 @@ TEST_F(ResizingHostObserverTest, NoSetSizeForSameSize) {
FakeDesktopResizer* desktop_resizer =
new FakeDesktopResizer(SkISize::Make(640, 480), false,
supported_sizes, arraysize(supported_sizes));
- SetDesktopResizer(desktop_resizer);
+ SetDesktopResizer(scoped_ptr<FakeDesktopResizer>(desktop_resizer));
+
SkISize client_sizes[] = { { 640, 640 }, { 1024, 768 }, { 640, 480 } };
SkISize expected_sizes[] = { { 640, 480 }, { 640, 480 }, { 640, 480 } };
VerifySizes(client_sizes, expected_sizes, arraysize(client_sizes));
« no previous file with comments | « remoting/host/resizing_host_observer.cc ('k') | remoting/host/session_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698