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

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

Issue 6660001: Getting service process on Mac to handle having things moved/changed underneath it. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move over to FilePathWatcher Created 9 years, 9 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
OLDNEW
1 // Copyright (c) 2010 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"
6
5 #include <vector> 7 #include <vector>
6 8
7 #include "base/base64.h" 9 #include "base/base64.h"
8 #include "base/command_line.h" 10 #include "base/command_line.h"
9 #include "base/crypto/rsa_private_key.h" 11 #include "base/crypto/rsa_private_key.h"
10 #include "base/message_loop.h" 12 #include "base/message_loop.h"
11 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
12 #include "chrome/service/service_process.h" 14 #include "chrome/common/service_process_util.h"
13 #include "remoting/host/host_key_pair.h" 15 #include "remoting/host/host_key_pair.h"
14 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
16 18
17 TEST(ServiceProcessTest, DISABLED_Run) { 19 TEST(ServiceProcessTest, DISABLED_Run) {
18 MessageLoopForUI main_message_loop; 20 MessageLoopForUI main_message_loop;
19 ServiceProcess process; 21 ServiceProcess process;
22 ServiceProcessState state;
20 CommandLine command_line(CommandLine::NO_PROGRAM); 23 CommandLine command_line(CommandLine::NO_PROGRAM);
21 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); 24 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state));
22 EXPECT_TRUE(process.Teardown()); 25 EXPECT_TRUE(process.Teardown());
23 } 26 }
24 27
25 #if defined(ENABLE_REMOTING) 28 #if defined(ENABLE_REMOTING)
26 // This test seems to break randomly so disabling it. 29 // This test seems to break randomly so disabling it.
27 TEST(ServiceProcessTest, DISABLED_RunChromoting) { 30 TEST(ServiceProcessTest, DISABLED_RunChromoting) {
28 MessageLoopForUI main_message_loop; 31 MessageLoopForUI main_message_loop;
29 ServiceProcess process; 32 ServiceProcess process;
33 ServiceProcessState state;
30 CommandLine command_line(CommandLine::NO_PROGRAM); 34 CommandLine command_line(CommandLine::NO_PROGRAM);
31 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); 35 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state));
32 36
33 // Then config the chromoting host and start it. 37 // Then config the chromoting host and start it.
34 process.remoting_host_manager()->SetCredentials("email", "token"); 38 process.remoting_host_manager()->SetCredentials("email", "token");
35 process.remoting_host_manager()->Enable(); 39 process.remoting_host_manager()->Enable();
36 process.remoting_host_manager()->Disable(); 40 process.remoting_host_manager()->Disable();
37 EXPECT_TRUE(process.Teardown()); 41 EXPECT_TRUE(process.Teardown());
38 } 42 }
39 43
40 class MockServiceProcess : public ServiceProcess { 44 class MockServiceProcess : public ServiceProcess {
41 private: 45 private:
42 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown); 46 FRIEND_TEST_ALL_PREFIXES(ServiceProcessTest, RunChromotingUntilShutdown);
43 MOCK_METHOD0(OnChromotingHostShutdown, void()); 47 MOCK_METHOD0(OnChromotingHostShutdown, void());
44 }; 48 };
45 49
46 ACTION_P(QuitMessageLoop, message_loop) { 50 ACTION_P(QuitMessageLoop, message_loop) {
47 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask()); 51 message_loop->PostTask(FROM_HERE, new MessageLoop::QuitTask());
48 } 52 }
49 53
50 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) { 54 TEST(ServiceProcessTest, DISABLED_RunChromotingUntilShutdown) {
51 MessageLoopForUI main_message_loop; 55 MessageLoopForUI main_message_loop;
52 MockServiceProcess process; 56 MockServiceProcess process;
57 ServiceProcessState state;
53 CommandLine command_line(CommandLine::NO_PROGRAM); 58 CommandLine command_line(CommandLine::NO_PROGRAM);
54 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line)); 59 EXPECT_TRUE(process.Initialize(&main_message_loop, command_line, &state));
55 60
56 // Expect chromoting shutdown be called because the login token is invalid. 61 // Expect chromoting shutdown be called because the login token is invalid.
57 EXPECT_CALL(process, OnChromotingHostShutdown()) 62 EXPECT_CALL(process, OnChromotingHostShutdown())
58 .WillOnce(QuitMessageLoop(&main_message_loop)); 63 .WillOnce(QuitMessageLoop(&main_message_loop));
59 64
60 // Then config the chromoting host and start it. 65 // Then config the chromoting host and start it.
61 process.remoting_host_manager()->SetCredentials("email", "token"); 66 process.remoting_host_manager()->SetCredentials("email", "token");
62 process.remoting_host_manager()->Enable(); 67 process.remoting_host_manager()->Enable();
63 MessageLoop::current()->Run(); 68 MessageLoop::current()->Run();
64 69
65 EXPECT_TRUE(process.Teardown()); 70 EXPECT_TRUE(process.Teardown());
66 } 71 }
67 #endif // defined(ENABLE_REMOTING) 72 #endif // defined(ENABLE_REMOTING)
OLDNEW
« chrome/common/service_process_util_unittest.cc ('K') | « chrome/service/service_process.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698