Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / gtk / event_utils_unittest.cc
blobb895242c52282962967f6c312d621c8aff5a1031
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 {
14 namespace {
16 const guint states[] = {
17 GDK_LOCK_MASK,
18 GDK_CONTROL_MASK,
19 GDK_SHIFT_MASK,
20 GDK_MOD1_MASK,
21 GDK_BUTTON1_MASK,
22 GDK_BUTTON2_MASK,
23 GDK_BUTTON3_MASK
26 const int flags[] = {
27 ui::EF_CAPS_LOCK_DOWN,
28 ui::EF_CONTROL_DOWN,
29 ui::EF_SHIFT_DOWN,
30 ui::EF_ALT_DOWN,
31 ui::EF_LEFT_MOUSE_BUTTON,
32 ui::EF_MIDDLE_MOUSE_BUTTON,
33 ui::EF_RIGHT_MOUSE_BUTTON
36 } // namespace
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