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