1 //
2 // Copyright (C) 2012 The Android Open Source Project
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //      http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #ifndef SHILL_CELLULAR_MOCK_MODEM_INFO_H_
18 #define SHILL_CELLULAR_MOCK_MODEM_INFO_H_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <base/macros.h>
24 #include <gmock/gmock.h>
25 
26 #include "shill/cellular/modem_info.h"
27 #include "shill/mock_control.h"
28 #include "shill/mock_event_dispatcher.h"
29 #include "shill/mock_manager.h"
30 #include "shill/mock_metrics.h"
31 #include "shill/mock_pending_activation_store.h"
32 
33 namespace shill {
34 
35 class MockModemInfo : public ModemInfo {
36  public:
37   MockModemInfo();
38 
39   // All nullptr parameters are replaced by mock objects.
40   MockModemInfo(ControlInterface* control,
41                 EventDispatcher* dispatcher,
42                 Metrics* metrics,
43                 Manager* manager);
44 
45   ~MockModemInfo() override;
46 
47   // Replaces data members in ModemInfo by mock objects.
48   // The following are relaced by mocks if they are nullptr: control_interface,
49   // dispatcher, metrics, manager.
50   // The following are always replaced by mocks: pending_activation_store.
51   void SetMockMembers();
52 
53   // Accessors for mock objects
mock_pending_activation_store()54   MockPendingActivationStore* mock_pending_activation_store() const {
55     return mock_pending_activation_store_;
56   }
mock_control_interface()57   MockControl* mock_control_interface() const {
58     return mock_control_.get();
59   }
mock_dispatcher()60   MockEventDispatcher* mock_dispatcher() const {
61     return mock_dispatcher_.get();
62   }
mock_metrics()63   MockMetrics* mock_metrics() const {
64     return mock_metrics_.get();
65   }
mock_manager()66   MockManager* mock_manager() const {
67     return mock_manager_.get();
68   }
69 
70   MOCK_METHOD0(Start, void());
71   MOCK_METHOD0(Stop, void());
72   MOCK_METHOD1(OnDeviceInfoAvailable, void(const std::string& link_name));
73 
74  private:
75   std::unique_ptr<MockControl> mock_control_;
76   std::unique_ptr<MockEventDispatcher> mock_dispatcher_;
77   std::unique_ptr<MockMetrics> mock_metrics_;
78   std::unique_ptr<MockManager> mock_manager_;
79 
80   // owned by ModemInfo
81   MockPendingActivationStore* mock_pending_activation_store_;
82 
83   DISALLOW_COPY_AND_ASSIGN(MockModemInfo);
84 };
85 
86 }  // namespace shill
87 
88 #endif  // SHILL_CELLULAR_MOCK_MODEM_INFO_H_
89