| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/scoped_temp_dir.h" | 11 #include "base/scoped_temp_dir.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/extensions/extension_event_router.h" | 14 #include "chrome/browser/extensions/extension_event_router.h" |
| 15 #include "chrome/browser/extensions/extension_menu_manager.h" | 15 #include "chrome/browser/extensions/extension_menu_manager.h" |
| 16 #include "chrome/browser/extensions/test_extension_prefs.h" | 16 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 17 #include "chrome/common/chrome_notification_types.h" | 17 #include "chrome/common/chrome_notification_types.h" |
| 18 #include "chrome/common/chrome_paths.h" | 18 #include "chrome/common/chrome_paths.h" |
| 19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
| 21 #include "chrome/test/base/testing_profile.h" | 21 #include "chrome/test/base/testing_profile.h" |
| 22 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/common/context_menu_params.h" |
| 23 #include "content/test/test_browser_thread.h" | 24 #include "content/test/test_browser_thread.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "webkit/glue/context_menu.h" | |
| 27 | 27 |
| 28 using content::BrowserThread; | 28 using content::BrowserThread; |
| 29 using testing::_; | 29 using testing::_; |
| 30 using testing::AtLeast; | 30 using testing::AtLeast; |
| 31 using testing::Return; | 31 using testing::Return; |
| 32 using testing::SaveArg; | 32 using testing::SaveArg; |
| 33 | 33 |
| 34 // Base class for tests. | 34 // Base class for tests. |
| 35 class ExtensionMenuManagerTest : public testing::Test { | 35 class ExtensionMenuManagerTest : public testing::Test { |
| 36 public: | 36 public: |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 | 422 |
| 423 ASSERT_TRUE(manager_.context_items_.empty()); | 423 ASSERT_TRUE(manager_.context_items_.empty()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 TEST_F(ExtensionMenuManagerTest, ExecuteCommand) { | 426 TEST_F(ExtensionMenuManagerTest, ExecuteCommand) { |
| 427 MockTestingProfile profile; | 427 MockTestingProfile profile; |
| 428 | 428 |
| 429 scoped_ptr<MockExtensionEventRouter> mock_event_router( | 429 scoped_ptr<MockExtensionEventRouter> mock_event_router( |
| 430 new MockExtensionEventRouter(&profile)); | 430 new MockExtensionEventRouter(&profile)); |
| 431 | 431 |
| 432 ContextMenuParams params; | 432 content::ContextMenuParams params; |
| 433 params.media_type = WebKit::WebContextMenuData::MediaTypeImage; | 433 params.media_type = WebKit::WebContextMenuData::MediaTypeImage; |
| 434 params.src_url = GURL("http://foo.bar/image.png"); | 434 params.src_url = GURL("http://foo.bar/image.png"); |
| 435 params.page_url = GURL("http://foo.bar"); | 435 params.page_url = GURL("http://foo.bar"); |
| 436 params.selection_text = ASCIIToUTF16("Hello World"); | 436 params.selection_text = ASCIIToUTF16("Hello World"); |
| 437 params.is_editable = false; | 437 params.is_editable = false; |
| 438 | 438 |
| 439 Extension* extension = AddExtension("test"); | 439 Extension* extension = AddExtension("test"); |
| 440 ExtensionMenuItem* item = CreateTestItem(extension); | 440 ExtensionMenuItem* item = CreateTestItem(extension); |
| 441 ExtensionMenuItem::Id id = item->id(); | 441 ExtensionMenuItem::Id id = item->id(); |
| 442 ASSERT_TRUE(manager_.AddContextItem(extension, item)); | 442 ASSERT_TRUE(manager_.AddContextItem(extension, item)); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 ASSERT_TRUE(new_item->checked()); | 578 ASSERT_TRUE(new_item->checked()); |
| 579 ASSERT_TRUE(child1->checked()); | 579 ASSERT_TRUE(child1->checked()); |
| 580 | 580 |
| 581 // Removing |parent| should cause only |child1| to be selected. | 581 // Removing |parent| should cause only |child1| to be selected. |
| 582 manager_.RemoveContextMenuItem(parent->id()); | 582 manager_.RemoveContextMenuItem(parent->id()); |
| 583 parent = NULL; | 583 parent = NULL; |
| 584 ASSERT_FALSE(new_item->checked()); | 584 ASSERT_FALSE(new_item->checked()); |
| 585 ASSERT_TRUE(child1->checked()); | 585 ASSERT_TRUE(child1->checked()); |
| 586 } | 586 } |
| 587 | 587 |
| OLD | NEW |