1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/gtk/event_utils.h"
7 #include "base/basictypes.h"
8 #include "base/strings/stringprintf.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/events/event_constants.h"
12 namespace event_utils
{
16 const guint states
[] = {
27 ui::EF_CAPS_LOCK_DOWN
,
31 ui::EF_LEFT_MOUSE_BUTTON
,
32 ui::EF_MIDDLE_MOUSE_BUTTON
,
33 ui::EF_RIGHT_MOUSE_BUTTON
38 TEST(EventUtilsTest
, EventFlagsFromGdkState
) {
39 ASSERT_EQ(arraysize(states
), arraysize(flags
));
41 const int size
= arraysize(states
);
42 for (int i
= 0; i
< size
; ++i
) {
43 SCOPED_TRACE(base::StringPrintf(
44 "Checking EventFlagsFromGdkState: i = %d", i
));
45 EXPECT_EQ(flags
[i
], EventFlagsFromGdkState(states
[i
]));
48 for (int i
= 0; i
< size
; ++i
) {
49 for (int j
= i
+ 1; j
< size
; ++j
) {
50 SCOPED_TRACE(base::StringPrintf(
51 "Checking EventFlagsFromGdkState: i = %d, j = %d", i
, j
));
52 EXPECT_EQ(flags
[i
] | flags
[j
],
53 EventFlagsFromGdkState(states
[i
] | states
[j
]));
58 } // namespace event_utils