OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "chromeos/dbus/shill_client_unittest_base.h" | 7 #include "chromeos/dbus/shill_client_unittest_base.h" |
8 #include "chromeos/dbus/shill_profile_client.h" | 8 #include "chromeos/dbus/shill_profile_client.h" |
9 #include "dbus/message.h" | 9 #include "dbus/message.h" |
10 #include "dbus/object_path.h" | 10 #include "dbus/object_path.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // Create the expected value. | 109 // Create the expected value. |
110 base::ListValue* entries = new base::ListValue; | 110 base::ListValue* entries = new base::ListValue; |
111 entries->Append(base::Value::CreateStringValue(kExampleEntryPath)); | 111 entries->Append(base::Value::CreateStringValue(kExampleEntryPath)); |
112 base::DictionaryValue value; | 112 base::DictionaryValue value; |
113 value.SetWithoutPathExpansion(flimflam::kEntriesProperty, entries); | 113 value.SetWithoutPathExpansion(flimflam::kEntriesProperty, entries); |
114 // Set expectations. | 114 // Set expectations. |
115 PrepareForMethodCall(flimflam::kGetPropertiesFunction, | 115 PrepareForMethodCall(flimflam::kGetPropertiesFunction, |
116 base::Bind(&ExpectNoArgument), | 116 base::Bind(&ExpectNoArgument), |
117 response.get()); | 117 response.get()); |
118 // Call method. | 118 // Call method. |
| 119 MockErrorCallback error_callback; |
119 client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath), | 120 client_->GetProperties(dbus::ObjectPath(kDefaultProfilePath), |
120 base::Bind(&ExpectDictionaryValueResult, &value)); | 121 base::Bind(&ExpectDictionaryValueResultWithoutStatus, |
| 122 &value), |
| 123 error_callback.GetCallback()); |
| 124 EXPECT_CALL(error_callback, Run(_, _)).Times(0); |
| 125 |
121 // Run the message loop. | 126 // Run the message loop. |
122 message_loop_.RunAllPending(); | 127 message_loop_.RunAllPending(); |
123 } | 128 } |
124 | 129 |
125 TEST_F(ShillProfileClientTest, GetEntry) { | 130 TEST_F(ShillProfileClientTest, GetEntry) { |
126 // Create response. | 131 // Create response. |
127 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 132 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
128 dbus::MessageWriter writer(response.get()); | 133 dbus::MessageWriter writer(response.get()); |
129 dbus::MessageWriter array_writer(NULL); | 134 dbus::MessageWriter array_writer(NULL); |
130 writer.OpenArray("{sv}", &array_writer); | 135 writer.OpenArray("{sv}", &array_writer); |
131 dbus::MessageWriter entry_writer(NULL); | 136 dbus::MessageWriter entry_writer(NULL); |
132 array_writer.OpenDictEntry(&entry_writer); | 137 array_writer.OpenDictEntry(&entry_writer); |
133 entry_writer.AppendString(flimflam::kTypeProperty); | 138 entry_writer.AppendString(flimflam::kTypeProperty); |
134 entry_writer.AppendVariantOfString(flimflam::kTypeWifi); | 139 entry_writer.AppendVariantOfString(flimflam::kTypeWifi); |
135 array_writer.CloseContainer(&entry_writer); | 140 array_writer.CloseContainer(&entry_writer); |
136 writer.CloseContainer(&array_writer); | 141 writer.CloseContainer(&array_writer); |
137 | 142 |
138 // Create the expected value. | 143 // Create the expected value. |
139 base::DictionaryValue value; | 144 base::DictionaryValue value; |
140 value.SetWithoutPathExpansion( | 145 value.SetWithoutPathExpansion( |
141 flimflam::kTypeProperty, | 146 flimflam::kTypeProperty, |
142 base::Value::CreateStringValue(flimflam::kTypeWifi)); | 147 base::Value::CreateStringValue(flimflam::kTypeWifi)); |
143 // Set expectations. | 148 // Set expectations. |
144 PrepareForMethodCall(flimflam::kGetEntryFunction, | 149 PrepareForMethodCall(flimflam::kGetEntryFunction, |
145 base::Bind(&ExpectStringArgument, kExampleEntryPath), | 150 base::Bind(&ExpectStringArgument, kExampleEntryPath), |
146 response.get()); | 151 response.get()); |
147 // Call method. | 152 // Call method. |
| 153 MockErrorCallback error_callback; |
148 client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath), | 154 client_->GetEntry(dbus::ObjectPath(kDefaultProfilePath), |
149 kExampleEntryPath, | 155 kExampleEntryPath, |
150 base::Bind(&ExpectDictionaryValueResult, &value)); | 156 base::Bind(&ExpectDictionaryValueResultWithoutStatus, |
| 157 &value), |
| 158 error_callback.GetCallback()); |
| 159 EXPECT_CALL(error_callback, Run(_, _)).Times(0); |
151 // Run the message loop. | 160 // Run the message loop. |
152 message_loop_.RunAllPending(); | 161 message_loop_.RunAllPending(); |
153 } | 162 } |
154 | 163 |
155 TEST_F(ShillProfileClientTest, DeleteEntry) { | 164 TEST_F(ShillProfileClientTest, DeleteEntry) { |
156 // Create response. | 165 // Create response. |
157 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); | 166 scoped_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); |
158 | 167 |
159 // Create the expected value. | 168 // Create the expected value. |
160 base::DictionaryValue value; | 169 base::DictionaryValue value; |
161 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty, | 170 value.SetWithoutPathExpansion(flimflam::kOfflineModeProperty, |
162 base::Value::CreateBooleanValue(true)); | 171 base::Value::CreateBooleanValue(true)); |
163 // Set expectations. | 172 // Set expectations. |
164 PrepareForMethodCall(flimflam::kDeleteEntryFunction, | 173 PrepareForMethodCall(flimflam::kDeleteEntryFunction, |
165 base::Bind(&ExpectStringArgument, kExampleEntryPath), | 174 base::Bind(&ExpectStringArgument, kExampleEntryPath), |
166 response.get()); | 175 response.get()); |
167 // Call method. | 176 // Call method. |
| 177 MockClosure mock_closure; |
| 178 MockErrorCallback mock_error_callback; |
168 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), | 179 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), |
169 kExampleEntryPath, | 180 kExampleEntryPath, |
170 base::Bind(&ExpectNoResultValue)); | 181 mock_closure.GetCallback(), |
| 182 mock_error_callback.GetCallback()); |
| 183 EXPECT_CALL(mock_closure, Run()).Times(1); |
| 184 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); |
| 185 |
171 // Run the message loop. | 186 // Run the message loop. |
172 message_loop_.RunAllPending(); | 187 message_loop_.RunAllPending(); |
173 } | 188 } |
174 | 189 |
175 } // namespace chromeos | 190 } // namespace chromeos |
OLD | NEW |