~thomas-voss/biometryd/remove-obsolete-configuration-header

« back to all changes in this revision

Viewing changes to tests/test_forwarding.cpp

  • Committer: Thomas Voß
  • Date: 2016-05-02 06:16:01 UTC
  • Revision ID: thomas.voss@canonical.com-20160502061601-vqzwfw4c0rxfna04
Initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical, Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
 
17
 *
 
18
 */
 
19
 
 
20
#include <biometry/devices/forwarding.h>
 
21
 
 
22
#include <gmock/gmock.h>
 
23
 
 
24
#include "mock_device.h"
 
25
 
 
26
TEST(Forwarding, calls_into_implementation)
 
27
{
 
28
    using namespace ::testing;
 
29
 
 
30
    MockTemplateStore ts;
 
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{}));
 
34
 
 
35
    MockIdentifier identifier;
 
36
    EXPECT_CALL(identifier, identify_user(_, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::Identification>::Ptr{}));
 
37
 
 
38
    MockVerifier verifier;
 
39
    EXPECT_CALL(verifier, verify_user(_, _, _)).Times(1).WillOnce(Return(biometry::Operation<biometry::Verification>::Ptr{}));
 
40
 
 
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));
 
45
 
 
46
    const biometry::Application app{biometry::Application::system()};
 
47
    const biometry::Reason reason{biometry::Reason::unknown()};
 
48
    const biometry::User user = biometry::User::current();
 
49
 
 
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);
 
55
}