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

Side by Side Diff: chrome/browser/tab_contents/render_view_context_menu_browsertest.cc

Issue 10702029: Move tab functions off Browser into browser_tabstrip and browser_tabrestore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
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 <string> 5 #include <string>
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/string16.h" 8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h" 11 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util. h" 12 #include "chrome/browser/tab_contents/render_view_context_menu_browsertest_util. h"
13 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/test/base/in_process_browser_test.h" 16 #include "chrome/test/base/in_process_browser_test.h"
16 #include "chrome/test/base/ui_test_utils.h" 17 #include "chrome/test/base/ui_test_utils.h"
17 #include "content/public/browser/navigation_controller.h" 18 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/render_view_host.h" 21 #include "content/public/browser/render_view_host.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_view.h" 23 #include "content/public/browser/web_contents_view.h"
23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
(...skipping 24 matching lines...) Expand all
48 49
49 class ContextMenuBrowserTest : public InProcessBrowserTest { 50 class ContextMenuBrowserTest : public InProcessBrowserTest {
50 public: 51 public:
51 ContextMenuBrowserTest() { } 52 ContextMenuBrowserTest() { }
52 53
53 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) { 54 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) {
54 content::ContextMenuParams params; 55 content::ContextMenuParams params;
55 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; 56 params.media_type = WebKit::WebContextMenuData::MediaTypeNone;
56 params.unfiltered_link_url = unfiltered_url; 57 params.unfiltered_link_url = unfiltered_url;
57 params.link_url = url; 58 params.link_url = url;
58 WebContents* web_contents = browser()->GetActiveWebContents(); 59 WebContents* web_contents = chrome::GetActiveWebContents(browser());
59 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); 60 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL();
60 #if defined(OS_MACOSX) 61 #if defined(OS_MACOSX)
61 params.writing_direction_default = 0; 62 params.writing_direction_default = 0;
62 params.writing_direction_left_to_right = 0; 63 params.writing_direction_left_to_right = 0;
63 params.writing_direction_right_to_left = 0; 64 params.writing_direction_right_to_left = 0;
64 #endif // OS_MACOSX 65 #endif // OS_MACOSX
65 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu( 66 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu(
66 browser()->GetActiveWebContents(), params); 67 chrome::GetActiveWebContents(browser()), params);
67 menu->Init(); 68 menu->Init();
68 return menu; 69 return menu;
69 } 70 }
70 }; 71 };
71 72
72 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, 73 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
73 OpenEntryPresentForNormalURLs) { 74 OpenEntryPresentForNormalURLs) {
74 scoped_ptr<TestRenderViewContextMenu> menu( 75 scoped_ptr<TestRenderViewContextMenu> menu(
75 CreateContextMenu(GURL("http://www.google.com/"), 76 CreateContextMenu(GURL("http://www.google.com/"),
76 GURL("http://www.google.com/"))); 77 GURL("http://www.google.com/")));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ui_test_utils::NavigateToURL( 110 ui_test_utils::NavigateToURL(
110 browser(), GURL("data:text/html,<a href='about:blank'>link</a>")); 111 browser(), GURL("data:text/html,<a href='about:blank'>link</a>"));
111 112
112 // Open a context menu. 113 // Open a context menu.
113 WebKit::WebMouseEvent mouse_event; 114 WebKit::WebMouseEvent mouse_event;
114 mouse_event.type = WebKit::WebInputEvent::MouseDown; 115 mouse_event.type = WebKit::WebInputEvent::MouseDown;
115 mouse_event.button = WebKit::WebMouseEvent::ButtonRight; 116 mouse_event.button = WebKit::WebMouseEvent::ButtonRight;
116 mouse_event.x = 15; 117 mouse_event.x = 15;
117 mouse_event.y = 15; 118 mouse_event.y = 15;
118 gfx::Rect offset; 119 gfx::Rect offset;
119 content::WebContents* tab = browser()->GetActiveWebContents(); 120 content::WebContents* tab = chrome::GetActiveWebContents(browser());
120 tab->GetView()->GetContainerBounds(&offset); 121 tab->GetView()->GetContainerBounds(&offset);
121 mouse_event.globalX = 15 + offset.x(); 122 mouse_event.globalX = 15 + offset.x();
122 mouse_event.globalY = 15 + offset.y(); 123 mouse_event.globalY = 15 + offset.y();
123 mouse_event.clickCount = 1; 124 mouse_event.clickCount = 1;
124 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 125 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
125 mouse_event.type = WebKit::WebInputEvent::MouseUp; 126 mouse_event.type = WebKit::WebInputEvent::MouseUp;
126 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 127 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
127 128
128 // The menu_observer will select "Open in new tab", wait for the new tab to 129 // The menu_observer will select "Open in new tab", wait for the new tab to
129 // be added. 130 // be added.
130 tab_observer.Wait(); 131 tab_observer.Wait();
131 tab = tab_observer.GetTab(); 132 tab = tab_observer.GetTab();
132 ui_test_utils::WaitForLoadStop(tab); 133 ui_test_utils::WaitForLoadStop(tab);
133 134
134 // Verify that it's the correct tab. 135 // Verify that it's the correct tab.
135 EXPECT_EQ(GURL("about:blank"), tab->GetURL()); 136 EXPECT_EQ(GURL("about:blank"), tab->GetURL());
136 } 137 }
137 138
138 } // namespace 139 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | chrome/browser/tab_contents/view_source_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698