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

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

Issue 8588039: Remove "open in new tab" items from context menu if the process doesn't (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <string>
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/string16.h"
9 #include "base/utf_string_conversions.h"
10 #include "chrome/app/chrome_command_ids.h"
11 #include "chrome/browser/tab_contents/render_view_context_menu.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/browser/tab_contents/tab_contents.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h"
17
18 namespace {
19
20 class TestRenderViewContextMenu : public RenderViewContextMenu {
21 public:
22 TestRenderViewContextMenu(TabContents* tab_contents, ContextMenuParams params)
23 : RenderViewContextMenu(tab_contents, params) { }
24
25 virtual void PlatformInit() { }
26 virtual bool GetAcceleratorForCommandId(
27 int command_id,
28 ui::Accelerator* accelerator) {
29 return false;
30 }
31
32 bool IsItemPresent(int command_id) {
33 return menu_model_.GetIndexOfCommandId(command_id) != -1;
34 }
35 };
36
37 class ContextMenuBrowserTest : public InProcessBrowserTest {
38 public:
39 ContextMenuBrowserTest() { }
40
41 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) {
42 ContextMenuParams params;
43 params.media_type = WebKit::WebContextMenuData::MediaTypeNone;
44 params.unfiltered_link_url = unfiltered_url;
45 params.link_url = url;
46 TabContents* tab_contents = browser()->GetSelectedTabContents();
47 params.page_url = tab_contents->controller().GetActiveEntry()->url();
48 #if defined(OS_MACOSX)
49 params.writing_direction_default = 0;
50 params.writing_direction_left_to_right = 0;
51 params.writing_direction_right_to_left = 0;
52 #endif // OS_MACOSX
53 TestRenderViewContextMenu* menu = new TestRenderViewContextMenu(
54 browser()->GetSelectedTabContents(), params);
55 menu->Init();
56 return menu;
57 }
58 };
59
60 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
61 OpenEntryPresentForNormalURLs) {
62 scoped_ptr<TestRenderViewContextMenu> menu(
63 CreateContextMenu(GURL("http://www.google.com/"),
64 GURL("http://www.google.com/")));
65
66 ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB));
67 ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW));
68 ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_COPYLINKLOCATION));
69 }
70
71 IN_PROC_BROWSER_TEST_F(ContextMenuBrowserTest,
72 OpenEntryAbsentForFilteredURLs) {
73 scoped_ptr<TestRenderViewContextMenu> menu(
74 CreateContextMenu(GURL("chrome://history"),
75 GURL()));
76
77 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB));
78 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW));
79 ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_COPYLINKLOCATION));
80 }
81
82 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/render_view_context_menu.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698