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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 public: | 48 public: |
49 MenuManagerTest() | 49 MenuManagerTest() |
50 : ui_thread_(BrowserThread::UI, &message_loop_), | 50 : ui_thread_(BrowserThread::UI, &message_loop_), |
51 file_thread_(BrowserThread::FILE, &message_loop_), | 51 file_thread_(BrowserThread::FILE, &message_loop_), |
52 profile_(new TestingProfile()), | 52 profile_(new TestingProfile()), |
53 manager_(profile_.get(), | 53 manager_(profile_.get(), |
54 ExtensionSystem::Get(profile_.get())->state_store()), | 54 ExtensionSystem::Get(profile_.get())->state_store()), |
55 prefs_(message_loop_.message_loop_proxy().get()), | 55 prefs_(message_loop_.message_loop_proxy().get()), |
56 next_id_(1) {} | 56 next_id_(1) {} |
57 | 57 |
58 virtual void TearDown() OVERRIDE { | 58 virtual void TearDown() override { |
59 prefs_.pref_service()->CommitPendingWrite(); | 59 prefs_.pref_service()->CommitPendingWrite(); |
60 message_loop_.RunUntilIdle(); | 60 message_loop_.RunUntilIdle(); |
61 } | 61 } |
62 | 62 |
63 // Returns a test item. | 63 // Returns a test item. |
64 MenuItem* CreateTestItem(Extension* extension, bool incognito = false) { | 64 MenuItem* CreateTestItem(Extension* extension, bool incognito = false) { |
65 MenuItem::Type type = MenuItem::NORMAL; | 65 MenuItem::Type type = MenuItem::NORMAL; |
66 MenuItem::ContextList contexts(MenuItem::ALL); | 66 MenuItem::ContextList contexts(MenuItem::ALL); |
67 const MenuItem::ExtensionKey key(extension->id()); | 67 const MenuItem::ExtensionKey key(extension->id()); |
68 MenuItem::Id id(incognito, key); | 68 MenuItem::Id id(incognito, key); |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 private: | 481 private: |
482 DISALLOW_COPY_AND_ASSIGN(MockEventRouter); | 482 DISALLOW_COPY_AND_ASSIGN(MockEventRouter); |
483 }; | 483 }; |
484 | 484 |
485 // A mock ExtensionSystem to serve our MockEventRouter. | 485 // A mock ExtensionSystem to serve our MockEventRouter. |
486 class MockExtensionSystem : public TestExtensionSystem { | 486 class MockExtensionSystem : public TestExtensionSystem { |
487 public: | 487 public: |
488 explicit MockExtensionSystem(Profile* profile) | 488 explicit MockExtensionSystem(Profile* profile) |
489 : TestExtensionSystem(profile) {} | 489 : TestExtensionSystem(profile) {} |
490 | 490 |
491 virtual EventRouter* event_router() OVERRIDE { | 491 virtual EventRouter* event_router() override { |
492 if (!mock_event_router_) | 492 if (!mock_event_router_) |
493 mock_event_router_.reset(new MockEventRouter(profile_)); | 493 mock_event_router_.reset(new MockEventRouter(profile_)); |
494 return mock_event_router_.get(); | 494 return mock_event_router_.get(); |
495 } | 495 } |
496 | 496 |
497 private: | 497 private: |
498 scoped_ptr<MockEventRouter> mock_event_router_; | 498 scoped_ptr<MockEventRouter> mock_event_router_; |
499 | 499 |
500 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem); | 500 DISALLOW_COPY_AND_ASSIGN(MockExtensionSystem); |
501 }; | 501 }; |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
763 EXPECT_EQ(4u, manager_.MenuItems(key1)->size()); | 763 EXPECT_EQ(4u, manager_.MenuItems(key1)->size()); |
764 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); | 764 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); |
765 | 765 |
766 // Remove all context menu items with incognito true. | 766 // Remove all context menu items with incognito true. |
767 manager_.RemoveAllIncognitoContextItems(); | 767 manager_.RemoveAllIncognitoContextItems(); |
768 EXPECT_EQ(2u, manager_.MenuItems(key1)->size()); | 768 EXPECT_EQ(2u, manager_.MenuItems(key1)->size()); |
769 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); | 769 EXPECT_EQ(1u, manager_.MenuItems(key2)->size()); |
770 } | 770 } |
771 | 771 |
772 } // namespace extensions | 772 } // namespace extensions |
OLD | NEW |