Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: chromeos/dbus/fake_shill_ipconfig_client.cc

Issue 31513002: dbus: Remove MockShillDeviceClient and MockShillIPConfigClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/dbus/shill_ipconfig_client_stub.h" 5 #include "chromeos/dbus/fake_shill_ipconfig_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chromeos/dbus/shill_property_changed_observer.h" 11 #include "chromeos/dbus/shill_property_changed_observer.h"
12 #include "dbus/bus.h" 12 #include "dbus/bus.h"
13 #include "dbus/message.h" 13 #include "dbus/message.h"
14 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
15 #include "dbus/object_proxy.h" 15 #include "dbus/object_proxy.h"
16 #include "dbus/values_util.h" 16 #include "dbus/values_util.h"
17 #include "third_party/cros_system_api/dbus/service_constants.h" 17 #include "third_party/cros_system_api/dbus/service_constants.h"
18 18
19 namespace chromeos { 19 namespace chromeos {
20 20
21 ShillIPConfigClientStub::ShillIPConfigClientStub() : weak_ptr_factory_(this) { 21 FakeShillIPConfigClient::FakeShillIPConfigClient() : weak_ptr_factory_(this) {
22 } 22 }
23 23
24 ShillIPConfigClientStub::~ShillIPConfigClientStub() { 24 FakeShillIPConfigClient::~FakeShillIPConfigClient() {
25 } 25 }
26 26
27 void ShillIPConfigClientStub::Init(dbus::Bus* bus) { 27 void FakeShillIPConfigClient::Init(dbus::Bus* bus) {
28 } 28 }
29 29
30 void ShillIPConfigClientStub::AddPropertyChangedObserver( 30 void FakeShillIPConfigClient::AddPropertyChangedObserver(
31 const dbus::ObjectPath& ipconfig_path, 31 const dbus::ObjectPath& ipconfig_path,
32 ShillPropertyChangedObserver* observer) { 32 ShillPropertyChangedObserver* observer) {
33 } 33 }
34 34
35 void ShillIPConfigClientStub::RemovePropertyChangedObserver( 35 void FakeShillIPConfigClient::RemovePropertyChangedObserver(
36 const dbus::ObjectPath& ipconfig_path, 36 const dbus::ObjectPath& ipconfig_path,
37 ShillPropertyChangedObserver* observer) { 37 ShillPropertyChangedObserver* observer) {
38 } 38 }
39 39
40 void ShillIPConfigClientStub::Refresh(const dbus::ObjectPath& ipconfig_path, 40 void FakeShillIPConfigClient::Refresh(const dbus::ObjectPath& ipconfig_path,
41 const VoidDBusMethodCallback& callback) { 41 const VoidDBusMethodCallback& callback) {
42 } 42 }
43 43
44 void ShillIPConfigClientStub::GetProperties( 44 void FakeShillIPConfigClient::GetProperties(
45 const dbus::ObjectPath& ipconfig_path, 45 const dbus::ObjectPath& ipconfig_path,
46 const DictionaryValueCallback& callback) { 46 const DictionaryValueCallback& callback) {
47 const base::DictionaryValue* dict = NULL; 47 const base::DictionaryValue* dict = NULL;
48 if (!ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(), 48 if (!ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(),
49 &dict)) 49 &dict))
50 return; 50 return;
51 base::MessageLoop::current()->PostTask( 51 base::MessageLoop::current()->PostTask(
52 FROM_HERE, base::Bind(&ShillIPConfigClientStub::PassProperties, 52 FROM_HERE, base::Bind(&FakeShillIPConfigClient::PassProperties,
53 weak_ptr_factory_.GetWeakPtr(), 53 weak_ptr_factory_.GetWeakPtr(),
54 dict, 54 dict,
55 callback)); 55 callback));
56 } 56 }
57 57
58 void ShillIPConfigClientStub::SetProperty( 58 void FakeShillIPConfigClient::SetProperty(
59 const dbus::ObjectPath& ipconfig_path, 59 const dbus::ObjectPath& ipconfig_path,
60 const std::string& name, 60 const std::string& name,
61 const base::Value& value, 61 const base::Value& value,
62 const VoidDBusMethodCallback& callback) { 62 const VoidDBusMethodCallback& callback) {
63 base::DictionaryValue* dict = NULL; 63 base::DictionaryValue* dict = NULL;
64 if (ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(), 64 if (ipconfigs_.GetDictionaryWithoutPathExpansion(ipconfig_path.value(),
65 &dict)) { 65 &dict)) {
66 // Update existing ip config stub object's properties. 66 // Update existing ip config stub object's properties.
67 dict->SetWithoutPathExpansion(name, value.DeepCopy()); 67 dict->SetWithoutPathExpansion(name, value.DeepCopy());
68 } else { 68 } else {
69 // Create a new stub ipconfig object, and update its properties. 69 // Create a new stub ipconfig object, and update its properties.
70 base::DictionaryValue* dvalue = new base::DictionaryValue; 70 base::DictionaryValue* dvalue = new base::DictionaryValue;
71 dvalue->SetWithoutPathExpansion(name, value.DeepCopy()); 71 dvalue->SetWithoutPathExpansion(name, value.DeepCopy());
72 ipconfigs_.SetWithoutPathExpansion(ipconfig_path.value(), 72 ipconfigs_.SetWithoutPathExpansion(ipconfig_path.value(),
73 dvalue); 73 dvalue);
74 } 74 }
75 base::MessageLoop::current()->PostTask( 75 base::MessageLoop::current()->PostTask(
76 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 76 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
77 } 77 }
78 78
79 void ShillIPConfigClientStub::ClearProperty( 79 void FakeShillIPConfigClient::ClearProperty(
80 const dbus::ObjectPath& ipconfig_path, 80 const dbus::ObjectPath& ipconfig_path,
81 const std::string& name, 81 const std::string& name,
82 const VoidDBusMethodCallback& callback) { 82 const VoidDBusMethodCallback& callback) {
83 base::MessageLoop::current()->PostTask( 83 base::MessageLoop::current()->PostTask(
84 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 84 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
85 } 85 }
86 86
87 void ShillIPConfigClientStub::Remove(const dbus::ObjectPath& ipconfig_path, 87 void FakeShillIPConfigClient::Remove(const dbus::ObjectPath& ipconfig_path,
88 const VoidDBusMethodCallback& callback) { 88 const VoidDBusMethodCallback& callback) {
89 base::MessageLoop::current()->PostTask( 89 base::MessageLoop::current()->PostTask(
90 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS)); 90 FROM_HERE, base::Bind(callback, DBUS_METHOD_CALL_SUCCESS));
91 } 91 }
92 92
93 void ShillIPConfigClientStub::PassProperties( 93 void FakeShillIPConfigClient::PassProperties(
94 const base::DictionaryValue* values, 94 const base::DictionaryValue* values,
95 const DictionaryValueCallback& callback) const { 95 const DictionaryValueCallback& callback) const {
96 callback.Run(DBUS_METHOD_CALL_SUCCESS, *values); 96 callback.Run(DBUS_METHOD_CALL_SUCCESS, *values);
97 } 97 }
98 98
99 } // namespace chromeos 99 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698