| 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/utf_string_conversions.h" | 5 #include "base/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" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 | 66 |
| 67 extensions::ContextMenuMatcher& extension_items() { | 67 extensions::ContextMenuMatcher& extension_items() { |
| 68 return extension_items_; | 68 return extension_items_; |
| 69 } | 69 } |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 // These two functions implement pure virtual methods of | 72 // These two functions implement pure virtual methods of |
| 73 // RenderViewContextMenu. | 73 // RenderViewContextMenu. |
| 74 virtual bool GetAcceleratorForCommandId(int command_id, | 74 virtual bool GetAcceleratorForCommandId( |
| 75 ui::Accelerator* accelerator) { | 75 int command_id, |
| 76 ui::Accelerator* accelerator) OVERRIDE { |
| 76 // None of our commands have accelerators, so always return false. | 77 // None of our commands have accelerators, so always return false. |
| 77 return false; | 78 return false; |
| 78 } | 79 } |
| 79 virtual void PlatformInit() {} | 80 virtual void PlatformInit() OVERRIDE {} |
| 80 virtual void PlatformCancel() {} | 81 virtual void PlatformCancel() OVERRIDE {} |
| 81 }; | 82 }; |
| 82 | 83 |
| 83 } // namespace | 84 } // namespace |
| 84 | 85 |
| 85 class ExtensionContextMenuBrowserTest : public ExtensionBrowserTest { | 86 class ExtensionContextMenuBrowserTest : public ExtensionBrowserTest { |
| 86 public: | 87 public: |
| 87 // Helper to load an extension from context_menus/|subdirectory| in the | 88 // Helper to load an extension from context_menus/|subdirectory| in the |
| 88 // extensions test data dir. | 89 // extensions test data dir. |
| 89 const extensions::Extension* LoadContextMenuExtension( | 90 const extensions::Extension* LoadContextMenuExtension( |
| 90 std::string subdirectory) { | 91 std::string subdirectory) { |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 521 } |
| 521 | 522 |
| 522 // Tests enabling and disabling a context menu item. | 523 // Tests enabling and disabling a context menu item. |
| 523 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Enabled) { | 524 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Enabled) { |
| 524 TestEnabledContextMenu(true); | 525 TestEnabledContextMenu(true); |
| 525 TestEnabledContextMenu(false); | 526 TestEnabledContextMenu(false); |
| 526 } | 527 } |
| 527 | 528 |
| 528 class ExtensionContextMenuBrowserLazyTest : | 529 class ExtensionContextMenuBrowserLazyTest : |
| 529 public ExtensionContextMenuBrowserTest { | 530 public ExtensionContextMenuBrowserTest { |
| 530 void SetUpCommandLine(CommandLine* command_line) { | 531 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 531 ExtensionContextMenuBrowserTest::SetUpCommandLine(command_line); | 532 ExtensionContextMenuBrowserTest::SetUpCommandLine(command_line); |
| 532 // Set shorter delays to prevent test timeouts. | 533 // Set shorter delays to prevent test timeouts. |
| 533 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "0"); | 534 command_line->AppendSwitchASCII(switches::kEventPageIdleTime, "0"); |
| 534 command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "0"); | 535 command_line->AppendSwitchASCII(switches::kEventPageUnloadingTime, "0"); |
| 535 } | 536 } |
| 536 }; | 537 }; |
| 537 | 538 |
| 538 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserLazyTest, EventPage) { | 539 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserLazyTest, EventPage) { |
| 539 GURL about_blank("about:blank"); | 540 GURL about_blank("about:blank"); |
| 540 LazyBackgroundObserver page_complete; | 541 LazyBackgroundObserver page_complete; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); | 580 ASSERT_TRUE(LoadContextMenuExtensionIncognito("incognito")); |
| 580 | 581 |
| 581 // Wait for the extension's processes to tell us they've created an item. | 582 // Wait for the extension's processes to tell us they've created an item. |
| 582 ASSERT_TRUE(created.WaitUntilSatisfied()); | 583 ASSERT_TRUE(created.WaitUntilSatisfied()); |
| 583 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); | 584 ASSERT_TRUE(created_incognito.WaitUntilSatisfied()); |
| 584 ASSERT_EQ(2u, GetItems().size()); | 585 ASSERT_EQ(2u, GetItems().size()); |
| 585 | 586 |
| 586 browser()->profile()->DestroyOffTheRecordProfile(); | 587 browser()->profile()->DestroyOffTheRecordProfile(); |
| 587 ASSERT_EQ(1u, GetItems().size()); | 588 ASSERT_EQ(1u, GetItems().size()); |
| 588 } | 589 } |
| OLD | NEW |