2
* Copyright © 2013 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3,
6
* as published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Alan Griffiths <alan@octopull.co.uk>
19
#include "mir/report/legacy_input_report.h"
20
#include "mir/logging/logger.h"
24
#include "mir/test/fake_shared.h"
26
#include <gtest/gtest.h>
27
#include <gmock/gmock.h>
29
namespace ml = mir::logging;
30
namespace mri = mir::report::legacy_input;
36
class MockLogger : public ml::Logger
39
MOCK_METHOD3(log, void(ml::Severity severity, const std::string& message, const std::string& component));
40
~MockLogger() noexcept(true) {}
43
struct InputReport : public testing::Test
49
mri::initialize(mir::test::fake_shared(logger));
53
char const* const component = "android-input";
54
char const* const LOG_TAG = "Foo";
57
TEST_F(InputReport, debug_message)
59
// default minimum log priority is "informational". "debug" is lower than that.
60
EXPECT_CALL(logger, log(_, _, _)).Times(0);
62
ALOG(LOG_DEBUG, NULL, "Test function is %s", __PRETTY_FUNCTION__);
65
TEST_F(InputReport, unknown_message)
67
char const* const unknown = "Unknown message";
69
// default minimum log priority is "informational". "unknown" is lower than that.
70
// Actually, I don't think this is even a valid priority.
71
EXPECT_CALL(logger, log(_, _, _)).Times(0);
73
ALOG(LOG_UNKNOWN, NULL, unknown);
76
TEST_F(InputReport, verbose_message)
78
char const* const verbose = "A very long story. (OK, I lied.)";
80
// default minimum log priority is "informational". "verbose" is lower than that.
81
EXPECT_CALL(logger, log(_, _, _)).Times(0);
83
ALOG(LOG_VERBOSE, NULL, verbose);
86
TEST_F(InputReport, info_message)
88
EXPECT_CALL(logger, log(
89
ml::Severity::informational,
90
"[Foo]Some informational message",
93
ALOGI("Some informational message");
96
TEST_F(InputReport, warning_message)
98
EXPECT_CALL(logger, log(
99
ml::Severity::warning,
106
TEST_F(InputReport, error_message)
108
EXPECT_CALL(logger, log(
110
"[Foo]An error occurred!",
113
ALOGE("An error occurred!");