Chromium Code Reviews| 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/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.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/event_names.h" | 14 #include "chrome/browser/extensions/event_names.h" |
| 15 #include "chrome/browser/extensions/event_router.h" | 15 #include "chrome/browser/extensions/event_router.h" |
| 16 #include "chrome/browser/extensions/extension_system_factory.h" | 16 #include "chrome/browser/extensions/extension_system_factory.h" |
| 17 #include "chrome/browser/extensions/menu_manager.h" | 17 #include "chrome/browser/extensions/menu_manager.h" |
| 18 #include "chrome/browser/extensions/test_extension_prefs.h" | 18 #include "chrome/browser/extensions/test_extension_prefs.h" |
| 19 #include "chrome/browser/extensions/test_extension_system.h" | 19 #include "chrome/browser/extensions/test_extension_system.h" |
| 20 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
| 21 #include "chrome/browser/prefs/pref_service_syncable.h" | |
| 21 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "chrome/common/chrome_paths.h" | 23 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 24 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 25 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
| 26 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
| 27 #include "content/public/common/context_menu_params.h" | 28 #include "content/public/common/context_menu_params.h" |
| 28 #include "content/public/test/test_browser_thread.h" | 29 #include "content/public/test/test_browser_thread.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 43 class MenuManagerTest : public testing::Test { | 44 class MenuManagerTest : public testing::Test { |
| 44 public: | 45 public: |
| 45 MenuManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_), | 46 MenuManagerTest() : ui_thread_(BrowserThread::UI, &message_loop_), |
| 46 file_thread_(BrowserThread::FILE, &message_loop_), | 47 file_thread_(BrowserThread::FILE, &message_loop_), |
| 47 manager_(&profile_), | 48 manager_(&profile_), |
| 48 prefs_(message_loop_.message_loop_proxy()), | 49 prefs_(message_loop_.message_loop_proxy()), |
| 49 next_id_(1) { | 50 next_id_(1) { |
| 50 } | 51 } |
| 51 | 52 |
| 52 virtual void TearDown() OVERRIDE { | 53 virtual void TearDown() OVERRIDE { |
| 53 prefs_.pref_service()->CommitPendingWrite(); | 54 prefs_.pref_service()->CommitPendingWrite(); |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
pref_service() should return a PrefService instead
Jói
2013/02/07 14:52:32
Done.
| |
| 54 message_loop_.RunUntilIdle(); | 55 message_loop_.RunUntilIdle(); |
| 55 } | 56 } |
| 56 | 57 |
| 57 // Returns a test item. | 58 // Returns a test item. |
| 58 MenuItem* CreateTestItem(Extension* extension, bool incognito = false) { | 59 MenuItem* CreateTestItem(Extension* extension, bool incognito = false) { |
| 59 MenuItem::Type type = MenuItem::NORMAL; | 60 MenuItem::Type type = MenuItem::NORMAL; |
| 60 MenuItem::ContextList contexts(MenuItem::ALL); | 61 MenuItem::ContextList contexts(MenuItem::ALL); |
| 61 MenuItem::Id id(incognito, extension->id()); | 62 MenuItem::Id id(incognito, extension->id()); |
| 62 id.uid = next_id_++; | 63 id.uid = next_id_++; |
| 63 return new MenuItem(id, "test", false, true, type, contexts); | 64 return new MenuItem(id, "test", false, true, type, contexts); |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 EXPECT_EQ(4u, manager_.MenuItems(extension1->id())->size()); | 747 EXPECT_EQ(4u, manager_.MenuItems(extension1->id())->size()); |
| 747 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size()); | 748 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size()); |
| 748 | 749 |
| 749 // Remove all context menu items with incognito true. | 750 // Remove all context menu items with incognito true. |
| 750 manager_.RemoveAllIncognitoContextItems(); | 751 manager_.RemoveAllIncognitoContextItems(); |
| 751 EXPECT_EQ(2u, manager_.MenuItems(extension1->id())->size()); | 752 EXPECT_EQ(2u, manager_.MenuItems(extension1->id())->size()); |
| 752 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size()); | 753 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size()); |
| 753 } | 754 } |
| 754 | 755 |
| 755 } // namespace extensions | 756 } // namespace extensions |
| OLD | NEW |