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_test_message_listener.h" | 9 #include "chrome/browser/extensions/extension_test_message_listener.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return menu; | 149 return menu; |
150 } | 150 } |
151 | 151 |
152 // Shortcut to return the current ExtensionMenuManager. | 152 // Shortcut to return the current ExtensionMenuManager. |
153 ExtensionMenuManager* menu_manager() { | 153 ExtensionMenuManager* menu_manager() { |
154 return browser()->profile()->GetExtensionService()->menu_manager(); | 154 return browser()->profile()->GetExtensionService()->menu_manager(); |
155 } | 155 } |
156 | 156 |
157 // Returns a pointer to the currently loaded extension with |name|, or null | 157 // Returns a pointer to the currently loaded extension with |name|, or null |
158 // if not found. | 158 // if not found. |
159 const Extension* GetExtensionNamed(std::string name) { | 159 const extensions::Extension* GetExtensionNamed(std::string name) { |
160 const ExtensionSet* extensions = | 160 const ExtensionSet* extensions = |
161 browser()->profile()->GetExtensionService()->extensions(); | 161 browser()->profile()->GetExtensionService()->extensions(); |
162 ExtensionSet::const_iterator i; | 162 ExtensionSet::const_iterator i; |
163 for (i = extensions->begin(); i != extensions->end(); ++i) { | 163 for (i = extensions->begin(); i != extensions->end(); ++i) { |
164 if ((*i)->name() == name) { | 164 if ((*i)->name() == name) { |
165 return *i; | 165 return *i; |
166 } | 166 } |
167 } | 167 } |
168 return NULL; | 168 return NULL; |
169 } | 169 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 ExpectLabelAndType("radio3", MenuModel::TYPE_RADIO, menu, index++); | 350 ExpectLabelAndType("radio3", MenuModel::TYPE_RADIO, menu, index++); |
351 ExpectLabelAndType("radio4", MenuModel::TYPE_RADIO, menu, index++); | 351 ExpectLabelAndType("radio4", MenuModel::TYPE_RADIO, menu, index++); |
352 EXPECT_EQ(MenuModel::TYPE_SEPARATOR, menu.GetTypeAt(index++)); | 352 EXPECT_EQ(MenuModel::TYPE_SEPARATOR, menu.GetTypeAt(index++)); |
353 ExpectLabelAndType("normal3", MenuModel::TYPE_COMMAND, menu, index++); | 353 ExpectLabelAndType("normal3", MenuModel::TYPE_COMMAND, menu, index++); |
354 } | 354 } |
355 | 355 |
356 // Tests a number of cases for auto-generated and explicitly added separators. | 356 // Tests a number of cases for auto-generated and explicitly added separators. |
357 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Separators) { | 357 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Separators) { |
358 // Load the extension. | 358 // Load the extension. |
359 ASSERT_TRUE(LoadContextMenuExtension("separators")); | 359 ASSERT_TRUE(LoadContextMenuExtension("separators")); |
360 const Extension* extension = GetExtensionNamed("Separators Test"); | 360 const extensions::Extension* extension = GetExtensionNamed("Separators Test"); |
361 ASSERT_TRUE(extension != NULL); | 361 ASSERT_TRUE(extension != NULL); |
362 | 362 |
363 // Navigate to test1.html inside the extension, which should create a bunch | 363 // Navigate to test1.html inside the extension, which should create a bunch |
364 // of items at the top-level (but they'll get pushed into an auto-generated | 364 // of items at the top-level (but they'll get pushed into an auto-generated |
365 // parent). | 365 // parent). |
366 ExtensionTestMessageListener listener1("test1 create finished", false); | 366 ExtensionTestMessageListener listener1("test1 create finished", false); |
367 ui_test_utils::NavigateToURL(browser(), | 367 ui_test_utils::NavigateToURL(browser(), |
368 GURL(extension->GetResourceURL("test1.html"))); | 368 GURL(extension->GetResourceURL("test1.html"))); |
369 listener1.WaitUntilSatisfied(); | 369 listener1.WaitUntilSatisfied(); |
370 | 370 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 page_url, GURL(), frame_url, std::string("Page item"))); | 501 page_url, GURL(), frame_url, std::string("Page item"))); |
502 ASSERT_TRUE(MenuHasItemWithLabel( | 502 ASSERT_TRUE(MenuHasItemWithLabel( |
503 page_url, GURL(), frame_url, std::string("Frame item"))); | 503 page_url, GURL(), frame_url, std::string("Frame item"))); |
504 } | 504 } |
505 | 505 |
506 // Tests enabling and disabling a context menu item. | 506 // Tests enabling and disabling a context menu item. |
507 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Enabled) { | 507 IN_PROC_BROWSER_TEST_F(ExtensionContextMenuBrowserTest, Enabled) { |
508 TestEnabledContextMenu(true); | 508 TestEnabledContextMenu(true); |
509 TestEnabledContextMenu(false); | 509 TestEnabledContextMenu(false); |
510 } | 510 } |
OLD | NEW |