1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/ash/components/tether/tether_session_completion_logger.h"
#include <memory>
#include "base/test/metrics/histogram_tester.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ash {
namespace tether {
class TetherSessionCompletionLoggerTest : public testing::Test {
public:
TetherSessionCompletionLoggerTest(const TetherSessionCompletionLoggerTest&) =
delete;
TetherSessionCompletionLoggerTest& operator=(
const TetherSessionCompletionLoggerTest&) = delete;
protected:
TetherSessionCompletionLoggerTest() = default;
~TetherSessionCompletionLoggerTest() override = default;
void SetUp() override {
logger_ = std::make_unique<TetherSessionCompletionLogger>();
}
void TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason
expected_session_completion_reason) {
logger_->RecordTetherSessionCompletion(expected_session_completion_reason);
histogram_tester_.ExpectUniqueSample(
"InstantTethering.SessionCompletionReason",
expected_session_completion_reason, 1);
}
std::unique_ptr<TetherSessionCompletionLogger> logger_;
base::HistogramTester histogram_tester_;
};
TEST_F(TetherSessionCompletionLoggerTest, TestOther) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::OTHER);
}
TEST_F(TetherSessionCompletionLoggerTest, TestUserDisconnected) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
USER_DISCONNECTED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestConnectionDropped) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
CONNECTION_DROPPED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestUserLoggedOut) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::USER_LOGGED_OUT);
}
TEST_F(TetherSessionCompletionLoggerTest, TestUserClosedLid) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::USER_CLOSED_LID);
}
TEST_F(TetherSessionCompletionLoggerTest, TestBluetoothDisabled) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
BLUETOOTH_DISABLED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestCellularDisabled) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
CELLULAR_DISABLED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestWiFiDisabled) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::WIFI_DISABLED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestBluetoothControllerDisappeared) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
BLUETOOTH_CONTROLLER_DISAPPEARED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestMultiDeviceHostUnverified) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
MULTIDEVICE_HOST_UNVERIFIED);
}
TEST_F(TetherSessionCompletionLoggerTest, TestBetterTogetherSuiteDisabled) {
TestSessionCompletionReasonRecorded(
TetherSessionCompletionLogger::SessionCompletionReason::
BETTER_TOGETHER_SUITE_DISABLED);
}
} // namespace tether
} // namespace ash
|