| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/service/service_process.h" | 5 #include "chrome/service/service_process.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "chrome/common/service_process_util.h" | 13 #include "chrome/common/service_process_util.h" |
| 14 #include "remoting/host/host_key_pair.h" | |
| 15 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 16 |
| 18 TEST(ServiceProcessTest, DISABLED_Run) { | 17 TEST(ServiceProcessTest, DISABLED_Run) { |
| 19 MessageLoopForUI main_message_loop; | 18 MessageLoopForUI main_message_loop; |
| 20 ServiceProcess process; | 19 ServiceProcess process; |
| 21 ServiceProcessState state; | 20 ServiceProcessState state; |
| 22 CommandLine command_line(CommandLine::NO_PROGRAM); | 21 CommandLine command_line(CommandLine::NO_PROGRAM); |
| 23 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state)); | 22 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state)); |
| 24 EXPECT_TRUE(process.Teardown()); | 23 EXPECT_TRUE(process.Teardown()); |
| 25 } | 24 } |
| 26 | |
| 27 #if defined(ENABLE_REMOTING) | |
| 28 // This test seems to break randomly so disabling it. | |
| 29 TEST(ServiceProcessTest, DISABLED_RunChromoting) { | |
| 30 MessageLoopForUI main_message_loop; | |
| 31 ServiceProcess process; | |
| 32 ServiceProcessState state; | |
| 33 CommandLine command_line(CommandLine::NO_PROGRAM); | |
| 34 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state)); | |
| 35 | |
| 36 // Then config the chromoting host and start it. | |
| 37 process.remoting_host_manager()->SetCredentials("email", "token"); | |
| 38 process.remoting_host_manager()->Enable(); | |
| 39 process.remoting_host_manager()->Disable(); | |
| 40 EXPECT_TRUE(process.Teardown()); | |
| 41 } | |
| 42 | |
| 43 class MockServiceProcess : public ServiceProcess { | |
| 44 private: | |
| 45 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); | |
| 46 MOCK_METHOD0(OnChromotingHostShutdown, void()); | |
| 47 }; | |
| 48 | |
| 49 ACTION_P(QuitMessageLoop, message_loop) { | |
| 50 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | |
| 51 } | |
| 52 | |
| 53 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) { | |
| 54 MessageLoopForUI main_message_loop; | |
| 55 MockServiceProcess process; | |
| 56 ServiceProcessState state; | |
| 57 CommandLine command_line(CommandLine::NO_PROGRAM); | |
| 58 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state)); | |
| 59 | |
| 60 // Expect chromoting shutdown be called because the login token is invalid. | |
| 61 EXPECT_CALL(process, OnChromotingHostShutdown()) | |
| 62 .WillOnce(QuitMessageLoop(&main_message_loop)); | |
| 63 | |
| 64 // Then config the chromoting host and start it. | |
| 65 process.remoting_host_manager()->SetCredentials("email", "token"); | |
| 66 process.remoting_host_manager()->Enable(); | |
| 67 MessageLoop::current()->Run(); | |
| 68 | |
| 69 EXPECT_TRUE(process.Teardown()); | |
| 70 } | |
| 71 #endif // defined(ENABLE_REMOTING) | |
| OLD | NEW |