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

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

Issue 1739183003: Make extensions::DictionaryBuilder and extensions::ListValue unmovable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
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 <utility> 7 #include <utility>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 10 matching lines...) Expand all
21 public: 21 public:
22 KeepAliveTest() 22 KeepAliveTest()
23 : notification_service_(content::NotificationService::Create()) {} 23 : notification_service_(content::NotificationService::Create()) {}
24 ~KeepAliveTest() override {} 24 ~KeepAliveTest() override {}
25 25
26 void SetUp() override { 26 void SetUp() override {
27 ExtensionsTest::SetUp(); 27 ExtensionsTest::SetUp();
28 message_loop_.reset(new base::MessageLoop); 28 message_loop_.reset(new base::MessageLoop);
29 extension_ = 29 extension_ =
30 ExtensionBuilder() 30 ExtensionBuilder()
31 .SetManifest(std::move( 31 .SetManifest(
32 DictionaryBuilder() 32 DictionaryBuilder()
33 .Set("name", "app") 33 .Set("name", "app")
34 .Set("version", "1") 34 .Set("version", "1")
35 .Set("manifest_version", 2) 35 .Set("manifest_version", 2)
36 .Set("app", 36 .Set("app", DictionaryBuilder()
37 std::move(DictionaryBuilder().Set( 37 .Set("background",
38 "background", 38 DictionaryBuilder()
39 std::move(DictionaryBuilder().Set( 39 .Set("scripts",
40 "scripts", std::move(ListBuilder().Append( 40 ListBuilder()
41 "background.js"))))))))) 41 .Append("background.js")
42 .Build())
43 .Build())
44 .Build())
45 .Build())
42 .SetID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") 46 .SetID("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
43 .Build(); 47 .Build();
44 } 48 }
45 49
46 void TearDown() override { 50 void TearDown() override {
47 message_loop_.reset(); 51 message_loop_.reset();
48 ExtensionsTest::TearDown(); 52 ExtensionsTest::TearDown();
49 } 53 }
50 54
51 void WaitUntilLazyKeepAliveChanges() { 55 void WaitUntilLazyKeepAliveChanges() {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 EXPECT_EQ(0, GetKeepAliveCount()); 107 EXPECT_EQ(0, GetKeepAliveCount());
104 } 108 }
105 109
106 TEST_F(KeepAliveTest, UnloadExtension) { 110 TEST_F(KeepAliveTest, UnloadExtension) {
107 mojo::InterfacePtr<KeepAlive> keep_alive; 111 mojo::InterfacePtr<KeepAlive> keep_alive;
108 CreateKeepAlive(mojo::GetProxy(&keep_alive)); 112 CreateKeepAlive(mojo::GetProxy(&keep_alive));
109 EXPECT_EQ(1, GetKeepAliveCount()); 113 EXPECT_EQ(1, GetKeepAliveCount());
110 114
111 scoped_refptr<const Extension> other_extension = 115 scoped_refptr<const Extension> other_extension =
112 ExtensionBuilder() 116 ExtensionBuilder()
113 .SetManifest(std::move( 117 .SetManifest(
114 DictionaryBuilder() 118 DictionaryBuilder()
115 .Set("name", "app") 119 .Set("name", "app")
116 .Set("version", "1") 120 .Set("version", "1")
117 .Set("manifest_version", 2) 121 .Set("manifest_version", 2)
118 .Set("app", std::move(DictionaryBuilder().Set( 122 .Set("app",
119 "background", 123 DictionaryBuilder()
120 std::move(DictionaryBuilder().Set( 124 .Set("background",
121 "scripts", std::move(ListBuilder().Append( 125 DictionaryBuilder()
122 "background.js"))))))))) 126 .Set("scripts", ListBuilder()
127 .Append("background.js")
128 .Build())
129 .Build())
130 .Build())
131 .Build())
123 .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb") 132 .SetID("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
124 .Build(); 133 .Build();
125 134
126 ExtensionRegistry::Get(browser_context()) 135 ExtensionRegistry::Get(browser_context())
127 ->TriggerOnUnloaded(other_extension.get(), 136 ->TriggerOnUnloaded(other_extension.get(),
128 UnloadedExtensionInfo::REASON_DISABLE); 137 UnloadedExtensionInfo::REASON_DISABLE);
129 EXPECT_EQ(1, GetKeepAliveCount()); 138 EXPECT_EQ(1, GetKeepAliveCount());
130 139
131 ExtensionRegistry::Get(browser_context()) 140 ExtensionRegistry::Get(browser_context())
132 ->TriggerOnUnloaded(extension(), UnloadedExtensionInfo::REASON_DISABLE); 141 ->TriggerOnUnloaded(extension(), UnloadedExtensionInfo::REASON_DISABLE);
(...skipping 18 matching lines...) Expand all
151 // ProcessManager and so the keep-alive count should remain unchanged. 160 // ProcessManager and so the keep-alive count should remain unchanged.
152 EXPECT_EQ(1, GetKeepAliveCount()); 161 EXPECT_EQ(1, GetKeepAliveCount());
153 162
154 // Wait for |keep_alive| to disconnect. 163 // Wait for |keep_alive| to disconnect.
155 base::RunLoop run_loop; 164 base::RunLoop run_loop;
156 keep_alive.set_connection_error_handler(run_loop.QuitClosure()); 165 keep_alive.set_connection_error_handler(run_loop.QuitClosure());
157 run_loop.Run(); 166 run_loop.Run();
158 } 167 }
159 168
160 } // namespace extensions 169 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698