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

Side by Side Diff: content/browser/service_worker/service_worker_version_unittest.cc

Issue 2256173002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace a WrapUnique() nested inside a MakeUnique() Created 4 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
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 "content/browser/service_worker/service_worker_version.h" 5 #include "content/browser/service_worker/service_worker_version.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ASSERT_EQ(SERVICE_WORKER_OK, status); 239 ASSERT_EQ(SERVICE_WORKER_OK, status);
240 240
241 // Simulate adding one process to the pattern. 241 // Simulate adding one process to the pattern.
242 helper_->SimulateAddProcessToPattern(pattern_, 242 helper_->SimulateAddProcessToPattern(pattern_,
243 helper_->mock_render_process_id()); 243 helper_->mock_render_process_id());
244 ASSERT_TRUE(helper_->context()->process_manager() 244 ASSERT_TRUE(helper_->context()->process_manager()
245 ->PatternHasProcessToRun(pattern_)); 245 ->PatternHasProcessToRun(pattern_));
246 } 246 }
247 247
248 virtual std::unique_ptr<MessageReceiver> GetMessageReceiver() { 248 virtual std::unique_ptr<MessageReceiver> GetMessageReceiver() {
249 return base::WrapUnique(new MessageReceiver()); 249 return base::MakeUnique<MessageReceiver>();
250 } 250 }
251 251
252 void TearDown() override { 252 void TearDown() override {
253 version_ = 0; 253 version_ = 0;
254 registration_ = 0; 254 registration_ = 0;
255 helper_.reset(); 255 helper_.reset();
256 } 256 }
257 257
258 void SimulateDispatchEvent(ServiceWorkerMetrics::EventType event_type) { 258 void SimulateDispatchEvent(ServiceWorkerMetrics::EventType event_type) {
259 ServiceWorkerStatusCode status = 259 ServiceWorkerStatusCode status =
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 ServiceWorkerFailToStartTest() 328 ServiceWorkerFailToStartTest()
329 : ServiceWorkerVersionTest() {} 329 : ServiceWorkerVersionTest() {}
330 330
331 void set_start_mode(MessageReceiverDisallowStart::StartMode mode) { 331 void set_start_mode(MessageReceiverDisallowStart::StartMode mode) {
332 MessageReceiverDisallowStart* helper = 332 MessageReceiverDisallowStart* helper =
333 static_cast<MessageReceiverDisallowStart*>(helper_.get()); 333 static_cast<MessageReceiverDisallowStart*>(helper_.get());
334 helper->set_start_mode(mode); 334 helper->set_start_mode(mode);
335 } 335 }
336 336
337 std::unique_ptr<MessageReceiver> GetMessageReceiver() override { 337 std::unique_ptr<MessageReceiver> GetMessageReceiver() override {
338 return base::WrapUnique(new MessageReceiverDisallowStart()); 338 return base::MakeUnique<MessageReceiverDisallowStart>();
339 } 339 }
340 340
341 private: 341 private:
342 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFailToStartTest); 342 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFailToStartTest);
343 }; 343 };
344 344
345 class MessageReceiverDisallowStop : public MessageReceiver { 345 class MessageReceiverDisallowStop : public MessageReceiver {
346 public: 346 public:
347 MessageReceiverDisallowStop() : MessageReceiver() {} 347 MessageReceiverDisallowStop() : MessageReceiver() {}
348 ~MessageReceiverDisallowStop() override {} 348 ~MessageReceiverDisallowStop() override {}
349 349
350 void OnStopWorker(int embedded_worker_id) override { 350 void OnStopWorker(int embedded_worker_id) override {
351 // Do nothing. 351 // Do nothing.
352 } 352 }
353 353
354 private: 354 private:
355 DISALLOW_COPY_AND_ASSIGN(MessageReceiverDisallowStop); 355 DISALLOW_COPY_AND_ASSIGN(MessageReceiverDisallowStop);
356 }; 356 };
357 357
358 class ServiceWorkerStallInStoppingTest : public ServiceWorkerVersionTest { 358 class ServiceWorkerStallInStoppingTest : public ServiceWorkerVersionTest {
359 protected: 359 protected:
360 ServiceWorkerStallInStoppingTest() : ServiceWorkerVersionTest() {} 360 ServiceWorkerStallInStoppingTest() : ServiceWorkerVersionTest() {}
361 361
362 std::unique_ptr<MessageReceiver> GetMessageReceiver() override { 362 std::unique_ptr<MessageReceiver> GetMessageReceiver() override {
363 return base::WrapUnique(new MessageReceiverDisallowStop()); 363 return base::MakeUnique<MessageReceiverDisallowStop>();
364 } 364 }
365 365
366 private: 366 private:
367 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStallInStoppingTest); 367 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerStallInStoppingTest);
368 }; 368 };
369 369
370 class MessageReceiverMojoTestService : public MessageReceiver { 370 class MessageReceiverMojoTestService : public MessageReceiver {
371 public: 371 public:
372 MessageReceiverMojoTestService() : MessageReceiver() {} 372 MessageReceiverMojoTestService() : MessageReceiver() {}
373 ~MessageReceiverMojoTestService() override {} 373 ~MessageReceiverMojoTestService() override {}
374 374
375 void OnSetupMojo(shell::InterfaceRegistry* registry) override { 375 void OnSetupMojo(shell::InterfaceRegistry* registry) override {
376 registry->AddInterface(base::Bind(&TestMojoServiceImpl::Create)); 376 registry->AddInterface(base::Bind(&TestMojoServiceImpl::Create));
377 } 377 }
378 378
379 private: 379 private:
380 DISALLOW_COPY_AND_ASSIGN(MessageReceiverMojoTestService); 380 DISALLOW_COPY_AND_ASSIGN(MessageReceiverMojoTestService);
381 }; 381 };
382 382
383 class ServiceWorkerVersionWithMojoTest : public ServiceWorkerVersionTest { 383 class ServiceWorkerVersionWithMojoTest : public ServiceWorkerVersionTest {
384 protected: 384 protected:
385 ServiceWorkerVersionWithMojoTest() : ServiceWorkerVersionTest() {} 385 ServiceWorkerVersionWithMojoTest() : ServiceWorkerVersionTest() {}
386 386
387 std::unique_ptr<MessageReceiver> GetMessageReceiver() override { 387 std::unique_ptr<MessageReceiver> GetMessageReceiver() override {
388 return base::WrapUnique(new MessageReceiverMojoTestService()); 388 return base::MakeUnique<MessageReceiverMojoTestService>();
389 } 389 }
390 390
391 private: 391 private:
392 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersionWithMojoTest); 392 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersionWithMojoTest);
393 }; 393 };
394 394
395 TEST_F(ServiceWorkerVersionTest, ConcurrentStartAndStop) { 395 TEST_F(ServiceWorkerVersionTest, ConcurrentStartAndStop) {
396 // Call StartWorker() multiple times. 396 // Call StartWorker() multiple times.
397 ServiceWorkerStatusCode status1 = SERVICE_WORKER_ERROR_FAILED; 397 ServiceWorkerStatusCode status1 = SERVICE_WORKER_ERROR_FAILED;
398 ServiceWorkerStatusCode status2 = SERVICE_WORKER_ERROR_FAILED; 398 ServiceWorkerStatusCode status2 = SERVICE_WORKER_ERROR_FAILED;
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1737 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); 1737 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1);
1738 histogram_tester_.ExpectTotalCount(kLinkTapDown, 0); 1738 histogram_tester_.ExpectTotalCount(kLinkTapDown, 0);
1739 EXPECT_EQ(SERVICE_WORKER_OK, status); 1739 EXPECT_EQ(SERVICE_WORKER_OK, status);
1740 StopWorker(); 1740 StopWorker();
1741 // The UMA for kLinkMouseDown must be recorded when the worker stopped. 1741 // The UMA for kLinkMouseDown must be recorded when the worker stopped.
1742 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1); 1742 histogram_tester_.ExpectTotalCount(kLinkMouseDown, 1);
1743 histogram_tester_.ExpectTotalCount(kLinkTapDown, 1); 1743 histogram_tester_.ExpectTotalCount(kLinkTapDown, 1);
1744 } 1744 }
1745 1745
1746 } // namespace content 1746 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698