blob: 93b48fbd28e723ccd9e1431f6eefec80cf169341 [file] [log] [blame]
Alex Deymo38429cf2015-11-12 02:27:221//
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,
Sen Jiang255e22b2016-05-20 23:15:2929 GetConnectionType(ConnectionType::kUnknown,
30 ConnectionTethering::kUnknown));
Colin Howesc9e98d62018-09-18 17:35:2031 EXPECT_EQ(metrics::ConnectionType::kDisconnected,
32 GetConnectionType(ConnectionType::kDisconnected,
33 ConnectionTethering::kUnknown));
Alex Deymo38429cf2015-11-12 02:27:2234 EXPECT_EQ(metrics::ConnectionType::kEthernet,
Sen Jiang255e22b2016-05-20 23:15:2935 GetConnectionType(ConnectionType::kEthernet,
36 ConnectionTethering::kUnknown));
Amin Hassani7cc8bb02019-01-15 00:29:4737 EXPECT_EQ(
38 metrics::ConnectionType::kWifi,
39 GetConnectionType(ConnectionType::kWifi, ConnectionTethering::kUnknown));
Alex Deymo38429cf2015-11-12 02:27:2240 EXPECT_EQ(metrics::ConnectionType::kCellular,
Sen Jiang255e22b2016-05-20 23:15:2941 GetConnectionType(ConnectionType::kCellular,
42 ConnectionTethering::kUnknown));
Alex Deymo38429cf2015-11-12 02:27:2243 EXPECT_EQ(metrics::ConnectionType::kTetheredEthernet,
Sen Jiang255e22b2016-05-20 23:15:2944 GetConnectionType(ConnectionType::kEthernet,
45 ConnectionTethering::kConfirmed));
Alex Deymo38429cf2015-11-12 02:27:2246 EXPECT_EQ(metrics::ConnectionType::kTetheredWifi,
Sen Jiang255e22b2016-05-20 23:15:2947 GetConnectionType(ConnectionType::kWifi,
48 ConnectionTethering::kConfirmed));
Alex Deymo38429cf2015-11-12 02:27:2249
50 // Ensure that we don't report tethered ethernet unless it's confirmed.
51 EXPECT_EQ(metrics::ConnectionType::kEthernet,
Sen Jiang255e22b2016-05-20 23:15:2952 GetConnectionType(ConnectionType::kEthernet,
53 ConnectionTethering::kNotDetected));
Alex Deymo38429cf2015-11-12 02:27:2254 EXPECT_EQ(metrics::ConnectionType::kEthernet,
Sen Jiang255e22b2016-05-20 23:15:2955 GetConnectionType(ConnectionType::kEthernet,
56 ConnectionTethering::kSuspected));
Alex Deymo38429cf2015-11-12 02:27:2257 EXPECT_EQ(metrics::ConnectionType::kEthernet,
Sen Jiang255e22b2016-05-20 23:15:2958 GetConnectionType(ConnectionType::kEthernet,
59 ConnectionTethering::kUnknown));
Alex Deymo38429cf2015-11-12 02:27:2260
61 // Ditto for tethered wifi.
62 EXPECT_EQ(metrics::ConnectionType::kWifi,
Sen Jiang255e22b2016-05-20 23:15:2963 GetConnectionType(ConnectionType::kWifi,
64 ConnectionTethering::kNotDetected));
Alex Deymo38429cf2015-11-12 02:27:2265 EXPECT_EQ(metrics::ConnectionType::kWifi,
Sen Jiang255e22b2016-05-20 23:15:2966 GetConnectionType(ConnectionType::kWifi,
67 ConnectionTethering::kSuspected));
Amin Hassani7cc8bb02019-01-15 00:29:4768 EXPECT_EQ(
69 metrics::ConnectionType::kWifi,
70 GetConnectionType(ConnectionType::kWifi, ConnectionTethering::kUnknown));
Alex Deymo38429cf2015-11-12 02:27:2271}
72
Alex Deymo38429cf2015-11-12 02:27:2273} // namespace metrics_utils
74} // namespace chromeos_update_engine