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

Side by Side Diff: extensions/browser/updater/update_service_unittest.cc

Issue 2802433004: ExtensionsTest: Move initialization to SetUp and avoid potential UAF. (Closed)
Patch Set: Created 3 years, 8 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 } 141 }
142 } 142 }
143 143
144 private: 144 private:
145 std::vector<InstallUpdateRequest> install_requests_; 145 std::vector<InstallUpdateRequest> install_requests_;
146 base::Closure next_install_callback_; 146 base::Closure next_install_callback_;
147 }; 147 };
148 148
149 class UpdateServiceTest : public ExtensionsTest { 149 class UpdateServiceTest : public ExtensionsTest {
150 public: 150 public:
151 UpdateServiceTest() { 151 UpdateServiceTest() {}
152 extensions_browser_client()->set_extension_system_factory(
153 &fake_extension_system_factory_);
154 }
155 ~UpdateServiceTest() override {} 152 ~UpdateServiceTest() override {}
156 153
157 void SetUp() override { 154 void SetUp() override {
158 ExtensionsTest::SetUp(); 155 ExtensionsTest::SetUp();
159 browser_threads_.reset(new content::TestBrowserThreadBundle( 156 browser_threads_.reset(new content::TestBrowserThreadBundle(
160 content::TestBrowserThreadBundle::DEFAULT)); 157 content::TestBrowserThreadBundle::DEFAULT));
161 158
159 extensions_browser_client()->set_extension_system_factory(
160 &fake_extension_system_factory_);
162 extensions_browser_client()->SetUpdateClientFactory(base::Bind( 161 extensions_browser_client()->SetUpdateClientFactory(base::Bind(
163 &UpdateServiceTest::CreateUpdateClient, base::Unretained(this))); 162 &UpdateServiceTest::CreateUpdateClient, base::Unretained(this)));
164 163
165 update_service_ = UpdateService::Get(browser_context()); 164 update_service_ = UpdateService::Get(browser_context());
166 } 165 }
167 166
168 protected: 167 protected:
169 UpdateService* update_service() const { return update_service_; } 168 UpdateService* update_service() const { return update_service_; }
170 FakeUpdateClient* update_client() const { return update_client_.get(); } 169 FakeUpdateClient* update_client() const { return update_client_.get(); }
171 170
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 EXPECT_EQ(*extension3->version(), pings[1].version) << reason; 345 EXPECT_EQ(*extension3->version(), pings[1].version) << reason;
347 EXPECT_EQ(reason, pings[1].reason) << reason; 346 EXPECT_EQ(reason, pings[1].reason) << reason;
348 347
349 pings.clear(); 348 pings.clear();
350 } 349 }
351 } 350 }
352 351
353 } // namespace 352 } // namespace
354 353
355 } // namespace extensions 354 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698