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 | #include "shill/mock_modem_info.h" |
| 6 | |
| 7 | namespace shill { |
| 8 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 9 | MockModemInfo::MockModemInfo() : |
| 10 | ModemInfo(NULL, NULL, NULL, NULL, NULL), |
Prathmesh Prabhu | 3b66bb9 | 2014-05-22 11:15:25 -0700 | [diff] [blame] | 11 | mock_pending_activation_store_(NULL) {} |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 12 | |
| 13 | MockModemInfo::MockModemInfo(ControlInterface *control, |
| 14 | EventDispatcher *dispatcher, |
| 15 | Metrics *metrics, |
| 16 | Manager *manager, |
| 17 | GLib *glib) : |
| 18 | ModemInfo(control, dispatcher, metrics, manager, glib), |
Prathmesh Prabhu | 3b66bb9 | 2014-05-22 11:15:25 -0700 | [diff] [blame] | 19 | mock_pending_activation_store_(NULL) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 20 | SetMockMembers(); |
| 21 | } |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 22 | |
| 23 | MockModemInfo::~MockModemInfo() {} |
| 24 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 25 | void MockModemInfo::SetMockMembers() { |
| 26 | // These are always replaced by mocks. |
| 27 | // Assumes ownership. |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 28 | set_pending_activation_store(new MockPendingActivationStore()); |
| 29 | mock_pending_activation_store_ = |
| 30 | static_cast<MockPendingActivationStore*>(pending_activation_store()); |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 31 | // These are replaced by mocks only if current unset in ModemInfo. |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 32 | if (control_interface() == NULL) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 33 | mock_control_.reset(new MockControl()); |
| 34 | set_control_interface(mock_control_.get()); |
| 35 | } |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 36 | if (dispatcher() == NULL) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 37 | mock_dispatcher_.reset(new MockEventDispatcher()); |
| 38 | set_event_dispatcher(mock_dispatcher_.get()); |
| 39 | } |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 40 | if (metrics() == NULL) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 41 | mock_metrics_.reset(new MockMetrics(dispatcher())); |
| 42 | set_metrics(mock_metrics_.get()); |
| 43 | } |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 44 | if (glib() == NULL) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 45 | mock_glib_.reset(new MockGLib()); |
| 46 | set_glib(mock_glib_.get()); |
| 47 | } |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 48 | if (manager() == NULL) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 49 | mock_manager_.reset(new MockManager(control_interface(), dispatcher(), |
| 50 | metrics(), glib())); |
| 51 | set_manager(mock_manager_.get()); |
| 52 | } |
| 53 | } |
| 54 | |
Paul Stewart | 8c116a9 | 2012-05-02 18:30:03 -0700 | [diff] [blame] | 55 | } // namespace shill |