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

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

Issue 12066003: Remove TabStripModel wrapper use. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 7 years, 10 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/tab_contents/render_view_context_menu_test_util.h" 13 #include "chrome/browser/tab_contents/render_view_context_menu_test_util.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/test/base/in_process_browser_test.h" 17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/public/browser/navigation_controller.h" 19 #include "content/public/browser/navigation_controller.h"
20 #include "content/public/browser/navigation_entry.h" 20 #include "content/public/browser/navigation_entry.h"
21 #include "content/public/browser/notification_service.h" 21 #include "content/public/browser/notification_service.h"
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_contents_view.h" 24 #include "content/public/browser/web_contents_view.h"
25 #include "content/public/test/browser_test_utils.h" 25 #include "content/public/test/browser_test_utils.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
28 28
29 using content::WebContents; 29 using content::WebContents;
30 30
31 namespace { 31 namespace {
32 32
33 class ContextMenuBrowserTest : public InProcessBrowserTest { 33 class ContextMenuBrowserTest : public InProcessBrowserTest {
34 public: 34 public:
35 ContextMenuBrowserTest() { } 35 ContextMenuBrowserTest() { }
36 36
37 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) { 37 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) {
38 content::ContextMenuParams params; 38 content::ContextMenuParams params;
39 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; 39 params.media_type = WebKit::WebContextMenuData::MediaTypeNone;
40 params.unfiltered_link_url = unfiltered_url; 40 params.unfiltered_link_url = unfiltered_url;
41 params.link_url = url; 41 params.link_url = url;
42 WebContents* web_contents = chrome::GetActiveWebContents(browser()); 42 WebContents* web_contents =
43 browser()->tab_strip_model()->GetActiveWebContents();
43 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); 44 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL();
44 #if defined(OS_MACOSX) 45 #if defined(OS_MACOSX)
45 params.writing_direction_default = 0; 46 params.writing_direction_default = 0;
46 params.writing_direction_left_to_right = 0; 47 params.writing_direction_left_to_right = 0;
47 params.writing_direction_right_to_left = 0; 48 params.writing_direction_right_to_left = 0;
48 #endif // OS_MACOSX 49 #endif // OS_MACOSX
49 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu( 50 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu(
50 chrome::GetActiveWebContents(browser()), params); 51 browser()->tab_strip_model()->GetActiveWebContents(), params);
51 menu->Init(); 52 menu->Init();
52 return menu; 53 return menu;
53 } 54 }
54 }; 55 };
55 56
56 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest, 57 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
57 OpenEntryPresentForNormalURLs) { 58 OpenEntryPresentForNormalURLs) {
58 scoped_ptr<TestRenderViewContextMenu> menu( 59 scoped_ptr<TestRenderViewContextMenu> menu(
59 CreateContextMenu(GURL("http://www.google.com/"), 60 CreateContextMenu(GURL("http://www.google.com/"),
60 GURL("http://www.google.com/"))); 61 GURL("http://www.google.com/")));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ui_test_utils::NavigateToURL( 94 ui_test_utils::NavigateToURL(
94 browser(), GURL("data:text/html,<a href='about:blank'>link</a>")); 95 browser(), GURL("data:text/html,<a href='about:blank'>link</a>"));
95 96
96 // Open a context menu. 97 // Open a context menu.
97 WebKit::WebMouseEvent mouse_event; 98 WebKit::WebMouseEvent mouse_event;
98 mouse_event.type = WebKit::WebInputEvent::MouseDown; 99 mouse_event.type = WebKit::WebInputEvent::MouseDown;
99 mouse_event.button = WebKit::WebMouseEvent::ButtonRight; 100 mouse_event.button = WebKit::WebMouseEvent::ButtonRight;
100 mouse_event.x = 15; 101 mouse_event.x = 15;
101 mouse_event.y = 15; 102 mouse_event.y = 15;
102 gfx::Rect offset; 103 gfx::Rect offset;
103 content::WebContents* tab = chrome::GetActiveWebContents(browser()); 104 content::WebContents* tab =
105 browser()->tab_strip_model()->GetActiveWebContents();
104 tab->GetView()->GetContainerBounds(&offset); 106 tab->GetView()->GetContainerBounds(&offset);
105 mouse_event.globalX = 15 + offset.x(); 107 mouse_event.globalX = 15 + offset.x();
106 mouse_event.globalY = 15 + offset.y(); 108 mouse_event.globalY = 15 + offset.y();
107 mouse_event.clickCount = 1; 109 mouse_event.clickCount = 1;
108 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 110 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
109 mouse_event.type = WebKit::WebInputEvent::MouseUp; 111 mouse_event.type = WebKit::WebInputEvent::MouseUp;
110 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 112 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
111 113
112 // The menu_observer will select "Open in new tab", wait for the new tab to 114 // The menu_observer will select "Open in new tab", wait for the new tab to
113 // be added. 115 // be added.
114 tab_observer.Wait(); 116 tab_observer.Wait();
115 tab = tab_observer.GetTab(); 117 tab = tab_observer.GetTab();
116 content::WaitForLoadStop(tab); 118 content::WaitForLoadStop(tab);
117 119
118 // Verify that it's the correct tab. 120 // Verify that it's the correct tab.
119 EXPECT_EQ(GURL("about:blank"), tab->GetURL()); 121 EXPECT_EQ(GURL("about:blank"), tab->GetURL());
120 } 122 }
121 123
122 } // namespace 124 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | chrome/browser/task_manager/task_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698