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

Side by Side Diff: base/message_loop/message_loop_unittest.cc

Issue 1852433005: Convert //base to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase after r384946 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
« no previous file with comments | « base/message_loop/message_loop_test.cc ('k') | base/message_loop/message_pump_glib.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
34 #include "base/win/scoped_handle.h" 34 #include "base/win/scoped_handle.h"
35 #endif 35 #endif
36 36
37 namespace base { 37 namespace base {
38 38
39 // TODO(darin): Platform-specific MessageLoop tests should be grouped together 39 // TODO(darin): Platform-specific MessageLoop tests should be grouped together
40 // to avoid chopping this file up with so many #ifdefs. 40 // to avoid chopping this file up with so many #ifdefs.
41 41
42 namespace { 42 namespace {
43 43
44 scoped_ptr<MessagePump> TypeDefaultMessagePumpFactory() { 44 std::unique_ptr<MessagePump> TypeDefaultMessagePumpFactory() {
45 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_DEFAULT); 45 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_DEFAULT);
46 } 46 }
47 47
48 scoped_ptr<MessagePump> TypeIOMessagePumpFactory() { 48 std::unique_ptr<MessagePump> TypeIOMessagePumpFactory() {
49 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_IO); 49 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_IO);
50 } 50 }
51 51
52 scoped_ptr<MessagePump> TypeUIMessagePumpFactory() { 52 std::unique_ptr<MessagePump> TypeUIMessagePumpFactory() {
53 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_UI); 53 return MessageLoop::CreateMessagePumpForType(MessageLoop::TYPE_UI);
54 } 54 }
55 55
56 class Foo : public RefCounted<Foo> { 56 class Foo : public RefCounted<Foo> {
57 public: 57 public:
58 Foo() : test_count_(0) { 58 Foo() : test_count_(0) {
59 } 59 }
60 60
61 void Test1ConstRef(const std::string& a) { 61 void Test1ConstRef(const std::string& a) {
62 ++test_count_; 62 ++test_count_;
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 original_runner->PostTask(FROM_HERE, 964 original_runner->PostTask(FROM_HERE,
965 Bind(&Foo::Test1ConstRef, foo.get(), "a")); 965 Bind(&Foo::Test1ConstRef, foo.get(), "a"));
966 loop.RunUntilIdle(); 966 loop.RunUntilIdle();
967 EXPECT_EQ(1, foo->test_count()); 967 EXPECT_EQ(1, foo->test_count());
968 } 968 }
969 969
970 TEST(MessageLoopTest, DeleteUnboundLoop) { 970 TEST(MessageLoopTest, DeleteUnboundLoop) {
971 // It should be possible to delete an unbound message loop on a thread which 971 // It should be possible to delete an unbound message loop on a thread which
972 // already has another active loop. This happens when thread creation fails. 972 // already has another active loop. This happens when thread creation fails.
973 MessageLoop loop; 973 MessageLoop loop;
974 scoped_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound( 974 std::unique_ptr<MessageLoop> unbound_loop(MessageLoop::CreateUnbound(
975 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback())); 975 MessageLoop::TYPE_DEFAULT, MessageLoop::MessagePumpFactoryCallback()));
976 unbound_loop.reset(); 976 unbound_loop.reset();
977 EXPECT_EQ(&loop, MessageLoop::current()); 977 EXPECT_EQ(&loop, MessageLoop::current());
978 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get()); 978 EXPECT_EQ(loop.task_runner(), ThreadTaskRunnerHandle::Get());
979 } 979 }
980 980
981 } // namespace base 981 } // namespace base
OLDNEW
« no previous file with comments | « base/message_loop/message_loop_test.cc ('k') | base/message_loop/message_pump_glib.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698