Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: chrome/browser/apps/guest_view/web_view_browsertest.cc

Issue 2569273002: Add constructors to WebInputEvents and setters so we can work at cleaning up these public structs. (Closed)
Patch Set: Fix mouse up event sender not modifying modifiers Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 2550 matching lines...) Expand 10 before | Expand all | Expand 10 after
3349 content::EnableAccessibilityForWebContents(guest_web_contents); 3353 content::EnableAccessibilityForWebContents(guest_web_contents);
3350 3354
3351 // Listen for accessibility events on both WebContents. 3355 // Listen for accessibility events on both WebContents.
3352 WebContentsAccessibilityEventWatcher main_event_watcher( 3356 WebContentsAccessibilityEventWatcher main_event_watcher(
3353 web_contents, ui::AX_EVENT_HOVER); 3357 web_contents, ui::AX_EVENT_HOVER);
3354 WebContentsAccessibilityEventWatcher guest_event_watcher( 3358 WebContentsAccessibilityEventWatcher guest_event_watcher(
3355 guest_web_contents, ui::AX_EVENT_HOVER); 3359 guest_web_contents, ui::AX_EVENT_HOVER);
3356 3360
3357 // Send an accessibility touch event to the main WebContents, but 3361 // Send an accessibility touch event to the main WebContents, but
3358 // positioned on top of the button inside the inner WebView. 3362 // positioned on top of the button inside the inner WebView.
3359 blink::WebMouseEvent accessibility_touch_event; 3363 blink::WebMouseEvent accessibility_touch_event(
3360 accessibility_touch_event.type = blink::WebInputEvent::MouseMove; 3364 blink::WebInputEvent::MouseMove,
3365 blink::WebInputEvent::IsTouchAccessibility,
3366 blink::WebInputEvent::TimeStampForTesting);
3361 accessibility_touch_event.x = 95; 3367 accessibility_touch_event.x = 95;
3362 accessibility_touch_event.y = 55; 3368 accessibility_touch_event.y = 55;
3363 accessibility_touch_event.modifiers =
3364 blink::WebInputEvent::IsTouchAccessibility;
3365 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent( 3369 web_contents->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
3366 accessibility_touch_event); 3370 accessibility_touch_event);
3367 3371
3368 // Ensure that we got just a single hover event on the guest WebContents, 3372 // Ensure that we got just a single hover event on the guest WebContents,
3369 // and that it was fired on a button. 3373 // and that it was fired on a button.
3370 guest_event_watcher.Wait(); 3374 guest_event_watcher.Wait();
3371 ui::AXNodeData hit_node = guest_event_watcher.node_data(); 3375 ui::AXNodeData hit_node = guest_event_watcher.node_data();
3372 EXPECT_EQ(1U, guest_event_watcher.count()); 3376 EXPECT_EQ(1U, guest_event_watcher.count());
3373 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role); 3377 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit_node.role);
3374 EXPECT_EQ(0U, main_event_watcher.count()); 3378 EXPECT_EQ(0U, main_event_watcher.count());
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 ClosingChromeSignInShouldNotCrash) { 3913 ClosingChromeSignInShouldNotCrash) {
3910 GURL signin_url{"chrome://chrome-signin"}; 3914 GURL signin_url{"chrome://chrome-signin"};
3911 3915
3912 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED); 3916 AddTabAtIndex(0, signin_url, ui::PAGE_TRANSITION_TYPED);
3913 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED); 3917 AddTabAtIndex(1, signin_url, ui::PAGE_TRANSITION_TYPED);
3914 WaitForWebViewInDom(); 3918 WaitForWebViewInDom();
3915 3919
3916 chrome::CloseTab(browser()); 3920 chrome::CloseTab(browser());
3917 } 3921 }
3918 #endif 3922 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698