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" |
11 #include "base/waitable_event.h" | 11 #include "base/waitable_event.h" |
12 #include "chrome/service/service_process.h" | 12 #include "chrome/service/service_process.h" |
13 #include "remoting/host/host_key_pair.h" | 13 #include "remoting/host/host_key_pair.h" |
14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 | 16 |
17 TEST(ServiceProcessTest, DISABLED_Run) { | 17 TEST(ServiceProcessTest, DISABLED_Run) { |
18 MessageLoopForUI main_message_loop; | 18 MessageLoopForUI main_message_loop; |
19 ServiceProcess process; | 19 ServiceProcess process; |
20 CommandLine command_line(CommandLine::ARGUMENTS_ONLY); | 20 CommandLine command_line(CommandLine::NO_PROGRAM); |
21 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); | 21 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); |
22 EXPECT_TRUE(process.Teardown()); | 22 EXPECT_TRUE(process.Teardown()); |
23 } | 23 } |
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::ARGUMENTS_ONLY); | 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 remoting::HostKeyPair key; |
35 key.Generate(); | 35 key.Generate(); |
36 process.SaveChromotingConfig("hello", "world", "it's a", "good day", &key); | 36 process.SaveChromotingConfig("hello", "world", "it's a", "good day", &key); |
37 EXPECT_TRUE(process.StartChromotingHost()); | 37 EXPECT_TRUE(process.StartChromotingHost()); |
38 EXPECT_TRUE(process.ShutdownChromotingHost()); | 38 EXPECT_TRUE(process.ShutdownChromotingHost()); |
39 EXPECT_TRUE(process.Teardown()); | 39 EXPECT_TRUE(process.Teardown()); |
40 } | 40 } |
41 | 41 |
42 class MockServiceProcess : public ServiceProcess { | 42 class MockServiceProcess : public ServiceProcess { |
43 private: | 43 private: |
44 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); | 44 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); |
45 MOCK_METHOD0(OnChromotingHostShutdown, void()); | 45 MOCK_METHOD0(OnChromotingHostShutdown, void()); |
46 }; | 46 }; |
47 | 47 |
48 ACTION_P(QuitMessageLoop, message_loop) { | 48 ACTION_P(QuitMessageLoop, message_loop) { |
49 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); | 49 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); |
50 } | 50 } |
51 | 51 |
52 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) { | 52 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) { |
53 MessageLoopForUI main_message_loop; | 53 MessageLoopForUI main_message_loop; |
54 MockServiceProcess process; | 54 MockServiceProcess process; |
55 CommandLine command_line(CommandLine::ARGUMENTS_ONLY); | 55 CommandLine command_line(CommandLine::NO_PROGRAM); |
56 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); | 56 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); |
57 | 57 |
58 // Expect chromoting shutdown be called because the login token is invalid. | 58 // Expect chromoting shutdown be called because the login token is invalid. |
59 EXPECT_CALL(process, OnChromotingHostShutdown()) | 59 EXPECT_CALL(process, OnChromotingHostShutdown()) |
60 .WillOnce(QuitMessageLoop(&main_message_loop)); | 60 .WillOnce(QuitMessageLoop(&main_message_loop)); |
61 | 61 |
62 // Then config the chromoting host and start it. | 62 // Then config the chromoting host and start it. |
63 remoting::HostKeyPair key; | 63 remoting::HostKeyPair key; |
64 key.Generate(); | 64 key.Generate(); |
65 process.SaveChromotingConfig("hello", "world", "it's a", "good day", &key); | 65 process.SaveChromotingConfig("hello", "world", "it's a", "good day", &key); |
66 EXPECT_TRUE(process.StartChromotingHost()); | 66 EXPECT_TRUE(process.StartChromotingHost()); |
67 MessageLoop::current()->Run(); | 67 MessageLoop::current()->Run(); |
68 | 68 |
69 EXPECT_TRUE(process.Teardown()); | 69 EXPECT_TRUE(process.Teardown()); |
70 } | 70 } |
71 #endif // defined(ENABLE_REMOTING) | 71 #endif // defined(ENABLE_REMOTING) |
OLD | NEW |