diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc | 1 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider.cc | 18 | ||||
-rw-r--r-- | chrome/browser/automation/automation_provider_win.cc | 3 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls.h | 6 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_linux.cc | 10 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_mac.mm | 240 | ||||
-rw-r--r-- | chrome/browser/automation/ui_controls_win.cc | 5 | ||||
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 19 | ||||
-rw-r--r-- | chrome/browser/browser_keyevents_browsertest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_location_bar_host_browsertest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/chromeos/compact_navigation_bar_browsertest.cc | 6 | ||||
-rw-r--r-- | chrome/browser/views/bookmark_bar_view_test.cc | 20 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_host_interactive_uitest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/frame/browser_view.cc | 31 |
14 files changed, 323 insertions, 53 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc index 269b2e2..82b05eb 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_browsertest.cc @@ -125,6 +125,7 @@ class AutocompleteEditViewTest : public InProcessBrowserTest, gfx::NativeWindow window = NULL; ASSERT_NO_FATAL_FAILURE(GetNativeWindow(&window)); ui_controls::SendKeyPressNotifyWhenDone(window, key, control, shift, alt, + false /* command */, new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); } diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index f46038a..e8cab61 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -80,6 +80,7 @@ #include "net/proxy/proxy_service.h" #include "net/proxy/proxy_config_service_fixed.h" #include "net/url_request/url_request_context.h" +#include "chrome/browser/automation/ui_controls.h" #include "views/event.h" #if defined(OS_WIN) @@ -90,11 +91,6 @@ #include "chrome/browser/printing/print_job.h" #endif // defined(OS_WIN) -#if !defined(OS_MACOSX) -// TODO(port): Port these to the mac. -#include "chrome/browser/automation/ui_controls.h" -#endif // !defined(OS_MACOSX) - using base::Time; class AutomationInterstitialPage : public InterstitialPage { @@ -114,7 +110,6 @@ class AutomationInterstitialPage : public InterstitialPage { DISALLOW_COPY_AND_ASSIGN(AutomationInterstitialPage); }; -#if !defined(OS_MACOSX) class ClickTask : public Task { public: explicit ClickTask(int flags) : flags_(flags) {} @@ -143,7 +138,6 @@ class ClickTask : public Task { DISALLOW_COPY_AND_ASSIGN(ClickTask); }; -#endif AutomationProvider::AutomationProvider(Profile* profile) : redirect_query_(0), @@ -361,13 +355,13 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(AutomationMsg_GetWindowBounds, GetWindowBounds) IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) -#if !defined(OS_MACOSX) IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) IPC_MESSAGE_HANDLER(AutomationMsg_WindowMouseMove, WindowSimulateMouseMove) IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) +#if !defined(OS_MACOSX) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, WindowSimulateDrag) -#endif +#endif // !defined(OS_MACOSX) IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) IPC_MESSAGE_HANDLER(AutomationMsg_Type, GetType) IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) @@ -978,7 +972,6 @@ class InvokeTaskLaterTask : public Task { DISALLOW_COPY_AND_ASSIGN(InvokeTaskLaterTask); }; -#if !defined(OS_MACOSX) void AutomationProvider::WindowSimulateClick(const IPC::Message& message, int handle, const gfx::Point& click, @@ -1011,9 +1004,10 @@ void AutomationProvider::WindowSimulateKeyPress(const IPC::Message& message, ((flags & views::Event::EF_SHIFT_DOWN) == views::Event::EF_SHIFT_DOWN), ((flags & views::Event::EF_ALT_DOWN) == - views::Event::EF_ALT_DOWN)); + views::Event::EF_ALT_DOWN), + ((flags & views::Event::EF_COMMAND_DOWN) == + views::Event::EF_COMMAND_DOWN)); } -#endif // !defined(OS_MACOSX) void AutomationProvider::IsWindowActive(int handle, bool* success, bool* is_active) { diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 2be9574..47f252b 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -218,7 +218,8 @@ void AutomationProvider::WindowSimulateDrag(int handle, ((flags & views::Event::EF_SHIFT_DOWN) == views::Event::EF_SHIFT_DOWN), ((flags & views::Event::EF_ALT_DOWN) == - views::Event::EF_ALT_DOWN)); + views::Event::EF_ALT_DOWN), + false); } SendMessage(top_level_hwnd, up_message, wparam_flags, MAKELPARAM(end.x, end.y)); diff --git a/chrome/browser/automation/ui_controls.h b/chrome/browser/automation/ui_controls.h index f1d8a07..b0a2675 100644 --- a/chrome/browser/automation/ui_controls.h +++ b/chrome/browser/automation/ui_controls.h @@ -47,12 +47,14 @@ bool SendKeyPress(gfx::NativeWindow window, base::KeyboardCode key, bool control, bool shift, - bool alt); + bool alt, + bool command); bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, base::KeyboardCode key, bool control, bool shift, bool alt, + bool command, Task* task); // Simulate a mouse move. (x,y) are absolute screen coordinates. @@ -86,6 +88,8 @@ void MoveMouseToCenterAndPress( views::View* view, #elif defined(TOOLKIT_GTK) GtkWidget* widget, +#elif defined(OS_MACOSX) + NSWindow* window, #endif MouseButton button, int state, diff --git a/chrome/browser/automation/ui_controls_linux.cc b/chrome/browser/automation/ui_controls_linux.cc index 77be4c1..973c1f4 100644 --- a/chrome/browser/automation/ui_controls_linux.cc +++ b/chrome/browser/automation/ui_controls_linux.cc @@ -144,7 +144,9 @@ void FakeAMouseMotionEvent(gint x, gint y) { namespace ui_controls { bool SendKeyPress(gfx::NativeWindow window, - base::KeyboardCode key, bool control, bool shift, bool alt) { + base::KeyboardCode key, + bool control, bool shift, bool alt, bool command) { + DCHECK(command == false); // No command key on Linux GdkWindow* event_window = NULL; GtkWidget* grab_widget = gtk_grab_get_current(); if (grab_widget) { @@ -215,8 +217,10 @@ bool SendKeyPress(gfx::NativeWindow window, bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, base::KeyboardCode key, - bool control, bool shift, bool alt, + bool control, bool shift, + bool alt, bool command, Task* task) { + DCHECK(command == false); // No command key on Linux int release_count = 1; if (control) release_count++; @@ -226,7 +230,7 @@ bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, release_count++; // This object will delete itself after running |task|. new EventWaiter(task, GDK_KEY_RELEASE, release_count); - return SendKeyPress(window, key, control, shift, alt); + return SendKeyPress(window, key, control, shift, alt, command); } bool SendMouseMove(long x, long y) { diff --git a/chrome/browser/automation/ui_controls_mac.mm b/chrome/browser/automation/ui_controls_mac.mm new file mode 100644 index 0000000..e16a968 --- /dev/null +++ b/chrome/browser/automation/ui_controls_mac.mm @@ -0,0 +1,240 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import <Cocoa/Cocoa.h> +#include <mach/mach_time.h> + +#include "chrome/browser/automation/ui_controls.h" +#include "chrome/browser/chrome_thread.h" + +// Implementation details: We use [NSApplication sendEvent:] instead +// of [NSApplication postEvent:atStart:] so that the event gets sent +// immediately. This lets us run the post-event task right +// immediately as well. Unfortunately I cannot subclass NSEvent (it's +// probably a class cluster) to allow other easy answers. For +// example, if I could subclass NSEvent, I could run the Task in it's +// dealloc routine (which necessarily happens after the event is +// dispatched). Unlike Linux, Mac does not have message loop +// observer/notification. Unlike windows, I cannot post non-events +// into the event queue. (I can post other kinds of tasks but can't +// guarantee their order with regards to events). + +namespace { + +// From +// http://stackoverflow.com/questions/1597383/cgeventtimestamp-to-nsdate +// Which credits Apple sample code for this routine. +uint64_t UpTimeInNanoseconds(void) { + uint64_t time; + uint64_t timeNano; + static mach_timebase_info_data_t sTimebaseInfo; + + time = mach_absolute_time(); + + // Convert to nanoseconds. + + // If this is the first time we've run, get the timebase. + // We can use denom == 0 to indicate that sTimebaseInfo is + // uninitialised because it makes no sense to have a zero + // denominator is a fraction. + if (sTimebaseInfo.denom == 0) { + (void) mach_timebase_info(&sTimebaseInfo); + } + + // This could overflow; for testing needs we probably don't care. + timeNano = time * sTimebaseInfo.numer / sTimebaseInfo.denom; + return timeNano; +} + +NSTimeInterval TimeIntervalSinceSystemStartup() { + return UpTimeInNanoseconds() / 1000000000.0; +} + +} // anonymous namespace + + +namespace ui_controls { + +bool SendKeyPress(gfx::NativeWindow window, + base::KeyboardCode key, + bool control, + bool shift, + bool alt, + bool command) { + return SendKeyPressNotifyWhenDone(window, key, + control, shift, alt, command, + NULL); +} + +// Win and Linux implement a SendKeyPress() this as a +// SendKeyPressAndRelease(), so we should as well (despite the name). +// +// TODO(jrg): handle "characters" better (e.g. apply shift?) +bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, + base::KeyboardCode key, + bool control, + bool shift, + bool alt, + bool command, + Task* task) { + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); + NSUInteger flags = 0; + if (control) + flags |= NSControlKeyMask; + if (shift) + flags |= NSShiftKeyMask; + if (alt) + flags |= NSAlternateKeyMask; + if (command) + flags |= NSCommandKeyMask; + unsigned char keycode = key; + NSString* charactersIgnoringModifiers = [[[NSString alloc] + initWithBytes:&keycode + length:1 + encoding:NSUTF8StringEncoding] + autorelease]; + NSString* characters = charactersIgnoringModifiers; + + // For events other than mouse moved, [event locationInWindow] is + // UNDEFINED if the event is not NSMouseMoved. Thus, the (0,0) + // locaiton should be fine. + // First a key down... + NSEvent* event = + [NSEvent keyEventWithType:NSKeyDown + location:NSMakePoint(0,0) + modifierFlags:flags + timestamp:TimeIntervalSinceSystemStartup() + windowNumber:[window windowNumber] + context:nil + characters:characters + charactersIgnoringModifiers:charactersIgnoringModifiers + isARepeat:NO + keyCode:key]; + [[NSApplication sharedApplication] sendEvent:event]; + // Then a key up. + event = + [NSEvent keyEventWithType:NSKeyUp + location:NSMakePoint(0,0) + modifierFlags:flags + timestamp:TimeIntervalSinceSystemStartup() + windowNumber:[window windowNumber] + context:nil + characters:characters + charactersIgnoringModifiers:charactersIgnoringModifiers + isARepeat:NO + keyCode:key]; + [[NSApplication sharedApplication] sendEvent:event]; + + if (task) + MessageLoop::current()->PostTask(FROM_HERE, task); + return true; +} + +bool SendMouseMove(long x, long y) { + return SendMouseMoveNotifyWhenDone(x, y, NULL); +} + +// Input position is in screen coordinates. However, NSMouseMoved +// events require them window-relative, so we adjust. We *DO* flip +// the coordinate space, so input events can be the same for all +// platforms. E.g. (0,0) is upper-left. +bool SendMouseMoveNotifyWhenDone(long x, long y, Task* task) { + NSWindow* window = [[NSApplication sharedApplication] keyWindow]; + CGFloat screenHeight = [[NSScreen mainScreen] frame].size.height; + NSPoint pointInWindow = NSMakePoint(x, screenHeight - y); // flip! + if (window) + pointInWindow = [window convertScreenToBase:pointInWindow]; + NSTimeInterval timestamp = TimeIntervalSinceSystemStartup(); + + NSEvent* event = + [NSEvent mouseEventWithType:NSMouseMoved + location:pointInWindow + modifierFlags:0 + timestamp:timestamp + windowNumber:[window windowNumber] + context:nil + eventNumber:0 + clickCount:0 + pressure:0.0]; + [[NSApplication sharedApplication] postEvent:event atStart:NO]; + if (task) + MessageLoop::current()->PostTask(FROM_HERE, task); + return true; +} + +bool SendMouseEvents(MouseButton type, int state) { + return SendMouseEventsNotifyWhenDone(type, state, NULL); +} + +bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, Task* task) { + // On windows it appears state can be (UP|DOWN). It is unclear if + // that'll happen here but prepare for it just in case. + if (state == (UP|DOWN)) { + return (SendMouseEventsNotifyWhenDone(type, DOWN, NULL) && + SendMouseEventsNotifyWhenDone(type, UP, task)); + } + + NSEventType etype = 0; + if (type == LEFT) { + if (state == UP) { + etype = NSLeftMouseUp; + } else { + etype = NSLeftMouseDown; + } + } else if (type == MIDDLE) { + if (state == UP) { + etype = NSOtherMouseUp; + } else { + etype = NSOtherMouseDown; + } + } else if (type == RIGHT) { + if (state == UP) { + etype = NSRightMouseUp; + } else { + etype = NSRightMouseDown; + } + } else { + return false; + } + NSWindow* window = [[NSApplication sharedApplication] keyWindow]; + NSPoint location = [NSEvent mouseLocation]; + NSPoint pointInWindow = location; + if (window) + pointInWindow = [window convertScreenToBase:pointInWindow]; + + NSEvent* event = + [NSEvent mouseEventWithType:etype + location:pointInWindow + modifierFlags:0 + timestamp:TimeIntervalSinceSystemStartup() + windowNumber:[window windowNumber] + context:nil + eventNumber:0 + clickCount:0 + pressure:0.0]; + [[NSApplication sharedApplication] sendEvent:event]; + if (task) + MessageLoop::current()->PostTask(FROM_HERE, task); + return true; +} + +bool SendMouseClick(MouseButton type) { + return SendMouseEventsNotifyWhenDone(type, UP|DOWN, NULL); +} + +// This appears to only be used by a function in test/ui_test_utils.h: +// ui_test_utils::ClickOnView(). That is not implemented on Mac, so +// we don't need to implement MoveMouseToCenterAndPress(). I've +// suggested an implementation of ClickOnView() which would call Cocoa +// directly and not need this indirection, so this may not be needed, +// ever. +void MoveMouseToCenterAndPress( + NSWindow* window, + MouseButton button, + int state, + Task* task) { + NOTIMPLEMENTED(); +} + +} // ui_controls diff --git a/chrome/browser/automation/ui_controls_win.cc b/chrome/browser/automation/ui_controls_win.cc index 82a31d0..4e9f673 100644 --- a/chrome/browser/automation/ui_controls_win.cc +++ b/chrome/browser/automation/ui_controls_win.cc @@ -325,14 +325,17 @@ bool SendMouseEventsImpl(MouseButton type, int state, Task* task) { // public functions ----------------------------------------------------------- bool SendKeyPress(gfx::NativeWindow window, base::KeyboardCode key, - bool control, bool shift, bool alt) { + bool control, bool shift, bool alt, bool command) { + DCHECK(command == false); // No command key on Windows return SendKeyPressImpl(key, control, shift, alt, NULL); } bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, base::KeyboardCode key, bool control, bool shift, bool alt, + bool command, Task* task) { + DCHECK(command == false); // No command key on Windows return SendKeyPressImpl(key, control, shift, alt, task); } diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index b5c9df23..5d03a5f 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -304,7 +304,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { ASSERT_TRUE(IsViewFocused(vid)); ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true, - false, false, + false, false, false, new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); } @@ -317,7 +317,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, TabsRememberFocus) { ASSERT_TRUE(IsViewFocused(vid)); ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_TAB, true, - true, false, + true, false, false, new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); } @@ -472,7 +472,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) { ASSERT_STREQ(kExpElementIDs[j], actual.c_str()); ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, - false, false, false)); + false, false, false, false)); if (j < arraysize(kExpElementIDs) - 1) { ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()-> @@ -499,7 +499,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FocusTraversal) { for (size_t j = 0; j < 7; ++j) { SCOPED_TRACE(StringPrintf("inner loop: %" PRIuS, j)); ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, - false, true, false)); + false, true, false, false)); if (j < arraysize(kExpElementIDs) - 1) { ui_test_utils::WaitForFocusChange(browser()->GetSelectedTabContents()-> @@ -571,7 +571,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { ASSERT_STREQ(kExpElementIDs[j], actual.c_str()); ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, - false, false, false)); + false, false, false, false)); if (j < arraysize(kExpElementIDs) - 1) { interstitial_page->WaitForFocusChange(); @@ -595,7 +595,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, MAYBE_FocusTraversalOnInterstitial) { // Now let's press shift-tab to move the focus in reverse. for (size_t j = 0; j < 7; ++j) { ASSERT_TRUE(ui_controls::SendKeyPress(window, base::VKEY_TAB, - false, true, false)); + false, true, false, false)); if (j < arraysize(kExpElementIDs) - 1) { interstitial_page->WaitForFocusChange(); @@ -663,7 +663,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { // Press Ctrl+F, which will make the Find box open and request focus. ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, - false, false, + false, false, false, new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); @@ -683,7 +683,7 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { // Now press Ctrl+F again and focus should move to the Find box. ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, - false, false, + false, false, false, new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); ASSERT_TRUE(IsViewFocused(VIEW_ID_FIND_IN_PAGE_TEXT_FIELD)); @@ -694,7 +694,8 @@ IN_PROC_BROWSER_TEST_F(BrowserFocusTest, FindFocusTest) { // Now press Ctrl+F again and focus should move to the Find box. ui_controls::SendKeyPressNotifyWhenDone(window, base::VKEY_F, true, false, - false, new MessageLoop::QuitTask()); + false, false, + new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); // See remark above on why we wait. diff --git a/chrome/browser/browser_keyevents_browsertest.cc b/chrome/browser/browser_keyevents_browsertest.cc index 7f76103..227f77f 100644 --- a/chrome/browser/browser_keyevents_browsertest.cc +++ b/chrome/browser/browser_keyevents_browsertest.cc @@ -135,7 +135,9 @@ class BrowserKeyEventsTest : public InProcessBrowserTest { gfx::NativeWindow window = NULL; ASSERT_NO_FATAL_FAILURE(GetNativeWindow(&window)); EXPECT_TRUE(ui_controls::SendKeyPressNotifyWhenDone( - window, key, control, shift, alt, new MessageLoop::QuitTask())); + window, key, control, shift, alt, + false /* command, */, + new MessageLoop::QuitTask())); ui_test_utils::RunMessageLoop(); } diff --git a/chrome/browser/chromeos/compact_location_bar_host_browsertest.cc b/chrome/browser/chromeos/compact_location_bar_host_browsertest.cc index 780e59b..7c4c4af 100644 --- a/chrome/browser/chromeos/compact_location_bar_host_browsertest.cc +++ b/chrome/browser/chromeos/compact_location_bar_host_browsertest.cc @@ -52,7 +52,7 @@ class CompactLocationBarHostTest : public InProcessBrowserTest { IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestCtrlLOpen) { // ctrl-l should not open compact location bar in normal mode. - ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false); + ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_TRUE(IsCurrentTabIndex(-1)); EXPECT_FALSE(clb_host()->IsVisible()); @@ -63,13 +63,14 @@ IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestCtrlLOpen) { EXPECT_FALSE(clb_host()->IsVisible()); // ctrl-l should not open compact location bar in compact nav mode. - ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false); + ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_TRUE(IsCurrentTabIndex(0)); EXPECT_TRUE(clb_host()->IsVisible()); // Esc to close it. - ui_controls::SendKeyPress(window(), base::VKEY_ESCAPE, false, false, false); + ui_controls::SendKeyPress(window(), base::VKEY_ESCAPE, + false, false, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_TRUE(IsCurrentTabIndex(0)); EXPECT_FALSE(clb_host()->IsVisible()); @@ -77,7 +78,7 @@ IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestCtrlLOpen) { IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestOnNewTab) { browser()->ToggleCompactNavigationBar(); - ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false); + ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_TRUE(IsCurrentTabIndex(0)); EXPECT_TRUE(clb_host()->IsVisible()); @@ -88,7 +89,7 @@ IN_PROC_BROWSER_TEST_F(CompactLocationBarHostTest, TestOnNewTab) { // See http://crbug.com/39858 for details. //EXPECT_FALSE(clb_host()->IsVisible()); - ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false); + ui_controls::SendKeyPress(window(), base::VKEY_L, true, false, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_TRUE(IsCurrentTabIndex(1)); EXPECT_TRUE(clb_host()->IsVisible()); diff --git a/chrome/browser/chromeos/compact_navigation_bar_browsertest.cc b/chrome/browser/chromeos/compact_navigation_bar_browsertest.cc index c773972..5194b2fb9 100644 --- a/chrome/browser/chromeos/compact_navigation_bar_browsertest.cc +++ b/chrome/browser/chromeos/compact_navigation_bar_browsertest.cc @@ -50,16 +50,16 @@ IN_PROC_BROWSER_TEST_F(CompactNavigationBarTest, TestAccelerator) { gfx::NativeWindow window = browser()->window()->GetNativeHandle(); // ctrl-shift-c should toggle compact navigation bar. - ui_controls::SendKeyPress(window, base::VKEY_C, true, true, false); + ui_controls::SendKeyPress(window, base::VKEY_C, true, true, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_TRUE(IsViewIdVisible(VIEW_ID_COMPACT_NAV_BAR)); - ui_controls::SendKeyPress(window, base::VKEY_C, true, true, false); + ui_controls::SendKeyPress(window, base::VKEY_C, true, true, false, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_FALSE(IsViewIdVisible(VIEW_ID_COMPACT_NAV_BAR)); // but ctrl-alt-c should not. - ui_controls::SendKeyPress(window, base::VKEY_C, true, false, true); + ui_controls::SendKeyPress(window, base::VKEY_C, true, false, true, false); ui_test_utils::RunAllPendingInMessageLoop(); EXPECT_FALSE(IsViewIdVisible(VIEW_ID_COMPACT_NAV_BAR)); } diff --git a/chrome/browser/views/bookmark_bar_view_test.cc b/chrome/browser/views/bookmark_bar_view_test.cc index 2f895dc..46f87e0 100644 --- a/chrome/browser/views/bookmark_bar_view_test.cc +++ b/chrome/browser/views/bookmark_bar_view_test.cc @@ -860,7 +860,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Send a down event, which should select the first item. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_DOWN, false, false, false, + NULL, base::VKEY_DOWN, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest10::Step3)); } @@ -873,7 +873,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Send a key down event, which should select the next item. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_DOWN, false, false, false, + NULL, base::VKEY_DOWN, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest10::Step4)); } @@ -886,7 +886,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Send a right arrow to force the menu to open. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_RIGHT, false, false, false, + NULL, base::VKEY_RIGHT, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest10::Step5)); } @@ -902,7 +902,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Send a left arrow to close the submenu. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_LEFT, false, false, false, + NULL, base::VKEY_LEFT, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest10::Step6)); } @@ -917,7 +917,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Send a down arrow to wrap back to f1a ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_DOWN, false, false, false, + NULL, base::VKEY_DOWN, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest10::Step7)); } @@ -930,7 +930,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Send enter, which should select the item. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_RETURN, false, false, false, + NULL, base::VKEY_RETURN, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest10::Step8)); } @@ -985,7 +985,7 @@ class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { void Step3() { // Send escape so that the context menu hides. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_ESCAPE, false, false, false, + NULL, base::VKEY_ESCAPE, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest11::Step4)); } @@ -1074,7 +1074,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { void Step4() { // Press tab to give focus to the cancel button. - ui_controls::SendKeyPress(NULL, base::VKEY_TAB, false, false, false); + ui_controls::SendKeyPress(NULL, base::VKEY_TAB, false, false, false, false); // For some reason return isn't processed correctly unless we delay. MessageLoop::current()->PostDelayedTask(FROM_HERE, @@ -1084,7 +1084,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { void Step5() { // And press enter so that the cancel button is selected. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_RETURN, false, false, false, + NULL, base::VKEY_RETURN, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest12::Step6)); } @@ -1213,7 +1213,7 @@ class BookmarkBarViewTest14 : public BookmarkBarViewEventTestBase { // Send escape so that the context menu hides. ui_controls::SendKeyPressNotifyWhenDone( - NULL, base::VKEY_ESCAPE, false, false, false, + NULL, base::VKEY_ESCAPE, false, false, false, false, CreateEventTask(this, &BookmarkBarViewTest14::Step3)); } diff --git a/chrome/browser/views/find_bar_host_interactive_uitest.cc b/chrome/browser/views/find_bar_host_interactive_uitest.cc index f4e9b27..f38ba01 100644 --- a/chrome/browser/views/find_bar_host_interactive_uitest.cc +++ b/chrome/browser/views/find_bar_host_interactive_uitest.cc @@ -114,7 +114,7 @@ IN_PROC_BROWSER_TEST_F(FindInPageTest, CrashEscHandlers) { // This used to crash until bug 1303709 was fixed. ui_controls::SendKeyPressNotifyWhenDone( browser()->window()->GetNativeHandle(), base::VKEY_ESCAPE, - false, false, false, new MessageLoop::QuitTask()); + false, false, false, false, new MessageLoop::QuitTask()); ui_test_utils::RunMessageLoop(); } diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index e8ee1d9..09000b0 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -1191,20 +1191,39 @@ void BrowserView::ToggleCompactNavigationBar() { // to windows. The real fix to this bug is to disable the commands when they // won't do anything. We'll need something like an overall clipboard command // manager to do that. +#if !defined(OS_MACOSX) void BrowserView::Cut() { - ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_X, true, - false, false); + ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_X, + true, false, false, false); } void BrowserView::Copy() { - ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, true, - false, false); + ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, + true, false, false, false); } void BrowserView::Paste() { - ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, true, - false, false); + ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, + true, false, false, false); } +#else +// Mac versions. Not tested by antyhing yet; +// don't assume written == works. +void BrowserView::Cut() { + ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_X, + false, false, false, true); +} + +void BrowserView::Copy() { + ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_C, + false, false, false, true); +} + +void BrowserView::Paste() { + ui_controls::SendKeyPress(GetNativeHandle(), base::VKEY_V, + false, false, false, true); +} +#endif /////////////////////////////////////////////////////////////////////////////// // BrowserView, BrowserWindowTesting implementation: |