Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "net/android/cellular_signal_strength.h" | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 | |
| 9 #include "net/base/network_change_notifier.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace net { | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 16 TEST(CellularSignalStrengthAndroidTest, SignalStrengthTest) { | |
| 17 int signal_strength_dbm = CellularSignalStrengthError.ERROR_NOT_SUPPORTED; | |
| 18 bool signal_strength_available = | |
| 19 android::cellular_signal_strength::GetSignalStrengthDbm( | |
| 20 &signal_strength_dbm); | |
| 21 | |
| 22 // Signal strength is likely unavailable if the device does not have an | |
| 23 // active cellular connection. | |
| 24 if (!NetworkChangeNotifier::IsConnectionCellular( | |
| 25 NetworkChangeNotifier::GetConnectionType())) { | |
| 26 return; | |
| 27 } | |
| 28 | |
| 29 EXPECT_TRUE(signal_strength_available); | |
| 30 // Signal strength (in dbM) should typically be between -130 and 0. | |
| 31 EXPECT_LE(-130, signal_strength_dbm); | |
| 32 EXPECT_GE(0, signal_strength_dbm); | |
| 33 } | |
| 34 | |
| 35 TEST(CellularSignalStrengthAndroidTest, SignalStrengthLevelTest) { | |
| 36 int signal_strength_level = CellularSignalStrengthError.ERROR_NOT_SUPPORTED; | |
| 37 bool signal_strength_level_available = | |
| 38 android::cellular_signal_strength::GetSignalLevel(&signal_strength_level); | |
| 39 | |
| 40 // Signal strength is likely unavailable if the device does not have an | |
|
bengr
2016/06/27 01:36:22
Why "likely?" Is the statement true if you remove
tbansal1
2016/06/27 19:01:17
I removed it. I am not sure what is the documented
| |
| 41 // active cellular connection. | |
| 42 if (!NetworkChangeNotifier::IsConnectionCellular( | |
| 43 NetworkChangeNotifier::GetConnectionType())) { | |
| 44 return; | |
| 45 } | |
| 46 | |
| 47 EXPECT_TRUE(signal_strength_level_available); | |
| 48 EXPECT_LE(0, signal_strength_level); | |
| 49 EXPECT_GE(4, signal_strength_level); | |
| 50 } | |
| 51 | |
| 52 } // namespace | |
| 53 | |
| 54 } // namespace net | |
| OLD | NEW |