1 // Copyright (c) 2011 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 #import <Cocoa/Cocoa.h>
7 #include "base/memory/singleton.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #import "chrome/browser/ui/cocoa/accelerators_cocoa.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/gtest_mac.h"
12 #include "ui/base/accelerators/platform_accelerator_cocoa.h"
14 TEST(AcceleratorsCocoaTest, GetAccelerator) {
15 AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
16 const ui::Accelerator* accelerator =
17 keymap->GetAcceleratorForCommand(IDC_COPY);
18 ASSERT_TRUE(accelerator);
19 ASSERT_TRUE(accelerator->platform_accelerator());
20 const ui::PlatformAcceleratorCocoa* platform_accelerator =
21 static_cast<const ui::PlatformAcceleratorCocoa*>(
22 accelerator->platform_accelerator());
23 EXPECT_NSEQ(@"c", platform_accelerator->characters());
24 EXPECT_EQ(NSCommandKeyMask, platform_accelerator->modifier_mask());
27 TEST(AcceleratorsCocoaTest, GetNullAccelerator) {
28 AcceleratorsCocoa* keymap = AcceleratorsCocoa::GetInstance();
29 const ui::Accelerator* accelerator =
30 keymap->GetAcceleratorForCommand(314159265);
31 EXPECT_FALSE(accelerator);