OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/network/network_state.h" | 5 #include "chromeos/network/network_state.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/i18n/streaming_utf8_validator.h" | 12 #include "base/i18n/streaming_utf8_validator.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chromeos/network/tether_constants.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
19 | 20 |
20 namespace chromeos { | 21 namespace chromeos { |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 class NetworkStateTest : public testing::Test { | 25 class NetworkStateTest : public testing::Test { |
25 public: | 26 public: |
26 NetworkStateTest() : network_state_("test_path") { | 27 NetworkStateTest() : network_state_("test_path") { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 EXPECT_EQ(network_state_.connection_state(), shill::kStateDisconnect); | 251 EXPECT_EQ(network_state_.connection_state(), shill::kStateDisconnect); |
251 EXPECT_FALSE(network_state_.IsConnectedState()); | 252 EXPECT_FALSE(network_state_.IsConnectedState()); |
252 EXPECT_FALSE(network_state_.IsReconnecting()); | 253 EXPECT_FALSE(network_state_.IsReconnecting()); |
253 | 254 |
254 network_state_.set_connection_state(shill::kStateConfiguration); | 255 network_state_.set_connection_state(shill::kStateConfiguration); |
255 EXPECT_EQ(network_state_.connection_state(), shill::kStateDisconnect); | 256 EXPECT_EQ(network_state_.connection_state(), shill::kStateDisconnect); |
256 EXPECT_FALSE(network_state_.IsConnectingState()); | 257 EXPECT_FALSE(network_state_.IsConnectingState()); |
257 EXPECT_FALSE(network_state_.IsReconnecting()); | 258 EXPECT_FALSE(network_state_.IsReconnecting()); |
258 } | 259 } |
259 | 260 |
| 261 TEST_F(NetworkStateTest, TetherProperties) { |
| 262 network_state_.set_type(kTypeTether); |
| 263 network_state_.set_carrier("Project Fi"); |
| 264 network_state_.set_battery_percentage(85); |
| 265 network_state_.set_signal_strength(75); |
| 266 |
| 267 base::DictionaryValue dictionary; |
| 268 network_state_.GetStateProperties(&dictionary); |
| 269 |
| 270 int signal_strength; |
| 271 EXPECT_TRUE(dictionary.GetIntegerWithoutPathExpansion(kTetherSignalStrength, |
| 272 &signal_strength)); |
| 273 EXPECT_EQ(75, signal_strength); |
| 274 |
| 275 int battery_percentage; |
| 276 EXPECT_TRUE(dictionary.GetIntegerWithoutPathExpansion( |
| 277 kTetherBatteryPercentage, &battery_percentage)); |
| 278 EXPECT_EQ(85, battery_percentage); |
| 279 |
| 280 std::string carrier; |
| 281 EXPECT_TRUE( |
| 282 dictionary.GetStringWithoutPathExpansion(kTetherCarrier, &carrier)); |
| 283 EXPECT_EQ("Project Fi", carrier); |
| 284 } |
| 285 |
260 } // namespace chromeos | 286 } // namespace chromeos |
OLD | NEW |