OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef CHROMEOS_DBUS_FAKE_GSM_SMS_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_MODEM_MESSAGING_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_GSM_SMS_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_MODEM_MESSAGING_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include "base/basictypes.h" |
9 | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "chromeos/chromeos_export.h" |
11 #include "base/values.h" | 11 #include "chromeos/dbus/modem_messaging_client.h" |
12 #include "chromeos/dbus/gsm_sms_client.h" | |
13 #include "dbus/object_path.h" | |
14 | 12 |
15 namespace chromeos { | 13 namespace chromeos { |
16 | 14 |
17 // A fake implementation of GsmSMSClient used for tests. | 15 class CHROMEOS_EXPORT FakeModemMessagingClient : public ModemMessagingClient { |
18 class CHROMEOS_EXPORT FakeGsmSMSClient : public GsmSMSClient { | |
19 public: | 16 public: |
20 FakeGsmSMSClient(); | 17 FakeModemMessagingClient(); |
21 virtual ~FakeGsmSMSClient(); | 18 virtual ~FakeModemMessagingClient(); |
22 | 19 |
23 // GsmSMSClient overrides | |
24 virtual void Init(dbus::Bus* bus) OVERRIDE; | 20 virtual void Init(dbus::Bus* bus) OVERRIDE; |
25 virtual void SetSmsReceivedHandler(const std::string& service_name, | 21 virtual void SetSmsReceivedHandler(const std::string& service_name, |
26 const dbus::ObjectPath& object_path, | 22 const dbus::ObjectPath& object_path, |
27 const SmsReceivedHandler& handler) | 23 const SmsReceivedHandler& handler) |
28 OVERRIDE; | 24 OVERRIDE; |
29 virtual void ResetSmsReceivedHandler(const std::string& service_name, | 25 virtual void ResetSmsReceivedHandler(const std::string& service_name, |
30 const dbus::ObjectPath& object_path) | 26 const dbus::ObjectPath& object_path) |
31 OVERRIDE; | 27 OVERRIDE; |
32 virtual void Delete(const std::string& service_name, | 28 virtual void Delete(const std::string& service_name, |
33 const dbus::ObjectPath& object_path, | 29 const dbus::ObjectPath& object_path, |
34 uint32 index, | 30 const dbus::ObjectPath& sms_path, |
35 const DeleteCallback& callback) OVERRIDE; | 31 const DeleteCallback& callback) OVERRIDE; |
36 virtual void Get(const std::string& service_name, | |
37 const dbus::ObjectPath& object_path, | |
38 uint32 index, | |
39 const GetCallback& callback) OVERRIDE; | |
40 virtual void List(const std::string& service_name, | 32 virtual void List(const std::string& service_name, |
41 const dbus::ObjectPath& object_path, | 33 const dbus::ObjectPath& object_path, |
42 const ListCallback& callback) OVERRIDE; | 34 const ListCallback& callback) OVERRIDE; |
43 virtual void RequestUpdate(const std::string& service_name, | |
44 const dbus::ObjectPath& object_path) OVERRIDE; | |
45 | |
46 // Sets if the command line switch for test is present. RequestUpdate() | |
47 // changes its behavior depending on the switch. | |
48 void set_sms_test_message_switch_present(bool is_present) { | |
49 sms_test_message_switch_present_ = is_present; | |
50 } | |
51 | 35 |
52 private: | 36 private: |
53 void PushTestMessageChain(); | 37 SmsReceivedHandler sms_received_handler_; |
54 void PushTestMessageDelayed(); | 38 std::vector<dbus::ObjectPath> message_paths_; |
55 bool PushTestMessage(); | |
56 | 39 |
57 int test_index_; | 40 DISALLOW_COPY_AND_ASSIGN(FakeModemMessagingClient); |
58 std::vector<std::string> test_messages_; | |
59 base::ListValue message_list_; | |
60 SmsReceivedHandler handler_; | |
61 | |
62 bool sms_test_message_switch_present_; | |
63 | |
64 base::WeakPtrFactory<FakeGsmSMSClient> weak_ptr_factory_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(FakeGsmSMSClient); | |
67 }; | 41 }; |
68 | 42 |
69 } // namespace chromeos | 43 } // namespace chromeos |
70 | 44 |
71 #endif // CHROMEOS_DBUS_FAKE_GSM_SMS_CLIENT_H_ | 45 #endif // CHROMEOS_DBUS_FAKE_MODEM_MESSAGING_CLIENT_H_ |
OLD | NEW |