OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/extensions/extension_event_router.h" | 13 #include "chrome/browser/extensions/extension_event_router.h" |
14 #include "chrome/browser/extensions/extension_menu_manager.h" | 14 #include "chrome/browser/extensions/extension_menu_manager.h" |
15 #include "chrome/browser/extensions/test_extension_prefs.h" | 15 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 16 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
18 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
19 #include "chrome/test/testing_profile.h" | 20 #include "chrome/test/testing_profile.h" |
20 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
21 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
24 #include "webkit/glue/context_menu.h" | 25 #include "webkit/glue/context_menu.h" |
25 | 26 |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 | 324 |
324 // Create a menu item with a different extension id and add it to the manager. | 325 // Create a menu item with a different extension id and add it to the manager. |
325 Extension* extension2 = AddExtension("2222"); | 326 Extension* extension2 = AddExtension("2222"); |
326 ExtensionMenuItem* item2 = CreateTestItem(extension2); | 327 ExtensionMenuItem* item2 = CreateTestItem(extension2); |
327 ASSERT_NE(item1->extension_id(), item2->extension_id()); | 328 ASSERT_NE(item1->extension_id(), item2->extension_id()); |
328 ASSERT_TRUE(manager_.AddContextItem(extension2, item2)); | 329 ASSERT_TRUE(manager_.AddContextItem(extension2, item2)); |
329 | 330 |
330 // Notify that the extension was unloaded, and make sure the right item is | 331 // Notify that the extension was unloaded, and make sure the right item is |
331 // gone. | 332 // gone. |
332 UnloadedExtensionInfo details(extension1, UnloadedExtensionInfo::DISABLE); | 333 UnloadedExtensionInfo details(extension1, UnloadedExtensionInfo::DISABLE); |
333 notifier->Notify(NotificationType::EXTENSION_UNLOADED, | 334 notifier->Notify(chrome::NOTIFICATION_EXTENSION_UNLOADED, |
334 Source<Profile>(NULL), | 335 Source<Profile>(NULL), |
335 Details<UnloadedExtensionInfo>(&details)); | 336 Details<UnloadedExtensionInfo>(&details)); |
336 ASSERT_EQ(NULL, manager_.MenuItems(extension1->id())); | 337 ASSERT_EQ(NULL, manager_.MenuItems(extension1->id())); |
337 ASSERT_EQ(1u, manager_.MenuItems(extension2->id())->size()); | 338 ASSERT_EQ(1u, manager_.MenuItems(extension2->id())->size()); |
338 ASSERT_TRUE(manager_.GetItemById(id1) == NULL); | 339 ASSERT_TRUE(manager_.GetItemById(id1) == NULL); |
339 ASSERT_TRUE(manager_.GetItemById(item2->id()) != NULL); | 340 ASSERT_TRUE(manager_.GetItemById(item2->id()) != NULL); |
340 } | 341 } |
341 | 342 |
342 // A mock message service for tests of ExtensionMenuManager::ExecuteCommand. | 343 // A mock message service for tests of ExtensionMenuManager::ExecuteCommand. |
343 class MockExtensionEventRouter : public ExtensionEventRouter { | 344 class MockExtensionEventRouter : public ExtensionEventRouter { |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 ASSERT_EQ(params.page_url.spec(), tmp); | 481 ASSERT_EQ(params.page_url.spec(), tmp); |
481 | 482 |
482 string16 tmp16; | 483 string16 tmp16; |
483 ASSERT_TRUE(info->GetString("selectionText", &tmp16)); | 484 ASSERT_TRUE(info->GetString("selectionText", &tmp16)); |
484 ASSERT_EQ(params.selection_text, tmp16); | 485 ASSERT_EQ(params.selection_text, tmp16); |
485 | 486 |
486 bool bool_tmp = true; | 487 bool bool_tmp = true; |
487 ASSERT_TRUE(info->GetBoolean("editable", &bool_tmp)); | 488 ASSERT_TRUE(info->GetBoolean("editable", &bool_tmp)); |
488 ASSERT_EQ(params.is_editable, bool_tmp); | 489 ASSERT_EQ(params.is_editable, bool_tmp); |
489 } | 490 } |
OLD | NEW |