| 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "chrome/app/chrome_command_ids.h" | 6 #include "chrome/app/chrome_command_ids.h" |
| 7 #include "chrome/browser/extensions/extension_browsertest.h" | 7 #include "chrome/browser/extensions/extension_browsertest.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 11 #include "chrome/browser/extensions/lazy_background_page_test_util.h" | 11 #include "chrome/browser/extensions/lazy_background_page_test_util.h" |
| 12 #include "chrome/browser/extensions/test_management_policy.h" | 12 #include "chrome/browser/extensions/test_management_policy.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 14 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/common/chrome_switches.h" | |
| 18 #include "chrome/test/base/ui_test_utils.h" | 17 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "content/public/common/context_menu_params.h" | 18 #include "content/public/common/context_menu_params.h" |
| 19 #include "extensions/common/switches.h" |
| 20 #include "net/dns/mock_host_resolver.h" | 20 #include "net/dns/mock_host_resolver.h" |
| 21 #include "ui/base/models/menu_model.h" | 21 #include "ui/base/models/menu_model.h" |
| 22 | 22 |
| 23 using content::WebContents; | 23 using content::WebContents; |
| 24 using extensions::MenuItem; | 24 using extensions::MenuItem; |
| 25 using ui::MenuModel; | 25 using ui::MenuModel; |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 // This test class helps us sidestep platform-specific issues with popping up a | 28 // This test class helps us sidestep platform-specific issues with popping up a |
| 29 // real context menu, while still running through the actual code in | 29 // real context menu, while still running through the actual code in |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Enabled) { | 601 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Enabled) { |
| 602 TestEnabledContextMenu(true); | 602 TestEnabledContextMenu(true); |
| 603 TestEnabledContextMenu(false); | 603 TestEnabledContextMenu(false); |
| 604 } | 604 } |
| 605 | 605 |
| 606 class ExtensionContextMenuBrowserLazyTest : | 606 class ExtensionContextMenuBrowserLazyTest : |
| 607 public ExtensionContextMenuBrowserTest { | 607 public ExtensionContextMenuBrowserTest { |
| 608 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 608 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 609 ExtensionContextMenuBrowserTest::SetUpCommandLine(command_line); | 609 ExtensionContextMenuBrowserTest::SetUpCommandLine(command_line); |
| 610 // Set shorter delays to prevent test timeouts. | 610 // Set shorter delays to prevent test timeouts. |
| 611 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "0"); | 611 command_line->AppendSwitchASCII( |
| 612 command_line->AppendSwitchASCII(switches::kEventPageSuspendingTime, "0"); | 612 extensions::switches::kEventPageIdleTime, "0"); |
| 613 command_line->AppendSwitchASCII( |
| 614 extensions::switches::kEventPageSuspendingTime, "0"); |
| 613 } | 615 } |
| 614 }; | 616 }; |
| 615 | 617 |
| 616 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserLazyTest, EventPage) { | 618 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserLazyTest, EventPage) { |
| 617 GURL about_blank("about:blank"); | 619 GURL about_blank("about:blank"); |
| 618 LazyBackgroundObserver page_complete; | 620 LazyBackgroundObserver page_complete; |
| 619 const extensions::Extension* extension = LoadContextMenuExtension( | 621 const extensions::Extension* extension = LoadContextMenuExtension( |
| 620 "event_page"); | 622 "event_page"); |
| 621 ASSERT_TRUE(extension); | 623 ASSERT_TRUE(extension); |
| 622 page_complete.Wait(); | 624 page_complete.Wait(); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); | 659 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); |
| 658 | 660 |
| 659 // Wait for the extension's processes to tell us they've created an item. | 661 // Wait for the extension's processes to tell us they've created an item. |
| 660 ASSERT_TRUE(created.WaitUntilSatisfied()); | 662 ASSERT_TRUE(created.WaitUntilSatisfied()); |
| 661 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); | 663 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); |
| 662 ASSERT_EQ(2u, GetItems().size()); | 664 ASSERT_EQ(2u, GetItems().size()); |
| 663 | 665 |
| 664 browser()->profile()->DestroyOffTheRecordProfile(); | 666 browser()->profile()->DestroyOffTheRecordProfile(); |
| 665 ASSERT_EQ(1u, GetItems().size()); | 667 ASSERT_EQ(1u, GetItems().size()); |
| 666 } | 668 } |
| OLD | NEW |