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

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

Issue 2843813002: Remove SetWithoutPathExpansion (Closed)
Patch Set: Fix CrOS Error Created 3 years, 8 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
OLDNEW
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 <utility>
6
5 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h"
6 #include "base/run_loop.h" 9 #include "base/run_loop.h"
7 #include "base/test/mock_callback.h" 10 #include "base/test/mock_callback.h"
8 #include "base/values.h" 11 #include "base/values.h"
9 #include "chromeos/dbus/shill_client_unittest_base.h" 12 #include "chromeos/dbus/shill_client_unittest_base.h"
10 #include "chromeos/dbus/shill_profile_client.h" 13 #include "chromeos/dbus/shill_profile_client.h"
11 #include "dbus/message.h" 14 #include "dbus/message.h"
12 #include "dbus/object_path.h" 15 #include "dbus/object_path.h"
13 #include "dbus/values_util.h" 16 #include "dbus/values_util.h"
14 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 writer.OpenArray("{sv}", &array_writer); 103 writer.OpenArray("{sv}", &array_writer);
101 dbus::MessageWriter entry_writer(NULL); 104 dbus::MessageWriter entry_writer(NULL);
102 array_writer.OpenDictEntry(&entry_writer); 105 array_writer.OpenDictEntry(&entry_writer);
103 entry_writer.AppendString(shill::kEntriesProperty); 106 entry_writer.AppendString(shill::kEntriesProperty);
104 AppendVariantOfArrayOfStrings(&entry_writer, 107 AppendVariantOfArrayOfStrings(&entry_writer,
105 std::vector<std::string>(1, kExampleEntryPath)); 108 std::vector<std::string>(1, kExampleEntryPath));
106 array_writer.CloseContainer(&entry_writer); 109 array_writer.CloseContainer(&entry_writer);
107 writer.CloseContainer(&array_writer); 110 writer.CloseContainer(&array_writer);
108 111
109 // Create the expected value. 112 // Create the expected value.
110 base::ListValue* entries = new base::ListValue; 113 auto entries = base::MakeUnique<base::ListValue>();
111 entries->AppendString(kExampleEntryPath); 114 entries->AppendString(kExampleEntryPath);
112 base::DictionaryValue value; 115 base::DictionaryValue value;
113 value.SetWithoutPathExpansion(shill::kEntriesProperty, entries); 116 value.SetWithoutPathExpansion(shill::kEntriesProperty, std::move(entries));
114 // Set expectations. 117 // Set expectations.
115 PrepareForMethodCall(shill::kGetPropertiesFunction, 118 PrepareForMethodCall(shill::kGetPropertiesFunction,
116 base::Bind(&ExpectNoArgument), 119 base::Bind(&ExpectNoArgument),
117 response.get()); 120 response.get());
118 // Call method. 121 // Call method.
119 base::MockCallback<ShillProfileClient::ErrorCallback> error_callback; 122 base::MockCallback<ShillProfileClient::ErrorCallback> error_callback;
120 client_->GetProperties( 123 client_->GetProperties(
121 dbus::ObjectPath(kDefaultProfilePath), 124 dbus::ObjectPath(kDefaultProfilePath),
122 base::Bind(&ExpectDictionaryValueResultWithoutStatus, &value), 125 base::Bind(&ExpectDictionaryValueResultWithoutStatus, &value),
123 error_callback.Get()); 126 error_callback.Get());
(...skipping 11 matching lines...) Expand all
135 writer.OpenArray("{sv}", &array_writer); 138 writer.OpenArray("{sv}", &array_writer);
136 dbus::MessageWriter entry_writer(NULL); 139 dbus::MessageWriter entry_writer(NULL);
137 array_writer.OpenDictEntry(&entry_writer); 140 array_writer.OpenDictEntry(&entry_writer);
138 entry_writer.AppendString(shill::kTypeProperty); 141 entry_writer.AppendString(shill::kTypeProperty);
139 entry_writer.AppendVariantOfString(shill::kTypeWifi); 142 entry_writer.AppendVariantOfString(shill::kTypeWifi);
140 array_writer.CloseContainer(&entry_writer); 143 array_writer.CloseContainer(&entry_writer);
141 writer.CloseContainer(&array_writer); 144 writer.CloseContainer(&array_writer);
142 145
143 // Create the expected value. 146 // Create the expected value.
144 base::DictionaryValue value; 147 base::DictionaryValue value;
145 value.SetWithoutPathExpansion(shill::kTypeProperty, 148 value.SetStringWithoutPathExpansion(shill::kTypeProperty, shill::kTypeWifi);
146 new base::Value(shill::kTypeWifi));
147 // Set expectations. 149 // Set expectations.
148 PrepareForMethodCall(shill::kGetEntryFunction, 150 PrepareForMethodCall(shill::kGetEntryFunction,
149 base::Bind(&ExpectStringArgument, kExampleEntryPath), 151 base::Bind(&ExpectStringArgument, kExampleEntryPath),
150 response.get()); 152 response.get());
151 // Call method. 153 // Call method.
152 base::MockCallback<ShillProfileClient::ErrorCallback> error_callback; 154 base::MockCallback<ShillProfileClient::ErrorCallback> error_callback;
153 client_->GetEntry( 155 client_->GetEntry(
154 dbus::ObjectPath(kDefaultProfilePath), kExampleEntryPath, 156 dbus::ObjectPath(kDefaultProfilePath), kExampleEntryPath,
155 base::Bind(&ExpectDictionaryValueResultWithoutStatus, &value), 157 base::Bind(&ExpectDictionaryValueResultWithoutStatus, &value),
156 error_callback.Get()); 158 error_callback.Get());
157 EXPECT_CALL(error_callback, Run(_, _)).Times(0); 159 EXPECT_CALL(error_callback, Run(_, _)).Times(0);
158 // Run the message loop. 160 // Run the message loop.
159 base::RunLoop().RunUntilIdle(); 161 base::RunLoop().RunUntilIdle();
160 } 162 }
161 163
162 TEST_F(ShillProfileClientTest, DeleteEntry) { 164 TEST_F(ShillProfileClientTest, DeleteEntry) {
163 // Create response. 165 // Create response.
164 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty()); 166 std::unique_ptr<dbus::Response> response(dbus::Response::CreateEmpty());
165 167
166 // Create the expected value. 168 // Create the expected value.
167 base::DictionaryValue value; 169 base::DictionaryValue value;
168 value.SetWithoutPathExpansion(shill::kOfflineModeProperty, 170 value.SetBooleanWithoutPathExpansion(shill::kOfflineModeProperty, true);
169 new base::Value(true));
170 // Set expectations. 171 // Set expectations.
171 PrepareForMethodCall(shill::kDeleteEntryFunction, 172 PrepareForMethodCall(shill::kDeleteEntryFunction,
172 base::Bind(&ExpectStringArgument, kExampleEntryPath), 173 base::Bind(&ExpectStringArgument, kExampleEntryPath),
173 response.get()); 174 response.get());
174 // Call method. 175 // Call method.
175 base::MockCallback<base::Closure> mock_closure; 176 base::MockCallback<base::Closure> mock_closure;
176 base::MockCallback<ShillProfileClient::ErrorCallback> mock_error_callback; 177 base::MockCallback<ShillProfileClient::ErrorCallback> mock_error_callback;
177 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), kExampleEntryPath, 178 client_->DeleteEntry(dbus::ObjectPath(kDefaultProfilePath), kExampleEntryPath,
178 mock_closure.Get(), mock_error_callback.Get()); 179 mock_closure.Get(), mock_error_callback.Get());
179 EXPECT_CALL(mock_closure, Run()).Times(1); 180 EXPECT_CALL(mock_closure, Run()).Times(1);
180 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0); 181 EXPECT_CALL(mock_error_callback, Run(_, _)).Times(0);
181 182
182 // Run the message loop. 183 // Run the message loop.
183 base::RunLoop().RunUntilIdle(); 184 base::RunLoop().RunUntilIdle();
184 } 185 }
185 186
186 } // namespace chromeos 187 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/shill_manager_client_unittest.cc ('k') | chromeos/dbus/shill_service_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698