2
* Copyright (C) 2016 Canonical, Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 3.
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 Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Thomas Voß <thomas.voss@canonical.com>
20
#include <biometry/devices/forwarding.h>
22
#include <gmock/gmock.h>
24
#include "mock_device.h"
26
TEST(Forwarding, calls_into_implementation)
28
using namespace ::testing;
31
EXPECT_CALL(ts, size(_, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::TemplateStore::SizeQuery>::Ptr{}));
32
EXPECT_CALL(ts, enroll(_, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::TemplateStore::Enrollment>::Ptr{}));
33
EXPECT_CALL(ts, clear(_, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::TemplateStore::Clearance>::Ptr{}));
35
MockIdentifier identifier;
36
EXPECT_CALL(identifier, identify_user(_, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::Identification>::Ptr{}));
38
MockVerifier verifier;
39
EXPECT_CALL(verifier, verify_user(_, _, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::Verification>::Ptr{}));
41
auto impl = std::make_shared<MockDevice>();
42
EXPECT_CALL(*impl, template_store()).Times(3).WillRepeatedly(ReturnRef(ts));
43
EXPECT_CALL(*impl, identifier()).Times(1).WillOnce(ReturnRef(identifier));
44
EXPECT_CALL(*impl, verifier()).Times(1).WillOnce(ReturnRef(verifier));
46
const biometry::Application app{biometry::Application::system()};
47
const biometry::Reason reason{biometry::Reason::unknown()};
48
const biometry::User user = biometry::User::current();
50
impl->template_store().size(app, user);
51
impl->template_store().enroll(app, user);
52
impl->template_store().clear(app, user);
53
impl->identifier().identify_user(app, reason);
54
impl->verifier().verify_user(app, user, reason);