1
/*****************************************************************************
3
* utouch-frame - Touch Frame Library
5
* Copyright (C) 2011 Canonical Ltd.
7
* This program is free software: you can redistribute it and/or modify it
8
* under the terms of the GNU General Public License as published by the
9
* Free Software Foundation, either version 3 of the License, or (at your
10
* option) any later version.
12
* This program is distributed in the hope that it will be useful, but
13
* WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* General Public License for more details.
17
* You should have received a copy of the GNU General Public License along
18
* with this program. If not, see <http://www.gnu.org/licenses/>.
20
****************************************************************************/
30
const Value NewValue(UFTouchState state) {
36
const Value NewValue(float floating) {
38
value.floating = floating;
42
const Value NewValue(int boolean) {
44
value.boolean = boolean;
48
bool IsEqual(const utouch::frame::testing::Touch& a,
49
const utouch::frame::testing::Touch& b) {
50
/* We rely on the fact that values are stored in maps, so if the values are
51
* equal they will also be stored in the same order. */
52
for (auto property_a = a.first.cbegin(), property_b = b.first.cbegin();
53
property_a != a.first.cend() && property_b != b.first.cend();
54
++property_a, ++property_b) {
55
if (property_a->first != property_b->first)
58
switch (property_a->first) {
59
case UFTouchPropertyState:
60
if (property_a->second.state != property_b->second.state)
63
case UFTouchPropertyWindowX:
64
case UFTouchPropertyWindowY:
65
if (property_a->second.floating != property_b->second.floating)
68
case UFTouchPropertyOwned:
69
case UFTouchPropertyPendingEnd:
70
if ((property_a->second.boolean && !property_b->second.boolean) ||
71
(!property_a->second.boolean && property_b->second.boolean))
75
throw std::runtime_error("Unknown property to check for equality");
79
for (auto value_a = a.second.cbegin(), value_b = b.second.cbegin();
80
value_a != a.second.cend() && value_b != b.second.cend();
82
if (value_a->first != value_b->first || value_a->second != value_b->second)
88
} // namespace testing