| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/crypto/rsa_private_key.h" | 9 #include "base/crypto/rsa_private_key.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 #if defined(ENABLE_REMOTING) | 25 #if defined(ENABLE_REMOTING) |
| 26 // This test seems to break randomly so disabling it. | 26 // This test seems to break randomly so disabling it. |
| 27 TEST(ServiceProcessTest, DISABLED_RunChromoting) { | 27 TEST(ServiceProcessTest, DISABLED_RunChromoting) { |
| 28 MessageLoopForUI main_message_loop; | 28 MessageLoopForUI main_message_loop; |
| 29 ServiceProcess process; | 29 ServiceProcess process; |
| 30 CommandLine command_line(CommandLine::NO_PROGRAM); | 30 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 31 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); | 31 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); |
| 32 | 32 |
| 33 // Then config the chromoting host and start it. | 33 // Then config the chromoting host and start it. |
| 34 remoting::HostKeyPair key; | 34 process.remoting_host_manager()->SetCredentials("email", "token"); |
| 35 key.Generate(); | 35 process.remoting_host_manager()->Enable(); |
| 36 process.SaveChromotingConfig("hello", "world", "it's a", "good day", &key); | 36 process.remoting_host_manager()->Disable(); |
| 37 EXPECT_TRUE(process.StartChromotingHost()); | |
| 38 EXPECT_TRUE(process.ShutdownChromotingHost()); | |
| 39 EXPECT_TRUE(process.Teardown()); | 37 EXPECT_TRUE(process.Teardown()); |
| 40 } | 38 } |
| 41 | 39 |
| 42 class MockServiceProcess : public ServiceProcess { | 40 class MockServiceProcess : public ServiceProcess { |
| 43 private: | 41 private: |
| 44 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); | 42 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); |
| 45 MOCK_METHOD0(OnChromotingHostShutdown, void()); | 43 MOCK_METHOD0(OnChromotingHostShutdown, void()); |
| 46 }; | 44 }; |
| 47 | 45 |
| 48 ACTION_P(QuitMessageLoop, message_loop) { | 46 ACTION_P(QuitMessageLoop, message_loop) { |
| 49 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 47 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
| 50 } | 48 } |
| 51 | 49 |
| 52 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) { | 50 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) { |
| 53 MessageLoopForUI main_message_loop; | 51 MessageLoopForUI main_message_loop; |
| 54 MockServiceProcess process; | 52 MockServiceProcess process; |
| 55 CommandLine command_line(CommandLine::NO_PROGRAM); | 53 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 56 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); | 54 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); |
| 57 | 55 |
| 58 // Expect chromoting shutdown be called because the login token is invalid. | 56 // Expect chromoting shutdown be called because the login token is invalid. |
| 59 EXPECT_CALL(process, OnChromotingHostShutdown()) | 57 EXPECT_CALL(process, OnChromotingHostShutdown()) |
| 60 .WillOnce(QuitMessageLoop(&main_message_loop)); | 58 .WillOnce(QuitMessageLoop(&main_message_loop)); |
| 61 | 59 |
| 62 // Then config the chromoting host and start it. | 60 // Then config the chromoting host and start it. |
| 63 remoting::HostKeyPair key; | 61 process.remoting_host_manager()->SetCredentials("email", "token"); |
| 64 key.Generate(); | 62 process.remoting_host_manager()->Enable(); |
| 65 process.SaveChromotingConfig("hello", "world", "it's a", "good day", &key); | |
| 66 EXPECT_TRUE(process.StartChromotingHost()); | |
| 67 MessageLoop::current()->Run(); | 63 MessageLoop::current()->Run(); |
| 68 | 64 |
| 69 EXPECT_TRUE(process.Teardown()); | 65 EXPECT_TRUE(process.Teardown()); |
| 70 } | 66 } |
| 71 #endif // defined(ENABLE_REMOTING) | 67 #endif // defined(ENABLE_REMOTING) |
| OLD | NEW |