metrics_utils_unittest.cc revision 38429cf76aaac8c499004b6f537229a26b381602
1// 2// Copyright (C) 2015 The Android Open Source Project 3// 4// Licensed under the Apache License, Version 2.0 (the "License"); 5// you may not use this file except in compliance with the License. 6// You may obtain a copy of the License at 7// 8// http://www.apache.org/licenses/LICENSE-2.0 9// 10// Unless required by applicable law or agreed to in writing, software 11// distributed under the License is distributed on an "AS IS" BASIS, 12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13// See the License for the specific language governing permissions and 14// limitations under the License. 15// 16 17#include "update_engine/metrics_utils.h" 18 19#include <gtest/gtest.h> 20 21namespace chromeos_update_engine { 22namespace metrics_utils { 23 24class MetricsUtilsTest : public ::testing::Test {}; 25 26TEST(MetricsUtilsTest, GetConnectionType) { 27 // Check that expected combinations map to the right value. 28 EXPECT_EQ(metrics::ConnectionType::kUnknown, 29 GetConnectionType(NetworkConnectionType::kUnknown, 30 NetworkTethering::kUnknown)); 31 EXPECT_EQ(metrics::ConnectionType::kEthernet, 32 GetConnectionType(NetworkConnectionType::kEthernet, 33 NetworkTethering::kUnknown)); 34 EXPECT_EQ(metrics::ConnectionType::kWifi, 35 GetConnectionType(NetworkConnectionType::kWifi, 36 NetworkTethering::kUnknown)); 37 EXPECT_EQ(metrics::ConnectionType::kWimax, 38 GetConnectionType(NetworkConnectionType::kWimax, 39 NetworkTethering::kUnknown)); 40 EXPECT_EQ(metrics::ConnectionType::kBluetooth, 41 GetConnectionType(NetworkConnectionType::kBluetooth, 42 NetworkTethering::kUnknown)); 43 EXPECT_EQ(metrics::ConnectionType::kCellular, 44 GetConnectionType(NetworkConnectionType::kCellular, 45 NetworkTethering::kUnknown)); 46 EXPECT_EQ(metrics::ConnectionType::kTetheredEthernet, 47 GetConnectionType(NetworkConnectionType::kEthernet, 48 NetworkTethering::kConfirmed)); 49 EXPECT_EQ(metrics::ConnectionType::kTetheredWifi, 50 GetConnectionType(NetworkConnectionType::kWifi, 51 NetworkTethering::kConfirmed)); 52 53 // Ensure that we don't report tethered ethernet unless it's confirmed. 54 EXPECT_EQ(metrics::ConnectionType::kEthernet, 55 GetConnectionType(NetworkConnectionType::kEthernet, 56 NetworkTethering::kNotDetected)); 57 EXPECT_EQ(metrics::ConnectionType::kEthernet, 58 GetConnectionType(NetworkConnectionType::kEthernet, 59 NetworkTethering::kSuspected)); 60 EXPECT_EQ(metrics::ConnectionType::kEthernet, 61 GetConnectionType(NetworkConnectionType::kEthernet, 62 NetworkTethering::kUnknown)); 63 64 // Ditto for tethered wifi. 65 EXPECT_EQ(metrics::ConnectionType::kWifi, 66 GetConnectionType(NetworkConnectionType::kWifi, 67 NetworkTethering::kNotDetected)); 68 EXPECT_EQ(metrics::ConnectionType::kWifi, 69 GetConnectionType(NetworkConnectionType::kWifi, 70 NetworkTethering::kSuspected)); 71 EXPECT_EQ(metrics::ConnectionType::kWifi, 72 GetConnectionType(NetworkConnectionType::kWifi, 73 NetworkTethering::kUnknown)); 74} 75 76} // namespace metrics_utils 77} // namespace chromeos_update_engine 78