~compiz-team/compiz/compiz.fix_1041535.1

« back to all changes in this revision

Viewing changes to compizconfig/mocks/libcompizconfig/compizconfig_ccs_integrated_setting_factory_mock.h

  • Committer: Sam Spilsbury
  • Date: 2012-09-23 10:17:42 UTC
  • Revision ID: sam.spilsbury@canonical.com-20120923101742-x05erkxxh9mqbifm
Added mocks for the integrated settings storage and integrated settings factory interfaces. Construction test for CCSGNOMEIntegration with mocks

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Compiz configuration system library
 
3
 *
 
4
 * Copyright (C) 2012 Canonical Ltd.
 
5
 *
 
6
 * This library is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Lesser General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2.1 of the License, or (at your option) any later version.
 
10
 
 
11
 * This library is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
14
 * Lesser General Public License for more details.
 
15
 
 
16
 * You should have received a copy of the GNU Lesser General Public
 
17
 * License along with this library; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 *
 
20
 * Authored By:
 
21
 * Sam Spilsbury <sam.spilsbury@canonical.com>
 
22
 */
 
23
#ifndef _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H
 
24
#define _COMPIZCONFIG_CCS_INTEGRATED_SETTING_FACTORY_MOCK_H
 
25
 
 
26
#include <gtest/gtest.h>
 
27
#include <gmock/gmock.h>
 
28
 
 
29
#include <ccs.h>
 
30
#include <ccs-backend.h>
 
31
 
 
32
CCSIntegratedSettingFactory *
 
33
ccsMockIntegratedSettingFactoryNew (CCSObjectAllocationInterface *ai);
 
34
 
 
35
void
 
36
ccsMockIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *);
 
37
 
 
38
class CCSIntegratedSettingFactoryGMockInterface
 
39
{
 
40
    public:
 
41
 
 
42
        virtual ~CCSIntegratedSettingFactoryGMockInterface () {}
 
43
 
 
44
        virtual CCSIntegratedSetting * createIntegratedSettingForCCSNameAndType (CCSIntegration *integration,
 
45
                                                                                 const char     *pluginName,
 
46
                                                                                 const char     *settingName,
 
47
                                                                                 CCSSettingType type) = 0;
 
48
};
 
49
 
 
50
class CCSIntegratedSettingFactoryGMock :
 
51
    public CCSIntegratedSettingFactoryGMockInterface
 
52
{
 
53
    public:
 
54
 
 
55
        MOCK_METHOD4 (createIntegratedSettingForCCSNameAndType, CCSIntegratedSetting * (CCSIntegration *,
 
56
                                                                                        const char     *,
 
57
                                                                                        const char     *,
 
58
                                                                                        CCSSettingType  ));
 
59
 
 
60
        CCSIntegratedSettingFactoryGMock (CCSIntegratedSettingFactory *integratedSettingFactory) :
 
61
            mIntegratedSettingFactory (integratedSettingFactory)
 
62
        {
 
63
        }
 
64
 
 
65
        CCSIntegratedSettingFactory *
 
66
        getIntegratedSettingFactory ()
 
67
        {
 
68
            return mIntegratedSettingFactory;
 
69
        }
 
70
 
 
71
    public:
 
72
 
 
73
        static CCSIntegratedSetting *
 
74
        ccsIntegratedSettingFactoryCreateIntegratedSettingForCCSSettingNameAndType (CCSIntegratedSettingFactory *factory,
 
75
                                                                                    CCSIntegration              *integration,
 
76
                                                                                    const char                  *pluginName,
 
77
                                                                                    const char                  *settingName,
 
78
                                                                                    CCSSettingType              type)
 
79
        {
 
80
            return reinterpret_cast <CCSIntegratedSettingFactoryGMockInterface *> (factory)->createIntegratedSettingForCCSNameAndType (integration,
 
81
                                                                                                                                       pluginName,
 
82
                                                                                                                                       settingName,
 
83
                                                                                                                                       type);
 
84
        }
 
85
 
 
86
        static void
 
87
        ccsIntegratedSettingFactoryFree (CCSIntegratedSettingFactory *integratedSettingFactory)
 
88
        {
 
89
            ccsMockIntegratedSettingFactoryFree (integratedSettingFactory);
 
90
        }
 
91
 
 
92
    private:
 
93
 
 
94
        CCSIntegratedSettingFactory *mIntegratedSettingFactory;
 
95
};
 
96
 
 
97
extern const CCSIntegratedSettingFactoryInterface mockIntegratedSettingFactoryInterface;
 
98
 
 
99
#endif