~compiz-team/compiz/compiz.fix_1050610

« back to all changes in this revision

Viewing changes to tests/system/xorg-gtest/include/compiz-xorg-gtest.h

  • Committer: Tarmac
  • Author(s): Sam Spilsbury
  • Date: 2012-09-20 18:25:11 UTC
  • mfrom: (3375.3.10 compiz)
  • Revision ID: tarmac-20120920182511-svt36y79zm7en1v2
This adds a system testing framework based on Xorg-GTest (launchpad.net/xorg-gtest). It will find an existing installation of xorg-gtest and compile it locally (similar to Google Test) and provides a class XorgSystemTest in the namespace compiz::testing, which will spawn compiz inside of a dummy X Sever. You can then test by interacting with the server and querying its state.

XEventMatcher is a very basic concept for matching X events as they come in. Right now, the events have to be matched in order, but its feasible that in future we could have out of order matching like we do in Google Mock. Some utility functions added on top of xorg-gtest were WaitForEventOfTypeOnWindow, which works just like the former function by checks if it matches a window or satisfies some arbitrary criteria in the case of WaitForEventOfTypeOnWindowMatching.. Fixes: . Approved by Daniel van Vugt, jenkins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Compiz XOrg GTest
 
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 _COMPIZ_XORG_GTEST_H
 
24
#define _COMPIZ_XORG_GTEST_H
 
25
#include <gtest/gtest.h>
 
26
#include <gmock/gmock.h>
 
27
#include <xorg/gtest/xorg-gtest.h>
 
28
 
 
29
using ::testing::MatcherInterface;
 
30
 
 
31
namespace compiz
 
32
{
 
33
    namespace testing
 
34
    {
 
35
        typedef  ::testing::MatcherInterface <const XEvent &> XEventMatcher;
 
36
 
 
37
        std::list <Window> NET_CLIENT_LIST_STACKING (Display *);
 
38
        bool WaitForEventOfTypeOnWindow (Display *dpy,
 
39
                                         Window  w,
 
40
                                         int     type,
 
41
                                         int     ext,
 
42
                                         int     extType,
 
43
                                         int     timeout = 1000);
 
44
        bool WaitForEventOfTypeOnWindowMatching (Display             *dpy,
 
45
                                                 Window              w,
 
46
                                                 int                 type,
 
47
                                                 int                 ext,
 
48
                                                 int                 extType,
 
49
                                                 const XEventMatcher &matcher,
 
50
                                                 int                 timeout = 1000);
 
51
 
 
52
        class XorgSystemTest :
 
53
            public xorg::testing::Test
 
54
        {
 
55
            public:
 
56
 
 
57
                virtual void SetUp ();
 
58
                virtual void TearDown ();
 
59
 
 
60
            private:
 
61
 
 
62
                xorg::testing::Process mCompizProcess;
 
63
        };
 
64
    }
 
65
}
 
66
 
 
67
#endif