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

Side by Side Diff: extensions/browser/mojo/keep_alive_impl_unittest.cc

Issue 671763002: Extract ProcessManager from ExtensionSystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 1 month 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
« no previous file with comments | « extensions/browser/mojo/keep_alive_impl.cc ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/mojo/keep_alive_impl.h" 5 #include "extensions/browser/mojo/keep_alive_impl.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "extensions/browser/extension_registry.h" 10 #include "extensions/browser/extension_registry.h"
11 #include "extensions/browser/extension_system.h" 11 #include "extensions/browser/extension_system.h"
12 #include "extensions/browser/extensions_test.h" 12 #include "extensions/browser/extensions_test.h"
13 #include "extensions/browser/mock_extension_system.h" 13 #include "extensions/browser/mock_extension_system.h"
14 #include "extensions/browser/process_manager.h" 14 #include "extensions/browser/process_manager.h"
15 #include "extensions/browser/test_extensions_browser_client.h" 15 #include "extensions/browser/test_extensions_browser_client.h"
16 #include "extensions/common/extension_builder.h" 16 #include "extensions/common/extension_builder.h"
17 17
18 namespace extensions { 18 namespace extensions {
19 19
20 namespace {
21
22 class TestExtensionSystem : public MockExtensionSystem {
23 public:
24 explicit TestExtensionSystem(content::BrowserContext* context)
25 : MockExtensionSystem(context),
26 process_manager_(ProcessManager::Create(context)) {}
27
28 ProcessManager* process_manager() override { return process_manager_.get(); }
29
30 private:
31 scoped_ptr<ProcessManager> process_manager_;
32 };
33
34 } // namespace
35
36 class KeepAliveTest : public ExtensionsTest { 20 class KeepAliveTest : public ExtensionsTest {
37 public: 21 public:
38 KeepAliveTest() 22 KeepAliveTest()
39 : notification_service_(content::NotificationService::Create()) {} 23 : notification_service_(content::NotificationService::Create()) {}
40 ~KeepAliveTest() override {} 24 ~KeepAliveTest() override {}
41 25
42 void SetUp() override { 26 void SetUp() override {
43 ExtensionsTest::SetUp(); 27 ExtensionsTest::SetUp();
44 message_loop_.reset(new base::MessageLoop); 28 message_loop_.reset(new base::MessageLoop);
45 browser_client_.reset(new TestExtensionsBrowserClient(browser_context())); 29 browser_client_.reset(new TestExtensionsBrowserClient(browser_context()));
(...skipping 28 matching lines...) Expand all
74 } 58 }
75 } 59 }
76 60
77 void CreateKeepAlive(mojo::InterfaceRequest<KeepAlive> request) { 61 void CreateKeepAlive(mojo::InterfaceRequest<KeepAlive> request) {
78 KeepAliveImpl::Create(browser_context(), extension_.get(), request.Pass()); 62 KeepAliveImpl::Create(browser_context(), extension_.get(), request.Pass());
79 } 63 }
80 64
81 const Extension* extension() { return extension_.get(); } 65 const Extension* extension() { return extension_.get(); }
82 66
83 int GetKeepAliveCount() { 67 int GetKeepAliveCount() {
84 return ExtensionSystem::Get(browser_context()) 68 return ProcessManager::Get(browser_context())
85 ->process_manager()
86 ->GetLazyKeepaliveCount(extension()); 69 ->GetLazyKeepaliveCount(extension());
87 } 70 }
88 71
89 private: 72 private:
90 scoped_ptr<base::MessageLoop> message_loop_; 73 scoped_ptr<base::MessageLoop> message_loop_;
91 MockExtensionSystemFactory<TestExtensionSystem> extension_system_factory_; 74 MockExtensionSystemFactory<MockExtensionSystem> extension_system_factory_;
92 scoped_ptr<content::NotificationService> notification_service_; 75 scoped_ptr<content::NotificationService> notification_service_;
93 scoped_refptr<const Extension> extension_; 76 scoped_refptr<const Extension> extension_;
94 scoped_ptr<TestExtensionsBrowserClient> browser_client_; 77 scoped_ptr<TestExtensionsBrowserClient> browser_client_;
95 78
96 DISALLOW_COPY_AND_ASSIGN(KeepAliveTest); 79 DISALLOW_COPY_AND_ASSIGN(KeepAliveTest);
97 }; 80 };
98 81
99 TEST_F(KeepAliveTest, Basic) { 82 TEST_F(KeepAliveTest, Basic) {
100 mojo::InterfacePtr<KeepAlive> keep_alive; 83 mojo::InterfacePtr<KeepAlive> keep_alive;
101 CreateKeepAlive(mojo::GetProxy(&keep_alive)); 84 CreateKeepAlive(mojo::GetProxy(&keep_alive));
(...skipping 16 matching lines...) Expand all
118 keep_alive.reset(); 101 keep_alive.reset();
119 WaitUntilLazyKeepAliveChanges(); 102 WaitUntilLazyKeepAliveChanges();
120 EXPECT_EQ(1, GetKeepAliveCount()); 103 EXPECT_EQ(1, GetKeepAliveCount());
121 104
122 other_keep_alive.reset(); 105 other_keep_alive.reset();
123 WaitUntilLazyKeepAliveChanges(); 106 WaitUntilLazyKeepAliveChanges();
124 EXPECT_EQ(0, GetKeepAliveCount()); 107 EXPECT_EQ(0, GetKeepAliveCount());
125 } 108 }
126 109
127 } // namespace extensions 110 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/mojo/keep_alive_impl.cc ('k') | extensions/browser/process_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698