Chromium Code Reviews| Index: remoting/host/chromoting_host_unittest.cc |
| diff --git a/remoting/host/chromoting_host_unittest.cc b/remoting/host/chromoting_host_unittest.cc |
| index 4f48e530c6787c1396303310fcd68219b8943ccc..6dd0a5a611cd211d813f3c5504bf30dfa7eeb1b3 100644 |
| --- a/remoting/host/chromoting_host_unittest.cc |
| +++ b/remoting/host/chromoting_host_unittest.cc |
| @@ -18,7 +18,6 @@ |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -using ::remoting::protocol::LocalLoginCredentials; |
| using ::remoting::protocol::MockClientStub; |
| using ::remoting::protocol::MockConnectionToClient; |
| using ::remoting::protocol::MockConnectionToClientEventHandler; |
| @@ -102,9 +101,6 @@ class ChromotingHostTest : public testing::Test { |
| host_ = ChromotingHost::Create(&context_, config_, |
| desktop_environment_.get(), |
| access_verifier, false); |
| - credentials_.set_type(protocol::PASSWORD); |
| - credentials_.set_username("user"); |
| - credentials_.set_credential("password"); |
| connection_ = new MockConnectionToClient( |
| &handler_, &host_stub_, event_executor_); |
| connection2_ = new MockConnectionToClient( |
| @@ -163,17 +159,12 @@ class ChromotingHostTest : public testing::Test { |
| } |
| // Helper method to pretend a client is connected to ChromotingHost. |
| - void SimulateClientConnection(int connection_index, bool authenticate) { |
| + void SimulateClientConnection(int connection_index) { |
| scoped_refptr<MockConnectionToClient> connection = |
| (connection_index == 0) ? connection_ : connection2_; |
| - MockUserAuthenticator *user_authenticator = new MockUserAuthenticator; |
| - EXPECT_CALL(*user_authenticator, Authenticate(_, _)) |
| - .WillOnce(Return(authenticate)); |
| - |
| scoped_refptr<ClientSession> client = new ClientSession( |
| host_.get(), |
| - user_authenticator, |
| connection, |
| event_executor_, |
| desktop_environment_->capturer()); |
| @@ -186,9 +177,7 @@ class ChromotingHostTest : public testing::Test { |
| context_.network_message_loop()->PostTask( |
| FROM_HERE, |
| NewRunnableMethod(client.get(), |
| - &ClientSession::BeginSessionRequest, |
| - &credentials_, |
| - base::Bind(&DummyDoneTask))); |
| + &ClientSession::OnAuthorizationComplete)); |
| } |
| // Helper method to remove a client connection from ChromotingHost. |
| @@ -218,7 +207,6 @@ class ChromotingHostTest : public testing::Test { |
| scoped_refptr<ChromotingHost> host_; |
| scoped_refptr<InMemoryHostConfig> config_; |
| MockChromotingHostContext context_; |
| - protocol::LocalLoginCredentials credentials_; |
| scoped_refptr<MockConnectionToClient> connection_; |
| std::string session_jid_; |
| scoped_ptr<MockSession> session_; |
| @@ -256,9 +244,6 @@ TEST_F(ChromotingHostTest, DISABLED_StartAndShutdown) { |
| TEST_F(ChromotingHostTest, DISABLED_Connect) { |
| host_->Start(); |
| - EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) |
| - .WillOnce(RunDoneTask()); |
| - |
| // When the video packet is received we first shutdown ChromotingHost |
| // then execute the done task. |
| { |
| @@ -277,17 +262,13 @@ TEST_F(ChromotingHostTest, DISABLED_Connect) { |
| EXPECT_CALL(*connection_.get(), Disconnect()) |
| .RetiresOnSaturation(); |
| } |
| - SimulateClientConnection(0, true); |
| + SimulateClientConnection(0); |
| message_loop_.Run(); |
| } |
| TEST_F(ChromotingHostTest, DISABLED_Reconnect) { |
| host_->Start(); |
| - EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) |
| - .Times(2) |
| - .WillRepeatedly(RunDoneTask()); |
| - |
| // When the video packet is received we first disconnect the mock |
| // connection. |
| { |
| @@ -316,7 +297,7 @@ TEST_F(ChromotingHostTest, DISABLED_Reconnect) { |
| .WillOnce(QuitMainMessageLoop(&message_loop_)) |
| .RetiresOnSaturation(); |
| - SimulateClientConnection(0, true); |
| + SimulateClientConnection(0); |
| message_loop_.Run(); |
| // Connect the client again. |
| @@ -338,21 +319,13 @@ TEST_F(ChromotingHostTest, DISABLED_Reconnect) { |
| EXPECT_CALL(*connection_.get(), Disconnect()) |
| .RetiresOnSaturation(); |
| - SimulateClientConnection(0, true); |
| + SimulateClientConnection(0); |
| message_loop_.Run(); |
| } |
| TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { |
| host_->Start(); |
| - EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) |
| - .Times(1) |
| - .WillRepeatedly(RunDoneTask()); |
| - |
| - EXPECT_CALL(client_stub2_, BeginSessionResponse(_, _)) |
| - .Times(1) |
| - .WillRepeatedly(RunDoneTask()); |
| - |
| // When a video packet is received we connect the second mock |
| // connection. |
| { |
| @@ -367,7 +340,7 @@ TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { |
| InvokeWithoutArgs( |
| CreateFunctor( |
| this, |
| - &ChromotingHostTest::SimulateClientConnection, 1, true)), |
| + &ChromotingHostTest::SimulateClientConnection, 1)), |
| RunDoneTask())) |
| .RetiresOnSaturation(); |
| // Check that the second connection does not affect curtain mode. |
| @@ -391,67 +364,7 @@ TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { |
| EXPECT_CALL(*connection2_.get(), Disconnect()) |
| .RetiresOnSaturation(); |
| - SimulateClientConnection(0, true); |
| - message_loop_.Run(); |
| -} |
| - |
| -TEST_F(ChromotingHostTest, CurtainModeFail) { |
|
Wez
2011/11/03 00:25:02
Assuming that we retain the idea of curtain mode,
Sergey Ulanov
2011/11/03 01:21:12
Done.
|
| - host_->Start(); |
| - |
| - EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) |
| - .WillOnce(RunDoneTask()); |
| - |
| - // Ensure that curtain mode is not activated if a connection does not |
| - // authenticate. |
| - EXPECT_CALL(*curtain_, EnableCurtainMode(_)) |
| - .Times(0); |
| - EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| - .Times(0); |
| - EXPECT_CALL(*connection_.get(), Disconnect()) |
| - .WillOnce(QuitMainMessageLoop(&message_loop_)); |
| - SimulateClientConnection(0, false); |
| - RemoveClientConnection(); |
| - message_loop_.Run(); |
| -} |
| - |
| -TEST_F(ChromotingHostTest, CurtainModeFailSecond) { |
| - host_->Start(); |
| - |
| - EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) |
| - .WillOnce(RunDoneTask()); |
| - |
| - EXPECT_CALL(client_stub2_, BeginSessionResponse(_, _)) |
| - .WillOnce(RunDoneTask()); |
| - |
| - |
| - // When a video packet is received we connect the second mock |
| - // connection. |
| - { |
| - InSequence s; |
| - EXPECT_CALL(*curtain_, EnableCurtainMode(true)) |
| - .WillOnce(QuitMainMessageLoop(&message_loop_)); |
| - EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| - .Times(0); |
| - EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| - .WillOnce(DoAll( |
| - InvokeWithoutArgs( |
| - CreateFunctor( |
| - this, |
| - &ChromotingHostTest::SimulateClientConnection, 1, false)), |
| - RunDoneTask())) |
| - .RetiresOnSaturation(); |
| - // Check that the second connection does not affect curtain mode. |
| - EXPECT_CALL(*curtain_, EnableCurtainMode(_)) |
| - .Times(0); |
| - EXPECT_CALL(*disconnect_window_, Show(_, _)) |
| - .Times(0); |
| - EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) |
| - .Times(AnyNumber()); |
| - EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) |
| - .Times(0); |
| - } |
| - |
| - SimulateClientConnection(0, true); |
| + SimulateClientConnection(0); |
| message_loop_.Run(); |
| } |
| @@ -461,9 +374,6 @@ TEST_F(ChromotingHostTest, CurtainModeIT2Me) { |
| host_->Start(); |
| host_->set_it2me(true); |
| - EXPECT_CALL(client_stub_, BeginSessionResponse(_, _)) |
| - .WillOnce(RunDoneTask()); |
| - |
| // When the video packet is received we first shutdown ChromotingHost |
| // then execute the done task. |
| bool curtain_activated = false; |
| @@ -492,8 +402,17 @@ TEST_F(ChromotingHostTest, CurtainModeIT2Me) { |
| EXPECT_CALL(*connection_.get(), Disconnect()) |
| .InSequence(s1, s2) |
| .RetiresOnSaturation(); |
| + EXPECT_CALL(*local_input_monitor_, Stop()) |
| + .Times(1) |
| + .InSequence(s1, s2); |
| + EXPECT_CALL(*continue_window_, Hide()) |
| + .Times(1) |
| + .InSequence(s1); |
| + EXPECT_CALL(*disconnect_window_, Hide()) |
| + .Times(1) |
| + .InSequence(s2); |
|
Wez
2011/11/03 00:25:02
How come these have changed?
Sergey Ulanov
2011/11/03 01:21:12
They haven't changed. I just added them to fix gun
|
| } |
| - SimulateClientConnection(0, true); |
| + SimulateClientConnection(0); |
| message_loop_.Run(); |
| host_->set_it2me(false); |
| EXPECT_THAT(curtain_activated, false); |