summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/gtk/accelerators_gtk_unittest.cc
blob: 00083c7b8f2166c16e1b04c5733be5247da2bc81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <gdk/gdkkeysyms.h>

#include "base/memory/singleton.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/ui/gtk/accelerators_gtk.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/accelerators/platform_accelerator_gtk.h"

TEST(AcceleratorsGtkTest, GetAccelerator) {
  AcceleratorsGtk* keymap = AcceleratorsGtk::GetInstance();
  const ui::Accelerator* accelerator =
      keymap->GetPrimaryAcceleratorForCommand(IDC_COPY);
  ASSERT_TRUE(accelerator);
  EXPECT_EQ(static_cast<guint>(GDK_c),
            GetGdkKeyCodeForAccelerator(*accelerator));
  EXPECT_EQ(GDK_CONTROL_MASK, GetGdkModifierForAccelerator(*accelerator));
}

TEST(AcceleratorsGtkTest, GetNullAccelerator) {
  AcceleratorsGtk* keymap = AcceleratorsGtk::GetInstance();
  const ui::Accelerator* accelerator =
      keymap->GetPrimaryAcceleratorForCommand(IDC_MinimumLabelValue - 1);
  EXPECT_FALSE(accelerator);
}