blob: 7f1c95e8665b7b7bd726e5950a91bcc747ba2076 [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
Ben Chanc54afe52014-11-05 10:28:08 -08005#include "shill/cellular/mock_modem_info.h"
Paul Stewart8c116a92012-05-02 18:30:03 -07006
7namespace shill {
8
Prathmesh Prabhu27526f12013-03-25 19:42:18 -07009MockModemInfo::MockModemInfo() :
Ben Chanea18c6c2014-09-30 13:08:26 -070010 ModemInfo(nullptr, nullptr, nullptr, nullptr, nullptr),
11 mock_pending_activation_store_(nullptr) {}
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070012
Paul Stewart2f6c7892015-06-16 13:13:10 -070013MockModemInfo::MockModemInfo(ControlInterface* control,
14 EventDispatcher* dispatcher,
15 Metrics* metrics,
16 Manager* manager,
17 GLib* glib) :
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070018 ModemInfo(control, dispatcher, metrics, manager, glib),
Ben Chanea18c6c2014-09-30 13:08:26 -070019 mock_pending_activation_store_(nullptr) {
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.
Ben Chanea18c6c2014-09-30 13:08:26 -070032 if (control_interface() == nullptr) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070033 mock_control_.reset(new MockControl());
34 set_control_interface(mock_control_.get());
35 }
Ben Chanea18c6c2014-09-30 13:08:26 -070036 if (dispatcher() == nullptr) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070037 mock_dispatcher_.reset(new MockEventDispatcher());
38 set_event_dispatcher(mock_dispatcher_.get());
39 }
Ben Chanea18c6c2014-09-30 13:08:26 -070040 if (metrics() == nullptr) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070041 mock_metrics_.reset(new MockMetrics(dispatcher()));
42 set_metrics(mock_metrics_.get());
43 }
Ben Chanea18c6c2014-09-30 13:08:26 -070044 if (glib() == nullptr) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070045 mock_glib_.reset(new MockGLib());
46 set_glib(mock_glib_.get());
47 }
Ben Chanea18c6c2014-09-30 13:08:26 -070048 if (manager() == nullptr) {
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