| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/location.h" |
| 6 #include "base/single_thread_task_runner.h" |
| 5 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/thread_task_runner_handle.h" |
| 7 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/apps/app_browsertest_util.h" | 11 #include "chrome/browser/apps/app_browsertest_util.h" |
| 9 #include "chrome/browser/chrome_content_browser_client.h" | 12 #include "chrome/browser/chrome_content_browser_client.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert
est_util.h" | 14 #include "chrome/browser/renderer_context_menu/render_view_context_menu_browsert
est_util.h" |
| 12 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti
l.h" | 15 #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_uti
l.h" |
| 13 #include "chrome/test/base/interactive_test_utils.h" | 16 #include "chrome/test/base/interactive_test_utils.h" |
| 14 #include "chrome/test/base/test_launcher_utils.h" | 17 #include "chrome/test/base/test_launcher_utils.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "components/guest_view/browser/guest_view_base.h" | 19 #include "components/guest_view/browser/guest_view_base.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 337 |
| 335 void Init() { initial_widget_count_ = CountWidgets(); } | 338 void Init() { initial_widget_count_ = CountWidgets(); } |
| 336 | 339 |
| 337 // Returns the last widget created. | 340 // Returns the last widget created. |
| 338 content::RenderWidgetHost* last_render_widget_host() { | 341 content::RenderWidgetHost* last_render_widget_host() { |
| 339 return last_render_widget_host_; | 342 return last_render_widget_host_; |
| 340 } | 343 } |
| 341 | 344 |
| 342 private: | 345 private: |
| 343 void ScheduleWait() { | 346 void ScheduleWait() { |
| 344 base::MessageLoop::current()->PostDelayedTask( | 347 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 345 FROM_HERE, | 348 FROM_HERE, |
| 346 base::Bind(&PopupCreatedObserver::Wait, base::Unretained(this)), | 349 base::Bind(&PopupCreatedObserver::Wait, base::Unretained(this)), |
| 347 base::TimeDelta::FromMilliseconds(200)); | 350 base::TimeDelta::FromMilliseconds(200)); |
| 348 } | 351 } |
| 349 | 352 |
| 350 size_t CountWidgets() { | 353 size_t CountWidgets() { |
| 351 scoped_ptr<content::RenderWidgetHostIterator> widgets( | 354 scoped_ptr<content::RenderWidgetHostIterator> widgets( |
| 352 content::RenderWidgetHost::GetRenderWidgetHosts()); | 355 content::RenderWidgetHost::GetRenderWidgetHosts()); |
| 353 size_t num_widgets = 0; | 356 size_t num_widgets = 0; |
| 354 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { | 357 while (content::RenderWidgetHost* widget = widgets->GetNextHost()) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 void DragTestStep1() { | 417 void DragTestStep1() { |
| 415 // Move mouse to start of text. | 418 // Move mouse to start of text. |
| 416 MoveMouseInsideWindow(gfx::Point(45, 8)); | 419 MoveMouseInsideWindow(gfx::Point(45, 8)); |
| 417 MoveMouseInsideWindow(gfx::Point(45, 9)); | 420 MoveMouseInsideWindow(gfx::Point(45, 9)); |
| 418 SendMouseEvent(ui_controls::LEFT, ui_controls::DOWN); | 421 SendMouseEvent(ui_controls::LEFT, ui_controls::DOWN); |
| 419 | 422 |
| 420 MoveMouseInsideWindow(gfx::Point(74, 12)); | 423 MoveMouseInsideWindow(gfx::Point(74, 12)); |
| 421 MoveMouseInsideWindow(gfx::Point(78, 12)); | 424 MoveMouseInsideWindow(gfx::Point(78, 12)); |
| 422 | 425 |
| 423 // Now wait a bit before moving mouse to initiate drag/drop. | 426 // Now wait a bit before moving mouse to initiate drag/drop. |
| 424 base::MessageLoop::current()->PostDelayedTask( | 427 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 425 FROM_HERE, | 428 FROM_HERE, base::Bind(&WebViewInteractiveTest::DragTestStep2, |
| 426 base::Bind(&WebViewInteractiveTest::DragTestStep2, | 429 base::Unretained(this)), |
| 427 base::Unretained(this)), | |
| 428 base::TimeDelta::FromMilliseconds(200)); | 430 base::TimeDelta::FromMilliseconds(200)); |
| 429 } | 431 } |
| 430 | 432 |
| 431 void DragTestStep2() { | 433 void DragTestStep2() { |
| 432 // Drag source over target. | 434 // Drag source over target. |
| 433 MoveMouseInsideWindow(gfx::Point(76, 76)); | 435 MoveMouseInsideWindow(gfx::Point(76, 76)); |
| 434 | 436 |
| 435 // Create a second mouse over the source to trigger the drag over event. | 437 // Create a second mouse over the source to trigger the drag over event. |
| 436 MoveMouseInsideWindow(gfx::Point(76, 77)); | 438 MoveMouseInsideWindow(gfx::Point(76, 77)); |
| 437 | 439 |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 | 1165 |
| 1164 // Now verify that the selection text propagates properly to RWHV. | 1166 // Now verify that the selection text propagates properly to RWHV. |
| 1165 content::RenderWidgetHostView* guest_rwhv = | 1167 content::RenderWidgetHostView* guest_rwhv = |
| 1166 guest_web_contents()->GetRenderWidgetHostView(); | 1168 guest_web_contents()->GetRenderWidgetHostView(); |
| 1167 ASSERT_TRUE(guest_rwhv); | 1169 ASSERT_TRUE(guest_rwhv); |
| 1168 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); | 1170 std::string selected_text = base::UTF16ToUTF8(guest_rwhv->GetSelectedText()); |
| 1169 ASSERT_TRUE(selected_text.size() >= 10u); | 1171 ASSERT_TRUE(selected_text.size() >= 10u); |
| 1170 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); | 1172 ASSERT_EQ("AAAAAAAAAA", selected_text.substr(0, 10)); |
| 1171 } | 1173 } |
| 1172 #endif | 1174 #endif |
| OLD | NEW |