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 #include "shill/mock_service.h"
18
19 #include <string>
20
21 #include <base/memory/ref_counted.h>
22 #include <base/strings/stringprintf.h>
23 #include <gmock/gmock.h>
24
25 #include "shill/refptr_types.h"
26 #include "shill/store_interface.h"
27 #include "shill/technology.h"
28
29 using std::string;
30 using testing::_;
31 using testing::Return;
32 using testing::ReturnRef;
33
34 namespace shill {
35
36 class ControlInterface;
37 class EventDispatcher;
38 class Manager;
39
MockService(ControlInterface * control_interface,EventDispatcher * dispatcher,Metrics * metrics,Manager * manager)40 MockService::MockService(ControlInterface* control_interface,
41 EventDispatcher* dispatcher,
42 Metrics* metrics,
43 Manager* manager)
44 : Service(control_interface, dispatcher, metrics, manager,
45 Technology::kUnknown) {
46 const string& id = unique_name();
47 EXPECT_CALL(*this, GetRpcIdentifier()).WillRepeatedly(Return(id));
48 EXPECT_CALL(*this, GetStorageIdentifier()).WillRepeatedly(Return(id));
49 ON_CALL(*this, IsVisible()).WillByDefault(Return(true));
50 ON_CALL(*this, state()).WillByDefault(Return(kStateUnknown));
51 ON_CALL(*this, failure()).WillByDefault(Return(kFailureUnknown));
52 ON_CALL(*this, technology()).WillByDefault(Return(Technology::kUnknown));
53 ON_CALL(*this, connection()).WillByDefault(ReturnRef(mock_connection_));
54 }
55
~MockService()56 MockService::~MockService() {}
57
FauxSave(StoreInterface * store)58 bool MockService::FauxSave(StoreInterface* store) {
59 return store->SetString(GetStorageIdentifier(), "dummy", "dummy");
60 }
61
62 } // namespace shill
63