| Index: chromeos/components/tether/device_status_util_unittest.cc
|
| diff --git a/chromeos/components/tether/device_status_util_unittest.cc b/chromeos/components/tether/device_status_util_unittest.cc
|
| index 3aa05abf599b54c649cce84416a08151adb49c88..5eca9e0e8a8cc0b177881734d49aec6b67f85487 100644
|
| --- a/chromeos/components/tether/device_status_util_unittest.cc
|
| +++ b/chromeos/components/tether/device_status_util_unittest.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/macros.h"
|
| #include "base/memory/ptr_util.h"
|
| #include "chromeos/components/tether/fake_tether_host_fetcher.h"
|
| +#include "chromeos/components/tether/proto_test_util.h"
|
| #include "components/cryptauth/remote_device.h"
|
| #include "components/cryptauth/remote_device_test_util.h"
|
| #include "components/prefs/testing_pref_service.h"
|
| @@ -20,42 +21,6 @@ namespace chromeos {
|
|
|
| namespace tether {
|
|
|
| -namespace {
|
| -
|
| -const char kDoNotSetStringField[] = "doNotSetField";
|
| -const int kDoNotSetIntField = -100;
|
| -
|
| -// Creates a DeviceStatus object using the parameters provided. If
|
| -// |kDoNotSetStringField| or |kDoNotSetIntField| are passed, these fields will
|
| -// not be set in the output.
|
| -DeviceStatus CreateFakeDeviceStatus(const std::string& cell_provider_name,
|
| - int battery_percentage,
|
| - int connection_strength) {
|
| - // TODO(khorimoto): Once a ConnectedWifiSsid field is added as a property of
|
| - // Tether networks, give an option to pass a parameter for that field as well.
|
| - WifiStatus wifi_status;
|
| - wifi_status.set_status_code(
|
| - WifiStatus_StatusCode::WifiStatus_StatusCode_CONNECTED);
|
| - wifi_status.set_ssid("Google A");
|
| -
|
| - DeviceStatus device_status;
|
| - if (battery_percentage != kDoNotSetIntField) {
|
| - device_status.set_battery_percentage(battery_percentage);
|
| - }
|
| - if (cell_provider_name != kDoNotSetStringField) {
|
| - device_status.set_cell_provider(cell_provider_name);
|
| - }
|
| - if (connection_strength != kDoNotSetIntField) {
|
| - device_status.set_connection_strength(connection_strength);
|
| - }
|
| -
|
| - device_status.mutable_wifi_status()->CopyFrom(wifi_status);
|
| -
|
| - return device_status;
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| class DeviceStatusUtilTest : public testing::Test {
|
| public:
|
| DeviceStatusUtilTest() {}
|
| @@ -65,10 +30,10 @@ class DeviceStatusUtilTest : public testing::Test {
|
| };
|
|
|
| TEST_F(DeviceStatusUtilTest, TestNotPresent) {
|
| - DeviceStatus status =
|
| - CreateFakeDeviceStatus(kDoNotSetStringField /* cell_provider_name */,
|
| - kDoNotSetIntField /* battery_percentage */,
|
| - kDoNotSetIntField /* connection_strength */);
|
| + DeviceStatus status = CreateTestDeviceStatus(
|
| + proto_test_util::kDoNotSetStringField /* cell_provider_name */,
|
| + proto_test_util::kDoNotSetIntField /* battery_percentage */,
|
| + proto_test_util::kDoNotSetIntField /* connection_strength */);
|
|
|
| std::string carrier;
|
| int32_t battery_percentage;
|
| @@ -83,9 +48,10 @@ TEST_F(DeviceStatusUtilTest, TestNotPresent) {
|
| }
|
|
|
| TEST_F(DeviceStatusUtilTest, TestEmptyCellProvider) {
|
| - DeviceStatus status = CreateFakeDeviceStatus(
|
| - "" /* cell_provider_name */, kDoNotSetIntField /* battery_percentage */,
|
| - kDoNotSetIntField /* connection_strength */);
|
| + DeviceStatus status = CreateTestDeviceStatus(
|
| + "" /* cell_provider_name */,
|
| + proto_test_util::kDoNotSetIntField /* battery_percentage */,
|
| + proto_test_util::kDoNotSetIntField /* connection_strength */);
|
|
|
| std::string carrier;
|
| int32_t battery_percentage;
|
| @@ -100,7 +66,7 @@ TEST_F(DeviceStatusUtilTest, TestEmptyCellProvider) {
|
| }
|
|
|
| TEST_F(DeviceStatusUtilTest, TestBelowMinValue) {
|
| - DeviceStatus status = CreateFakeDeviceStatus(
|
| + DeviceStatus status = CreateTestDeviceStatus(
|
| "cellProvider" /* cell_provider_name */, -1 /* battery_percentage */,
|
| -1 /* connection_strength */);
|
|
|
| @@ -117,7 +83,7 @@ TEST_F(DeviceStatusUtilTest, TestBelowMinValue) {
|
| }
|
|
|
| TEST_F(DeviceStatusUtilTest, TestAboveMaxValue) {
|
| - DeviceStatus status = CreateFakeDeviceStatus(
|
| + DeviceStatus status = CreateTestDeviceStatus(
|
| "cellProvider" /* cell_provider_name */, 101 /* battery_percentage */,
|
| 5 /* connection_strength */);
|
|
|
| @@ -134,7 +100,7 @@ TEST_F(DeviceStatusUtilTest, TestAboveMaxValue) {
|
| }
|
|
|
| TEST_F(DeviceStatusUtilTest, TestValidValues) {
|
| - DeviceStatus status = CreateFakeDeviceStatus(
|
| + DeviceStatus status = CreateTestDeviceStatus(
|
| "cellProvider" /* cell_provider_name */, 50 /* battery_percentage */,
|
| 2 /* connection_strength */);
|
|
|
|
|