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

Side by Side Diff: chrome/browser/automation/automation_provider.cc

Issue 174113: Linux: more interactive tests porting.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: compile fixes Created 11 years, 4 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 | « no previous file | chrome/browser/automation/ui_controls.h » ('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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/browser/automation/automation_provider.h" 5 #include "chrome/browser/automation/automation_provider.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/message_box_flags.h" 8 #include "app/message_box_flags.h"
9 #include "base/file_version_info.h" 9 #include "base/file_version_info.h"
10 #include "base/json_reader.h" 10 #include "base/json_reader.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 #if defined(OS_WIN) || defined(OS_LINUX) 64 #if defined(OS_WIN) || defined(OS_LINUX)
65 // TODO(port): Port these to the mac. 65 // TODO(port): Port these to the mac.
66 #include "chrome/browser/automation/ui_controls.h" 66 #include "chrome/browser/automation/ui_controls.h"
67 #endif 67 #endif
68 68
69 #if defined(OS_WIN) 69 #if defined(OS_WIN)
70 #include "chrome/browser/views/bookmark_bar_view.h" 70 #include "chrome/browser/views/bookmark_bar_view.h"
71 #include "views/widget/root_view.h" 71 #include "views/widget/root_view.h"
72 #include "views/widget/widget_win.h" 72 #include "views/widget/widget_win.h"
73 #include "views/window/window.h" 73 #include "views/window/window.h"
74 #elif defined(OS_LINUX)
75 #include "chrome/browser/gtk/view_id_util.h"
74 #endif 76 #endif
75 77
76 using base::Time; 78 using base::Time;
77 79
78 #if defined(OS_WIN) 80 #if defined(OS_WIN)
79 static void MoveMouse(const POINT& point) { 81 static void MoveMouse(const POINT& point) {
80 SetCursorPos(point.x, point.y); 82 SetCursorPos(point.x, point.y);
81 83
82 // Now, make sure that GetMessagePos returns the values we just set by 84 // Now, make sure that GetMessagePos returns the values we just set by
83 // simulating a mouse move. The value returned by GetMessagePos is updated 85 // simulating a mouse move. The value returned by GetMessagePos is updated
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
780 } 782 }
781 783
782 virtual std::string GetHTMLContents() { return contents_; } 784 virtual std::string GetHTMLContents() { return contents_; }
783 785
784 private: 786 private:
785 std::string contents_; 787 std::string contents_;
786 788
787 DISALLOW_COPY_AND_ASSIGN(AutomationInterstitialPage); 789 DISALLOW_COPY_AND_ASSIGN(AutomationInterstitialPage);
788 }; 790 };
789 791
792 #if !defined(OS_MACOSX)
793 class ClickTask : public Task {
794 public:
795 ClickTask(gfx::Point point, int flags) : point_(point), flags_(flags) {}
796 virtual ~ClickTask() {}
797
798 virtual void Run() {
799 ui_controls::MouseButton button = ui_controls::LEFT;
800 if ((flags_ & views::Event::EF_LEFT_BUTTON_DOWN) ==
801 views::Event::EF_LEFT_BUTTON_DOWN) {
802 button = ui_controls::LEFT;
803 } else if ((flags_ & views::Event::EF_RIGHT_BUTTON_DOWN) ==
804 views::Event::EF_RIGHT_BUTTON_DOWN) {
805 button = ui_controls::RIGHT;
806 } else if ((flags_ & views::Event::EF_MIDDLE_BUTTON_DOWN) ==
807 views::Event::EF_MIDDLE_BUTTON_DOWN) {
808 button = ui_controls::MIDDLE;
809 } else {
810 NOTREACHED();
811 }
812
813 ui_controls::SendMouseClick(point_, button);
814 }
815
816 private:
817 gfx::Point point_;
818 int flags_;
819
820 DISALLOW_COPY_AND_ASSIGN(ClickTask);
821 };
822 #endif
823
790 AutomationProvider::AutomationProvider(Profile* profile) 824 AutomationProvider::AutomationProvider(Profile* profile)
791 : redirect_query_(0), 825 : redirect_query_(0),
792 profile_(profile), 826 profile_(profile),
793 reply_message_(NULL) { 827 reply_message_(NULL) {
794 browser_tracker_.reset(new AutomationBrowserTracker(this)); 828 browser_tracker_.reset(new AutomationBrowserTracker(this));
795 tab_tracker_.reset(new AutomationTabTracker(this)); 829 tab_tracker_.reset(new AutomationTabTracker(this));
796 window_tracker_.reset(new AutomationWindowTracker(this)); 830 window_tracker_.reset(new AutomationWindowTracker(this));
797 autocomplete_edit_tracker_.reset( 831 autocomplete_edit_tracker_.reset(
798 new AutomationAutocompleteEditTracker(this)); 832 new AutomationAutocompleteEditTracker(this));
799 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this)); 833 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this));
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 *success = true; 1508 *success = true;
1475 gfx::Point point; 1509 gfx::Point point;
1476 if (screen_coordinates) 1510 if (screen_coordinates)
1477 views::View::ConvertPointToScreen(view, &point); 1511 views::View::ConvertPointToScreen(view, &point);
1478 else 1512 else
1479 views::View::ConvertPointToView(view, root_view, &point); 1513 views::View::ConvertPointToView(view, root_view, &point);
1480 *bounds = view->GetLocalBounds(false); 1514 *bounds = view->GetLocalBounds(false);
1481 bounds->set_origin(point); 1515 bounds->set_origin(point);
1482 } 1516 }
1483 } 1517 }
1518 #elif defined(OS_LINUX)
1519 gfx::NativeWindow window = window_tracker_->GetResource(handle);
1520 GtkWidget* widget = ViewIDUtil::GetWidget(GTK_WIDGET(window),
1521 static_cast<ViewID>(view_id));
1522 if (!widget)
1523 return;
1524 *success = true;
1525 *bounds = gfx::Rect(0, 0,
1526 widget->allocation.width, widget->allocation.height);
1527 gint x, y;
1528 if (screen_coordinates) {
1529 gdk_window_get_origin(widget->window, &x, &y);
1530 if (GTK_WIDGET_NO_WINDOW(widget)) {
1531 x += widget->allocation.x;
1532 y += widget->allocation.y;
1533 }
1534 } else {
1535 gtk_widget_translate_coordinates(widget, GTK_WIDGET(window),
1536 0, 0, &x, &y);
1537 }
1538 bounds->set_origin(gfx::Point(x, y));
1484 #else 1539 #else
1485 NOTIMPLEMENTED(); 1540 NOTIMPLEMENTED();
1486 #endif 1541 #endif
1487 } 1542 }
1488 } 1543 }
1489 1544
1490 #if defined(OS_WIN) 1545 #if defined(OS_WIN)
1491 // This task enqueues a mouse event on the event loop, so that the view 1546 // This task enqueues a mouse event on the event loop, so that the view
1492 // that it's being sent to can do the requisite post-processing. 1547 // that it's being sent to can do the requisite post-processing.
1493 class MouseEventTask : public Task { 1548 class MouseEventTask : public Task {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1593 }; 1648 };
1594 #endif // defined(OS_WIN) 1649 #endif // defined(OS_WIN)
1595 1650
1596 #if defined(OS_WIN) || defined(OS_LINUX) 1651 #if defined(OS_WIN) || defined(OS_LINUX)
1597 void AutomationProvider::WindowSimulateClick(const IPC::Message& message, 1652 void AutomationProvider::WindowSimulateClick(const IPC::Message& message,
1598 int handle, 1653 int handle,
1599 const gfx::Point& click, 1654 const gfx::Point& click,
1600 int flags) { 1655 int flags) {
1601 1656
1602 if (window_tracker_->ContainsHandle(handle)) { 1657 if (window_tracker_->ContainsHandle(handle)) {
1603 gfx::NativeWindow window = window_tracker_->GetResource(handle); 1658 ui_controls::SendMouseMoveNotifyWhenDone(click.x(), click.y(),
1604 ui_controls::SendMouseMove(click.x(), click.y()); 1659 new ClickTask(click, flags));
1605
1606 ui_controls::MouseButton button = ui_controls::LEFT;
1607 if ((flags & views::Event::EF_LEFT_BUTTON_DOWN) ==
1608 views::Event::EF_LEFT_BUTTON_DOWN) {
1609 button = ui_controls::LEFT;
1610 } else if ((flags & views::Event::EF_RIGHT_BUTTON_DOWN) ==
1611 views::Event::EF_RIGHT_BUTTON_DOWN) {
1612 button = ui_controls::RIGHT;
1613 } else if ((flags & views::Event::EF_MIDDLE_BUTTON_DOWN) ==
1614 views::Event::EF_MIDDLE_BUTTON_DOWN) {
1615 button = ui_controls::MIDDLE;
1616 } else {
1617 NOTREACHED();
1618 }
1619 ui_controls::SendMouseClick(window, click, button);
1620 } 1660 }
1621 } 1661 }
1622 #endif 1662 #endif
1623 1663
1624 #if defined(OS_WIN) 1664 #if defined(OS_WIN)
1625 void AutomationProvider::WindowSimulateDrag(int handle, 1665 void AutomationProvider::WindowSimulateDrag(int handle,
1626 std::vector<POINT> drag_path, 1666 std::vector<POINT> drag_path,
1627 int flags, 1667 int flags,
1628 bool press_escape_en_route, 1668 bool press_escape_en_route,
1629 IPC::Message* reply_message) { 1669 IPC::Message* reply_message) {
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after
3094 NOTREACHED(); 3134 NOTREACHED();
3095 return NULL; 3135 return NULL;
3096 } 3136 }
3097 3137
3098 RenderViewHost* view_host = tab_contents->render_view_host(); 3138 RenderViewHost* view_host = tab_contents->render_view_host();
3099 return view_host; 3139 return view_host;
3100 } 3140 }
3101 3141
3102 return NULL; 3142 return NULL;
3103 } 3143 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/automation/ui_controls.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698