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 "chrome/browser/extensions/menu_manager.h" | 5 #include "chrome/browser/extensions/menu_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 // Create a menu item with a different extension id and add it to the manager. | 452 // Create a menu item with a different extension id and add it to the manager. |
453 Extension* extension2 = AddExtension("2222"); | 453 Extension* extension2 = AddExtension("2222"); |
454 std::unique_ptr<MenuItem> item2 = CreateTestItem(extension2); | 454 std::unique_ptr<MenuItem> item2 = CreateTestItem(extension2); |
455 MenuItem* item2_ptr = item2.get(); | 455 MenuItem* item2_ptr = item2.get(); |
456 ASSERT_NE(item1_ptr->extension_id(), item2->extension_id()); | 456 ASSERT_NE(item1_ptr->extension_id(), item2->extension_id()); |
457 ASSERT_TRUE(manager_.AddContextItem(extension2, std::move(item2))); | 457 ASSERT_TRUE(manager_.AddContextItem(extension2, std::move(item2))); |
458 | 458 |
459 // Notify that the extension was unloaded, and make sure the right item is | 459 // Notify that the extension was unloaded, and make sure the right item is |
460 // gone. | 460 // gone. |
461 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_.get()); | 461 ExtensionRegistry* registry = ExtensionRegistry::Get(profile_.get()); |
462 registry->TriggerOnUnloaded(extension1, | 462 registry->TriggerOnUnloaded(extension1, UnloadedExtensionReason::DISABLE); |
463 UnloadedExtensionInfo::REASON_DISABLE); | |
464 | 463 |
465 ASSERT_EQ(NULL, manager_.MenuItems(MenuItem::ExtensionKey(extension1->id()))); | 464 ASSERT_EQ(NULL, manager_.MenuItems(MenuItem::ExtensionKey(extension1->id()))); |
466 ASSERT_EQ( | 465 ASSERT_EQ( |
467 1u, manager_.MenuItems(MenuItem::ExtensionKey(extension2->id()))->size()); | 466 1u, manager_.MenuItems(MenuItem::ExtensionKey(extension2->id()))->size()); |
468 ASSERT_TRUE(manager_.GetItemById(id1) == NULL); | 467 ASSERT_TRUE(manager_.GetItemById(id1) == NULL); |
469 ASSERT_TRUE(manager_.GetItemById(item2_ptr->id()) != NULL); | 468 ASSERT_TRUE(manager_.GetItemById(item2_ptr->id()) != NULL); |
470 } | 469 } |
471 | 470 |
472 namespace { | 471 namespace { |
473 | 472 |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 EXPECT_EQ(4u, manager_.MenuItems(key1)->size()); | 768 EXPECT_EQ(4u, manager_.MenuItems(key1)->size()); |
770 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); | 769 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); |
771 | 770 |
772 // Remove all context menu items with incognito true. | 771 // Remove all context menu items with incognito true. |
773 manager_.RemoveAllIncognitoContextItems(); | 772 manager_.RemoveAllIncognitoContextItems(); |
774 EXPECT_EQ(2u, manager_.MenuItems(key1)->size()); | 773 EXPECT_EQ(2u, manager_.MenuItems(key1)->size()); |
775 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); | 774 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); |
776 } | 775 } |
777 | 776 |
778 } // namespace extensions | 777 } // namespace extensions |
OLD | NEW |