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 <queue> | 5 #include <queue> |
6 #include <set> | 6 #include <set> |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 std::set<aura::Window*> observed_windows_; | 291 std::set<aura::Window*> observed_windows_; |
292 bool wait_for_widget_shown_ = false; | 292 bool wait_for_widget_shown_ = false; |
293 | 293 |
294 DISALLOW_COPY_AND_ASSIGN(SelectControlWaiter); | 294 DISALLOW_COPY_AND_ASSIGN(SelectControlWaiter); |
295 }; | 295 }; |
296 | 296 |
297 // Simulate real click with delay between mouse down and up. | 297 // Simulate real click with delay between mouse down and up. |
298 class LeftMouseClick { | 298 class LeftMouseClick { |
299 public: | 299 public: |
300 explicit LeftMouseClick(content::WebContents* web_contents) | 300 explicit LeftMouseClick(content::WebContents* web_contents) |
301 : web_contents_(web_contents) {} | 301 : web_contents_(web_contents), |
| 302 mouse_event_(blink::WebInputEvent::MouseDown, |
| 303 blink::WebInputEvent::NoModifiers, |
| 304 blink::WebInputEvent::TimeStampForTesting) { |
| 305 mouse_event_.button = blink::WebMouseEvent::Button::Left; |
| 306 } |
302 | 307 |
303 ~LeftMouseClick() { | 308 ~LeftMouseClick() { |
304 DCHECK(click_completed_); | 309 DCHECK(click_completed_); |
305 } | 310 } |
306 | 311 |
307 void Click(const gfx::Point& point, int duration_ms) { | 312 void Click(const gfx::Point& point, int duration_ms) { |
308 DCHECK(click_completed_); | 313 DCHECK(click_completed_); |
309 click_completed_ = false; | 314 click_completed_ = false; |
310 mouse_event_.type = blink::WebInputEvent::MouseDown; | 315 mouse_event_.setType(blink::WebInputEvent::MouseDown); |
311 mouse_event_.button = blink::WebMouseEvent::Button::Left; | |
312 mouse_event_.x = point.x(); | 316 mouse_event_.x = point.x(); |
313 mouse_event_.y = point.y(); | 317 mouse_event_.y = point.y(); |
314 mouse_event_.modifiers = 0; | |
315 const gfx::Rect offset = web_contents_->GetContainerBounds(); | 318 const gfx::Rect offset = web_contents_->GetContainerBounds(); |
316 mouse_event_.globalX = point.x() + offset.x(); | 319 mouse_event_.globalX = point.x() + offset.x(); |
317 mouse_event_.globalY = point.y() + offset.y(); | 320 mouse_event_.globalY = point.y() + offset.y(); |
318 mouse_event_.clickCount = 1; | 321 mouse_event_.clickCount = 1; |
319 web_contents_->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 322 web_contents_->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
320 mouse_event_); | 323 mouse_event_); |
321 | 324 |
322 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 325 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
323 FROM_HERE, base::Bind(&LeftMouseClick::SendMouseUp, | 326 FROM_HERE, base::Bind(&LeftMouseClick::SendMouseUp, |
324 base::Unretained(this)), | 327 base::Unretained(this)), |
325 base::TimeDelta::FromMilliseconds(duration_ms)); | 328 base::TimeDelta::FromMilliseconds(duration_ms)); |
326 } | 329 } |
327 | 330 |
328 // Wait for click completed. | 331 // Wait for click completed. |
329 void Wait() { | 332 void Wait() { |
330 if (click_completed_) | 333 if (click_completed_) |
331 return; | 334 return; |
332 message_loop_runner_ = new content::MessageLoopRunner; | 335 message_loop_runner_ = new content::MessageLoopRunner; |
333 message_loop_runner_->Run(); | 336 message_loop_runner_->Run(); |
334 message_loop_runner_ = nullptr; | 337 message_loop_runner_ = nullptr; |
335 } | 338 } |
336 | 339 |
337 private: | 340 private: |
338 void SendMouseUp() { | 341 void SendMouseUp() { |
339 mouse_event_.type = blink::WebInputEvent::MouseUp; | 342 mouse_event_.setType(blink::WebInputEvent::MouseUp); |
340 web_contents_->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 343 web_contents_->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
341 mouse_event_); | 344 mouse_event_); |
342 click_completed_ = true; | 345 click_completed_ = true; |
343 if (message_loop_runner_) | 346 if (message_loop_runner_) |
344 message_loop_runner_->Quit(); | 347 message_loop_runner_->Quit(); |
345 } | 348 } |
346 | 349 |
347 // Unowned pointer. | 350 // Unowned pointer. |
348 content::WebContents* web_contents_; | 351 content::WebContents* web_contents_; |
349 | 352 |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 content::ExecuteScript( | 774 content::ExecuteScript( |
772 GetGuestWebContents(), | 775 GetGuestWebContents(), |
773 base::StringPrintf("onAppCommand('%s');", message.c_str()))); | 776 base::StringPrintf("onAppCommand('%s');", message.c_str()))); |
774 | 777 |
775 if (listener) { | 778 if (listener) { |
776 ASSERT_TRUE(listener->WaitUntilSatisfied()); | 779 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
777 } | 780 } |
778 } | 781 } |
779 | 782 |
780 void OpenContextMenu(content::WebContents* web_contents) { | 783 void OpenContextMenu(content::WebContents* web_contents) { |
781 blink::WebMouseEvent mouse_event; | 784 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, |
782 mouse_event.type = blink::WebInputEvent::MouseDown; | 785 blink::WebInputEvent::NoModifiers, |
| 786 blink::WebInputEvent::TimeStampForTesting); |
783 mouse_event.button = blink::WebMouseEvent::Button::Right; | 787 mouse_event.button = blink::WebMouseEvent::Button::Right; |
784 mouse_event.x = 1; | 788 mouse_event.x = 1; |
785 mouse_event.y = 1; | 789 mouse_event.y = 1; |
786 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 790 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
787 mouse_event); | 791 mouse_event); |
788 mouse_event.type = blink::WebInputEvent::MouseUp; | 792 mouse_event.setType(blink::WebInputEvent::MouseUp); |
789 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 793 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
790 mouse_event); | 794 mouse_event); |
791 } | 795 } |
792 | 796 |
793 content::WebContents* GetGuestWebContents() { | 797 content::WebContents* GetGuestWebContents() { |
794 return guest_web_contents_; | 798 return guest_web_contents_; |
795 } | 799 } |
796 | 800 |
797 content::WebContents* GetEmbedderWebContents() { | 801 content::WebContents* GetEmbedderWebContents() { |
798 if (!embedder_web_contents_) { | 802 if (!embedder_web_contents_) { |
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3356 content::EnableAccessibilityForWebContents(guest_web_contents); | 3360 content::EnableAccessibilityForWebContents(guest_web_contents); |
3357 | 3361 |
3358 // Listen for accessibility events on both WebContents. | 3362 // Listen for accessibility events on both WebContents. |
3359 WebContentsAccessibilityEventWatcher main_event_watcher( | 3363 WebContentsAccessibilityEventWatcher main_event_watcher( |
3360 web_contents, ui::AX_EVENT_HOVER); | 3364 web_contents, ui::AX_EVENT_HOVER); |
3361 WebContentsAccessibilityEventWatcher guest_event_watcher( | 3365 WebContentsAccessibilityEventWatcher guest_event_watcher( |
3362 guest_web_contents, ui::AX_EVENT_HOVER); | 3366 guest_web_contents, ui::AX_EVENT_HOVER); |
3363 | 3367 |
3364 // Send an accessibility touch event to the main WebContents, but | 3368 // Send an accessibility touch event to the main WebContents, but |
3365 // positioned on top of the button inside the inner WebView. | 3369 // positioned on top of the button inside the inner WebView. |
3366 blink::WebMouseEvent accessibility_touch_event; | 3370 blink::WebMouseEvent accessibility_touch_event( |
3367 accessibility_touch_event.type = blink::WebInputEvent::MouseMove; | 3371 blink::WebInputEvent::MouseMove, |
| 3372 blink::WebInputEvent::IsTouchAccessibility, |
| 3373 blink::WebInputEvent::TimeStampForTesting); |
3368 accessibility_touch_event.x = 95; | 3374 accessibility_touch_event.x = 95; |
3369 accessibility_touch_event.y = 55; | 3375 accessibility_touch_event.y = 55; |
3370 accessibility_touch_event.modifiers = | |
3371 blink::WebInputEvent::IsTouchAccessibility; | |
3372 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( | 3376 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( |
3373 accessibility_touch_event); | 3377 accessibility_touch_event); |
3374 | 3378 |
3375 // Ensure that we got just a single hover event on the guest WebContents, | 3379 // Ensure that we got just a single hover event on the guest WebContents, |
3376 // and that it was fired on a button. | 3380 // and that it was fired on a button. |
3377 guest_event_watcher.Wait(); | 3381 guest_event_watcher.Wait(); |
3378 ui::AXNodeData hit_node = guest_event_watcher.node_data(); | 3382 ui::AXNodeData hit_node = guest_event_watcher.node_data(); |
3379 EXPECT_EQ(1U, guest_event_watcher.count()); | 3383 EXPECT_EQ(1U, guest_event_watcher.count()); |
3380 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role); | 3384 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role); |
3381 EXPECT_EQ(0U, main_event_watcher.count()); | 3385 EXPECT_EQ(0U, main_event_watcher.count()); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3916 ClosingChromeSignInShouldNotCrash) { | 3920 ClosingChromeSignInShouldNotCrash) { |
3917 GURL signin_url{"chrome://chrome-signin"}; | 3921 GURL signin_url{"chrome://chrome-signin"}; |
3918 | 3922 |
3919 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); | 3923 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); |
3920 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); | 3924 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); |
3921 WaitForWebViewInDom(); | 3925 WaitForWebViewInDom(); |
3922 | 3926 |
3923 chrome::CloseTab(browser()); | 3927 chrome::CloseTab(browser()); |
3924 } | 3928 } |
3925 #endif | 3929 #endif |
OLD | NEW |