| OLD | NEW |
| 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/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_tabstrip.h" | 15 #include "chrome/browser/ui/browser_tabstrip.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
| 20 #include "content/public/browser/notification_service.h" | 21 #include "content/public/browser/notification_service.h" |
| 21 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 22 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
| 23 #include "content/public/browser/web_contents_view.h" | 24 #include "content/public/browser/web_contents_view.h" |
| 24 #include "content/public/test/browser_test_utils.h" | 25 #include "content/public/test/browser_test_utils.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
| 27 | 28 |
| 28 using content::WebContents; | 29 using content::WebContents; |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 class TestRenderViewContextMenu : public RenderViewContextMenu { | |
| 33 public: | |
| 34 TestRenderViewContextMenu(WebContents* web_contents, | |
| 35 content::ContextMenuParams params) | |
| 36 : RenderViewContextMenu(web_contents, params) { } | |
| 37 | |
| 38 virtual void PlatformInit() { } | |
| 39 virtual void PlatformCancel() { } | |
| 40 virtual bool GetAcceleratorForCommandId( | |
| 41 int command_id, | |
| 42 ui::Accelerator* accelerator) { | |
| 43 return false; | |
| 44 } | |
| 45 | |
| 46 bool IsItemPresent(int command_id) { | |
| 47 return menu_model_.GetIndexOfCommandId(command_id) != -1; | |
| 48 } | |
| 49 }; | |
| 50 | |
| 51 class ContextMenuBrowserTest : public InProcessBrowserTest { | 33 class ContextMenuBrowserTest : public InProcessBrowserTest { |
| 52 public: | 34 public: |
| 53 ContextMenuBrowserTest() { } | 35 ContextMenuBrowserTest() { } |
| 54 | 36 |
| 55 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) { | 37 TestRenderViewContextMenu* CreateContextMenu(GURL unfiltered_url, GURL url) { |
| 56 content::ContextMenuParams params; | 38 content::ContextMenuParams params; |
| 57 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; | 39 params.media_type = WebKit::WebContextMenuData::MediaTypeNone; |
| 58 params.unfiltered_link_url = unfiltered_url; | 40 params.unfiltered_link_url = unfiltered_url; |
| 59 params.link_url = url; | 41 params.link_url = url; |
| 60 WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 42 WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 // be added. | 113 // be added. |
| 132 tab_observer.Wait(); | 114 tab_observer.Wait(); |
| 133 tab = tab_observer.GetTab(); | 115 tab = tab_observer.GetTab(); |
| 134 content::WaitForLoadStop(tab); | 116 content::WaitForLoadStop(tab); |
| 135 | 117 |
| 136 // Verify that it's the correct tab. | 118 // Verify that it's the correct tab. |
| 137 EXPECT_EQ(GURL("about:blank"), tab->GetURL()); | 119 EXPECT_EQ(GURL("about:blank"), tab->GetURL()); |
| 138 } | 120 } |
| 139 | 121 |
| 140 } // namespace | 122 } // namespace |
| OLD | NEW |