Commit 19cb1e03 authored by tmoniuszko's avatar tmoniuszko Committed by Commit bot

Force U.S. English keyboard layout for TextfieldTest.KeysWithModifiersTest

BUG=633136

Review-Url: https://codereview.chromium.org/2197113002
Cr-Commit-Position: refs/heads/master@{#419454}
parent a7e4b7e2
......@@ -388,8 +388,6 @@ test("chromedriver_tests") {
"net/test_http_server.cc",
"net/test_http_server.h",
"net/websocket_unittest.cc",
"test_util.cc",
"test_util.h",
]
# TODO(jschuh): crbug.com/167187 fix size_t to int truncations.
......@@ -403,6 +401,7 @@ test("chromedriver_tests") {
"//net:http_server",
"//net:test_support",
"//testing/gtest",
"//ui/events:test_support",
"//url",
]
}
......@@ -14,8 +14,8 @@
#include "chrome/test/chromedriver/chrome/status.h"
#include "chrome/test/chromedriver/chrome/ui_events.h"
#include "chrome/test/chromedriver/key_converter.h"
#include "chrome/test/chromedriver/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/test/keyboard_layout.h"
namespace {
......@@ -165,7 +165,6 @@ TEST(KeyConverter, FrenchKeyOnEnglishLayout) {
#if defined(OS_WIN)
TEST(KeyConverter, NeedsCtrlAndAlt) {
RestoreKeyboardLayoutOnDestruct restore;
int ctrl_and_alt = kControlKeyModifierMask | kAltKeyModifierMask;
KeyEvent event_array[] = {
CreateKeyDownEvent(ui::VKEY_CONTROL, 0),
......@@ -175,7 +174,7 @@ TEST(KeyConverter, NeedsCtrlAndAlt) {
CreateKeyUpEvent(ui::VKEY_Q, ctrl_and_alt),
CreateKeyUpEvent(ui::VKEY_MENU, 0),
CreateKeyUpEvent(ui::VKEY_CONTROL, 0)};
ASSERT_TRUE(SwitchKeyboardLayout("00000407"));
ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_GERMAN);
CheckEventsReleaseModifiers("@", event_array, arraysize(event_array));
}
#endif
......@@ -281,6 +280,7 @@ TEST(KeyConverter, MAYBE_AllShorthandKeys) {
#endif
TEST(KeyConverter, MAYBE_AllEnglishKeyboardSymbols) {
ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_ENGLISH_US);
base::string16 keys;
const ui::KeyboardCode kSymbolKeyCodes[] = {
ui::VKEY_OEM_3,
......
......@@ -9,9 +9,9 @@
#include "build/build_config.h"
#include "chrome/test/chromedriver/chrome/ui_events.h"
#include "chrome/test/chromedriver/keycode_text_conversion.h"
#include "chrome/test/chromedriver/test_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/keyboard_layout.h"
namespace {
......@@ -32,13 +32,11 @@ void CheckCharToKeyCode(char character, ui::KeyboardCode key_code,
key_code, modifiers);
}
#if defined(OS_WIN)
void CheckCharToKeyCode(wchar_t character, ui::KeyboardCode key_code,
int modifiers) {
CheckCharToKeyCode16(base::WideToUTF16(std::wstring(1, character))[0],
key_code, modifiers);
}
#endif
void CheckCantConvertChar(wchar_t character) {
std::wstring character_string;
......@@ -127,14 +125,12 @@ TEST(KeycodeTextConversionTest, MAYBE_CharToKeyCode) {
#endif
TEST(KeycodeTextConversionTest, MAYBE_NonShiftModifiers) {
RestoreKeyboardLayoutOnDestruct restore;
ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_GERMAN);
#if defined(OS_WIN)
ASSERT_TRUE(SwitchKeyboardLayout("00000407")); // german
int ctrl_and_alt = kControlKeyModifierMask | kAltKeyModifierMask;
CheckCharToKeyCode('@', ui::VKEY_Q, ctrl_and_alt);
EXPECT_EQ("@", ConvertKeyCodeToTextNoError(ui::VKEY_Q, ctrl_and_alt));
#elif defined(OS_MACOSX)
ASSERT_TRUE(SwitchKeyboardLayout("com.apple.keylayout.German"));
EXPECT_EQ("@", ConvertKeyCodeToTextNoError(
ui::VKEY_L, kAltKeyModifierMask));
#endif
......@@ -142,26 +138,30 @@ TEST(KeycodeTextConversionTest, MAYBE_NonShiftModifiers) {
#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX)
// Not implemented on Linux.
// Fails if German layout is not installed on Mac.
// Fails if tested layouts are not installed on Mac.
#define MAYBE_NonEnglish DISABLED_NonEnglish
#else
#define MAYBE_NonEnglish NonEnglish
#endif
TEST(KeycodeTextConversionTest, MAYBE_NonEnglish) {
RestoreKeyboardLayoutOnDestruct restore;
#if defined(OS_WIN)
ASSERT_TRUE(SwitchKeyboardLayout("00000408")); // greek
CheckCharToKeyCode(';', ui::VKEY_Q, 0);
EXPECT_EQ(";", ConvertKeyCodeToTextNoError(ui::VKEY_Q, 0));
// Regression test for chromedriver bug #405.
ASSERT_TRUE(SwitchKeyboardLayout("00000419")); // russian
CheckCharToKeyCode(L'\u0438', ui::VKEY_B, 0);
EXPECT_EQ(base::UTF16ToUTF8(L"\u0438"),
ConvertKeyCodeToTextNoError(ui::VKEY_B, 0));
#elif defined(OS_MACOSX)
ASSERT_TRUE(SwitchKeyboardLayout("com.apple.keylayout.German"));
CheckCharToKeyCode('z', ui::VKEY_Y, 0);
EXPECT_EQ("z", ConvertKeyCodeToTextNoError(ui::VKEY_Y, 0));
#endif
// For Greek and Russian keyboard layouts, which are very different from
// QWERTY, Windows just uses virtual key codes that match the QWERTY layout,
// and translates them to other characters. If we wanted to test something
// like German, whose layout is very similar to QWERTY, we'd need to be
// careful, as in this case Windows maps the keyboard scan codes to the
// appropriate (different) VKEYs instead of mapping the VKEYs to different
// characters.
{
ui::ScopedKeyboardLayout greek_layout(ui::KEYBOARD_LAYOUT_GREEK);
CheckCharToKeyCode(';', ui::VKEY_Q, 0);
EXPECT_EQ(";", ConvertKeyCodeToTextNoError(ui::VKEY_Q, 0));
}
{
// Regression test for chromedriver bug #405.
ui::ScopedKeyboardLayout russian_layout(ui::KEYBOARD_LAYOUT_RUSSIAN);
CheckCharToKeyCode(L'\u0438', ui::VKEY_B, 0);
EXPECT_EQ(base::WideToUTF8(L"\u0438"),
ConvertKeyCodeToTextNoError(ui::VKEY_B, 0));
}
}
// Copyright (c) 2013 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 "chrome/test/chromedriver/test_util.h"
#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
RestoreKeyboardLayoutOnDestruct::RestoreKeyboardLayoutOnDestruct() {
#if defined(OS_WIN)
layout_ = GetKeyboardLayout(NULL);
#elif defined(OS_MACOSX)
layout_.reset(TISCopyCurrentKeyboardInputSource());
#elif defined(OS_LINUX)
NOTIMPLEMENTED();
#endif
}
RestoreKeyboardLayoutOnDestruct::~RestoreKeyboardLayoutOnDestruct() {
#if defined(OS_WIN)
ActivateKeyboardLayout(layout_, 0);
#elif defined(OS_MACOSX)
TISSelectInputSource(layout_);
#elif defined(OS_LINUX)
NOTIMPLEMENTED();
#endif
}
#if defined(OS_WIN)
bool SwitchKeyboardLayout(const std::string& input_locale_identifier) {
HKL layout = LoadKeyboardLayout(
base::UTF8ToWide(input_locale_identifier).c_str(), 0);
if (!layout)
return false;
return !!ActivateKeyboardLayout(layout, 0);
}
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
bool SwitchKeyboardLayout(const std::string& input_source_id) {
base::ScopedCFTypeRef<CFMutableDictionaryRef> filter_dict(
CFDictionaryCreateMutable(kCFAllocatorDefault,
1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
base::ScopedCFTypeRef<CFStringRef> id_ref(CFStringCreateWithCString(
kCFAllocatorDefault, input_source_id.c_str(), kCFStringEncodingUTF8));
CFDictionaryAddValue(filter_dict, kTISPropertyInputSourceID, id_ref);
base::ScopedCFTypeRef<CFArrayRef> sources(
TISCreateInputSourceList(filter_dict, true));
if (CFArrayGetCount(sources) != 1)
return false;
TISInputSourceRef source = (TISInputSourceRef)CFArrayGetValueAtIndex(
sources, 0);
return TISSelectInputSource(source) == noErr;
}
#endif // defined(OS_MACOSX)
// Copyright (c) 2013 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.
#ifndef CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_
#define CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_
#include <string>
#include "base/macros.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_MACOSX)
#include <Carbon/Carbon.h>
#include "base/mac/scoped_cftyperef.h"
#endif
// Restores the keyboard layout that was active at this object's creation
// when this object goes out of scope.
class RestoreKeyboardLayoutOnDestruct {
public:
RestoreKeyboardLayoutOnDestruct();
~RestoreKeyboardLayoutOnDestruct();
private:
#if defined(OS_WIN)
HKL layout_;
#elif defined(OS_MACOSX)
base::ScopedCFTypeRef<TISInputSourceRef> layout_;
#endif
DISALLOW_COPY_AND_ASSIGN(RestoreKeyboardLayoutOnDestruct);
};
#if defined(OS_WIN)
// Loads and activates the given keyboard layout. |input_locale_identifier|
// is composed of a device and language ID. Returns true on success.
// See http://msdn.microsoft.com/en-us/library/dd318693(v=vs.85).aspx
// Example: "00000409" is the default en-us keyboard layout.
bool SwitchKeyboardLayout(const std::string& input_locale_identifier);
#endif // defined(OS_WIN)
#if defined(OS_MACOSX)
// Selects the input source for the given input source ID. Returns true on
// success.
// Example: "com.apple.keyboardlayout.US" is the default en-us keyboard layout.
bool SwitchKeyboardLayout(const std::string& input_source_id);
#endif // defined(OS_MACOSX)
#endif // CHROME_TEST_CHROMEDRIVER_TEST_UTIL_H_
......@@ -276,6 +276,10 @@ static_library("test_support") {
"test/event_generator.h",
"test/events_test_utils.cc",
"test/events_test_utils.h",
"test/keyboard_layout.cc",
"test/keyboard_layout.h",
"test/keyboard_layout_mac.cc",
"test/keyboard_layout_win.cc",
"test/motion_event_test_utils.cc",
"test/motion_event_test_utils.h",
"test/platform_event_source_test_api.cc",
......@@ -313,6 +317,10 @@ static_library("test_support") {
]
}
if (is_mac) {
libs = [ "Carbon.framework" ]
}
if (use_x11) {
sources += [
"test/events_test_utils_x11.cc",
......
......@@ -12,46 +12,12 @@
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/dom_us_layout_data.h"
#include "ui/events/test/keyboard_layout.h"
namespace ui {
namespace {
enum Layout {
LAYOUT_US,
LAYOUT_FR,
LAYOUT_KR,
LAYOUT_JP,
};
// |LoadKeyboardLayout()| ensures the locale to be loaded into the system
// (Similar to temporarily adding a locale in Control Panel), otherwise
// |ToUnicodeEx()| will fall-back to the default locale.
// See MSDN LoadKeyboardLayout():
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646305(v=vs.85).aspx
// And language constants and strings:
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx
HKL GetInputLocale(Layout layout) {
switch (layout) {
case LAYOUT_US:
return ::LoadKeyboardLayout(L"00000409", KLF_ACTIVATE);
case LAYOUT_FR:
return ::LoadKeyboardLayout(L"0000040c", KLF_ACTIVATE);
case LAYOUT_KR:
// |LoadKeyboardLayout(L"00000412", KLF_ACTIVATE)| returns the correct
// Korean locale, but it will fail on DrMemory tests.
// See https://crbug.com/612736#c6
// However we could bypass it since we are only testing non-printable keys
// on Korean locale.
// (This issue only happens on Korean and Japanese).
return reinterpret_cast<HKL>(0x04120412);
case LAYOUT_JP:
return reinterpret_cast<HKL>(0x04110411);
default:
return 0;
}
}
struct TestKey {
KeyboardCode key_code;
const char* normal;
......@@ -126,7 +92,7 @@ class PlatformKeyMapTest : public testing::Test {
};
TEST_F(PlatformKeyMapTest, USLayout) {
PlatformKeyMap keymap(GetInputLocale(LAYOUT_US));
PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
const TestKey kUSLayoutTestCases[] = {
// n s c a sc sa ac
......@@ -174,7 +140,7 @@ TEST_F(PlatformKeyMapTest, USLayout) {
}
TEST_F(PlatformKeyMapTest, FRLayout) {
PlatformKeyMap keymap(GetInputLocale(LAYOUT_FR));
PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_FRENCH));
const TestKey kFRLayoutTestCases[] = {
// n s c a sc sa ac
......@@ -222,7 +188,7 @@ TEST_F(PlatformKeyMapTest, FRLayout) {
}
TEST_F(PlatformKeyMapTest, NumPad) {
PlatformKeyMap keymap(GetInputLocale(LAYOUT_US));
PlatformKeyMap keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
const struct TestCase {
KeyboardCode key_code;
......@@ -271,7 +237,7 @@ TEST_F(PlatformKeyMapTest, NumPad) {
}
TEST_F(PlatformKeyMapTest, NonPrintableKey) {
HKL layout = GetInputLocale(LAYOUT_US);
HKL layout = GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US);
PlatformKeyMap keymap(layout);
for (const auto& test_case : kNonPrintableCodeMap) {
......@@ -317,8 +283,9 @@ TEST_F(PlatformKeyMapTest, KoreanSpecificKeys) {
{VKEY_HANJA, DomKey::HANJA_MODE, DomKey::UNIDENTIFIED},
};
PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US));
PlatformKeyMap kr_keymap(GetInputLocale(LAYOUT_KR));
PlatformKeyMap us_keymap(
GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
PlatformKeyMap kr_keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_KOREAN));
for (const auto& test_case : kKoreanTestCases) {
EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl(
us_keymap, test_case.key_code, EF_NONE))
......@@ -346,8 +313,9 @@ TEST_F(PlatformKeyMapTest, JapaneseSpecificKeys) {
{VKEY_ATTN, DomKey::KANA_MODE, DomKey::ATTN},
};
PlatformKeyMap us_keymap(GetInputLocale(LAYOUT_US));
PlatformKeyMap jp_keymap(GetInputLocale(LAYOUT_JP));
PlatformKeyMap us_keymap(
GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_ENGLISH_US));
PlatformKeyMap jp_keymap(GetPlatformKeyboardLayout(KEYBOARD_LAYOUT_JAPANESE));
for (const auto& test_case : kJapaneseTestCases) {
EXPECT_EQ(test_case.us_key, DomKeyFromKeyboardCodeImpl(
us_keymap, test_case.key_code, EF_NONE))
......
// Copyright 2016 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 "ui/events/test/keyboard_layout.h"
#include "base/logging.h"
namespace ui {
ScopedKeyboardLayout::ScopedKeyboardLayout(KeyboardLayout layout) {
original_layout_ = GetActiveLayout();
ActivateLayout(GetPlatformKeyboardLayout(layout));
}
ScopedKeyboardLayout::~ScopedKeyboardLayout() {
ActivateLayout(original_layout_);
}
#if !defined(OS_WIN) && !(defined(OS_MACOSX) && !defined(OS_IOS))
PlatformKeyboardLayout ScopedKeyboardLayout::GetActiveLayout() {
NOTIMPLEMENTED();
return nullptr;
}
void ScopedKeyboardLayout::ActivateLayout(PlatformKeyboardLayout layout) {
NOTIMPLEMENTED();
}
PlatformKeyboardLayout GetPlatformKeyboardLayout(KeyboardLayout layout) {
NOTIMPLEMENTED();
return nullptr;
}
#endif
} // namespace ui
// Copyright 2016 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.
#ifndef UI_EVENTS_TEST_KEYBOARD_LAYOUT_H_
#define UI_EVENTS_TEST_KEYBOARD_LAYOUT_H_
#include "base/macros.h"
#include "build/build_config.h"
#if defined(OS_WIN)
#include <windows.h>
#elif defined(OS_MACOSX) && !defined(OS_IOS)
#include <Carbon/Carbon.h>
#include "base/mac/scoped_cftyperef.h"
#endif
namespace ui {
enum KeyboardLayout {
KEYBOARD_LAYOUT_ENGLISH_US,
KEYBOARD_LAYOUT_FRENCH,
KEYBOARD_LAYOUT_GERMAN,
KEYBOARD_LAYOUT_GREEK,
KEYBOARD_LAYOUT_JAPANESE,
KEYBOARD_LAYOUT_KOREAN,
KEYBOARD_LAYOUT_RUSSIAN,
};
#if defined(OS_WIN)
using PlatformKeyboardLayout = HKL;
#elif defined(OS_MACOSX) && !defined(OS_IOS)
using PlatformKeyboardLayout = base::ScopedCFTypeRef<TISInputSourceRef>;
#else
// Dummy type for unsupported platforms.
using PlatformKeyboardLayout = void*;
#endif
PlatformKeyboardLayout GetPlatformKeyboardLayout(KeyboardLayout layout);
// Changes the active keyboard layout for the scope of this object.
class ScopedKeyboardLayout {
public:
explicit ScopedKeyboardLayout(KeyboardLayout layout);
~ScopedKeyboardLayout();
private:
static PlatformKeyboardLayout GetActiveLayout();
static void ActivateLayout(PlatformKeyboardLayout layout);
PlatformKeyboardLayout original_layout_;
DISALLOW_COPY_AND_ASSIGN(ScopedKeyboardLayout);
};
} // namespace ui
#endif // UI_EVENTS_TEST_KEYBOARD_LAYOUT_H_
// Copyright 2016 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 "ui/events/test/keyboard_layout.h"
#include "base/logging.h"
namespace ui {
PlatformKeyboardLayout GetPlatformKeyboardLayout(KeyboardLayout layout) {
// Right now tests only need US English. If other layouts need to be
// supported in the future this code should be extended.
DCHECK_EQ(KEYBOARD_LAYOUT_ENGLISH_US, layout);
const char kUsInputSourceId[] = "com.apple.keylayout.US";
base::ScopedCFTypeRef<CFMutableDictionaryRef> input_source_list_filter(
CFDictionaryCreateMutable(kCFAllocatorDefault, 1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks));
base::ScopedCFTypeRef<CFStringRef> input_source_id_ref(
CFStringCreateWithCString(kCFAllocatorDefault, kUsInputSourceId,
kCFStringEncodingUTF8));
CFDictionaryAddValue(input_source_list_filter, kTISPropertyInputSourceID,
input_source_id_ref);
base::ScopedCFTypeRef<CFArrayRef> input_source_list(
TISCreateInputSourceList(input_source_list_filter, true));
if (CFArrayGetCount(input_source_list) != 1)
return PlatformKeyboardLayout();
return PlatformKeyboardLayout(
(TISInputSourceRef)CFArrayGetValueAtIndex(input_source_list, 0));
}
PlatformKeyboardLayout ScopedKeyboardLayout::GetActiveLayout() {
return PlatformKeyboardLayout(TISCopyCurrentKeyboardInputSource());
}
void ScopedKeyboardLayout::ActivateLayout(PlatformKeyboardLayout layout) {
DCHECK(layout);
OSStatus result = TISSelectInputSource(layout);
DCHECK_EQ(noErr, result);
}
} // namespace ui
// Copyright 2016 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 "ui/events/test/keyboard_layout.h"
#include "base/logging.h"
namespace ui {
// |LoadKeyboardLayout()| ensures the locale to be loaded into the system
// (Similar to temporarily adding a locale in Control Panel), otherwise
// |ToUnicodeEx()| will fall-back to the default locale.
// See MSDN LoadKeyboardLayout():
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms646305(v=vs.85).aspx
// And language constants and strings:
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx
PlatformKeyboardLayout GetPlatformKeyboardLayout(KeyboardLayout layout) {
switch (layout) {
case KEYBOARD_LAYOUT_ENGLISH_US:
return LoadKeyboardLayout(L"00000409", KLF_ACTIVATE);
case KEYBOARD_LAYOUT_FRENCH:
return LoadKeyboardLayout(L"0000040c", KLF_ACTIVATE);
case KEYBOARD_LAYOUT_GERMAN:
return LoadKeyboardLayout(L"00000407", KLF_ACTIVATE);
case KEYBOARD_LAYOUT_GREEK:
return LoadKeyboardLayout(L"00000408", KLF_ACTIVATE);
case KEYBOARD_LAYOUT_JAPANESE:
return LoadKeyboardLayout(L"00000411", KLF_ACTIVATE);
case KEYBOARD_LAYOUT_KOREAN:
return LoadKeyboardLayout(L"00000412", KLF_ACTIVATE);
case KEYBOARD_LAYOUT_RUSSIAN:
return LoadKeyboardLayout(L"00000419", KLF_ACTIVATE);
}
NOTREACHED();
return 0;
}
PlatformKeyboardLayout ScopedKeyboardLayout::GetActiveLayout() {
return GetKeyboardLayout(0);
}
void ScopedKeyboardLayout::ActivateLayout(PlatformKeyboardLayout layout) {
DCHECK(layout);
HKL result = ActivateKeyboardLayout(layout, 0);
DCHECK(!!result);
}
} // namespace ui
......@@ -36,6 +36,7 @@
#include "ui/events/event_utils.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/event_generator.h"
#include "ui/events/test/keyboard_layout.h"
#include "ui/gfx/render_text.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/controls/textfield/textfield_controller.h"
......@@ -759,7 +760,19 @@ TEST_F(TextfieldTest, KeyTest) {
EXPECT_STR_EQ("TexT!1!1", textfield_->text());
}
TEST_F(TextfieldTest, KeysWithModifiersTest) {
#if defined(OS_WIN) || defined(OS_MACOSX)
#define MAYBE_KeysWithModifiersTest KeysWithModifiersTest
#else
// TODO(crbug.com/645104): Implement keyboard layout changing for other
// platforms.
#define MAYBE_KeysWithModifiersTest DISABLED_KeysWithModifiersTest
#endif
TEST_F(TextfieldTest, MAYBE_KeysWithModifiersTest) {
// Activate U.S. English keyboard layout. Modifier keys in other layouts may
// change the text inserted into a texfield and cause this test to fail.
ui::ScopedKeyboardLayout keyboard_layout(ui::KEYBOARD_LAYOUT_ENGLISH_US);
InitTextfield();
const int ctrl = ui::EF_CONTROL_DOWN;
const int alt = ui::EF_ALT_DOWN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment