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

Side by Side Diff: extensions/renderer/api/serial/serial_api_unittest.cc

Issue 1899083003: Convert //extensions/renderer from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 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 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 environment->service_provider()->AddService<device::serial::SerialService>( 415 environment->service_provider()->AddService<device::serial::SerialService>(
416 base::Bind(&SerialApiTest::CreateSerialService, 416 base::Bind(&SerialApiTest::CreateSerialService,
417 base::Unretained(this))); 417 base::Unretained(this)));
418 environment->service_provider()->AddService(base::Bind( 418 environment->service_provider()->AddService(base::Bind(
419 &StashBackend::BindToRequest, base::Unretained(stash_backend))); 419 &StashBackend::BindToRequest, base::Unretained(stash_backend)));
420 environment->service_provider()->IgnoreServiceRequests<KeepAlive>(); 420 environment->service_provider()->IgnoreServiceRequests<KeepAlive>();
421 } 421 }
422 422
423 scoped_refptr<TestIoHandlerBase> io_handler_; 423 scoped_refptr<TestIoHandlerBase> io_handler_;
424 424
425 scoped_ptr<StashBackend> stash_backend_; 425 std::unique_ptr<StashBackend> stash_backend_;
426 426
427 private: 427 private:
428 scoped_refptr<device::SerialIoHandler> GetIoHandler() { 428 scoped_refptr<device::SerialIoHandler> GetIoHandler() {
429 if (!io_handler_.get()) 429 if (!io_handler_.get())
430 io_handler_ = new TestIoHandlerBase; 430 io_handler_ = new TestIoHandlerBase;
431 return io_handler_; 431 return io_handler_;
432 } 432 }
433 433
434 void CreateSerialService( 434 void CreateSerialService(
435 mojo::InterfaceRequest<device::serial::SerialService> request) { 435 mojo::InterfaceRequest<device::serial::SerialService> request) {
436 new device::SerialServiceImpl( 436 new device::SerialServiceImpl(
437 new device::SerialConnectionFactory( 437 new device::SerialConnectionFactory(
438 base::Bind(&SerialApiTest::GetIoHandler, base::Unretained(this)), 438 base::Bind(&SerialApiTest::GetIoHandler, base::Unretained(this)),
439 base::ThreadTaskRunnerHandle::Get()), 439 base::ThreadTaskRunnerHandle::Get()),
440 scoped_ptr<device::SerialDeviceEnumerator>( 440 std::unique_ptr<device::SerialDeviceEnumerator>(
441 new FakeSerialDeviceEnumerator), 441 new FakeSerialDeviceEnumerator),
442 std::move(request)); 442 std::move(request));
443 } 443 }
444 444
445 DISALLOW_COPY_AND_ASSIGN(SerialApiTest); 445 DISALLOW_COPY_AND_ASSIGN(SerialApiTest);
446 }; 446 };
447 447
448 TEST_F(SerialApiTest, GetDevices) { 448 TEST_F(SerialApiTest, GetDevices) {
449 RunTest("serial_unittest.js", "testGetDevices"); 449 RunTest("serial_unittest.js", "testGetDevices");
450 } 450 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 695
696 TEST_F(SerialApiTest, SendUnknownConnectionId) { 696 TEST_F(SerialApiTest, SendUnknownConnectionId) {
697 RunTest("serial_unittest.js", "testSendUnknownConnectionId"); 697 RunTest("serial_unittest.js", "testSendUnknownConnectionId");
698 } 698 }
699 699
700 // Note: these tests are disabled, since there is no good story for persisting 700 // Note: these tests are disabled, since there is no good story for persisting
701 // the stashed handles when an extension process is shut down. See 701 // the stashed handles when an extension process is shut down. See
702 // https://crbug.com/538774 702 // https://crbug.com/538774
703 TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEcho) { 703 TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEcho) {
704 ASSERT_NO_FATAL_FAILURE(RunTest("serial_unittest.js", "testSendAndStash")); 704 ASSERT_NO_FATAL_FAILURE(RunTest("serial_unittest.js", "testSendAndStash"));
705 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); 705 std::unique_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
706 ApiTestEnvironment new_api_test_env(new_env.get()); 706 ApiTestEnvironment new_api_test_env(new_env.get());
707 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); 707 PrepareEnvironment(&new_api_test_env, stash_backend_.get());
708 new_api_test_env.RunTest("serial_unittest.js", "testRestoreAndReceive"); 708 new_api_test_env.RunTest("serial_unittest.js", "testRestoreAndReceive");
709 } 709 }
710 710
711 TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEchoError) { 711 TEST_F(SerialApiTest, DISABLED_StashAndRestoreDuringEchoError) {
712 io_handler_ = 712 io_handler_ =
713 new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DEVICE_LOST); 713 new ReceiveErrorTestIoHandler(device::serial::ReceiveError::DEVICE_LOST);
714 ASSERT_NO_FATAL_FAILURE( 714 ASSERT_NO_FATAL_FAILURE(
715 RunTest("serial_unittest.js", "testRestoreAndReceiveErrorSetUp")); 715 RunTest("serial_unittest.js", "testRestoreAndReceiveErrorSetUp"));
716 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); 716 std::unique_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
717 ApiTestEnvironment new_api_test_env(new_env.get()); 717 ApiTestEnvironment new_api_test_env(new_env.get());
718 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); 718 PrepareEnvironment(&new_api_test_env, stash_backend_.get());
719 new_api_test_env.RunTest("serial_unittest.js", "testRestoreAndReceiveError"); 719 new_api_test_env.RunTest("serial_unittest.js", "testRestoreAndReceiveError");
720 } 720 }
721 721
722 // https://crbug.com/599898 722 // https://crbug.com/599898
723 #if defined(LEAK_SANITIZER) 723 #if defined(LEAK_SANITIZER)
724 #define MAYBE_StashAndRestoreNoConnections DISABLED_StashAndRestoreNoConnections 724 #define MAYBE_StashAndRestoreNoConnections DISABLED_StashAndRestoreNoConnections
725 #else 725 #else
726 #define MAYBE_StashAndRestoreNoConnections StashAndRestoreNoConnections 726 #define MAYBE_StashAndRestoreNoConnections StashAndRestoreNoConnections
727 #endif 727 #endif
728 TEST_F(SerialApiTest, MAYBE_StashAndRestoreNoConnections) { 728 TEST_F(SerialApiTest, MAYBE_StashAndRestoreNoConnections) {
729 ASSERT_NO_FATAL_FAILURE( 729 ASSERT_NO_FATAL_FAILURE(
730 RunTest("serial_unittest.js", "testStashNoConnections")); 730 RunTest("serial_unittest.js", "testStashNoConnections"));
731 io_handler_ = nullptr; 731 io_handler_ = nullptr;
732 scoped_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment()); 732 std::unique_ptr<ModuleSystemTestEnvironment> new_env(CreateEnvironment());
733 ApiTestEnvironment new_api_test_env(new_env.get()); 733 ApiTestEnvironment new_api_test_env(new_env.get());
734 PrepareEnvironment(&new_api_test_env, stash_backend_.get()); 734 PrepareEnvironment(&new_api_test_env, stash_backend_.get());
735 new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections"); 735 new_api_test_env.RunTest("serial_unittest.js", "testRestoreNoConnections");
736 } 736 }
737 737
738 } // namespace extensions 738 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/api/serial/data_sender_unittest.cc ('k') | extensions/renderer/api_activity_logger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698