Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS 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 SHILL_MOCK_MODEM_INFO_ |
| 6 | #define SHILL_MOCK_MODEM_INFO_ |
| 7 | |
| 8 | #include <base/basictypes.h> |
| 9 | #include <gmock/gmock.h> |
| 10 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 11 | #include "shill/mock_cellular_operator_info.h" |
| 12 | #include "shill/mock_control.h" |
| 13 | #include "shill/mock_event_dispatcher.h" |
| 14 | #include "shill/mock_glib.h" |
| 15 | #include "shill/mock_manager.h" |
| 16 | #include "shill/mock_metrics.h" |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 17 | #include "shill/mock_pending_activation_store.h" |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 18 | #include "shill/modem_info.h" |
| 19 | |
| 20 | namespace shill { |
| 21 | |
| 22 | class MockModemInfo : public ModemInfo { |
| 23 | public: |
| 24 | MockModemInfo(); |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 25 | |
| 26 | // All NULL parameters are replaced by mock objects. |
| 27 | MockModemInfo(ControlInterface *control, |
| 28 | EventDispatcher *dispatcher, |
| 29 | Metrics *metrics, |
| 30 | Manager *manager, |
| 31 | GLib *glib); |
| 32 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 33 | virtual ~MockModemInfo(); |
| 34 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 35 | // Replaces data members in ModemInfo by mock objects. |
| 36 | // The following are relaced by mocks if they are NULL: control_interface, |
| 37 | // dispatcher, metrics, manager, glib. |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 38 | // The following are always replaced by mocks: pending_activation_store, |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 39 | // cellular_operator_info. |
| 40 | void SetMockMembers(); |
| 41 | |
| 42 | // Create a new provider_db and set it in ModemInfo. |
| 43 | // ModemInfo takes ownership. |
| 44 | void SetProviderDB(const char *provider_db_path); |
| 45 | |
| 46 | // Accessors for mock objects |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 47 | MockPendingActivationStore* mock_pending_activation_store() const { |
| 48 | return mock_pending_activation_store_; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 49 | } |
| 50 | MockCellularOperatorInfo* mock_cellular_operator_info() const { |
| 51 | return mock_cellular_operator_info_; |
| 52 | } |
| 53 | MockControl* mock_control_interface() const { |
| 54 | return mock_control_.get(); |
| 55 | } |
| 56 | MockEventDispatcher* mock_dispatcher() const { |
| 57 | return mock_dispatcher_.get(); |
| 58 | } |
| 59 | MockMetrics* mock_metrics() const { |
| 60 | return mock_metrics_.get(); |
| 61 | } |
| 62 | MockManager* mock_manager() const { |
| 63 | return mock_manager_.get(); |
| 64 | } |
| 65 | MockGLib* mock_glib() const { |
| 66 | return mock_glib_.get(); |
| 67 | } |
| 68 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 69 | MOCK_METHOD0(Start, void()); |
| 70 | MOCK_METHOD0(Stop, void()); |
| 71 | MOCK_METHOD1(OnDeviceInfoAvailable, void(const std::string &link_name)); |
| 72 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 73 | private: |
| 74 | scoped_ptr<MockControl> mock_control_; |
| 75 | scoped_ptr<MockEventDispatcher> mock_dispatcher_; |
| 76 | scoped_ptr<MockMetrics> mock_metrics_; |
| 77 | scoped_ptr<MockManager> mock_manager_; |
| 78 | scoped_ptr<MockGLib> mock_glib_; |
| 79 | |
| 80 | // owned by ModemInfo |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 81 | MockPendingActivationStore *mock_pending_activation_store_; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 82 | MockCellularOperatorInfo *mock_cellular_operator_info_; |
| 83 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 84 | DISALLOW_COPY_AND_ASSIGN(MockModemInfo); |
| 85 | }; |
| 86 | |
| 87 | } // namespace shill |
| 88 | |
| 89 | #endif // SHILL_MOCK_MODEM_INFO_ |