Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(618)

Side by Side Diff: chrome/browser/extensions/menu_manager_unittest.cc

Issue 12546016: Remove the Extensions URLRequestContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android webview init fix merged in. Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/prefs/pref_service.h" 12 #include "base/prefs/pref_service.h"
13 #include "base/run_loop.h"
13 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
14 #include "base/values.h" 15 #include "base/values.h"
15 #include "chrome/browser/chrome_notification_types.h" 16 #include "chrome/browser/chrome_notification_types.h"
16 #include "chrome/browser/extensions/event_names.h" 17 #include "chrome/browser/extensions/event_names.h"
17 #include "chrome/browser/extensions/event_router.h" 18 #include "chrome/browser/extensions/event_router.h"
18 #include "chrome/browser/extensions/extension_system_factory.h" 19 #include "chrome/browser/extensions/extension_system_factory.h"
19 #include "chrome/browser/extensions/menu_manager.h" 20 #include "chrome/browser/extensions/menu_manager.h"
20 #include "chrome/browser/extensions/test_extension_prefs.h" 21 #include "chrome/browser/extensions/test_extension_prefs.h"
21 #include "chrome/browser/extensions/test_extension_system.h" 22 #include "chrome/browser/extensions/test_extension_system.h"
22 #include "chrome/browser/prefs/pref_service_syncable.h" 23 #include "chrome/browser/prefs/pref_service_syncable.h"
23 #include "chrome/common/chrome_paths.h" 24 #include "chrome/common/chrome_paths.h"
24 #include "chrome/common/extensions/api/context_menus.h" 25 #include "chrome/common/extensions/api/context_menus.h"
25 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
26 #include "chrome/common/extensions/extension_constants.h" 27 #include "chrome/common/extensions/extension_constants.h"
27 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
28 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
29 #include "content/public/common/context_menu_params.h" 30 #include "content/public/common/context_menu_params.h"
30 #include "content/public/test/test_browser_thread.h" 31 #include "content/public/test/test_browser_thread_bundle.h"
31 #include "testing/gmock/include/gmock/gmock.h" 32 #include "testing/gmock/include/gmock/gmock.h"
32 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
33 34
34 using content::BrowserThread;
35 using testing::_; 35 using testing::_;
36 using testing::AtLeast; 36 using testing::AtLeast;
37 using testing::DeleteArg; 37 using testing::DeleteArg;
38 using testing::InSequence; 38 using testing::InSequence;
39 using testing::Return; 39 using testing::Return;
40 using testing::SaveArg; 40 using testing::SaveArg;
41 41
42 namespace extensions { 42 namespace extensions {
43 43
44 namespace context_menus = api::context_menus; 44 namespace context_menus = api::context_menus;
45 45
46 // Base class for tests. 46 // Base class for tests.
47 class MenuManagerTest : public testing::Test { 47 class MenuManagerTest : public testing::Test {
48 public: 48 public:
49 MenuManagerTest() 49 MenuManagerTest()
50 : ui_thread_(BrowserThread::UI, &message_loop_), 50 : manager_(&profile_),
51 file_thread_(BrowserThread::FILE, &message_loop_), 51 prefs_(base::MessageLoopForUI::current()->message_loop_proxy().get()),
52 manager_(&profile_),
53 prefs_(message_loop_.message_loop_proxy().get()),
54 next_id_(1) {} 52 next_id_(1) {}
55 53
56 virtual void TearDown() OVERRIDE { 54 virtual void TearDown() OVERRIDE {
57 prefs_.pref_service()->CommitPendingWrite(); 55 prefs_.pref_service()->CommitPendingWrite();
58 message_loop_.RunUntilIdle(); 56 base::RunLoop().RunUntilIdle();
59 } 57 }
60 58
61 // Returns a test item. 59 // Returns a test item.
62 MenuItem* CreateTestItem(Extension* extension, bool incognito = false) { 60 MenuItem* CreateTestItem(Extension* extension, bool incognito = false) {
63 MenuItem::Type type = MenuItem::NORMAL; 61 MenuItem::Type type = MenuItem::NORMAL;
64 MenuItem::ContextList contexts(MenuItem::ALL); 62 MenuItem::ContextList contexts(MenuItem::ALL);
65 MenuItem::Id id(incognito, extension->id()); 63 MenuItem::Id id(incognito, extension->id());
66 id.uid = next_id_++; 64 id.uid = next_id_++;
67 return new MenuItem(id, "test", false, true, type, contexts); 65 return new MenuItem(id, "test", false, true, type, contexts);
68 } 66 }
(...skipping 10 matching lines...) Expand all
79 77
80 // Creates and returns a test Extension. The caller does *not* own the return 78 // Creates and returns a test Extension. The caller does *not* own the return
81 // value. 79 // value.
82 Extension* AddExtension(std::string name) { 80 Extension* AddExtension(std::string name) {
83 scoped_refptr<Extension> extension = prefs_.AddExtension(name); 81 scoped_refptr<Extension> extension = prefs_.AddExtension(name);
84 extensions_.push_back(extension); 82 extensions_.push_back(extension);
85 return extension.get(); 83 return extension.get();
86 } 84 }
87 85
88 protected: 86 protected:
89 base::MessageLoopForUI message_loop_; 87 content::TestBrowserThreadBundle thread_bundle_;
90 content::TestBrowserThread ui_thread_;
91 content::TestBrowserThread file_thread_;
92 TestingProfile profile_; 88 TestingProfile profile_;
93 89
94 MenuManager manager_; 90 MenuManager manager_;
95 ExtensionList extensions_; 91 ExtensionList extensions_;
96 TestExtensionPrefs prefs_; 92 TestExtensionPrefs prefs_;
97 int next_id_; 93 int next_id_;
98 94
99 private: 95 private:
100 DISALLOW_COPY_AND_ASSIGN(MenuManagerTest); 96 DISALLOW_COPY_AND_ASSIGN(MenuManagerTest);
101 }; 97 };
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
751 EXPECT_EQ(4u, manager_.MenuItems(extension1->id())->size()); 747 EXPECT_EQ(4u, manager_.MenuItems(extension1->id())->size());
752 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size()); 748 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size());
753 749
754 // Remove all context menu items with incognito true. 750 // Remove all context menu items with incognito true.
755 manager_.RemoveAllIncognitoContextItems(); 751 manager_.RemoveAllIncognitoContextItems();
756 EXPECT_EQ(2u, manager_.MenuItems(extension1->id())->size()); 752 EXPECT_EQ(2u, manager_.MenuItems(extension1->id())->size());
757 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size()); 753 EXPECT_EQ(1u, manager_.MenuItems(extension2->id())->size());
758 } 754 }
759 755
760 } // namespace extensions 756 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_warning_service_unittest.cc ('k') | chrome/browser/history/shortcuts_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698