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

Side by Side Diff: extensions/browser/api/mime_handler_private/mime_handler_private_unittest.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/api/mime_handler_private/mime_handler_private.h" 5 #include "extensions/browser/api/mime_handler_private/mime_handler_private.h"
6 6
7 #include <memory>
7 #include <utility> 8 #include <utility>
8 9
9 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/ptr_util.h"
10 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
11 #include "content/public/browser/stream_handle.h" 12 #include "content/public/browser/stream_handle.h"
12 #include "content/public/browser/stream_info.h" 13 #include "content/public/browser/stream_info.h"
13 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h" 14 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_gues t.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 16
16 namespace extensions { 17 namespace extensions {
17 18
18 class TestStreamHandle : public content::StreamHandle { 19 class TestStreamHandle : public content::StreamHandle {
19 public: 20 public:
(...skipping 13 matching lines...) Expand all
33 } 34 }
34 35
35 private: 36 private:
36 GURL url_; 37 GURL url_;
37 std::queue<base::Closure> close_callbacks_; 38 std::queue<base::Closure> close_callbacks_;
38 }; 39 };
39 40
40 class MimeHandlerServiceImplTest : public testing::Test { 41 class MimeHandlerServiceImplTest : public testing::Test {
41 public: 42 public:
42 void SetUp() override { 43 void SetUp() override {
43 scoped_ptr<content::StreamInfo> stream_info(new content::StreamInfo); 44 std::unique_ptr<content::StreamInfo> stream_info(new content::StreamInfo);
44 stream_info->handle = make_scoped_ptr(new TestStreamHandle); 45 stream_info->handle = base::WrapUnique(new TestStreamHandle);
45 stream_info->mime_type = "test/unit"; 46 stream_info->mime_type = "test/unit";
46 stream_info->original_url = GURL("test://extensions_unittests"); 47 stream_info->original_url = GURL("test://extensions_unittests");
47 stream_container_.reset( 48 stream_container_.reset(
48 new StreamContainer(std::move(stream_info), 1, true, GURL(), "")); 49 new StreamContainer(std::move(stream_info), 1, true, GURL(), ""));
49 service_.reset(new MimeHandlerServiceImpl(stream_container_->GetWeakPtr(), 50 service_.reset(new MimeHandlerServiceImpl(stream_container_->GetWeakPtr(),
50 mojo::GetProxy(&service_ptr_))); 51 mojo::GetProxy(&service_ptr_)));
51 } 52 }
52 void TearDown() override { 53 void TearDown() override {
53 service_.reset(); 54 service_.reset();
54 stream_container_.reset(); 55 stream_container_.reset();
55 } 56 }
56 57
57 void AbortCallback() { abort_called_ = true; } 58 void AbortCallback() { abort_called_ = true; }
58 void GetStreamInfoCallback(mime_handler::StreamInfoPtr stream_info) { 59 void GetStreamInfoCallback(mime_handler::StreamInfoPtr stream_info) {
59 stream_info_ = std::move(stream_info); 60 stream_info_ = std::move(stream_info);
60 } 61 }
61 62
62 base::MessageLoop message_loop_; 63 base::MessageLoop message_loop_;
63 scoped_ptr<StreamContainer> stream_container_; 64 std::unique_ptr<StreamContainer> stream_container_;
64 mime_handler::MimeHandlerServicePtr service_ptr_; 65 mime_handler::MimeHandlerServicePtr service_ptr_;
65 scoped_ptr<mime_handler::MimeHandlerService> service_; 66 std::unique_ptr<mime_handler::MimeHandlerService> service_;
66 bool abort_called_ = false; 67 bool abort_called_ = false;
67 mime_handler::StreamInfoPtr stream_info_; 68 mime_handler::StreamInfoPtr stream_info_;
68 }; 69 };
69 70
70 TEST_F(MimeHandlerServiceImplTest, Abort) { 71 TEST_F(MimeHandlerServiceImplTest, Abort) {
71 service_->AbortStream(base::Bind(&MimeHandlerServiceImplTest::AbortCallback, 72 service_->AbortStream(base::Bind(&MimeHandlerServiceImplTest::AbortCallback,
72 base::Unretained(this))); 73 base::Unretained(this)));
73 EXPECT_TRUE(abort_called_); 74 EXPECT_TRUE(abort_called_);
74 75
75 abort_called_ = false; 76 abort_called_ = false;
(...skipping 28 matching lines...) Expand all
104 ASSERT_FALSE(stream_info_); 105 ASSERT_FALSE(stream_info_);
105 106
106 stream_container_.reset(); 107 stream_container_.reset();
107 service_->GetStreamInfo( 108 service_->GetStreamInfo(
108 base::Bind(&MimeHandlerServiceImplTest::GetStreamInfoCallback, 109 base::Bind(&MimeHandlerServiceImplTest::GetStreamInfoCallback,
109 base::Unretained(this))); 110 base::Unretained(this)));
110 ASSERT_FALSE(stream_info_); 111 ASSERT_FALSE(stream_info_);
111 } 112 }
112 113
113 } // namespace extensions 114 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698