1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_COMMON_MAC_MOCK_LAUNCHD_H_
6 #define CHROME_COMMON_MAC_MOCK_LAUNCHD_H_
12 #include "base/files/file_path.h"
13 #include "base/mac/scoped_cftyperef.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "chrome/common/mac/launchd.h"
16 #include "chrome/common/multi_process_lock.h"
22 // TODO(dmaclach): Write this in terms of a real mock.
23 // http://crbug.com/76923
24 class MockLaunchd
: public Launchd
{
26 static bool MakeABundle(const base::FilePath
& dst
,
27 const std::string
& name
,
28 base::FilePath
* bundle_root
,
29 base::FilePath
* executable
);
31 MockLaunchd(const base::FilePath
& file
, base::MessageLoop
* loop
,
32 bool create_socket
, bool as_service
);
33 virtual ~MockLaunchd();
35 virtual CFDictionaryRef
CopyExports() OVERRIDE
;
36 virtual CFDictionaryRef
CopyJobDictionary(CFStringRef label
) OVERRIDE
;
37 virtual CFDictionaryRef
CopyDictionaryByCheckingIn(CFErrorRef
* error
)
39 virtual bool RemoveJob(CFStringRef label
, CFErrorRef
* error
) OVERRIDE
;
40 virtual bool RestartJob(Domain domain
,
43 CFStringRef session_type
) OVERRIDE
;
44 virtual CFMutableDictionaryRef
CreatePlistFromFile(
47 CFStringRef name
) OVERRIDE
;
48 virtual bool WritePlistToFile(Domain domain
,
51 CFDictionaryRef dict
) OVERRIDE
;
52 virtual bool DeletePlist(Domain domain
,
54 CFStringRef name
) OVERRIDE
;
58 bool restart_called() const { return restart_called_
; }
59 bool remove_called() const { return remove_called_
; }
60 bool checkin_called() const { return checkin_called_
; }
61 bool write_called() const { return write_called_
; }
62 bool delete_called() const { return delete_called_
; }
66 std::string pipe_name_
;
67 base::MessageLoop
* message_loop_
;
68 scoped_ptr
<MultiProcessLock
> running_lock_
;
78 #endif // CHROME_COMMON_MAC_MOCK_LAUNCHD_H_