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

Side by Side Diff: chromeos/network/network_device_handler_unittest.cc

Issue 2666093002: Remove base::FundamentalValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 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 <memory> 5 #include <memory>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 base::RunLoop().RunUntilIdle(); 121 base::RunLoop().RunUntilIdle();
122 EXPECT_EQ(kResultSuccess, result_); 122 EXPECT_EQ(kResultSuccess, result_);
123 std::string type; 123 std::string type;
124 properties_->GetString(shill::kTypeProperty, &type); 124 properties_->GetString(shill::kTypeProperty, &type);
125 EXPECT_EQ(shill::kTypeWifi, type); 125 EXPECT_EQ(shill::kTypeWifi, type);
126 } 126 }
127 127
128 TEST_F(NetworkDeviceHandlerTest, SetDeviceProperty) { 128 TEST_F(NetworkDeviceHandlerTest, SetDeviceProperty) {
129 // Set the shill::kScanIntervalProperty to true. The call 129 // Set the shill::kScanIntervalProperty to true. The call
130 // should succeed and the value should be set. 130 // should succeed and the value should be set.
131 network_device_handler_->SetDeviceProperty(kDefaultCellularDevicePath, 131 network_device_handler_->SetDeviceProperty(
132 shill::kScanIntervalProperty, 132 kDefaultCellularDevicePath, shill::kScanIntervalProperty, base::Value(1),
133 base::FundamentalValue(1), 133 success_callback_, error_callback_);
134 success_callback_,
135 error_callback_);
136 base::RunLoop().RunUntilIdle(); 134 base::RunLoop().RunUntilIdle();
137 EXPECT_EQ(kResultSuccess, result_); 135 EXPECT_EQ(kResultSuccess, result_);
138 136
139 // GetDeviceProperties should return the value set by SetDeviceProperty. 137 // GetDeviceProperties should return the value set by SetDeviceProperty.
140 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, 138 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath,
141 properties_success_callback_, 139 properties_success_callback_,
142 error_callback_); 140 error_callback_);
143 base::RunLoop().RunUntilIdle(); 141 base::RunLoop().RunUntilIdle();
144 EXPECT_EQ(kResultSuccess, result_); 142 EXPECT_EQ(kResultSuccess, result_);
145 int interval = 0; 143 int interval = 0;
146 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion( 144 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion(
147 shill::kScanIntervalProperty, &interval)); 145 shill::kScanIntervalProperty, &interval));
148 EXPECT_EQ(1, interval); 146 EXPECT_EQ(1, interval);
149 147
150 // Repeat the same with value false. 148 // Repeat the same with value false.
151 network_device_handler_->SetDeviceProperty(kDefaultCellularDevicePath, 149 network_device_handler_->SetDeviceProperty(
152 shill::kScanIntervalProperty, 150 kDefaultCellularDevicePath, shill::kScanIntervalProperty, base::Value(2),
153 base::FundamentalValue(2), 151 success_callback_, error_callback_);
154 success_callback_,
155 error_callback_);
156 base::RunLoop().RunUntilIdle(); 152 base::RunLoop().RunUntilIdle();
157 EXPECT_EQ(kResultSuccess, result_); 153 EXPECT_EQ(kResultSuccess, result_);
158 154
159 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, 155 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath,
160 properties_success_callback_, 156 properties_success_callback_,
161 error_callback_); 157 error_callback_);
162 base::RunLoop().RunUntilIdle(); 158 base::RunLoop().RunUntilIdle();
163 EXPECT_EQ(kResultSuccess, result_); 159 EXPECT_EQ(kResultSuccess, result_);
164 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion( 160 EXPECT_TRUE(properties_->GetIntegerWithoutPathExpansion(
165 shill::kScanIntervalProperty, &interval)); 161 shill::kScanIntervalProperty, &interval));
166 EXPECT_EQ(2, interval); 162 EXPECT_EQ(2, interval);
167 163
168 // Set property on an invalid path. 164 // Set property on an invalid path.
169 network_device_handler_->SetDeviceProperty(kUnknownCellularDevicePath, 165 network_device_handler_->SetDeviceProperty(
170 shill::kScanIntervalProperty, 166 kUnknownCellularDevicePath, shill::kScanIntervalProperty, base::Value(1),
171 base::FundamentalValue(1), 167 success_callback_, error_callback_);
172 success_callback_,
173 error_callback_);
174 base::RunLoop().RunUntilIdle(); 168 base::RunLoop().RunUntilIdle();
175 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); 169 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
176 170
177 // Setting a owner-protected device property through SetDeviceProperty must 171 // Setting a owner-protected device property through SetDeviceProperty must
178 // fail. 172 // fail.
179 network_device_handler_->SetDeviceProperty( 173 network_device_handler_->SetDeviceProperty(
180 kDefaultCellularDevicePath, 174 kDefaultCellularDevicePath, shill::kCellularAllowRoamingProperty,
181 shill::kCellularAllowRoamingProperty, 175 base::Value(true), success_callback_, error_callback_);
182 base::FundamentalValue(true),
183 success_callback_,
184 error_callback_);
185 base::RunLoop().RunUntilIdle(); 176 base::RunLoop().RunUntilIdle();
186 EXPECT_NE(kResultSuccess, result_); 177 EXPECT_NE(kResultSuccess, result_);
187 } 178 }
188 179
189 TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) { 180 TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) {
190 // Start with disabled data roaming. 181 // Start with disabled data roaming.
191 ShillDeviceClient::TestInterface* device_test = 182 ShillDeviceClient::TestInterface* device_test =
192 fake_device_client_->GetTestInterface(); 183 fake_device_client_->GetTestInterface();
193 device_test->SetDeviceProperty(kDefaultCellularDevicePath, 184 device_test->SetDeviceProperty(kDefaultCellularDevicePath,
194 shill::kCellularAllowRoamingProperty, 185 shill::kCellularAllowRoamingProperty,
195 base::FundamentalValue(false)); 186 base::Value(false));
196 187
197 network_device_handler_->SetCellularAllowRoaming(true); 188 network_device_handler_->SetCellularAllowRoaming(true);
198 base::RunLoop().RunUntilIdle(); 189 base::RunLoop().RunUntilIdle();
199 190
200 // Roaming should be enabled now. 191 // Roaming should be enabled now.
201 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath, 192 network_device_handler_->GetDeviceProperties(kDefaultCellularDevicePath,
202 properties_success_callback_, 193 properties_success_callback_,
203 error_callback_); 194 error_callback_);
204 base::RunLoop().RunUntilIdle(); 195 base::RunLoop().RunUntilIdle();
205 EXPECT_EQ(kResultSuccess, result_); 196 EXPECT_EQ(kResultSuccess, result_);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 382
392 // Test that the shill error propagates to the error callback. 383 // Test that the shill error propagates to the error callback.
393 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, 384 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin,
394 kNewPin, success_callback_, 385 kNewPin, success_callback_,
395 error_callback_); 386 error_callback_);
396 base::RunLoop().RunUntilIdle(); 387 base::RunLoop().RunUntilIdle();
397 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); 388 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_);
398 } 389 }
399 390
400 } // namespace chromeos 391 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_device_handler_impl.cc ('k') | chromeos/network/network_state_handler_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698