blob: 5d5d279822ef4e51602f6b121e18dc13897e7bc9 [file] [log] [blame]
Paul Stewart8c116a92012-05-02 18:30:03 -07001// 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
7namespace shill {
8
Prathmesh Prabhu27526f12013-03-25 19:42:18 -07009MockModemInfo::MockModemInfo() :
10 ModemInfo(NULL, NULL, NULL, NULL, NULL),
Prathmesh Prabhu3b66bb92014-05-22 11:15:25 -070011 mock_pending_activation_store_(NULL) {}
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070012
13MockModemInfo::MockModemInfo(ControlInterface *control,
14 EventDispatcher *dispatcher,
15 Metrics *metrics,
16 Manager *manager,
17 GLib *glib) :
18 ModemInfo(control, dispatcher, metrics, manager, glib),
Prathmesh Prabhu3b66bb92014-05-22 11:15:25 -070019 mock_pending_activation_store_(NULL) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070020 SetMockMembers();
21}
Paul Stewart8c116a92012-05-02 18:30:03 -070022
23MockModemInfo::~MockModemInfo() {}
24
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070025void MockModemInfo::SetMockMembers() {
26 // These are always replaced by mocks.
27 // Assumes ownership.
Arman Uguray41cc6342013-03-29 16:34:39 -070028 set_pending_activation_store(new MockPendingActivationStore());
29 mock_pending_activation_store_ =
30 static_cast<MockPendingActivationStore*>(pending_activation_store());
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070031 // These are replaced by mocks only if current unset in ModemInfo.
Alex Vakulenko8a532292014-06-16 17:18:44 -070032 if (control_interface() == NULL) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070033 mock_control_.reset(new MockControl());
34 set_control_interface(mock_control_.get());
35 }
Alex Vakulenko8a532292014-06-16 17:18:44 -070036 if (dispatcher() == NULL) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070037 mock_dispatcher_.reset(new MockEventDispatcher());
38 set_event_dispatcher(mock_dispatcher_.get());
39 }
Alex Vakulenko8a532292014-06-16 17:18:44 -070040 if (metrics() == NULL) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070041 mock_metrics_.reset(new MockMetrics(dispatcher()));
42 set_metrics(mock_metrics_.get());
43 }
Alex Vakulenko8a532292014-06-16 17:18:44 -070044 if (glib() == NULL) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070045 mock_glib_.reset(new MockGLib());
46 set_glib(mock_glib_.get());
47 }
Alex Vakulenko8a532292014-06-16 17:18:44 -070048 if (manager() == NULL) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070049 mock_manager_.reset(new MockManager(control_interface(), dispatcher(),
50 metrics(), glib()));
51 set_manager(mock_manager_.get());
52 }
53}
54
Paul Stewart8c116a92012-05-02 18:30:03 -070055} // namespace shill