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