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

Unified Diff: net/android/cellular_signal_strength_unittest.cc

Issue 1879743002: Expose cellular signal strength on Android to native (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Paul's comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/android/cellular_signal_strength_unittest.cc
diff --git a/net/android/cellular_signal_strength_unittest.cc b/net/android/cellular_signal_strength_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..19a218c4422eba81b3b884a388926cc11e14598d
--- /dev/null
+++ b/net/android/cellular_signal_strength_unittest.cc
@@ -0,0 +1,54 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/android/cellular_signal_strength.h"
+
+#include <stdint.h>
+
+#include "net/base/network_change_notifier.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+namespace {
+
+TEST(CellularSignalStrengthAndroidTest, SignalStrengthTest) {
+ int signal_strength_dbm = CellularSignalStrengthError.ERROR_NOT_SUPPORTED;
+ bool signal_strength_available =
+ android::cellular_signal_strength::GetSignalStrengthDbm(
+ &signal_strength_dbm);
+
+ // Signal strength is unavailable if the device does not have an active
+ // cellular connection.
+ if (!NetworkChangeNotifier::IsConnectionCellular(
+ NetworkChangeNotifier::GetConnectionType())) {
+ return;
+ }
+
+ EXPECT_TRUE(signal_strength_available);
+ // Signal strength (in dbM) should typically be between -130 and 0.
+ EXPECT_LE(-130, signal_strength_dbm);
+ EXPECT_GE(0, signal_strength_dbm);
+}
+
+TEST(CellularSignalStrengthAndroidTest, SignalStrengthLevelTest) {
+ int signal_strength_level = CellularSignalStrengthError.ERROR_NOT_SUPPORTED;
+ bool signal_strength_level_available =
+ android::cellular_signal_strength::GetSignalLevel(&signal_strength_level);
+
+ // Signal strength is unavailable if the device does not have an active
+ // cellular connection.
+ if (!NetworkChangeNotifier::IsConnectionCellular(
+ NetworkChangeNotifier::GetConnectionType())) {
+ return;
+ }
+
+ EXPECT_TRUE(signal_strength_level_available);
+ EXPECT_LE(0, signal_strength_level);
+ EXPECT_GE(4, signal_strength_level);
+}
+
+} // namespace
+
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698