Commit fa3326e1 authored by wutao's avatar wutao Committed by Commit Bot

autotest_private: Fix StringToKeyCode

Bug: b/157229763
Test: new js test
Change-Id: I759e303d43bef8ee620c51960524f26c7510f0ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2212664
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#771215}
parent 71489561
......@@ -646,11 +646,11 @@ ui::KeyboardCode StringToKeyCode(const std::string& str) {
DCHECK(base::IsStringASCII(str));
if (str.length() == 1) {
char c = str[0];
if (c >= 'a' || c <= 'z') {
if (c >= 'a' && c <= 'z') {
return static_cast<ui::KeyboardCode>(static_cast<int>(ui::VKEY_A) +
(c - 'a'));
}
if (c >= '0' || c <= '9') {
if (c >= '0' && c <= '9') {
return static_cast<ui::KeyboardCode>(static_cast<int>(ui::VKEY_0) +
(c - '0'));
}
......
......@@ -746,7 +746,6 @@ var defaultTests = [
});
});
},
// This test verifies that api to activate accelrator works as expected.
function acceleratorTest() {
// Ash level accelerator.
......@@ -779,6 +778,19 @@ var defaultTests = [
});
});
},
// This test verifies that api to activate accelrator with number works as
// expected.
function acceleratorWithNumberTest() {
// An ash accelerator with number to reset UI scale.
var accelerator = newAccelerator('0', true /* shift */, true /* control */);
chrome.autotestPrivate.activateAccelerator(
accelerator,
function(success) {
chrome.test.assertNoLastError();
chrome.test.assertTrue(success);
chrome.test.succeed();
});
},
function setMetricsEnabled() {
chrome.autotestPrivate.setMetricsEnabled(true, chrome.test.callbackPass());
},
......
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