Commit 6ed556e1 authored by mohsen@chromium.org's avatar mohsen@chromium.org

Enable touch text selection tests on all Aura platforms

In order to make touch text selection ready for Windows and other Aura
platforms, a prerequisite is to enable tests. Following tests are
enabled:
 - TouchSelectionControllerImplTest in views_unittests;
 - TouchEditableImplAuraTest in content_browsertests.

BUG=377561

Review URL: https://codereview.chromium.org/304883002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273770 0039d316-1c4b-4281-b951-d872f2087c98
parent de472fac
...@@ -255,20 +255,31 @@ void TouchEditableImplAura::ConvertPointToScreen(gfx::Point* point) { ...@@ -255,20 +255,31 @@ void TouchEditableImplAura::ConvertPointToScreen(gfx::Point* point) {
if (!rwhva_) if (!rwhva_)
return; return;
aura::Window* window = rwhva_->GetNativeView(); aura::Window* window = rwhva_->GetNativeView();
aura::Window* root = window->GetRootWindow();
// First convert the point to root window coordinates, then if there is a
// screen position client, convert it to screen coordinates.
aura::Window::ConvertPointToTarget(window, root, point);
aura::client::ScreenPositionClient* screen_position_client = aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(window->GetRootWindow()); aura::client::GetScreenPositionClient(root);
if (screen_position_client) if (screen_position_client)
screen_position_client->ConvertPointToScreen(window, point); screen_position_client->ConvertPointToScreen(root, point);
} }
void TouchEditableImplAura::ConvertPointFromScreen(gfx::Point* point) { void TouchEditableImplAura::ConvertPointFromScreen(gfx::Point* point) {
if (!rwhva_) if (!rwhva_)
return; return;
aura::Window* window = rwhva_->GetNativeView(); aura::Window* window = rwhva_->GetNativeView();
aura::Window* root = window->GetRootWindow();
// If there is a screen position client, convert the point from screen to root
// window and then to client coordinates. Otherwise, suppose the point is in
// root window coordinates and convert it to client coordinates.
aura::client::ScreenPositionClient* screen_position_client = aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(window->GetRootWindow()); aura::client::GetScreenPositionClient(root);
if (screen_position_client) if (screen_position_client)
screen_position_client->ConvertPointFromScreen(window, point); screen_position_client->ConvertPointFromScreen(root, point);
aura::Window::ConvertPointToTarget(root, window, point);
} }
bool TouchEditableImplAura::DrawsHandles() { bool TouchEditableImplAura::DrawsHandles() {
......
...@@ -167,13 +167,13 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, ...@@ -167,13 +167,13 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
// Check if selection handles are showing. // Check if selection handles are showing.
EXPECT_TRUE(GetTouchSelectionController(touch_editable)); EXPECT_TRUE(GetTouchSelectionController(touch_editable));
EXPECT_STREQ("Some text we can select", selection.c_str()); EXPECT_EQ("Some text we can select", selection);
// Lets move the handles a bit to modify the selection // Lets move the handles a bit to modify the selection
touch_editable->Reset(); touch_editable->Reset();
generator.GestureScrollSequence( generator.GestureScrollSequence(
gfx::Point(10, 47), gfx::Point(bounds.x() + 10, bounds.y() + 47),
gfx::Point(30, 47), gfx::Point(bounds.x() + 30, bounds.y() + 47),
base::TimeDelta::FromMilliseconds(20), base::TimeDelta::FromMilliseconds(20),
5); 5);
touch_editable->WaitForSelectionChangeCallback(); touch_editable->WaitForSelectionChangeCallback();
...@@ -221,7 +221,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, ...@@ -221,7 +221,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
std::string selection; std::string selection;
value->GetAsString(&selection); value->GetAsString(&selection);
EXPECT_STREQ("Some", selection.c_str()); EXPECT_EQ("Some", selection);
// Start scrolling. Handles should get hidden. // Start scrolling. Handles should get hidden.
ui::GestureEvent scroll_begin(ui::ET_GESTURE_SCROLL_BEGIN, ui::GestureEvent scroll_begin(ui::ET_GESTURE_SCROLL_BEGIN,
...@@ -282,7 +282,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, ...@@ -282,7 +282,7 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
std::string selection; std::string selection;
value->GetAsString(&selection); value->GetAsString(&selection);
EXPECT_STREQ("Some", selection.c_str()); EXPECT_EQ("Some", selection);
} }
IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
...@@ -318,7 +318,13 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, ...@@ -318,7 +318,13 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
content::ExecuteScriptAndGetValue(main_frame, "get_selection()"); content::ExecuteScriptAndGetValue(main_frame, "get_selection()");
std::string selection; std::string selection;
value->GetAsString(&selection); value->GetAsString(&selection);
EXPECT_STREQ("Some", selection.c_str()); #if defined(OS_WIN)
// In Windows, the default behavior is to select the whitespace after the word
// when the word is selected.
EXPECT_EQ("Some ", selection);
#else
EXPECT_EQ("Some", selection);
#endif // defined (OS_WIN)
} }
IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
...@@ -361,8 +367,8 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest, ...@@ -361,8 +367,8 @@ IN_PROC_BROWSER_TEST_F(TouchEditableImplAuraTest,
// Move the cursor handle. // Move the cursor handle.
generator.GestureScrollSequence( generator.GestureScrollSequence(
gfx::Point(50, 59), gfx::Point(bounds.x() + 50, bounds.y() + 59),
gfx::Point(10, 59), gfx::Point(bounds.x() + 10, bounds.y() + 59),
base::TimeDelta::FromMilliseconds(20), base::TimeDelta::FromMilliseconds(20),
1); 1);
touch_editable->WaitForSelectionChangeCallback(); touch_editable->WaitForSelectionChangeCallback();
......
...@@ -1169,11 +1169,6 @@ ...@@ -1169,11 +1169,6 @@
'test/webui_resource_browsertest.cc', 'test/webui_resource_browsertest.cc',
], ],
'conditions': [ 'conditions': [
['chromeos==0', {
'sources!': [
'browser/web_contents/touch_editable_impl_aura_browsertest.cc',
],
}],
['OS=="win"', { ['OS=="win"', {
'resource_include_dirs': [ 'resource_include_dirs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit', '<(SHARED_INTERMEDIATE_DIR)/webkit',
......
...@@ -732,11 +732,7 @@ ...@@ -732,11 +732,7 @@
'window/dialog_delegate_unittest.cc', 'window/dialog_delegate_unittest.cc',
], ],
'conditions': [ 'conditions': [
['chromeos==0', { ['chromeos==1', {
'sources!': [
'touchui/touch_selection_controller_impl_unittest.cc',
],
}, { # use_chromeos==1
'sources/': [ 'sources/': [
['exclude', 'ime/input_method_bridge_unittest.cc'], ['exclude', 'ime/input_method_bridge_unittest.cc'],
['exclude', 'widget/desktop_aura'], ['exclude', 'widget/desktop_aura'],
......
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