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_notification_types.h" |
17 #include "chrome/common/chrome_paths.h" | 17 #include "chrome/common/chrome_paths.h" |
18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
19 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
20 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
21 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
22 #include "content/common/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 #include "webkit/glue/context_menu.h" | 25 #include "webkit/glue/context_menu.h" |
26 | 26 |
27 using testing::_; | 27 using testing::_; |
28 using testing::AtLeast; | 28 using testing::AtLeast; |
29 using testing::Return; | 29 using testing::Return; |
30 using testing::SaveArg; | 30 using testing::SaveArg; |
31 | 31 |
32 // Base class for tests. | 32 // Base class for tests. |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 ASSERT_FALSE(manager_.ChangeParent(item4->id(), &item1->id())); | 304 ASSERT_FALSE(manager_.ChangeParent(item4->id(), &item1->id())); |
305 ASSERT_FALSE(manager_.ChangeParent(item1->id(), &item4->id())); | 305 ASSERT_FALSE(manager_.ChangeParent(item1->id(), &item4->id())); |
306 | 306 |
307 // Make sure you can't make an item be it's own parent. | 307 // Make sure you can't make an item be it's own parent. |
308 ASSERT_FALSE(manager_.ChangeParent(item1->id(), &item1->id())); | 308 ASSERT_FALSE(manager_.ChangeParent(item1->id(), &item1->id())); |
309 } | 309 } |
310 | 310 |
311 // Tests that we properly remove an extension's menu item when that extension is | 311 // Tests that we properly remove an extension's menu item when that extension is |
312 // unloaded. | 312 // unloaded. |
313 TEST_F(ExtensionMenuManagerTest, ExtensionUnloadRemovesMenuItems) { | 313 TEST_F(ExtensionMenuManagerTest, ExtensionUnloadRemovesMenuItems) { |
314 NotificationService* notifier = NotificationService::current(); | 314 content::NotificationService* notifier = |
| 315 content::NotificationService::current(); |
315 ASSERT_TRUE(notifier != NULL); | 316 ASSERT_TRUE(notifier != NULL); |
316 | 317 |
317 // Create a test extension. | 318 // Create a test extension. |
318 Extension* extension1 = AddExtension("1111"); | 319 Extension* extension1 = AddExtension("1111"); |
319 | 320 |
320 // Create an ExtensionMenuItem and put it into the manager. | 321 // Create an ExtensionMenuItem and put it into the manager. |
321 ExtensionMenuItem* item1 = CreateTestItem(extension1); | 322 ExtensionMenuItem* item1 = CreateTestItem(extension1); |
322 ExtensionMenuItem::Id id1 = item1->id(); | 323 ExtensionMenuItem::Id id1 = item1->id(); |
323 ASSERT_EQ(extension1->id(), item1->extension_id()); | 324 ASSERT_EQ(extension1->id(), item1->extension_id()); |
324 ASSERT_TRUE(manager_.AddContextItem(extension1, item1)); | 325 ASSERT_TRUE(manager_.AddContextItem(extension1, item1)); |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 ASSERT_EQ(params.page_url.spec(), tmp); | 484 ASSERT_EQ(params.page_url.spec(), tmp); |
484 | 485 |
485 string16 tmp16; | 486 string16 tmp16; |
486 ASSERT_TRUE(info->GetString("selectionText", &tmp16)); | 487 ASSERT_TRUE(info->GetString("selectionText", &tmp16)); |
487 ASSERT_EQ(params.selection_text, tmp16); | 488 ASSERT_EQ(params.selection_text, tmp16); |
488 | 489 |
489 bool bool_tmp = true; | 490 bool bool_tmp = true; |
490 ASSERT_TRUE(info->GetBoolean("editable", &bool_tmp)); | 491 ASSERT_TRUE(info->GetBoolean("editable", &bool_tmp)); |
491 ASSERT_EQ(params.is_editable, bool_tmp); | 492 ASSERT_EQ(params.is_editable, bool_tmp); |
492 } | 493 } |
OLD | NEW |