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

Side by Side Diff: chrome/test/base/ui_test_utils.cc

Issue 10703141: End-to-end browser tests for speech recognition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved test to /chrome/test Created 8 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/speech/basic_recognition.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/base/ui_test_utils.h" 5 #include "chrome/test/base/ui_test_utils.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #endif 9 #endif
10 10
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 *ordinal = observer.active_match_ordinal(); 629 *ordinal = observer.active_match_ordinal();
630 return observer.number_of_matches(); 630 return observer.number_of_matches();
631 } 631 }
632 632
633 void CloseAllInfoBars(TabContents* tab) { 633 void CloseAllInfoBars(TabContents* tab) {
634 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); 634 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper();
635 while (infobar_helper->infobar_count() > 0) 635 while (infobar_helper->infobar_count() > 0)
636 infobar_helper->RemoveInfoBar(infobar_helper->GetInfoBarDelegateAt(0)); 636 infobar_helper->RemoveInfoBar(infobar_helper->GetInfoBarDelegateAt(0));
637 } 637 }
638 638
639 void SimulateMouseClick(content::WebContents* tab) { 639 void SimulateMouseClick(content::WebContents* tab, const gfx::Point& point) {
640 int x = tab->GetView()->GetContainerSize().width() / 2; 640 const int x = point.x();
641 int y = tab->GetView()->GetContainerSize().height() / 2; 641 const int y = point.y();
642 WebKit::WebMouseEvent mouse_event; 642 WebKit::WebMouseEvent mouse_event;
643 mouse_event.type = WebKit::WebInputEvent::MouseDown; 643 mouse_event.type = WebKit::WebInputEvent::MouseDown;
644 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 644 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
645 mouse_event.x = x; 645 mouse_event.x = x;
646 mouse_event.y = y; 646 mouse_event.y = y;
647 // Mac needs globalX/globalY for events to plugins. 647 // Mac needs globalX/globalY for events to plugins.
648 gfx::Rect offset; 648 gfx::Rect offset;
649 tab->GetView()->GetContainerBounds(&offset); 649 tab->GetView()->GetContainerBounds(&offset);
650 mouse_event.globalX = x + offset.x(); 650 mouse_event.globalX = x + offset.x();
651 mouse_event.globalY = y + offset.y(); 651 mouse_event.globalY = y + offset.y();
652 mouse_event.clickCount = 1; 652 mouse_event.clickCount = 1;
653 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 653 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
654 mouse_event.type = WebKit::WebInputEvent::MouseUp; 654 mouse_event.type = WebKit::WebInputEvent::MouseUp;
655 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 655 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
656 } 656 }
657 657
658 void SimulateMouseClick(content::WebContents* tab) {
659 int x = tab->GetView()->GetContainerSize().width() / 2;
660 int y = tab->GetView()->GetContainerSize().height() / 2;
661 SimulateMouseClick(tab, gfx::Point(x, y));
662 }
663
658 void SimulateMouseEvent(content::WebContents* tab, 664 void SimulateMouseEvent(content::WebContents* tab,
659 WebKit::WebInputEvent::Type type, 665 WebKit::WebInputEvent::Type type,
660 const gfx::Point& point) { 666 const gfx::Point& point) {
661 WebKit::WebMouseEvent mouse_event; 667 WebKit::WebMouseEvent mouse_event;
662 mouse_event.type = type; 668 mouse_event.type = type;
663 mouse_event.x = point.x(); 669 mouse_event.x = point.x();
664 mouse_event.y = point.y(); 670 mouse_event.y = point.y();
665 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 671 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
666 } 672 }
667 673
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 int state, 1295 int state,
1290 const base::Closure& followup) { 1296 const base::Closure& followup) {
1291 if (!followup.is_null()) 1297 if (!followup.is_null())
1292 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); 1298 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup);
1293 else 1299 else
1294 ui_controls::SendMouseEvents(button, state); 1300 ui_controls::SendMouseEvents(button, state);
1295 } 1301 }
1296 1302
1297 } // namespace internal 1303 } // namespace internal
1298 } // namespace ui_test_utils 1304 } // namespace ui_test_utils
OLDNEW
« no previous file with comments | « chrome/test/base/ui_test_utils.h ('k') | chrome/test/data/speech/basic_recognition.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698