| Index: chrome/browser/browser_keyevents_browsertest.cc
|
| diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc
|
| index a9703a0918225d6b01ec0fdf818d093299a0f749..59255e5e0dc291414fa5a91958278bb71c588920 100644
|
| --- a/chrome/browser/browser_keyevents_browsertest.cc
|
| +++ b/chrome/browser/browser_keyevents_browsertest.cc
|
| @@ -32,24 +32,24 @@ using content::RenderViewHost;
|
| namespace {
|
|
|
| const char kTestingPage[] = "files/keyevents_test.html";
|
| -const wchar_t kSuppressEventJS[] =
|
| - L"window.domAutomationController.send(setDefaultAction('%ls', %ls));";
|
| -const wchar_t kGetResultJS[] =
|
| - L"window.domAutomationController.send(keyEventResult[%d]);";
|
| +const char kSuppressEventJS[] =
|
| + "window.domAutomationController.send(setDefaultAction('%s', %s));";
|
| +const char kGetResultJS[] =
|
| + "window.domAutomationController.send(keyEventResult[%d]);";
|
| const wchar_t kGetResultLengthJS[] =
|
| L"window.domAutomationController.send(keyEventResult.length);";
|
| const wchar_t kGetFocusedElementJS[] =
|
| L"window.domAutomationController.send(focusedElement);";
|
| -const wchar_t kSetFocusedElementJS[] =
|
| - L"window.domAutomationController.send(setFocusedElement('%ls'));";
|
| -const wchar_t kGetTextBoxValueJS[] =
|
| - L"window.domAutomationController.send("
|
| - L"document.getElementById('%ls').value);";
|
| -const wchar_t kSetTextBoxValueJS[] =
|
| - L"window.domAutomationController.send("
|
| - L"document.getElementById('%ls').value = '%ls');";
|
| -const wchar_t kStartTestJS[] =
|
| - L"window.domAutomationController.send(startTest(%d));";
|
| +const char kSetFocusedElementJS[] =
|
| + "window.domAutomationController.send(setFocusedElement('%s'));";
|
| +const char kGetTextBoxValueJS[] =
|
| + "window.domAutomationController.send("
|
| + "document.getElementById('%s').value);";
|
| +const char kSetTextBoxValueJS[] =
|
| + "window.domAutomationController.send("
|
| + "document.getElementById('%s').value = '%s');";
|
| +const char kStartTestJS[] =
|
| + "window.domAutomationController.send(startTest(%d));";
|
|
|
| // Maximum lenght of the result array in KeyEventTestData structure.
|
| const size_t kMaxResultLength = 10;
|
| @@ -81,8 +81,8 @@ struct KeyEventTestData {
|
| const char* const result[kMaxResultLength];
|
| };
|
|
|
| -const wchar_t* GetBoolString(bool value) {
|
| - return value ? L"true" : L"false";
|
| +const char* GetBoolString(bool value) {
|
| + return value ? "true" : "false";
|
| }
|
|
|
| // A class to help wait for the finish of a key event test.
|
| @@ -142,13 +142,14 @@ class BrowserKeyEventsTest : public InProcessBrowserTest {
|
| // Set the suppress flag of an event specified by |type|. If |suppress| is
|
| // true then the web page will suppress all events with |type|. Following
|
| // event types are supported: keydown, keypress, keyup and textInput.
|
| - void SuppressEventByType(int tab_index, const wchar_t* type, bool suppress) {
|
| + void SuppressEventByType(int tab_index, const char* type, bool suppress) {
|
| ASSERT_LT(tab_index, browser()->tab_count());
|
| bool actual;
|
| ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
|
| browser()->GetWebContentsAt(tab_index)->GetRenderViewHost(),
|
| L"",
|
| - base::StringPrintf(kSuppressEventJS, type, GetBoolString(!suppress)),
|
| + ASCIIToWide(base::StringPrintf(kSuppressEventJS, type,
|
| + GetBoolString(!suppress))),
|
| &actual));
|
| ASSERT_EQ(!suppress, actual);
|
| }
|
| @@ -156,13 +157,13 @@ class BrowserKeyEventsTest : public InProcessBrowserTest {
|
| void SuppressEvents(int tab_index, bool keydown, bool keypress,
|
| bool keyup, bool textinput) {
|
| ASSERT_NO_FATAL_FAILURE(
|
| - SuppressEventByType(tab_index, L"keydown", keydown));
|
| + SuppressEventByType(tab_index, "keydown", keydown));
|
| ASSERT_NO_FATAL_FAILURE(
|
| - SuppressEventByType(tab_index, L"keypress", keypress));
|
| + SuppressEventByType(tab_index, "keypress", keypress));
|
| ASSERT_NO_FATAL_FAILURE(
|
| - SuppressEventByType(tab_index, L"keyup", keyup));
|
| + SuppressEventByType(tab_index, "keyup", keyup));
|
| ASSERT_NO_FATAL_FAILURE(
|
| - SuppressEventByType(tab_index, L"textInput", textinput));
|
| + SuppressEventByType(tab_index, "textInput", textinput));
|
| }
|
|
|
| void SuppressAllEvents(int tab_index, bool suppress) {
|
| @@ -185,7 +186,7 @@ class BrowserKeyEventsTest : public InProcessBrowserTest {
|
| std::string actual;
|
| ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
|
| browser()->GetWebContentsAt(tab_index)->GetRenderViewHost(),
|
| - L"", base::StringPrintf(kGetResultJS, i), &actual));
|
| + L"", ASCIIToWide(base::StringPrintf(kGetResultJS, i)), &actual));
|
|
|
| // If more events were received than expected, then the additional events
|
| // must be keyup events.
|
| @@ -205,39 +206,39 @@ class BrowserKeyEventsTest : public InProcessBrowserTest {
|
| ASSERT_EQ(WideToUTF8(focused), actual);
|
| }
|
|
|
| - void SetFocusedElement(int tab_index, const wchar_t* focused) {
|
| + void SetFocusedElement(int tab_index, const char* focused) {
|
| ASSERT_LT(tab_index, browser()->tab_count());
|
| bool actual;
|
| ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
|
| browser()->GetWebContentsAt(tab_index)->GetRenderViewHost(),
|
| L"",
|
| - base::StringPrintf(kSetFocusedElementJS, focused),
|
| + ASCIIToWide(base::StringPrintf(kSetFocusedElementJS, focused)),
|
| &actual));
|
| ASSERT_TRUE(actual);
|
| }
|
|
|
| - void CheckTextBoxValue(int tab_index, const wchar_t* id,
|
| + void CheckTextBoxValue(int tab_index, const char* id,
|
| const wchar_t* value) {
|
| ASSERT_LT(tab_index, browser()->tab_count());
|
| std::string actual;
|
| ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
|
| browser()->GetWebContentsAt(tab_index)->GetRenderViewHost(),
|
| L"",
|
| - base::StringPrintf(kGetTextBoxValueJS, id),
|
| + ASCIIToWide(base::StringPrintf(kGetTextBoxValueJS, id)),
|
| &actual));
|
| ASSERT_EQ(WideToUTF8(value), actual);
|
| }
|
|
|
| - void SetTextBoxValue(int tab_index, const wchar_t* id,
|
| - const wchar_t* value) {
|
| + void SetTextBoxValue(int tab_index, const char* id,
|
| + const char* value) {
|
| ASSERT_LT(tab_index, browser()->tab_count());
|
| std::string actual;
|
| ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractString(
|
| browser()->GetWebContentsAt(tab_index)->GetRenderViewHost(),
|
| L"",
|
| - base::StringPrintf(kSetTextBoxValueJS, id, value),
|
| + ASCIIToWide(base::StringPrintf(kSetTextBoxValueJS, id, value)),
|
| &actual));
|
| - ASSERT_EQ(WideToUTF8(value), actual);
|
| + ASSERT_STREQ(value, actual.c_str());
|
| }
|
|
|
| void StartTest(int tab_index, int result_length) {
|
| @@ -245,7 +246,8 @@ class BrowserKeyEventsTest : public InProcessBrowserTest {
|
| bool actual;
|
| ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
|
| browser()->GetWebContentsAt(tab_index)->GetRenderViewHost(),
|
| - L"", base::StringPrintf(kStartTestJS, result_length), &actual));
|
| + L"", ASCIIToWide(base::StringPrintf(kStartTestJS, result_length)),
|
| + &actual));
|
| ASSERT_TRUE(actual);
|
| }
|
|
|
| @@ -377,22 +379,22 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_NormalKeyEvents) {
|
| }
|
|
|
| // Input in normal text box.
|
| - ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, L"A"));
|
| + ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, "A"));
|
| for (size_t i = 0; i < arraysize(kTestWithInput); ++i) {
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestWithInput[i]))
|
| << "kTestWithInput[" << i << "] in text box failed:\n"
|
| << GetTestDataDescription(kTestWithInput[i]);
|
| }
|
| - EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, L"A", L"aA"));
|
| + EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, "A", L"aA"));
|
|
|
| // Input in password box.
|
| - ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, L"B"));
|
| + ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, "B"));
|
| for (size_t i = 0; i < arraysize(kTestWithInput); ++i) {
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestWithInput[i]))
|
| << "kTestWithInput[" << i << "] in password box failed:\n"
|
| << GetTestDataDescription(kTestWithInput[i]);
|
| }
|
| - EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, L"B", L"aA"));
|
| + EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, "B", L"aA"));
|
| }
|
|
|
| #if defined(OS_WIN) || defined(OS_LINUX)
|
| @@ -625,7 +627,7 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_AccessKeys) {
|
| EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"A"));
|
|
|
| // Blur the focused element.
|
| - EXPECT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, L""));
|
| + EXPECT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, ""));
|
| // Make sure no element is focused.
|
| EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L""));
|
|
|
| @@ -661,7 +663,7 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, MAYBE_AccessKeys) {
|
| EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L"D"));
|
|
|
| // Blur the focused element.
|
| - EXPECT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, L""));
|
| + EXPECT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, ""));
|
| // Make sure no element is focused.
|
| EXPECT_NO_FATAL_FAILURE(CheckFocusedElement(tab_index, L""));
|
| #if !defined(USE_ASH)
|
| @@ -792,15 +794,15 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, EditorKeyBindings) {
|
| ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
|
|
|
| int tab_index = browser()->active_index();
|
| - ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, L"A"));
|
| - ASSERT_NO_FATAL_FAILURE(SetTextBoxValue(tab_index, L"A", L"Hello"));
|
| + ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, "A"));
|
| + ASSERT_NO_FATAL_FAILURE(SetTextBoxValue(tab_index, "A", "Hello"));
|
| // Move the caret to the beginning of the line.
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlA));
|
| // Forward one character
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlF));
|
| // Delete to the end of the line.
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestCtrlK));
|
| - EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, L"A", L"H"));
|
| + EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, "A", L"H"));
|
| }
|
| #endif
|
|
|
| @@ -829,10 +831,10 @@ IN_PROC_BROWSER_TEST_F(BrowserKeyEventsTest, PageUpDownKeys) {
|
| ASSERT_TRUE(IsViewFocused(VIEW_ID_TAB_CONTAINER));
|
|
|
| int tab_index = browser()->active_index();
|
| - ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, L"A"));
|
| + ASSERT_NO_FATAL_FAILURE(SetFocusedElement(tab_index, "A"));
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestPageUp));
|
| EXPECT_NO_FATAL_FAILURE(TestKeyEvent(tab_index, kTestPageDown));
|
| - EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, L"A", L""));
|
| + EXPECT_NO_FATAL_FAILURE(CheckTextBoxValue(tab_index, "A", L""));
|
| }
|
|
|
| #if defined(OS_WIN)
|
|
|