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

Side by Side Diff: chrome/service/service_process_unittest.cc

Issue 3110004: Revert 55507 - Start chromoting host in the service process though a method ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/service/service_process.cc ('k') | remoting/host/heartbeat_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
6
7 #include "base/base64.h"
8 #include "base/crypto/rsa_private_key.h"
9 #include "base/message_loop.h"
10 #include "base/waitable_event.h"
11 #include "chrome/service/service_process.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 5 #include "testing/gtest/include/gtest/gtest.h"
14 6
15 TEST(ServiceProcessTest, Run) { 7 TEST(ServiceProcessTest, Run) {
16 MessageLoopForUI main_message_loop; 8 // TODO(hclam): Implement this test.
17 ServiceProcess process;
18 EXPECT_TRUE(process.Initialize(&main_message_loop));
19 EXPECT_TRUE(process.Teardown());
20 } 9 }
21
22 #if defined(ENABLE_REMOTING)
23 // TODO(hclam): This method should be made into a util.
24 static std::string GeneratePrivateKey() {
25 scoped_ptr<base::RSAPrivateKey> key(base::RSAPrivateKey::Create(2048));
26
27 std::vector<uint8> private_key_buf;
28 key->ExportPrivateKey(&private_key_buf);
29 std::string private_key_str(private_key_buf.begin(), private_key_buf.end());
30 std::string private_key_base64;
31 base::Base64Encode(private_key_str, &private_key_base64);
32 return private_key_base64;
33 }
34
35 TEST(ServiceProcessTest, RunChromoting) {
36 MessageLoopForUI main_message_loop;
37 ServiceProcess process;
38 EXPECT_TRUE(process.Initialize(&main_message_loop));
39
40 // Then config the chromoting host and start it.
41 process.SaveChromotingConfig("hello", "world", "it's a", "good day",
42 GeneratePrivateKey());
43 EXPECT_TRUE(process.StartChromotingHost());
44 EXPECT_TRUE(process.ShutdownChromotingHost());
45 EXPECT_TRUE(process.Teardown());
46 }
47
48 class MockServiceProcess : public ServiceProcess {
49 private:
50 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown);
51 MOCK_METHOD0(OnChromotingHostShutdown, void());
52 };
53
54 ACTION_P(QuitMessageLoop, message_loop) {
55 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
56 }
57
58 // This test is disabled and should be moved to an offline test suite because
59 // it actually trys to make connect. It'll take very long to get a failure.
60 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) {
61 MessageLoopForUI main_message_loop;
62 MockServiceProcess process;
63 EXPECT_TRUE(process.Initialize(&main_message_loop));
64
65 // Expect chromoting shutdown be called because the login token is invalid.
66 EXPECT_CALL(process, OnChromotingHostShutdown())
67 .WillOnce(QuitMessageLoop(&main_message_loop));
68
69 // Then config the chromoting host and start it.
70 process.SaveChromotingConfig("hello", "world", "it's a", "good day",
71 GeneratePrivateKey());
72 EXPECT_TRUE(process.StartChromotingHost());
73 MessageLoop::current()->Run();
74
75 EXPECT_TRUE(process.Teardown());
76 }
77 #endif // defined(ENABLE_REMOTING)
OLDNEW
« no previous file with comments | « chrome/service/service_process.cc ('k') | remoting/host/heartbeat_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698