| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 16 #include "content/public/browser/navigation_entry.h" | 16 #include "content/public/browser/navigation_entry.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
| 19 | 19 |
| 20 using content::WebContents; | 20 using content::WebContents; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 | 23 |
| 24 class TestRenderViewContextMenu : public RenderViewContextMenu { | 24 class TestRenderViewContextMenu : public RenderViewContextMenu { |
| 25 public: | 25 public: |
| 26 TestRenderViewContextMenu(WebContents* web_contents, ContextMenuParams params) | 26 TestRenderViewContextMenu(WebContents* web_contents, |
| 27 content::ContextMenuParams params) |
| 27 : RenderViewContextMenu(web_contents, params) { } | 28 : RenderViewContextMenu(web_contents, params) { } |
| 28 | 29 |
| 29 virtual void PlatformInit() { } | 30 virtual void PlatformInit() { } |
| 30 virtual bool GetAcceleratorForCommandId( | 31 virtual bool GetAcceleratorForCommandId( |
| 31 int command_id, | 32 int command_id, |
| 32 ui::Accelerator* accelerator) { | 33 ui::Accelerator* accelerator) { |
| 33 return false; | 34 return false; |
| 34 } | 35 } |
| 35 | 36 |
| 36 bool IsItemPresent(int command_id) { | 37 bool IsItemPresent(int command_id) { |
| 37 return menu_model_.GetIndexOfCommandId(command_id) != -1; | 38 return menu_model_.GetIndexOfCommandId(command_id) != -1; |
| 38 } | 39 } |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 class ContextMenuBrowserTest : public InProcessBrowserTest { | 42 class ContextMenuBrowserTest : public InProcessBrowserTest { |
| 42 public: | 43 public: |
| 43 ContextMenuBrowserTest() { } | 44 ContextMenuBrowserTest() { } |
| 44 | 45 |
| 45 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) { | 46 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) { |
| 46 ContextMenuParams params; | 47 content::ContextMenuParams params; |
| 47 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; | 48 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; |
| 48 params.unfiltered_link_url = unfiltered_url; | 49 params.unfiltered_link_url = unfiltered_url; |
| 49 params.link_url = url; | 50 params.link_url = url; |
| 50 WebContents* web_contents = browser()->GetSelectedWebContents(); | 51 WebContents* web_contents = browser()->GetSelectedWebContents(); |
| 51 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); | 52 params.page_url = web_contents->GetController().GetActiveEntry()->GetURL(); |
| 52 #if defined(OS_MACOSX) | 53 #if defined(OS_MACOSX) |
| 53 params.writing_direction_default = 0; | 54 params.writing_direction_default = 0; |
| 54 params.writing_direction_left_to_right = 0; | 55 params.writing_direction_left_to_right = 0; |
| 55 params.writing_direction_right_to_left = 0; | 56 params.writing_direction_right_to_left = 0; |
| 56 #endif // OS_MACOSX | 57 #endif // OS_MACOSX |
| (...skipping 20 matching lines...) Expand all Loading... |
| 77 scoped_ptr<TestRenderViewContextMenu> menu( | 78 scoped_ptr<TestRenderViewContextMenu> menu( |
| 78 CreateContextMenu(GURL("chrome://history"), | 79 CreateContextMenu(GURL("chrome://history"), |
| 79 GURL())); | 80 GURL())); |
| 80 | 81 |
| 81 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB)); | 82 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWTAB)); |
| 82 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW)); | 83 ASSERT_FALSE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_OPENLINKNEWWINDOW)); |
| 83 ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); | 84 ASSERT_TRUE(menu->IsItemPresent(IDC_CONTENT_CONTEXT_COPYLINKLOCATION)); |
| 84 } | 85 } |
| 85 | 86 |
| 86 } // namespace | 87 } // namespace |
| OLD | NEW |